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:
@@ -259,6 +259,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public bool IsReloading { get { return FireDelay > 0 || IsTraitDisabled; } }
|
||||
public bool ShouldExplode(Actor self) { return !IsReloading; }
|
||||
public bool OutOfAmmo { get { return ammoPool != null && !ammoPool.Info.SelfReloads && !ammoPool.HasAmmo(); } }
|
||||
|
||||
public WVec MuzzleOffset(Actor self, Barrel b)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user