From 4953ce314be22de97b121c8ae5f59c2e9c4e8f5f Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Thu, 3 Dec 2020 15:35:24 +0100 Subject: [PATCH] Make Attack turn during its own tick --- OpenRA.Mods.Common/Activities/Attack.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/OpenRA.Mods.Common/Activities/Attack.cs b/OpenRA.Mods.Common/Activities/Attack.cs index 1711db71a5..9c0ebadd34 100644 --- a/OpenRA.Mods.Common/Activities/Attack.cs +++ b/OpenRA.Mods.Common/Activities/Attack.cs @@ -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;