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:
@@ -80,13 +80,10 @@ namespace OpenRA.Mods.Common.Activities
|
||||
return this;
|
||||
|
||||
// Fly towards the target
|
||||
// TODO: Fix that the helicopter won't do anything if it has multiple weapons with different ranges
|
||||
// and the weapon with the longest range is out of ammo
|
||||
if (!target.IsInRange(self.CenterPosition, attackHeli.GetMaximumRangeVersusTarget(target)))
|
||||
helicopter.SetPosition(self, helicopter.CenterPosition + helicopter.FlyStep(desiredFacing));
|
||||
|
||||
// Fly backwards from the target
|
||||
// TODO: Same problem as with MaximumRange
|
||||
if (target.IsInRange(self.CenterPosition, attackHeli.GetMinimumRangeVersusTarget(target)))
|
||||
{
|
||||
// Facing 0 doesn't work with the following position change
|
||||
|
||||
@@ -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