diff --git a/src/game/Object/CreatureAI.h b/src/game/Object/CreatureAI.h index 7c1fca052..a05ef420b 100644 --- a/src/game/Object/CreatureAI.h +++ b/src/game/Object/CreatureAI.h @@ -68,7 +68,8 @@ enum CombatMovementFlags COMBAT_MOVEMENT_SCRIPT = 0x01, // Combat movement enforced by script COMBAT_MOVEMENT_LOS = 0x02, // Combat movement triggered by LoS issues COMBAT_MOVEMENT_OOM = 0x04, // Combat movement triggered by power exhaustion - COMBAT_MOVEMENT_DISTANCE = 0x08 // Combat movement triggered by distance checks + COMBAT_MOVEMENT_DISTANCE = 0x08, // Combat movement triggered by distance checks + COMBAT_MOVEMENT_SILENCE = 0x10 // Combat movement of a caster while silenced }; enum AIEventType @@ -318,7 +319,7 @@ class CreatureAI CanCastResult DoCastSpellIfCan(Unit* pTarget, uint32 uiSpell, uint32 uiCastFlags = 0, ObjectGuid OriginalCasterGuid = ObjectGuid()); /// Combat movement functions - void SetCombatMovement(bool enable, bool stopOrStartMovement = false); + void SetCombatMovement(bool enable, bool stopOrStartMovement = true); bool IsCombatMovement() const { return m_combatMovement != 0; } void AddCombatMovementFlags(uint32 cmFlags); void ClearCombatMovementFlags(uint32 cmFlags); diff --git a/src/game/Object/CreatureEventAI.cpp b/src/game/Object/CreatureEventAI.cpp index 450476795..a8d5eb23f 100644 --- a/src/game/Object/CreatureEventAI.cpp +++ b/src/game/Object/CreatureEventAI.cpp @@ -680,6 +680,9 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 case CAST_FAIL_NO_LOS: cmFlags |= COMBAT_MOVEMENT_LOS; break; + case CAST_FAIL_STATE: + cmFlags |= COMBAT_MOVEMENT_SILENCE; + break; default: break; } @@ -690,18 +693,20 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 if (!(action.cast.castFlags & CAST_NO_MELEE_IF_OOM)) { AddCombatMovementFlags(cmFlags); - SetCombatMovement(true,true); + SetCombatMovement(true, true); } } else { - if (m_combatMovement & (COMBAT_MOVEMENT_LOS | COMBAT_MOVEMENT_DISTANCE | COMBAT_MOVEMENT_OOM)) + if (m_combatMovement & (COMBAT_MOVEMENT_LOS | COMBAT_MOVEMENT_DISTANCE | COMBAT_MOVEMENT_OOM | COMBAT_MOVEMENT_SILENCE)) { - ClearCombatMovementFlags(COMBAT_MOVEMENT_LOS | COMBAT_MOVEMENT_DISTANCE | COMBAT_MOVEMENT_OOM); + bool silenceOff = m_combatMovement & COMBAT_MOVEMENT_SILENCE; + ClearCombatMovementFlags(COMBAT_MOVEMENT_LOS | COMBAT_MOVEMENT_DISTANCE | COMBAT_MOVEMENT_OOM | COMBAT_MOVEMENT_SILENCE); - if (!IsCombatMovement() && m_creature->IsNonMeleeSpellCasted(false) && m_creature->IsInCombat() && m_creature->getVictim()) + if (m_creature->IsInCombat() && m_creature->getVictim() && + (silenceOff || (!IsCombatMovement() && m_creature->IsNonMeleeSpellCasted(false)))) { - SetCombatMovement(false,true); + SetCombatMovement(true, true); // resetting the same chase movegen m_creature->SendMeleeAttackStop(m_creature->getVictim()); } } diff --git a/src/game/WorldHandlers/SpellEffects.cpp b/src/game/WorldHandlers/SpellEffects.cpp index a40d508ea..217322914 100644 --- a/src/game/WorldHandlers/SpellEffects.cpp +++ b/src/game/WorldHandlers/SpellEffects.cpp @@ -4857,6 +4857,14 @@ void Spell::EffectInterruptCast(SpellEffectIndex /*eff_idx*/) { unitTarget->ProhibitSpellSchool(GetSpellSchoolMask(curSpellInfo), GetSpellDuration(m_spellInfo)); unitTarget->InterruptSpell(CurrentSpellTypes(i), false); + if (unitTarget->ToCreature()) + { + if (CreatureAI* ai = unitTarget->ToCreature()->AI()) // TODO setup a better way to inform AI + { + ai->SetCombatMovement(true, true); + ai->AddCombatMovementFlags(COMBAT_MOVEMENT_SILENCE); + } + } } } }