Revert "Fix AttackFollow ignoring allowMove flag when auto-targeting."

This reverts commit 3e116060cfc0a3e46563716c3e594a4ba3051b93.
This commit is contained in:
Paul Chote
2020-03-01 20:02:32 +00:00
committed by abcdefg30
parent 05a2e77be2
commit 16e0ea611e
3 changed files with 5 additions and 14 deletions

View File

@@ -42,7 +42,6 @@ namespace OpenRA.Mods.Common.Traits
Activity requestedTargetPresetForActivity; Activity requestedTargetPresetForActivity;
bool opportunityForceAttack; bool opportunityForceAttack;
bool opportunityTargetIsPersistentTarget; bool opportunityTargetIsPersistentTarget;
bool scanningForOpportunityTarget;
public void SetRequestedTarget(Actor self, Target target, bool isForceAttack = false) public void SetRequestedTarget(Actor self, Target target, bool isForceAttack = false)
{ {
@@ -138,10 +137,7 @@ namespace OpenRA.Mods.Common.Traits
if (!IsAiming && Info.OpportunityFire && autoTarget != null && if (!IsAiming && Info.OpportunityFire && autoTarget != null &&
!autoTarget.IsTraitDisabled && autoTarget.Stance >= UnitStance.Defend) !autoTarget.IsTraitDisabled && autoTarget.Stance >= UnitStance.Defend)
{ {
scanningForOpportunityTarget = true;
OpportunityTarget = autoTarget.ScanForTarget(self, false, false); OpportunityTarget = autoTarget.ScanForTarget(self, false, false);
scanningForOpportunityTarget = false;
opportunityForceAttack = false; opportunityForceAttack = false;
opportunityTargetIsPersistentTarget = false; opportunityTargetIsPersistentTarget = false;
@@ -186,13 +182,8 @@ namespace OpenRA.Mods.Common.Traits
opportunityTargetIsPersistentTarget = false; opportunityTargetIsPersistentTarget = false;
} }
bool IDisableAutoTarget.DisableAutoTarget(Actor self, bool allowMove) bool IDisableAutoTarget.DisableAutoTarget(Actor self)
{ {
// HACK: Disable standard AutoTarget scanning, which we want to be
// controlled by the opportunity target logic in this trait
if (!allowMove && !scanningForOpportunityTarget)
return true;
return RequestedTarget.Type != TargetType.Invalid || return RequestedTarget.Type != TargetType.Invalid ||
(opportunityTargetIsPersistentTarget && OpportunityTarget.Type != TargetType.Invalid); (opportunityTargetIsPersistentTarget && OpportunityTarget.Type != TargetType.Invalid);
} }

View File

@@ -236,9 +236,8 @@ namespace OpenRA.Mods.Common.Traits
if (attacker.Disposed) if (attacker.Disposed)
return; return;
var allowMove = allowMovement && Stance > UnitStance.Defend;
foreach (var dat in disableAutoTarget) foreach (var dat in disableAutoTarget)
if (dat.DisableAutoTarget(self, allowMove)) if (dat.DisableAutoTarget(self))
return; return;
if (!attacker.IsInWorld) if (!attacker.IsInWorld)
@@ -250,6 +249,7 @@ namespace OpenRA.Mods.Common.Traits
} }
// Don't fire at an invisible enemy when we can't move to reveal it // Don't fire at an invisible enemy when we can't move to reveal it
var allowMove = allowMovement && Stance > UnitStance.Defend;
if (!allowMove && !attacker.CanBeViewedByPlayer(self.Owner)) if (!allowMove && !attacker.CanBeViewedByPlayer(self.Owner))
return; return;
@@ -291,7 +291,7 @@ namespace OpenRA.Mods.Common.Traits
if (nextScanTime <= 0 && ActiveAttackBases.Any()) if (nextScanTime <= 0 && ActiveAttackBases.Any())
{ {
foreach (var dat in disableAutoTarget) foreach (var dat in disableAutoTarget)
if (dat.DisableAutoTarget(self, allowMove)) if (dat.DisableAutoTarget(self))
return Target.Invalid; return Target.Invalid;
nextScanTime = self.World.SharedRandom.Next(Info.MinimumScanTimeInterval, Info.MaximumScanTimeInterval); nextScanTime = self.World.SharedRandom.Next(Info.MinimumScanTimeInterval, Info.MaximumScanTimeInterval);

View File

@@ -310,7 +310,7 @@ namespace OpenRA.Mods.Common.Traits
[RequireExplicitImplementation] [RequireExplicitImplementation]
public interface IDisableAutoTarget public interface IDisableAutoTarget
{ {
bool DisableAutoTarget(Actor self, bool allowMove); bool DisableAutoTarget(Actor self);
} }
[RequireExplicitImplementation] [RequireExplicitImplementation]