Always complete FlyAttack for a zero MaximumRange to avoid stalling
This commit is contained in:
@@ -119,14 +119,10 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
if (useLastVisibleTarget && !lastVisibleTarget.IsValidFor(self))
|
if (useLastVisibleTarget && !lastVisibleTarget.IsValidFor(self))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// If all weapons are invalid against the target
|
// If all valid weapons have depleted their ammo and Rearmable trait exists, return to RearmActor to reload
|
||||||
if (!useLastVisibleTarget && attackAircraft.Armaments.All(x => x.IsTraitPaused || !x.Weapon.IsValidAgainst(target, self.World, self)))
|
// and resume the activity after reloading if AbortOnResupply is set to 'false'
|
||||||
|
if (rearmable != null && !useLastVisibleTarget && attackAircraft.Armaments.All(x => x.IsTraitPaused || !x.Weapon.IsValidAgainst(target, self.World, self)))
|
||||||
{
|
{
|
||||||
// If Rearmable trait exists, return to RearmActor to reload and resume the activity after
|
|
||||||
// reloading if AbortOnResupply is set to 'false'.
|
|
||||||
if (rearmable == null)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
// Attack moves never resupply
|
// Attack moves never resupply
|
||||||
if (source == AttackSource.AttackMove)
|
if (source == AttackSource.AttackMove)
|
||||||
return true;
|
return true;
|
||||||
@@ -143,32 +139,19 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
var pos = self.CenterPosition;
|
var pos = self.CenterPosition;
|
||||||
var checkTarget = useLastVisibleTarget ? lastVisibleTarget : target;
|
var checkTarget = useLastVisibleTarget ? lastVisibleTarget : target;
|
||||||
|
|
||||||
// We don't know where the target actually is, so move to where we last saw it
|
var minimumRange = attackAircraft.Info.AttackType == AirAttackType.Strafe ? WDist.Zero : attackAircraft.GetMinimumRangeVersusTarget(target);
|
||||||
if (useLastVisibleTarget)
|
|
||||||
{
|
|
||||||
// HACK: Bot players ignore the standard visibility checks in target.Recalculate,
|
|
||||||
// which means that targetIsHiddenActor is always false, allowing lastVisibleMaximumRange
|
|
||||||
// to be assigned zero range by attackAircraft.GetMaximumRangeVersusTarget for e.g. cloaked actors.
|
|
||||||
// Catch and cancel this edge case to avoid the aircraft stopping mid-air!
|
|
||||||
if (self.Owner.IsBot && lastVisibleMaximumRange == WDist.Zero)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
// We've reached the assumed position but it is not there - give up
|
if (checkTarget.IsInRange(pos, lastVisibleMaximumRange) && !checkTarget.IsInRange(pos, minimumRange) && useLastVisibleTarget)
|
||||||
if (checkTarget.IsInRange(pos, lastVisibleMaximumRange))
|
return true;
|
||||||
return true;
|
|
||||||
|
|
||||||
// Fly towards the last known position
|
if (lastVisibleMaximumRange == WDist.Zero || lastVisibleMaximumRange < minimumRange)
|
||||||
QueueChild(new Fly(self, target, WDist.Zero, lastVisibleMaximumRange, checkTarget.CenterPosition, Color.Red));
|
return true;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var delta = attackAircraft.GetTargetPosition(pos, target) - pos;
|
var delta = attackAircraft.GetTargetPosition(pos, target) - pos;
|
||||||
var desiredFacing = delta.HorizontalLengthSquared != 0 ? delta.Yaw : aircraft.Facing;
|
var desiredFacing = delta.HorizontalLengthSquared != 0 ? delta.Yaw : aircraft.Facing;
|
||||||
|
|
||||||
QueueChild(new TakeOff(self));
|
QueueChild(new TakeOff(self));
|
||||||
|
|
||||||
var minimumRange = attackAircraft.Info.AttackType == AirAttackType.Strafe ? WDist.Zero : attackAircraft.GetMinimumRangeVersusTarget(target);
|
|
||||||
|
|
||||||
// Move into range of the target.
|
// Move into range of the target.
|
||||||
if (!target.IsInRange(pos, lastVisibleMaximumRange) || target.IsInRange(pos, minimumRange))
|
if (!target.IsInRange(pos, lastVisibleMaximumRange) || target.IsInRange(pos, minimumRange))
|
||||||
QueueChild(aircraft.MoveWithinRange(target, minimumRange, lastVisibleMaximumRange, target.CenterPosition, Color.Red));
|
QueueChild(aircraft.MoveWithinRange(target, minimumRange, lastVisibleMaximumRange, target.CenterPosition, Color.Red));
|
||||||
|
|||||||
Reference in New Issue
Block a user