Always clear requested targets when exiting AttackActivity/Flyattack.
This commit is contained in:
@@ -70,11 +70,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
Cancel(self);
|
Cancel(self);
|
||||||
|
|
||||||
if (IsCanceling)
|
if (IsCanceling)
|
||||||
{
|
|
||||||
// Cancel the requested target, but keep firing on it while in range
|
|
||||||
attackAircraft.ClearRequestedTarget();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
// Check that AttackFollow hasn't cancelled the target by modifying attack.Target
|
// Check that AttackFollow hasn't cancelled the target by modifying attack.Target
|
||||||
// Having both this and AttackFollow modify that field is a horrible hack.
|
// Having both this and AttackFollow modify that field is a horrible hack.
|
||||||
@@ -106,10 +102,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
|
|
||||||
// Target is hidden or dead, and we don't have a fallback position to move towards
|
// Target is hidden or dead, and we don't have a fallback position to move towards
|
||||||
if (useLastVisibleTarget && !lastVisibleTarget.IsValidFor(self))
|
if (useLastVisibleTarget && !lastVisibleTarget.IsValidFor(self))
|
||||||
{
|
|
||||||
attackAircraft.ClearRequestedTarget();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
// If all valid weapons have depleted their ammo and Rearmable trait exists, return to RearmActor to reload
|
// If all valid weapons have depleted their ammo and Rearmable trait exists, return to RearmActor to reload
|
||||||
// and resume the activity after reloading if AbortOnResupply is set to 'false'
|
// and resume the activity after reloading if AbortOnResupply is set to 'false'
|
||||||
@@ -127,10 +120,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
{
|
{
|
||||||
// We've reached the assumed position but it is not there - give up
|
// We've reached the assumed position but it is not there - give up
|
||||||
if (checkTarget.IsInRange(pos, lastVisibleMaximumRange))
|
if (checkTarget.IsInRange(pos, lastVisibleMaximumRange))
|
||||||
{
|
|
||||||
attackAircraft.ClearRequestedTarget();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
// Fly towards the last known position
|
// Fly towards the last known position
|
||||||
QueueChild(new Fly(self, target, WDist.Zero, lastVisibleMaximumRange, checkTarget.CenterPosition, Color.Red));
|
QueueChild(new Fly(self, target, WDist.Zero, lastVisibleMaximumRange, checkTarget.CenterPosition, Color.Red));
|
||||||
@@ -164,6 +154,12 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnLastRun(Actor self)
|
||||||
|
{
|
||||||
|
// Cancel the requested target, but keep firing on it while in range
|
||||||
|
attackAircraft.ClearRequestedTarget();
|
||||||
|
}
|
||||||
|
|
||||||
void IActivityNotifyStanceChanged.StanceChanged(Actor self, AutoTarget autoTarget, UnitStance oldStance, UnitStance newStance)
|
void IActivityNotifyStanceChanged.StanceChanged(Actor self, AutoTarget autoTarget, UnitStance oldStance, UnitStance newStance)
|
||||||
{
|
{
|
||||||
// Cancel non-forced targets when switching to a more restrictive stance if they are no longer valid for auto-targeting
|
// Cancel non-forced targets when switching to a more restrictive stance if they are no longer valid for auto-targeting
|
||||||
|
|||||||
@@ -258,11 +258,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public override bool Tick(Actor self)
|
public override bool Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (IsCanceling)
|
if (IsCanceling)
|
||||||
{
|
|
||||||
// Cancel the requested target, but keep firing on it while in range
|
|
||||||
attack.ClearRequestedTarget();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
// Check that AttackFollow hasn't cancelled the target by modifying attack.Target
|
// Check that AttackFollow hasn't cancelled the target by modifying attack.Target
|
||||||
// Having both this and AttackFollow modify that field is a horrible hack.
|
// Having both this and AttackFollow modify that field is a horrible hack.
|
||||||
@@ -315,10 +311,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
// If we are ticking again after previously sequencing a MoveWithRange then that move must have completed
|
// If we are ticking again after previously sequencing a MoveWithRange then that move must have completed
|
||||||
// Either we are in range and can see the target, or we've lost track of it and should give up
|
// Either we are in range and can see the target, or we've lost track of it and should give up
|
||||||
if (wasMovingWithinRange && targetIsHiddenActor)
|
if (wasMovingWithinRange && targetIsHiddenActor)
|
||||||
{
|
|
||||||
attack.ClearRequestedTarget();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
// Update target lines if required
|
// Update target lines if required
|
||||||
if (useLastVisibleTarget != oldUseLastVisibleTarget)
|
if (useLastVisibleTarget != oldUseLastVisibleTarget)
|
||||||
@@ -326,10 +319,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
// Target is hidden or dead, and we don't have a fallback position to move towards
|
// Target is hidden or dead, and we don't have a fallback position to move towards
|
||||||
if (useLastVisibleTarget && !lastVisibleTarget.IsValidFor(self))
|
if (useLastVisibleTarget && !lastVisibleTarget.IsValidFor(self))
|
||||||
{
|
|
||||||
attack.ClearRequestedTarget();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
var pos = self.CenterPosition;
|
var pos = self.CenterPosition;
|
||||||
var checkTarget = useLastVisibleTarget ? lastVisibleTarget : target;
|
var checkTarget = useLastVisibleTarget ? lastVisibleTarget : target;
|
||||||
@@ -339,26 +329,26 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
if (checkTarget.IsInRange(pos, maxRange) && !checkTarget.IsInRange(pos, minRange))
|
if (checkTarget.IsInRange(pos, maxRange) && !checkTarget.IsInRange(pos, minRange))
|
||||||
{
|
{
|
||||||
if (useLastVisibleTarget)
|
if (useLastVisibleTarget)
|
||||||
{
|
|
||||||
attack.ClearRequestedTarget();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We can't move into range, so give up
|
// We can't move into range, so give up
|
||||||
if (move == null || maxRange == WDist.Zero || maxRange < minRange)
|
if (move == null || maxRange == WDist.Zero || maxRange < minRange)
|
||||||
{
|
|
||||||
attack.ClearRequestedTarget();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
wasMovingWithinRange = true;
|
wasMovingWithinRange = true;
|
||||||
QueueChild(move.MoveWithinRange(target, minRange, maxRange, checkTarget.CenterPosition, Color.Red));
|
QueueChild(move.MoveWithinRange(target, minRange, maxRange, checkTarget.CenterPosition, Color.Red));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnLastRun(Actor self)
|
||||||
|
{
|
||||||
|
// Cancel the requested target, but keep firing on it while in range
|
||||||
|
attack.ClearRequestedTarget();
|
||||||
|
}
|
||||||
|
|
||||||
void IActivityNotifyStanceChanged.StanceChanged(Actor self, AutoTarget autoTarget, UnitStance oldStance, UnitStance newStance)
|
void IActivityNotifyStanceChanged.StanceChanged(Actor self, AutoTarget autoTarget, UnitStance oldStance, UnitStance newStance)
|
||||||
{
|
{
|
||||||
// Cancel non-forced targets when switching to a more restrictive stance if they are no longer valid for auto-targeting
|
// Cancel non-forced targets when switching to a more restrictive stance if they are no longer valid for auto-targeting
|
||||||
|
|||||||
Reference in New Issue
Block a user