private void UseTargetMovement(CacheObject obj, bool bForceNewMovement = false)
{
float currentDistance = Vector3.Distance(LastTargetLocation, CurrentTargetLocation);
if (DateTime.Now.Subtract(LastMovementAttempted).TotalMilliseconds >= 250 || (currentDistance >= 2f && !FunkyGame.Hero.IsMoving) || bForceNewMovement)
{
bool UsePowerMovement = true;
//Check for any circumstances where we use actor movement instead of power. (click or click-hold)
if (ObjectCache.CheckFlag(obj.targetType.Value, TargetType.AvoidanceMovements))
{
if (NonMovementCounter < 10 || currentDistance > 50f)
UsePowerMovement = false;
}
else if (ObjectCache.CheckFlag(obj.targetType.Value, TargetType.LineOfSight | TargetType.Backtrack))
{
UsePowerMovement = true;
}
else if (ObjectCache.CheckFlag(obj.targetType.Value, TargetType.LineOfSight))
{
Navigator.MoveTo(CurrentTargetLocation, "LOS");
LastMovementCommand = DateTime.Now;
return;
}
else
{
//Use Walk Power when not using LOS Movement, target is not an item and target does not ignore LOS.
if (!(NonMovementCounter < 10 &&
!obj.UsingLOSV3 &&
!obj.IgnoresLOSCheck &&
(obj.targetType.Value != TargetType.Item) &&
obj.targetType.Value != TargetType.Interactable))
{
UsePowerMovement = true;
}
}
//Preform Movement!
if (!UsePowerMovement)
ZetaDia.Me.Movement.MoveActor(CurrentTargetLocation);
else
ZetaDia.Me.UsePower(SNOPower.Walk, CurrentTargetLocation, FunkyGame.Hero.CurrentWorldDynamicID);
//and record when we sent the movement..
LastMovementCommand = DateTime.Now;
}
}