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,10 +209,17 @@ namespace OpenRA.Mods.Common.Activities
if (!attack.TargetInFiringArc(self, target, attack.Info.FacingTolerance)) if (!attack.TargetInFiringArc(self, target, attack.Info.FacingTolerance))
{ {
var desiredFacing = (attack.GetTargetPosition(pos, target) - pos).Yaw; var desiredFacing = (attack.GetTargetPosition(pos, target) - pos).Yaw;
// 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; attackStatus |= AttackStatus.NeedsToTurn;
QueueChild(new Turn(self, desiredFacing));
return AttackStatus.NeedsToTurn; return AttackStatus.NeedsToTurn;
} }
}
attackStatus |= AttackStatus.Attacking; attackStatus |= AttackStatus.Attacking;
DoAttack(self, attack, armaments); DoAttack(self, attack, armaments);