diff --git a/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs b/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs index 6f53c583ad..6b792b78bb 100644 --- a/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs +++ b/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs @@ -164,6 +164,9 @@ namespace OpenRA.Mods.Common.Traits public void AttackTarget(Target target, bool queued, bool allowMove) { + if (self.IsDisabled()) + return; + if (!target.IsValidFor(self)) return; diff --git a/OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs b/OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs index b2bd537606..1ab859ea67 100644 --- a/OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs +++ b/OpenRA.Mods.Common/Traits/Attack/AttackFollow.cs @@ -20,7 +20,7 @@ namespace OpenRA.Mods.Common.Traits public override object Create(ActorInitializer init) { return new AttackFollow(init.Self, this); } } - public class AttackFollow : AttackBase, ITick, ISync + public class AttackFollow : AttackBase, ITick, INotifyOwnerChanged, ISync { public Target Target { get; protected set; } @@ -46,6 +46,11 @@ namespace OpenRA.Mods.Common.Traits Target = Target.Invalid; } + public void OnOwnerChanged(Actor self, Player oldOwner, Player newOwner) + { + Target = Target.Invalid; + } + class AttackActivity : Activity { readonly AttackFollow attack; diff --git a/OpenRA.Mods.Common/Traits/Attack/AttackTurreted.cs b/OpenRA.Mods.Common/Traits/Attack/AttackTurreted.cs index 1157d39d2b..0badcb0b29 100644 --- a/OpenRA.Mods.Common/Traits/Attack/AttackTurreted.cs +++ b/OpenRA.Mods.Common/Traits/Attack/AttackTurreted.cs @@ -35,12 +35,11 @@ namespace OpenRA.Mods.Common.Traits if (!base.CanAttack(self, target)) return false; - var canAttack = false; foreach (var t in turrets) if (t.FaceTarget(self, target)) - canAttack = true; + return true; - return canAttack; + return false; } } } diff --git a/OpenRA.Mods.Common/Traits/Render/WithMakeAnimation.cs b/OpenRA.Mods.Common/Traits/Render/WithMakeAnimation.cs index d43f075418..c72a2c9c79 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithMakeAnimation.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithMakeAnimation.cs @@ -46,13 +46,13 @@ namespace OpenRA.Mods.Common.Traits } } - public void Reverse(Actor self, Activity activity) + public void Reverse(Actor self, Activity activity, bool queued = true) { renderBuilding.PlayCustomAnimBackwards(self, info.Sequence, () => { // avoids visual glitches as we wait for the actor to get destroyed renderBuilding.DefaultAnimation.PlayFetchIndex(info.Sequence, () => 0); - self.QueueActivity(activity); + self.QueueActivity(queued, activity); }); } } diff --git a/OpenRA.Mods.Common/Traits/Sellable.cs b/OpenRA.Mods.Common/Traits/Sellable.cs index 4f3aa47947..9bbfb3cc23 100644 --- a/OpenRA.Mods.Common/Traits/Sellable.cs +++ b/OpenRA.Mods.Common/Traits/Sellable.cs @@ -53,9 +53,9 @@ namespace OpenRA.Mods.Common.Traits var makeAnimation = self.TraitOrDefault(); if (makeAnimation != null) - makeAnimation.Reverse(self, new Sell()); + makeAnimation.Reverse(self, new Sell(), false); else - self.QueueActivity(new Sell()); + self.QueueActivity(false, new Sell()); } } }