aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index cdb2c2ace75..c1ee51ef98c 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -11405,17 +11405,24 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au
_oldFactionId = GetFaction();
SetFaction(charmer->GetFaction());
- // Set charmed
- charmer->SetCharm(this, true);
+ // Pause any Idle movement
+ PauseMovement(0, 0, false);
- if (GetTypeId() == TYPEID_UNIT)
- {
- PauseMovement(0, 0, false);
- GetMotionMaster()->Clear(MOTION_PRIORITY_NORMAL);
+ // Remove any active voluntary movement
+ GetMotionMaster()->Clear(MOTION_PRIORITY_NORMAL);
+ // Stop any remaining spline, if no involuntary movement is found
+ auto criteria = [](MovementGenerator const* movement) -> bool
+ {
+ return movement->Priority == MOTION_PRIORITY_HIGHEST;
+ };
+ if (!GetMotionMaster()->HasMovementGenerator(criteria))
StopMoving();
- }
- else if (Player* player = ToPlayer())
+
+ // Set charmed
+ charmer->SetCharm(this, true);
+
+ if (Player* player = ToPlayer())
{
if (player->isAFK())
player->ToggleAFK();