Core/Unit: movement related corrections prior to getting Charmed

Port From (https://github.com/TrinityCore/TrinityCore/commit/ef6a5d3c3c010f9ad63a71015a533a3894ab38b9)
This commit is contained in:
hondacrx
2021-12-27 17:10:23 -05:00
parent c209f30475
commit 5e193139a2
+18 -15
View File
@@ -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<MovementGenerator, bool> 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