diff options
author | jackpoz <giacomopoz@gmail.com> | 2020-08-06 17:59:36 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2022-01-26 16:23:15 +0100 |
commit | b3545479bfbd2b743288bd32094ce8c4856a1e3d (patch) | |
tree | eb4181b6b285047bcd49a45abb377ddf1751413f | |
parent | ffd85f9139119ec56a8a6f3add4ef4c0f047b838 (diff) |
Core/SAI: Fix creatures casting spells while moving with flag SMARTCAST_COMBAT_MOVE
Fixes #24019
(cherry picked from commit 2910d0fb2436d9865d792ef92cb415f831a0af93)
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartAI.cpp | 16 | ||||
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartAI.h | 2 | ||||
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartScript.cpp | 2 |
3 files changed, 12 insertions, 8 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp index e9727e3f8b9..3e58a5ec3eb 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.cpp +++ b/src/server/game/AI/SmartScripts/SmartAI.cpp @@ -788,7 +788,7 @@ void SmartAI::QuestReward(Player* player, Quest const* quest, LootItemType /*typ GetScript()->ProcessEventsFor(SMART_EVENT_REWARD_QUEST, player, quest->GetQuestId(), opt); } -void SmartAI::SetCombatMove(bool on) +void SmartAI::SetCombatMove(bool on, bool stopMoving) { if (_canCombatMove == on) return; @@ -803,19 +803,23 @@ void SmartAI::SetCombatMove(bool on) if (on) { if (!me->HasReactState(REACT_PASSIVE) && me->GetVictim() && !me->GetMotionMaster()->HasMovementGenerator([](MovementGenerator const* movement) -> bool - { - return movement->GetMovementGeneratorType() == CHASE_MOTION_TYPE && movement->Mode == MOTION_MODE_DEFAULT && movement->Priority == MOTION_PRIORITY_NORMAL; - })) + { + return movement->GetMovementGeneratorType() == CHASE_MOTION_TYPE && movement->Mode == MOTION_MODE_DEFAULT && movement->Priority == MOTION_PRIORITY_NORMAL; + })) { SetRun(_run); me->GetMotionMaster()->MoveChase(me->GetVictim()); } } else if (MovementGenerator* movement = me->GetMotionMaster()->GetMovementGenerator([](MovementGenerator const* a) -> bool + { + return a->GetMovementGeneratorType() == CHASE_MOTION_TYPE && a->Mode == MOTION_MODE_DEFAULT && a->Priority == MOTION_PRIORITY_NORMAL; + })) { - return a->GetMovementGeneratorType() == CHASE_MOTION_TYPE && a->Mode == MOTION_MODE_DEFAULT && a->Priority == MOTION_PRIORITY_NORMAL; - })) me->GetMotionMaster()->Remove(movement); + if (stopMoving) + me->StopMoving(); + } } } diff --git a/src/server/game/AI/SmartScripts/SmartAI.h b/src/server/game/AI/SmartScripts/SmartAI.h index 6d0c766d650..7cd0e7d800a 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.h +++ b/src/server/game/AI/SmartScripts/SmartAI.h @@ -60,7 +60,7 @@ class TC_GAME_API SmartAI : public CreatureAI void AddEscortState(uint32 escortState) { _escortState |= escortState; } void RemoveEscortState(uint32 escortState) { _escortState &= ~escortState; } void SetAutoAttack(bool on) { _canAutoAttack = on; } - void SetCombatMove(bool on); + void SetCombatMove(bool on, bool stopMoving = false); bool CanCombatMove() { return _canCombatMove; } void SetFollow(Unit* target, float dist = 0.0f, float angle = 0.0f, uint32 credit = 0, uint32 end = 0, uint32 creditType = 0); void StopFollow(bool complete); diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index dade4e32d60..9389a012e3d 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -599,7 +599,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u me->HasUnitFlag(UNIT_FLAG_SILENCED)) allowMove = true; - ENSURE_AI(SmartAI, me->AI())->SetCombatMove(allowMove); + ENSURE_AI(SmartAI, me->AI())->SetCombatMove(allowMove, true); } me->CastSpell(target->ToUnit(), e.action.cast.spell, triggerFlag); |