Make the AI only consider harvesters 'idle' if last resource search failed

Otherwise the AI would consider the harvester 'idle' in too many situations.
This way, the AI now only uses its own resource search algorithm if the next resource patch is too far away for the FindResources activity to find it.
This commit is contained in:
reaperrr
2017-12-02 08:45:35 +01:00
committed by abcdefg30
parent 4d553900cf
commit 9ad0d78cdd
3 changed files with 6 additions and 1 deletions

View File

@@ -826,7 +826,7 @@ namespace OpenRA.Mods.Common.AI
if (!harvester.IsIdle)
{
var act = harvester.CurrentActivity;
if (act.NextActivity == null || act.NextActivity.GetType() != typeof(FindResources))
if (!harv.LastSearchFailed || act.NextActivity == null || act.NextActivity.GetType() != typeof(FindResources))
continue;
}

View File

@@ -69,6 +69,8 @@ namespace OpenRA.Mods.Common.Activities
if (!harv.IsEmpty)
return deliver;
harv.LastSearchFailed = true;
var unblockCell = harv.LastHarvestedCell ?? (self.Location + harvInfo.UnblockCell);
var moveTo = mobile.NearestMoveableCell(unblockCell, 2, 5);
self.QueueActivity(mobile.MoveTo(moveTo, 1));
@@ -92,6 +94,8 @@ namespace OpenRA.Mods.Common.Activities
if (!claimLayer.TryClaimCell(self, closestHarvestablePosition.Value))
return ActivityUtils.SequenceActivities(new Wait(25), this);
harv.LastSearchFailed = false;
// If not given a direct order, assume ordered to the first resource location we find:
if (!harv.LastOrderLocation.HasValue)
harv.LastOrderLocation = closestHarvestablePosition;

View File

@@ -89,6 +89,7 @@ namespace OpenRA.Mods.Common.Traits
bool idleSmart = true;
int idleDuration;
[Sync] public bool LastSearchFailed;
[Sync] public Actor OwnerLinkedProc = null;
[Sync] public Actor LastLinkedProc = null;
[Sync] public Actor LinkedProc = null;