Only consider non-paused armaments (if any exist) when determining min/max range.

This commit is contained in:
darkademic
2023-06-06 17:31:37 +01:00
committed by abcdefg30
parent fa65e7fd3f
commit 19fa03435b

View File

@@ -191,9 +191,19 @@ namespace OpenRA.Mods.Common.Activities
if (armaments.Count == 0)
return AttackStatus.UnableToAttack;
// Update ranges
minRange = armaments.Max(a => a.Weapon.MinRange);
maxRange = armaments.Min(a => a.MaxRange());
// Update ranges. Exclude paused armaments except when ALL weapons are paused
// (e.g. out of ammo), in which case use the paused, valid weapon with highest range.
var activeArmaments = armaments.Where(x => !x.IsTraitPaused);
if (activeArmaments.Any())
{
minRange = activeArmaments.Max(a => a.Weapon.MinRange);
maxRange = activeArmaments.Min(a => a.MaxRange());
}
else
{
minRange = WDist.Zero;
maxRange = armaments.Max(a => a.MaxRange());
}
var pos = self.CenterPosition;
if (!target.IsInRange(pos, maxRange)