Check prerequisites for a number of abilities. Abort any attempt if these cannot be met, without losing the turn. TODO: Many more cases need to be added!
| 1801 | // Abort any attempt if these cannot be met, without losing the turn. |
| 1802 | // TODO: Many more cases need to be added! |
| 1803 | static bool _check_ability_possible(const ability_def& abil, bool quiet = false) |
| 1804 | { |
| 1805 | #ifdef WIZARD |
| 1806 | if (abil.ability >= ABIL_FIRST_WIZ) |
| 1807 | return you.wizard; |
| 1808 | #endif |
| 1809 | if (you.confused() && !testbits(abil.flags, abflag::conf_ok)) |
| 1810 | { |
| 1811 | if (!quiet) |
| 1812 | canned_msg(MSG_TOO_CONFUSED); |
| 1813 | return false; |
| 1814 | } |
| 1815 | |
| 1816 | if (you.berserk() && !testbits(abil.flags, abflag::berserk_ok)) |
| 1817 | { |
| 1818 | if (!quiet) |
| 1819 | canned_msg(MSG_TOO_BERSERK); |
| 1820 | return false; |
| 1821 | } |
| 1822 | |
| 1823 | if (abil.ability == ABIL_TROG_BERSERK |
| 1824 | && !you.can_go_berserk(true, false, quiet)) |
| 1825 | { |
| 1826 | return false; |
| 1827 | } |
| 1828 | |
| 1829 | if (you.confused() && !testbits(abil.flags, abflag::conf_ok)) |
| 1830 | { |
| 1831 | if (!quiet) |
| 1832 | canned_msg(MSG_TOO_CONFUSED); |
| 1833 | return false; |
| 1834 | } |
| 1835 | |
| 1836 | // Silence and engulf |
| 1837 | if (you.is_silenced()) |
| 1838 | { |
| 1839 | talent tal = get_talent(abil.ability); |
| 1840 | if (tal.is_invocation && abil.ability != ABIL_RENOUNCE_RELIGION) |
| 1841 | { |
| 1842 | if (!quiet) |
| 1843 | { |
| 1844 | mprf("You cannot call out to %s while %s.", |
| 1845 | god_name(you.religion).c_str(), player_silenced_reason()); |
| 1846 | } |
| 1847 | return false; |
| 1848 | } |
| 1849 | if (abil.ability == ABIL_WORD_OF_CHAOS) |
| 1850 | { |
| 1851 | if (!quiet) |
| 1852 | mprf("You cannot speak a word of chaos while %s.", player_silenced_reason()); |
| 1853 | return false; |
| 1854 | } |
| 1855 | } |
| 1856 | |
| 1857 | const god_power* god_power = god_power_from_ability(abil.ability); |
| 1858 | if (god_power && !god_power_usable(*god_power)) |
| 1859 | { |
| 1860 | if (!quiet) |
no test coverage detected