MCPcopy Create free account
hub / github.com/crawl/crawl / attack

Method attack

crawl-ref/source/melee-attack.cc:1739–1992  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1737 * from its starting position.
1738 */
1739bool 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

Callers 4

handle_phase_blockedMethod · 0.45
do_followup_attacksMethod · 0.45
swing_withMethod · 0.45

Calls 15

mons_alignedFunction · 0.85
player_under_penanceFunction · 0.85
god_hates_your_godFunction · 0.85
one_chance_inFunction · 0.85
simple_god_messageFunction · 0.85
xom_is_stimulatedFunction · 0.85
mprfFunction · 0.85
mons_self_destructsFunction · 0.85
is_unrandom_artefactFunction · 0.85
get_artefact_nameFunction · 0.85
set_artefact_nameFunction · 0.85
ifFunction · 0.85

Tested by

no test coverage detected