diff options
author | ccrs <ccrs@users.noreply.github.com> | 2020-05-11 19:38:36 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2022-01-04 15:33:04 +0100 |
commit | 9fd26c5f09c6c99635a8cd8ac961abe9d0c79e5d (patch) | |
tree | 4a79c00faa3e744675edcaa7e4f68e499655b79d /src | |
parent | a0538f979a2dfd81aa889d011324e8d5da895dc6 (diff) |
Core/Movement: 9080e78 followup
actually port back the previous implementation, now correctly
this implies that a unit that has a different victim than the one its chasing will stand still till either:
- a new movement replaces the current, for w/e reason
- the chase target is again the current victim
probably a pause implementation on the generator is a more elegant solution...
updates #24600
(cherry picked from commit 472e1fd8aeea80c6b32253007a204e645f89dc2e)
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Movement/MovementGenerators/ChaseMovementGenerator.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/server/game/Movement/MovementGenerators/ChaseMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/ChaseMovementGenerator.cpp index 056da0f5a5a..b3e9e56c81e 100644 --- a/src/server/game/Movement/MovementGenerators/ChaseMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/ChaseMovementGenerator.cpp @@ -26,6 +26,11 @@ #include "Unit.h" #include "Util.h" +static bool HasLostTarget(Unit* owner, Unit* target) +{ + return owner->GetVictim() != target; +} + static bool IsMutualChase(Unit* owner, Unit* target) { if (target->GetMotionMaster()->GetCurrentMovementGeneratorType() != CHASE_MOTION_TYPE) @@ -97,8 +102,8 @@ bool ChaseMovementGenerator::Update(Unit* owner, uint32 diff) if (!target || !target->IsInWorld()) return false; - // the owner might be unable to move (rooted or casting), pause movement - if (owner->HasUnitState(UNIT_STATE_NOT_MOVE) || owner->IsMovementPreventedByCasting()) + // the owner might be unable to move (rooted or casting), or we have lost the target, pause movement + if (owner->HasUnitState(UNIT_STATE_NOT_MOVE) || owner->IsMovementPreventedByCasting() || HasLostTarget(owner, target)) { owner->StopMoving(); _lastTargetPosition.reset(); |