Core/Creatures: Improved movement interruption while casting spells (#28845)

This commit is contained in:
Meji
2023-03-24 12:27:01 +01:00
committed by GitHub
parent d6d5d94ebe
commit cc57c9dad5
3 changed files with 11 additions and 15 deletions

View File

@@ -3407,21 +3407,10 @@ void Creature::DoNotReacquireSpellFocusTarget()
bool Creature::IsMovementPreventedByCasting() const
{
// first check if currently a movement allowed channel is active and we're not casting
if (Spell* spell = m_currentSpells[CURRENT_CHANNELED_SPELL])
{
if (spell->getState() != SPELL_STATE_FINISHED && spell->IsChannelActive())
if (spell->CheckMovement() != SPELL_CAST_OK)
return true;
}
if (!Unit::IsMovementPreventedByCasting() && !HasSpellFocus())
return false;
if (HasSpellFocus())
return true;
if (HasUnitState(UNIT_STATE_CASTING))
return true;
return false;
return true;
}
void Creature::StartPickPocketRefillTimer()

View File

@@ -3029,7 +3029,8 @@ bool Unit::IsMovementPreventedByCasting() const
return false;
if (Spell* spell = m_currentSpells[CURRENT_GENERIC_SPELL])
if (CanCastSpellWhileMoving(spell->GetSpellInfo()))
if (CanCastSpellWhileMoving(spell->GetSpellInfo()) || spell->getState() == SPELL_STATE_FINISHED ||
!spell->m_spellInfo->InterruptFlags.HasFlag(SpellInterruptFlags::Movement))
return false;
// channeled spells during channel stage (after the initial cast timer) allow movement with a specific spell attribute

View File

@@ -6875,6 +6875,12 @@ SpellCastResult Spell::CheckMovement() const
if (IsTriggered())
return SPELL_CAST_OK;
// Creatures (not controlled) give priority to spell casting over movement.
// We assume that the casting is always valid and the current movement
// is stopped by Unit:IsmovementPreventedByCasting to prevent casting interruption.
if (m_caster->IsCreature() && !m_caster->ToCreature()->IsControlledByPlayer())
return SPELL_CAST_OK;
if (Unit* unitCaster = m_caster->ToUnit())
{
if (!unitCaster->CanCastSpellWhileMoving(m_spellInfo))