fix(Core/SAI): Force SMC creatures to resume chasing victims once in… (#22581)

This commit is contained in:
Andrew
2025-08-12 14:31:08 -03:00
committed by GitHub
parent 743b6e7cd9
commit 5369aec3c9
4 changed files with 21 additions and 2 deletions
@@ -72,6 +72,8 @@ SmartAI::SmartAI(Creature* c) : CreatureAI(c)
mcanSpawn = true; mcanSpawn = true;
_chaseOnInterrupt = false;
// Xinef: Vehicle conditions // Xinef: Vehicle conditions
m_ConditionsTimer = 0; m_ConditionsTimer = 0;
if (me->GetVehicleKit()) if (me->GetVehicleKit())
@@ -212,6 +212,9 @@ public:
// Xinef // Xinef
void SetWPPauseTimer(uint32 time) { mWPPauseTimer = time; } void SetWPPauseTimer(uint32 time) { mWPPauseTimer = time; }
void SetChaseOnInterrupt(bool apply) { _chaseOnInterrupt = apply; }
[[nodiscard]] bool CanChaseOnInterrupt() const { return _chaseOnInterrupt; }
private: private:
bool mIsCharmed; bool mIsCharmed;
uint32 mFollowCreditType; uint32 mFollowCreditType;
@@ -257,6 +260,8 @@ private:
void CheckConditions(const uint32 diff); void CheckConditions(const uint32 diff);
ConditionList conditions; ConditionList conditions;
uint32 m_ConditionsTimer; uint32 m_ConditionsTimer;
bool _chaseOnInterrupt;
}; };
class SmartGameObjectAI : public GameObjectAI class SmartGameObjectAI : public GameObjectAI
@@ -742,6 +742,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (e.action.cast.castFlags & SMARTCAST_COMBAT_MOVE) if (e.action.cast.castFlags & SMARTCAST_COMBAT_MOVE)
{ {
CAST_AI(SmartAI, me->AI())->SetChaseOnInterrupt(true);
if (!me->isMoving()) // Don't try to reposition while we are moving if (!me->isMoving()) // Don't try to reposition while we are moving
{ {
// If cast flag SMARTCAST_COMBAT_MOVE is set combat movement will not be allowed unless target is outside spell range, out of mana, or LOS. // If cast flag SMARTCAST_COMBAT_MOVE is set combat movement will not be allowed unless target is outside spell range, out of mana, or LOS.
+10
View File
@@ -53,6 +53,7 @@
#include "Player.h" #include "Player.h"
#include "ReputationMgr.h" #include "ReputationMgr.h"
#include "ScriptMgr.h" #include "ScriptMgr.h"
#include "SmartAI.h"
#include "Spell.h" #include "Spell.h"
#include "SpellAuraEffects.h" #include "SpellAuraEffects.h"
#include "SpellAuras.h" #include "SpellAuras.h"
@@ -4128,6 +4129,15 @@ void Unit::InterruptSpell(CurrentSpellTypes spellType, bool withDelayed, bool wi
m_currentSpells[spellType] = nullptr; m_currentSpells[spellType] = nullptr;
spell->SetReferencedFromCurrent(false); spell->SetReferencedFromCurrent(false);
} }
// SAI creatures only
// Start chasing victim if they are spell casters (at least one SMC spell) if interrupted/silenced.
if (IsCreature())
{
if (SmartAI* ai = dynamic_cast<SmartAI*>(ToCreature()->AI()))
if (ai->CanChaseOnInterrupt())
ai->SetCombatMove(true);
}
} }
} }