mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/SAI: Fix creatures casting spells while moving with flag SMARTCAST_COMBAT_MOVE
Fixes #24019
(cherry picked from commit 2910d0fb24)
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user