fix(Core/Movement): Fixup root distancing mobs being stuck in a loop (#23514)

This commit is contained in:
killerwife
2025-11-03 07:44:29 +01:00
committed by GitHub
parent 92c7ba73bf
commit 288b495701
@@ -113,7 +113,7 @@ bool ChaseMovementGenerator<T>::DispatchSplineToPosition(T* owner, float x, floa
} }
owner->StopMoving(); owner->StopMoving();
return true; return false;
} }
if (cutPath) if (cutPath)
@@ -134,7 +134,7 @@ bool ChaseMovementGenerator<T>::DispatchSplineToPosition(T* owner, float x, floa
init.SetWalk(walk); init.SetWalk(walk);
init.Launch(); init.Launch();
return false; return true;
} }
template<class T> template<class T>
@@ -219,6 +219,8 @@ bool ChaseMovementGenerator<T>::DoUpdate(T* owner, uint32 time_diff)
{ {
i_recheckDistance.Reset(400); // Sniffed value i_recheckDistance.Reset(400); // Sniffed value
if (m_currentMode != CHASE_MODE_DISTANCING)
{
if (i_recalculateTravel && PositionOkay(owner, target, _movingTowards ? maxTarget : Optional<float>(), angle)) if (i_recalculateTravel && PositionOkay(owner, target, _movingTowards ? maxTarget : Optional<float>(), angle))
{ {
if ((owner->HasUnitState(UNIT_STATE_CHASE_MOVE) && !target->isMoving() && !mutualChase) || _range) if ((owner->HasUnitState(UNIT_STATE_CHASE_MOVE) && !target->isMoving() && !mutualChase) || _range)
@@ -234,6 +236,7 @@ bool ChaseMovementGenerator<T>::DoUpdate(T* owner, uint32 time_diff)
} }
} }
} }
}
// if we're done moving, we want to clean up // if we're done moving, we want to clean up
if (owner->HasUnitState(UNIT_STATE_CHASE_MOVE) && owner->movespline->Finalized()) if (owner->HasUnitState(UNIT_STATE_CHASE_MOVE) && owner->movespline->Finalized())
@@ -262,6 +265,9 @@ bool ChaseMovementGenerator<T>::DoUpdate(T* owner, uint32 time_diff)
i_leashExtensionTimer.Reset(cOwner->GetAttackTime(BASE_ATTACK)); i_leashExtensionTimer.Reset(cOwner->GetAttackTime(BASE_ATTACK));
} }
if (m_currentMode == CHASE_MODE_DISTANCING)
return true;
// if the target moved, we have to consider whether to adjust // if the target moved, we have to consider whether to adjust
if (!_lastTargetPosition || target->GetPosition() != _lastTargetPosition.value() || mutualChase != _mutualChase || !owner->IsWithinLOSInMap(target)) if (!_lastTargetPosition || target->GetPosition() != _lastTargetPosition.value() || mutualChase != _mutualChase || !owner->IsWithinLOSInMap(target))
{ {