From 5393b689d40e6cf588d2e94cc40ac0e16b6d8b06 Mon Sep 17 00:00:00 2001 From: tovl Date: Fri, 9 Aug 2019 23:57:57 +0200 Subject: [PATCH] Disable preemptive targeting for queued orders. --- OpenRA.Mods.Common/Activities/Move/AttackMoveActivity.cs | 6 +----- OpenRA.Mods.Common/Traits/Attack/AttackBase.cs | 9 +++------ OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs | 4 ++-- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/OpenRA.Mods.Common/Activities/Move/AttackMoveActivity.cs b/OpenRA.Mods.Common/Activities/Move/AttackMoveActivity.cs index c1b28f061a..6753597622 100644 --- a/OpenRA.Mods.Common/Activities/Move/AttackMoveActivity.cs +++ b/OpenRA.Mods.Common/Activities/Move/AttackMoveActivity.cs @@ -63,11 +63,7 @@ namespace OpenRA.Mods.Common.Activities ChildActivity.Cancel(self); var attackBases = autoTarget.ActiveAttackBases; foreach (var ab in attackBases) - { - var activity = ab.GetAttackActivity(self, target, true, false); - QueueChild(activity); - ab.OnQueueAttackActivity(self, activity, target, true, false); - } + QueueChild(ab.GetAttackActivity(self, target, true, false)); // Make sure to continue moving when the attack activities have finished. QueueChild(getInner()); diff --git a/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs b/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs index 72e4b78424..168d1bb7fb 100644 --- a/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs +++ b/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs @@ -399,15 +399,12 @@ namespace OpenRA.Mods.Common.Traits if (!target.IsValidFor(self)) return; - if (!queued) - self.CancelActivity(); - var activity = GetAttackActivity(self, target, allowMove, forceAttack, targetLineColor); - self.QueueActivity(activity); - OnQueueAttackActivity(self, activity, target, allowMove, forceAttack); + self.QueueActivity(queued, activity); + OnResolveAttackOrder(self, activity, target, queued, forceAttack); } - public virtual void OnQueueAttackActivity(Actor self, Activity activity, Target target, bool allowMove, bool forceAttack) { } + public virtual void OnResolveAttackOrder(Actor self, Activity activity, Target target, bool queued, bool forceAttack) { } public bool IsReachableTarget(Target target, bool allowMove) { diff --git a/OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs b/OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs index 8c63b97497..1583854920 100644 --- a/OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs +++ b/OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs @@ -157,11 +157,11 @@ namespace OpenRA.Mods.Common.Traits return new AttackActivity(self, newTarget, allowMove, forceAttack, targetLineColor); } - public override void OnQueueAttackActivity(Actor self, Activity activity, Target target, bool allowMove, bool forceAttack) + public override void OnResolveAttackOrder(Actor self, Activity activity, Target target, bool queued, bool forceAttack) { // We can improve responsiveness for turreted actors by preempting // the last order (usually a move) and setting the target immediately - if (self.CurrentActivity != null && self.CurrentActivity.NextActivity == activity) + if (!queued) { RequestedTarget = target; requestedForceAttack = forceAttack;