Add support for circumventing the target scan limit in AttackMove

This commit is contained in:
abcdefg30
2020-08-20 23:03:17 +02:00
committed by reaperrr
parent a12d127fd6
commit ad3722e19f
2 changed files with 7 additions and 5 deletions

View File

@@ -56,8 +56,9 @@ namespace OpenRA.Mods.Common.Activities
// We are currently not attacking, so scan for new targets.
if (autoTarget != null && (ChildActivity == null || runningInnerActivity))
{
// ScanForTarget already limits the scanning rate for performance so we don't need to do that here.
target = autoTarget.ScanForTarget(self, false, true);
// Use the standard ScanForTarget rate limit while we are running the inner 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, !runningInnerActivity);
// Cancel the current inner activity and queue attack activities if we find a new target.
if (target.Type != TargetType.Invalid)

View File

@@ -279,15 +279,16 @@ namespace OpenRA.Mods.Common.Traits
--nextScanTime;
}
public Target ScanForTarget(Actor self, bool allowMove, bool allowTurn)
public Target ScanForTarget(Actor self, bool allowMove, bool allowTurn, bool ignoreScanInterval = false)
{
if (nextScanTime <= 0 && ActiveAttackBases.Any())
if ((ignoreScanInterval || nextScanTime <= 0) && ActiveAttackBases.Any())
{
foreach (var dat in disableAutoTarget)
if (dat.DisableAutoTarget(self))
return Target.Invalid;
nextScanTime = self.World.SharedRandom.Next(Info.MinimumScanTimeInterval, Info.MaximumScanTimeInterval);
if (!ignoreScanInterval)
nextScanTime = self.World.SharedRandom.Next(Info.MinimumScanTimeInterval, Info.MaximumScanTimeInterval);
foreach (var ab in ActiveAttackBases)
{