aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjackpoz <giacomopoz@gmail.com>2020-08-06 17:59:36 +0200
committerjackpoz <giacomopoz@gmail.com>2020-08-06 17:59:36 +0200
commit2910d0fb2436d9865d792ef92cb415f831a0af93 (patch)
treee63f6a24d4a5c6c118791ee26ce5d44758906082 /src
parentbd5e832a648aadf1d1be94f913ea00b67398f249 (diff)
Core/SAI: Fix creatures casting spells while moving with flag SMARTCAST_COMBAT_MOVE
Fixes #24019
Diffstat (limited to 'src')
-rw-r--r--src/server/game/AI/SmartScripts/SmartAI.cpp16
-rw-r--r--src/server/game/AI/SmartScripts/SmartAI.h2
-rw-r--r--src/server/game/AI/SmartScripts/SmartScript.cpp2
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 e45e8e3841a..c03d70e35f8 100644
--- a/src/server/game/AI/SmartScripts/SmartAI.cpp
+++ b/src/server/game/AI/SmartScripts/SmartAI.cpp
@@ -786,7 +786,7 @@ void SmartAI::QuestReward(Player* player, Quest const* quest, uint32 opt)
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;
@@ -801,19 +801,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 6db2c080c32..b475513352c 100644
--- a/src/server/game/AI/SmartScripts/SmartAI.h
+++ b/src/server/game/AI/SmartScripts/SmartAI.h
@@ -59,7 +59,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 e7c7d337b1d..dac03891e43 100644
--- a/src/server/game/AI/SmartScripts/SmartScript.cpp
+++ b/src/server/game/AI/SmartScripts/SmartScript.cpp
@@ -565,7 +565,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
me->HasFlag(UNIT_FIELD_FLAGS, 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);