diff --git a/OpenRA.Mods.Common/AI/HackyAI.cs b/OpenRA.Mods.Common/AI/HackyAI.cs index 2e9ff259d0..5817c60151 100644 --- a/OpenRA.Mods.Common/AI/HackyAI.cs +++ b/OpenRA.Mods.Common/AI/HackyAI.cs @@ -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; } diff --git a/OpenRA.Mods.Common/Activities/FindResources.cs b/OpenRA.Mods.Common/Activities/FindResources.cs index 219ece03c1..87e277d2e2 100644 --- a/OpenRA.Mods.Common/Activities/FindResources.cs +++ b/OpenRA.Mods.Common/Activities/FindResources.cs @@ -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; diff --git a/OpenRA.Mods.Common/Traits/Harvester.cs b/OpenRA.Mods.Common/Traits/Harvester.cs index f4d5538ee1..2db33cd1c2 100644 --- a/OpenRA.Mods.Common/Traits/Harvester.cs +++ b/OpenRA.Mods.Common/Traits/Harvester.cs @@ -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;