Core/SAI: Fix creatures casting spells while moving with flag SMARTCAST_COMBAT_MOVE

Port From (https://github.com/TrinityCore/TrinityCore/commit/b3545479bfbd2b743288bd32094ce8c4856a1e3d)
This commit is contained in:
hondacrx
2022-03-02 18:02:58 -05:00
parent 47bea619f7
commit 3f8c0f897a
2 changed files with 6 additions and 2 deletions
+5 -1
View File
@@ -843,7 +843,7 @@ namespace Game.AI
GetScript().ProcessEventsFor(SmartEvents.RewardQuest, player, quest.Id, opt);
}
public void SetCombatMove(bool on)
public void SetCombatMove(bool on, bool stopMoving = false)
{
if (_canCombatMove == on)
return;
@@ -870,7 +870,11 @@ namespace Game.AI
{
var movement = me.GetMotionMaster().GetMovementGenerator(a => a.GetMovementGeneratorType() == MovementGeneratorType.Chase && a.Mode == MovementGeneratorMode.Default && a.Priority == MovementGeneratorPriority.Normal);
if (movement != null)
{
me.GetMotionMaster().Remove(movement);
if (stopMoving)
me.StopMoving();
}
}
}
}
+1 -1
View File
@@ -482,7 +482,7 @@ namespace Game.AI
!_me.IsWithinLOSInMap(target) || !hasPower || _me.HasUnitFlag(UnitFlags.Silenced))
allowMove = true;
((SmartAI)_me.GetAI()).SetCombatMove(allowMove);
((SmartAI)_me.GetAI()).SetCombatMove(allowMove, true);
}
_me.CastSpell(target.ToUnit(), e.Action.cast.spell, new CastSpellExtraArgs(triggerFlag));