diff options
author | ccrs <ccrs@users.noreply.github.com> | 2019-07-12 20:06:27 +0200 |
---|---|---|
committer | ccrs <ccrs@users.noreply.github.com> | 2019-07-12 20:06:27 +0200 |
commit | 294a3a2789582e05a7847620173d533bd07e44e9 (patch) | |
tree | 561a0ccc1cd9ae15ee24d1250e2fb3d469094a32 /src | |
parent | 4ee84bbecbccee2adb093d4c30172edc22ef8499 (diff) |
Core/Unit: movement related corrections prior to getting Charmed
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 23 |
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(); |