mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Creatures: Improved movement interruption while casting spells (#28845)
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user