aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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 15e1828cc26..5b4ce78a8a1 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -10897,17 +10897,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();