Core/Movement: Properly resume chase/follow movement if it was paused by a spell cast.
Port From (https://github.com/TrinityCore/TrinityCore/commit/6d2423b7334915c60225103863c3ffae3831719b)
This commit is contained in:
@@ -30,7 +30,7 @@ namespace Game.Movement
|
||||
ChaseAngle? _angle;
|
||||
|
||||
PathGenerator _path;
|
||||
Position _lastTargetPosition = new();
|
||||
Position _lastTargetPosition;
|
||||
uint _rangeCheckTimer = RANGE_CHECK_INTERVAL;
|
||||
bool _movingTowards = true;
|
||||
bool _mutualChase = true;
|
||||
@@ -56,7 +56,7 @@ namespace Game.Movement
|
||||
|
||||
owner.SetWalk(false);
|
||||
_path = null;
|
||||
_lastTargetPosition.Relocate(0.0f, 0.0f, 0.0f);
|
||||
_lastTargetPosition = null;
|
||||
}
|
||||
|
||||
public override void Reset(Unit owner)
|
||||
@@ -84,6 +84,7 @@ namespace Game.Movement
|
||||
if (owner.HasUnitState(UnitState.NotMove) || owner.IsMovementPreventedByCasting())
|
||||
{
|
||||
owner.StopMoving();
|
||||
_lastTargetPosition = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -124,9 +125,9 @@ namespace Game.Movement
|
||||
}
|
||||
|
||||
// if the target moved, we have to consider whether to adjust
|
||||
if (_lastTargetPosition != target.GetPosition() || mutualChase != _mutualChase)
|
||||
if (_lastTargetPosition == null || target.GetPosition() != _lastTargetPosition || mutualChase != _mutualChase)
|
||||
{
|
||||
_lastTargetPosition.Relocate(target.GetPosition());
|
||||
_lastTargetPosition = new(target.GetPosition());
|
||||
_mutualChase = mutualChase;
|
||||
if (owner.HasUnitState(UnitState.ChaseMove) || !PositionOkay(owner, target, minRange, maxRange, angle))
|
||||
{
|
||||
@@ -216,7 +217,7 @@ namespace Game.Movement
|
||||
|
||||
public override MovementGeneratorType GetMovementGeneratorType() { return MovementGeneratorType.Chase; }
|
||||
|
||||
public override void UnitSpeedChanged() { _lastTargetPosition.Relocate(0.0f, 0.0f, 0.0f); }
|
||||
public override void UnitSpeedChanged() { _lastTargetPosition = null; }
|
||||
|
||||
static bool IsMutualChase(Unit owner, Unit target)
|
||||
{
|
||||
|
||||
@@ -41,7 +41,6 @@ namespace Game.Movement
|
||||
_abstractFollower = new AbstractFollower(target);
|
||||
_range = range;
|
||||
_angle = angle;
|
||||
_lastTargetPosition = new();
|
||||
|
||||
Mode = MovementGeneratorMode.Default;
|
||||
Priority = MovementGeneratorPriority.Normal;
|
||||
@@ -57,7 +56,7 @@ namespace Game.Movement
|
||||
owner.StopMoving();
|
||||
UpdatePetSpeed(owner);
|
||||
_path = null;
|
||||
_lastTargetPosition.Relocate(0.0f, 0.0f, 0.0f);
|
||||
_lastTargetPosition = null;
|
||||
}
|
||||
|
||||
public override void Reset(Unit owner)
|
||||
@@ -80,6 +79,7 @@ namespace Game.Movement
|
||||
if (owner.HasUnitState(UnitState.NotMove) || owner.IsMovementPreventedByCasting())
|
||||
{
|
||||
owner.StopMoving();
|
||||
_lastTargetPosition = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -107,9 +107,9 @@ namespace Game.Movement
|
||||
DoMovementInform(owner, target);
|
||||
}
|
||||
|
||||
if (_lastTargetPosition.GetExactDistSq(target.GetPosition()) > 0.0f)
|
||||
if (_lastTargetPosition == null || _lastTargetPosition.GetExactDistSq(target.GetPosition()) > 0.0f)
|
||||
{
|
||||
_lastTargetPosition = target.GetPosition();
|
||||
_lastTargetPosition = new(target.GetPosition());
|
||||
if (owner.HasUnitState(UnitState.FollowMove) || !PositionOkay(owner, target, _range + FOLLOW_RANGE_TOLERANCE))
|
||||
{
|
||||
if (_path == null)
|
||||
@@ -202,7 +202,7 @@ namespace Game.Movement
|
||||
|
||||
public override MovementGeneratorType GetMovementGeneratorType() { return MovementGeneratorType.Follow; }
|
||||
|
||||
public override void UnitSpeedChanged() { _lastTargetPosition.Relocate(0.0f, 0.0f, 0.0f); }
|
||||
public override void UnitSpeedChanged() { _lastTargetPosition = null; }
|
||||
|
||||
static bool PositionOkay(Unit owner, Unit target, float range, ChaseAngle? angle = null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user