From a4c4897b4dd96c8901fca9034fa621af9097691e Mon Sep 17 00:00:00 2001 From: hondacrx Date: Sat, 1 Jan 2022 16:17:58 -0500 Subject: [PATCH] Core/SmartAI: add missing movement generator type check on SmartAI::SetCombatMove Port From (https://github.com/TrinityCore/TrinityCore/commit/e94dca132b4a505f3cc4583bd63879148ad51ca3) --- Source/Game/AI/SmartScripts/SmartAI.cs | 5 ++++- Source/Game/AI/SmartScripts/SmartScript.cs | 7 ++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/Game/AI/SmartScripts/SmartAI.cs b/Source/Game/AI/SmartScripts/SmartAI.cs index 4ad0a18dc..2e673bac8 100644 --- a/Source/Game/AI/SmartScripts/SmartAI.cs +++ b/Source/Game/AI/SmartScripts/SmartAI.cs @@ -849,7 +849,10 @@ namespace Game.AI { if (on) { - if (!me.HasReactState(ReactStates.Passive) && me.GetVictim() && !me.GetMotionMaster().HasMovementGenerator(movement => movement.Mode == MovementGeneratorMode.Default && movement.Priority == MovementGeneratorPriority.Normal)) + if (!me.HasReactState(ReactStates.Passive) && me.GetVictim() && !me.GetMotionMaster().HasMovementGenerator(movement => + { + return movement.GetMovementGeneratorType() == MovementGeneratorType.Chase && movement.Mode == MovementGeneratorMode.Default && movement.Priority == MovementGeneratorPriority.Normal; + })) { SetRun(_run); me.GetMotionMaster().MoveChase(me.GetVictim()); diff --git a/Source/Game/AI/SmartScripts/SmartScript.cs b/Source/Game/AI/SmartScripts/SmartScript.cs index 5ed77273e..25ca36f3e 100644 --- a/Source/Game/AI/SmartScripts/SmartScript.cs +++ b/Source/Game/AI/SmartScripts/SmartScript.cs @@ -452,9 +452,7 @@ namespace Game.AI if (e.Action.cast.castFlags.HasAnyFlag((uint)SmartCastFlags.CombatMove)) { - // 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. bool allowMove = false; SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(e.Action.cast.spell, _me.GetMap().GetDifficultyID()); var costs = spellInfo.CalcPowerCost(_me, spellInfo.GetSchoolMask()); @@ -479,8 +477,7 @@ namespace Game.AI } } - if (_me.GetDistance(target) > spellInfo.GetMaxRange(true) || - _me.GetDistance(target) < spellInfo.GetMinRange(true) || + if (_me.GetDistance(target) > spellInfo.GetMaxRange(true) || _me.GetDistance(target) < spellInfo.GetMinRange(true) || !_me.IsWithinLOSInMap(target) || !hasPower || _me.HasUnitFlag(UnitFlags.Silenced)) allowMove = true;