From 0a79109d019ea43351b955af4d94148775b97b2a Mon Sep 17 00:00:00 2001 From: Zimmermann Gyula Date: Tue, 1 Sep 2015 23:01:37 +0200 Subject: [PATCH] Implement HackyAI->UnitLimits. --- OpenRA.Mods.Common/AI/HackyAI.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/AI/HackyAI.cs b/OpenRA.Mods.Common/AI/HackyAI.cs index 883bde6886..7004ef9794 100644 --- a/OpenRA.Mods.Common/AI/HackyAI.cs +++ b/OpenRA.Mods.Common/AI/HackyAI.cs @@ -116,6 +116,9 @@ namespace OpenRA.Mods.Common.AI [Desc("What units to the AI should build.", "What % of the total army must be this type of unit.")] public readonly Dictionary UnitsToBuild = null; + [Desc("What units should the AI have a maximum limit to train.")] + public readonly Dictionary UnitLimits = null; + [Desc("What buildings to the AI should build.", "What % of the total base must be this type of building.")] public readonly Dictionary BuildingFractions = null; @@ -125,7 +128,7 @@ namespace OpenRA.Mods.Common.AI [Desc("Tells the AI what building types fall under the same common name.")] public readonly Dictionary BuildingCommonNames = null; - [Desc("What buildings should the AI have max limits n.", "What is the limit of the building.")] + [Desc("What buildings should the AI have a maximum limit to build.")] public readonly Dictionary BuildingLimits = null; // TODO Update OpenRA.Utility/Command.cs#L300 to first handle lists and also read nested ones @@ -984,7 +987,11 @@ namespace OpenRA.Mods.Common.AI ChooseRandomUnitToBuild(queue) : ChooseUnitToBuild(queue); - if (unit != null && Info.UnitsToBuild.Any(u => u.Key == unit.Name)) + if (unit != null + && Info.UnitsToBuild.ContainsKey(unit.Name) + && (!Info.UnitLimits.ContainsKey(unit.Name) + || World.Actors.Count(a => a.Info.Name == unit.Name && a.Owner == Player) < Info.UnitLimits[unit.Name])) + QueueOrder(Order.StartProduction(queue.Actor, unit.Name, 1)); }