Make Attack turn during its own tick

This commit is contained in:
abcdefg30
2020-12-03 15:35:24 +01:00
committed by Paul Chote
parent 86519bfda5
commit 4953ce314b

View File

@@ -209,9 +209,16 @@ namespace OpenRA.Mods.Common.Activities
if (!attack.TargetInFiringArc(self, target, attack.Info.FacingTolerance))
{
var desiredFacing = (attack.GetTargetPosition(pos, target) - pos).Yaw;
attackStatus |= AttackStatus.NeedsToTurn;
QueueChild(new Turn(self, desiredFacing));
return AttackStatus.NeedsToTurn;
// Don't queue a turn activity: Executing a child takes an additional tick during which the target may have moved again
facing.Facing = Util.TickFacing(facing.Facing, desiredFacing, facing.TurnSpeed);
// Check again if we turned enough and directly continue attacking if we did
if (!attack.TargetInFiringArc(self, target, attack.Info.FacingTolerance))
{
attackStatus |= AttackStatus.NeedsToTurn;
return AttackStatus.NeedsToTurn;
}
}
attackStatus |= AttackStatus.Attacking;