From 5e193139a2d0e8780fdc8827a1715974ac6fe2e3 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Mon, 27 Dec 2021 17:10:23 -0500 Subject: [PATCH] Core/Unit: movement related corrections prior to getting Charmed Port From (https://github.com/TrinityCore/TrinityCore/commit/ef6a5d3c3c010f9ad63a71015a533a3894ab38b9) --- Source/Game/Entities/Unit/Unit.Pets.cs | 33 ++++++++++++++------------ 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/Source/Game/Entities/Unit/Unit.Pets.cs b/Source/Game/Entities/Unit/Unit.Pets.cs index cae5fa554..8e0e30f97 100644 --- a/Source/Game/Entities/Unit/Unit.Pets.cs +++ b/Source/Game/Entities/Unit/Unit.Pets.cs @@ -17,8 +17,10 @@ using Framework.Constants; using Game.AI; +using Game.Movement; using Game.Networking.Packets; using Game.Spells; +using System; using System.Collections.Generic; using System.Linq; @@ -322,26 +324,27 @@ namespace Game.Entities _oldFactionId = GetFaction(); SetFaction(charmer.GetFaction()); + // Pause any Idle movement + PauseMovement(0, 0, false); + + // Remove any active voluntary movement + GetMotionMaster().Clear(MovementGeneratorPriority.Normal); + + // Stop any remaining spline, if no involuntary movement is found + Func criteria = movement => movement.Priority == MovementGeneratorPriority.Highest; + if (!GetMotionMaster().HasMovementGenerator(criteria)) + StopMoving(); + // Set charmed charmer.SetCharm(this, true); - if (IsTypeId(TypeId.Unit)) + Player player = ToPlayer(); + if (player) { - PauseMovement(0, 0, false); - GetMotionMaster().Clear(MovementGeneratorPriority.Normal); + if (player.IsAFK()) + player.ToggleAFK(); - StopMoving(); - } - else - { - Player player = ToPlayer(); - if (player) - { - if (player.IsAFK()) - player.ToggleAFK(); - - player.SetClientControl(this, false); - } + player.SetClientControl(this, false); } // charm is set by aura, and aura effect remove handler was called during apply handler execution