diff --git a/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs b/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs index 8acfa94f73..8e7fa78869 100644 --- a/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs +++ b/OpenRA.Mods.Common/Traits/Attack/AttackBase.cs @@ -233,17 +233,17 @@ namespace OpenRA.Mods.Common.Traits } // Enumerates all armaments, that this actor possesses, that can be used against Target t - public IEnumerable ChooseArmamentsForTarget(Target t, bool forceAttack, bool onlyEnabled = true) + public IEnumerable ChooseArmamentsForTarget(Target t, bool forceAttack) { // If force-fire is not used, and the target requires force-firing or the target is // terrain or invalid, no armaments can be used - if (!forceAttack && (t.RequiresForceFire || t.Type == TargetType.Terrain || t.Type == TargetType.Invalid)) + if (!forceAttack && (t.Type == TargetType.Terrain || t.Type == TargetType.Invalid || t.RequiresForceFire)) return Enumerable.Empty(); // Get target's owner; in case of terrain or invalid target there will be no problems // with owner == null since forceFire will have to be true in this part of the method // (short-circuiting in the logical expression below) - var owner = null as Player; + Player owner = null; if (t.Type == TargetType.FrozenActor) { owner = t.FrozenActor.Owner; @@ -260,10 +260,11 @@ namespace OpenRA.Mods.Common.Traits owner = t.Actor.Owner; } - return Armaments.Where(a => (!a.IsTraitDisabled || !onlyEnabled) - && a.Weapon.IsValidAgainst(t, self.World, self) + return Armaments.Where(a => + !a.IsTraitDisabled && (owner == null || (forceAttack ? a.Info.ForceTargetStances : a.Info.TargetStances) - .HasStance(self.Owner.Stances[owner]))); + .HasStance(self.Owner.Stances[owner])) + && a.Weapon.IsValidAgainst(t, self.World, self)); } public void AttackTarget(Target target, bool queued, bool allowMove, bool forceAttack = false)