Consider AutoTarget ScanRadius when attack moving

This commit is contained in:
Gustas
2022-09-04 16:04:18 +03:00
committed by Matthias Mailänder
parent 9fc0f79703
commit 3207d01cf2
2 changed files with 7 additions and 8 deletions

View File

@@ -61,7 +61,7 @@ namespace OpenRA.Mods.Common.Activities
{
// Use the standard ScanForTarget rate limit while we are running the move activity to save performance.
// Override the rate limit if our attack activity has completed so we can immediately acquire a new target instead of moving.
target = autoTarget.ScanForTarget(self, false, true, !runningMoveActivity);
target = autoTarget.ScanForTarget(self, autoTarget.AllowMove, true, !runningMoveActivity);
// Cancel the current move activity and queue attack activities if we find a new target.
if (target.Type != TargetType.Invalid)
@@ -70,7 +70,7 @@ namespace OpenRA.Mods.Common.Activities
ChildActivity?.Cancel(self);
foreach (var ab in autoTarget.ActiveAttackBases)
QueueChild(ab.GetAttackActivity(self, AttackSource.AttackMove, target, false, false));
QueueChild(ab.GetAttackActivity(self, AttackSource.AttackMove, target, autoTarget.AllowMove, false));
}
// Continue with the move activity (or queue a new one) when there are no targets.

View File

@@ -136,6 +136,7 @@ namespace OpenRA.Mods.Common.Traits
int nextScanTime = 0;
public UnitStance Stance { get; private set; }
public bool AllowMove => allowMovement && Stance > UnitStance.Defend;
[Sync]
public Actor Aggressor;
@@ -240,8 +241,7 @@ namespace OpenRA.Mods.Common.Traits
}
// 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;
// Not a lot we can do about things we can't hurt... although maybe we should automatically run away?
@@ -256,7 +256,7 @@ namespace OpenRA.Mods.Common.Traits
// Respect AutoAttack priorities.
if (Stance > UnitStance.ReturnFire)
{
var autoTarget = ScanForTarget(self, allowMove, true);
var autoTarget = ScanForTarget(self, AllowMove, true);
if (autoTarget != Target.Invalid)
attacker = autoTarget.Actor;
@@ -264,7 +264,7 @@ namespace OpenRA.Mods.Common.Traits
Aggressor = attacker;
Attack(Target.FromActor(Aggressor), allowMove);
Attack(Target.FromActor(Aggressor), AllowMove);
}
void INotifyIdle.TickIdle(Actor self)
@@ -272,9 +272,8 @@ namespace OpenRA.Mods.Common.Traits
if (IsTraitDisabled || !Info.ScanOnIdle || Stance < UnitStance.Defend)
return;
var allowMove = allowMovement && Stance > UnitStance.Defend;
var allowTurn = Info.AllowTurning && Stance > UnitStance.HoldFire;
ScanAndAttack(self, allowMove, allowTurn);
ScanAndAttack(self, AllowMove, allowTurn);
}
void ITick.Tick(Actor self)