From a586f108759f56911f671adc851a11ae97e52c9c Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Thu, 26 Sep 2019 21:59:54 +0200 Subject: [PATCH] Don't allow movement for actors without IMove However, this does not check if any existing IMove traits are enabled. --- OpenRA.Mods.Common/Traits/AutoTarget.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/AutoTarget.cs b/OpenRA.Mods.Common/Traits/AutoTarget.cs index c32938da20..1a8cad050f 100644 --- a/OpenRA.Mods.Common/Traits/AutoTarget.cs +++ b/OpenRA.Mods.Common/Traits/AutoTarget.cs @@ -127,6 +127,9 @@ namespace OpenRA.Mods.Common.Traits public class AutoTarget : ConditionalTrait, INotifyIdle, INotifyDamage, ITick, IResolveOrder, ISync, INotifyOwnerChanged { public readonly IEnumerable ActiveAttackBases; + + readonly bool allowMovement; + [Sync] int nextScanTime = 0; @@ -187,6 +190,8 @@ namespace OpenRA.Mods.Common.Traits stance = self.Owner.IsBot || !self.Owner.Playable ? info.InitialStanceAI : info.InitialStance; PredictedStance = stance; + + allowMovement = Info.AllowMovement && self.TraitOrDefault() != null; } protected override void Created(Actor self) @@ -244,7 +249,7 @@ namespace OpenRA.Mods.Common.Traits } // Don't fire at an invisible enemy when we can't move to reveal it - var allowMove = Info.AllowMovement && Stance > UnitStance.Defend; + var allowMove = allowMovement && Stance > UnitStance.Defend; if (!allowMove && !attacker.CanBeViewedByPlayer(self.Owner)) return; @@ -267,7 +272,7 @@ namespace OpenRA.Mods.Common.Traits if (IsTraitDisabled || Stance < UnitStance.Defend) return; - var allowMove = Info.AllowMovement && Stance > UnitStance.Defend; + var allowMove = allowMovement && Stance > UnitStance.Defend; var allowTurn = Info.AllowTurning && Stance > UnitStance.HoldFire; ScanAndAttack(self, allowMove, allowTurn); }