Initiate the processing of the attack * * Called from the main code (fight.cc), this method begins the actual combat * for a particular attack and is responsible for looping through each of the * appropriate phases (which then can call other related phases within * themselves). * * Note that this does *not* trigger offhand attacks, but *can* trigger other * derived attacks, e.g. cleaving o
| 1737 | * from its starting position. |
| 1738 | */ |
| 1739 | bool melee_attack::attack() |
| 1740 | { |
| 1741 | cleave_setup(); |
| 1742 | |
| 1743 | if (!is_involuntary && bad_attempt()) |
| 1744 | { |
| 1745 | cancel_attack = true; |
| 1746 | return false; |
| 1747 | } |
| 1748 | |
| 1749 | if (!cleaving) |
| 1750 | { |
| 1751 | // Check that we're attacking at least one non-firewood target and |
| 1752 | // cache this result. |
| 1753 | if (defender && !defender->is_firewood() && !mons_aligned(attacker, defender)) |
| 1754 | is_attacking_hostiles = true; |
| 1755 | |
| 1756 | if (!is_attacking_hostiles && !cleave_targets.empty()) |
| 1757 | { |
| 1758 | for (actor* targ : cleave_targets) |
| 1759 | { |
| 1760 | if (!targ->is_firewood() && !mons_aligned(attacker, targ)) |
| 1761 | { |
| 1762 | is_attacking_hostiles = true; |
| 1763 | break; |
| 1764 | } |
| 1765 | } |
| 1766 | } |
| 1767 | |
| 1768 | if (attacker->is_player() |
| 1769 | && player_under_penance(GOD_ELYVILON) |
| 1770 | && god_hates_your_god(GOD_ELYVILON) |
| 1771 | && !is_followup |
| 1772 | && one_chance_in(20)) |
| 1773 | { |
| 1774 | simple_god_message(" prevents your attack.", false, GOD_ELYVILON); |
| 1775 | return false; |
| 1776 | } |
| 1777 | |
| 1778 | // Wall jump attacks supposedly happen 'mid-air' and so shouldn't care |
| 1779 | // about water at the landing spot. |
| 1780 | if (wu_jian_attack != WU_JIAN_ATTACK_WALL_JUMP |
| 1781 | && attacker->fumbles_attack()) |
| 1782 | { |
| 1783 | // Xom thinks fumbles are funny... |
| 1784 | // ... and thinks fumbling when trying to hit yourself is just |
| 1785 | // hilarious. |
| 1786 | xom_is_stimulated(attacker == defender ? 200 : 10); |
| 1787 | |
| 1788 | // We may try for additional quick blade attacks, even if we fumble |
| 1789 | // the first. |
| 1790 | return handle_phase_multihit(); |
| 1791 | } |
| 1792 | |
| 1793 | if (!handle_phase_attempted()) |
| 1794 | return false; |
| 1795 | } |
| 1796 |
no test coverage detected