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
This commit is contained in:
ccrs
2020-05-11 19:38:36 +02:00
parent 16d4a39c7d
commit 472e1fd8ae

View File

@@ -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();