Check if weapon without self-reloading is out of ammo when deciding validity

This should prevent attacking helicopters (or other actors) staying at the range to target of a weapon that is out of ammo and needs manual reloading at a RearmBuilding or via upgrades.
This commit is contained in:
reaperrr
2016-06-17 13:14:15 +02:00
parent 2f1a6e8807
commit 4f55b088eb
3 changed files with 16 additions and 4 deletions

View File

@@ -186,7 +186,7 @@ namespace OpenRA.Mods.Common.Traits
// PERF: Avoid LINQ.
foreach (var armament in Armaments)
if (armament.Weapon.IsValidAgainst(t, self.World, self))
if (!armament.OutOfAmmo && armament.Weapon.IsValidAgainst(t, self.World, self))
return true;
return false;
@@ -203,6 +203,10 @@ namespace OpenRA.Mods.Common.Traits
{
if (armament.IsTraitDisabled)
continue;
if (armament.OutOfAmmo)
continue;
var range = armament.Weapon.MinRange;
if (min > range)
min = range;
@@ -222,6 +226,10 @@ namespace OpenRA.Mods.Common.Traits
{
if (armament.IsTraitDisabled)
continue;
if (armament.OutOfAmmo)
continue;
var range = armament.MaxRange();
if (max < range)
max = range;
@@ -242,6 +250,9 @@ namespace OpenRA.Mods.Common.Traits
if (armament.IsTraitDisabled)
continue;
if (armament.OutOfAmmo)
continue;
if (!armament.Weapon.IsValidAgainst(target, self.World, self))
continue;
@@ -265,6 +276,9 @@ namespace OpenRA.Mods.Common.Traits
if (armament.IsTraitDisabled)
continue;
if (armament.OutOfAmmo)
continue;
if (!armament.Weapon.IsValidAgainst(target, self.World, self))
continue;