Skip to content

Commit

Permalink
Spell: Immediately interrupt cast if target dies mid cast
Browse files Browse the repository at this point in the history
  • Loading branch information
killerwife committed Dec 25, 2024
1 parent 73e50e0 commit be092be
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/game/Spells/Spell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3707,6 +3707,12 @@ void Spell::update(uint32 difftime)
{
if (m_timer)
{
if (m_targets.getUnitTarget() && !m_IsTriggeredSpell && !IsAllowingDeadTarget(m_spellInfo) && !m_targets.getUnitTarget()->IsAlive())
{
cancel();
return;
}

if (difftime >= m_timer)
m_timer = 0;
else
Expand All @@ -3724,14 +3730,20 @@ void Spell::update(uint32 difftime)
{
// check if player has jumped before the channeling finished
if (m_caster->m_movementInfo.HasMovementFlag(MOVEFLAG_FALLING))
{
cancel();
return;
}

// check for incapacitating player states
if (m_caster->IsCrowdControlled())
{
// certain channel spells are not interrupted
if (!m_spellInfo->HasAttribute(SPELL_ATTR_EX_IS_CHANNELED) && !m_spellInfo->HasAttribute(SPELL_ATTR_EX3_IGNORE_CASTER_AND_TARGET_RESTRICTIONS))
{
cancel();
return;
}
}

if (m_spellInfo->HasAttribute(SPELL_ATTR_EX2_SPECIAL_TAMING_FLAG)) // these fail on lost target attention (aggro)
Expand All @@ -3740,7 +3752,10 @@ void Spell::update(uint32 difftime)
{
Unit* targetsTarget = target->GetTarget();
if (targetsTarget && targetsTarget != m_caster)
{
cancel();
return;
}
}
}

Expand Down Expand Up @@ -3789,6 +3804,7 @@ void Spell::update(uint32 difftime)
if (!m_caster->IsWithinCombatDistInMap(channelTarget, m_maxRange * 1.5f))
{
cancel();
return;
}
}
}
Expand Down

0 comments on commit be092be

Please sign in to comment.