diff options
| author | ccrs <ccrs@users.noreply.github.com> | 2019-07-12 20:06:27 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2021-12-15 23:42:06 +0100 |
| commit | ef6a5d3c3c010f9ad63a71015a533a3894ab38b9 (patch) | |
| tree | a73011bca99ab287e255f8104c7d5c49b2c42238 /src | |
| parent | 3bb61af1130acccfc8d785922181e98becf1c7e5 (diff) | |
Core/Unit: movement related corrections prior to getting Charmed
(cherry picked from commit 294a3a2789582e05a7847620173d533bd07e44e9)
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 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(); |
