From 5992530655dc75d5f1c96ef6e1fba3413df39f3e Mon Sep 17 00:00:00 2001 From: reaperrr Date: Fri, 17 Jun 2016 00:20:57 +0200 Subject: [PATCH 1/3] Fix AI giving orders to MCVs that already have orders Checking for IsMoving is a flawed approach no matter how you look at it. The MCV might just have temporarily stopped due to an obstacle, or about to be deployed. Checking for IsIdle instead ensures that the MCV really isn't already in the process of doing something. --- OpenRA.Mods.Common/AI/HackyAI.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/AI/HackyAI.cs b/OpenRA.Mods.Common/AI/HackyAI.cs index cbc3146afd..1ce6dc446b 100644 --- a/OpenRA.Mods.Common/AI/HackyAI.cs +++ b/OpenRA.Mods.Common/AI/HackyAI.cs @@ -825,8 +825,7 @@ namespace OpenRA.Mods.Common.AI foreach (var mcv in mcvs) { - var mover = mcv.TraitOrDefault(); - if (mover != null && mover.IsMoving) + if (!mcv.IsIdle) continue; var factType = mcv.Info.TraitInfo().IntoActor; From 8ba833777cf9eb8500dd18a08a69dea537c044fc Mon Sep 17 00:00:00 2001 From: reaperrr Date: Fri, 17 Jun 2016 00:24:10 +0200 Subject: [PATCH 2/3] Make AI deploy MCVs in the vincinity of existing construction yards While the general idea of AIs building distant secondary bases might be tempting, in reality the AI would way too often send the MCV close to some enemy base, wasting the cash and potentially increased build speed/additional build queue. Deploying MCVs close to the existing base ensures that the AI will actually have some benefit from building an MCV. --- OpenRA.Mods.Common/AI/HackyAI.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/AI/HackyAI.cs b/OpenRA.Mods.Common/AI/HackyAI.cs index 1ce6dc446b..b1c4b91d84 100644 --- a/OpenRA.Mods.Common/AI/HackyAI.cs +++ b/OpenRA.Mods.Common/AI/HackyAI.cs @@ -829,7 +829,7 @@ namespace OpenRA.Mods.Common.AI continue; var factType = mcv.Info.TraitInfo().IntoActor; - var desiredLocation = ChooseBuildLocation(factType, false, BuildingType.Building); + var desiredLocation = ChooseBuildLocation(factType, true, BuildingType.Building); if (desiredLocation == null) continue; From e647af3dd1a5d8bcc5f1c6f205eb3e2bd6994cb3 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Mon, 27 Jun 2016 18:17:51 +0200 Subject: [PATCH 3/3] Allow modders to choose AI MCV deployment base restriction For some mods, a random map location might be a better choice for the AI than deploying the MCV inside the base, so we allow modders to customize it. --- OpenRA.Mods.Common/AI/HackyAI.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/AI/HackyAI.cs b/OpenRA.Mods.Common/AI/HackyAI.cs index b1c4b91d84..d6725e21e9 100644 --- a/OpenRA.Mods.Common/AI/HackyAI.cs +++ b/OpenRA.Mods.Common/AI/HackyAI.cs @@ -125,6 +125,9 @@ namespace OpenRA.Mods.Common.AI [Desc("Radius in cells around the center of the base to expand.")] public readonly int MaxBaseRadius = 20; + [Desc("Should deployment of additional MCVs be restricted to MaxBaseRadius if explicit deploy locations are missing or occupied?")] + public readonly bool RestrictMCVDeploymentFallbackToBase = true; + [Desc("Radius in cells around each building with ProvideBuildableArea", "to check for a 3x3 area of water where naval structures can be built.", "Should match maximum adjacency of naval structures.")] @@ -817,7 +820,7 @@ namespace OpenRA.Mods.Common.AI } // Find any newly constructed MCVs and deploy them at a sensible - // backup location within the main base. + // backup location. void FindAndDeployBackupMcv(Actor self) { var mcvs = self.World.Actors.Where(a => a.Owner == Player && @@ -829,7 +832,7 @@ namespace OpenRA.Mods.Common.AI continue; var factType = mcv.Info.TraitInfo().IntoActor; - var desiredLocation = ChooseBuildLocation(factType, true, BuildingType.Building); + var desiredLocation = ChooseBuildLocation(factType, Info.RestrictMCVDeploymentFallbackToBase, BuildingType.Building); if (desiredLocation == null) continue;