From 76f2145db24e9d97225cf190bc6765e8fa970d83 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Sat, 25 Jul 2015 12:30:07 +0200 Subject: [PATCH] Added random factor to building production delay Early game AI usually follows the same build order (power plant first, then refinery), which also means they all start producing them at the same tick. This adds a random factor to the production delay, so not all AIs produce on the same tick. --- OpenRA.Mods.Common/AI/BaseBuilder.cs | 6 +++++- OpenRA.Mods.Common/AI/HackyAI.cs | 7 +++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/OpenRA.Mods.Common/AI/BaseBuilder.cs b/OpenRA.Mods.Common/AI/BaseBuilder.cs index b74eddc1cb..7b3d7e63bf 100644 --- a/OpenRA.Mods.Common/AI/BaseBuilder.cs +++ b/OpenRA.Mods.Common/AI/BaseBuilder.cs @@ -101,7 +101,11 @@ namespace OpenRA.Mods.Common.AI if (TickQueue(queue)) active = true; - waitTicks = active ? ai.Info.StructureProductionActiveDelay : ai.Info.StructureProductionInactiveDelay; + // Add a random factor so not every AI produces at the same tick early in the game. + // Minimum should not be negative as delays in HackyAI could be zero. + var randomFactor = world.SharedRandom.Next(0, ai.Info.StructureProductionRandomBonusDelay); + waitTicks = active ? ai.Info.StructureProductionActiveDelay + randomFactor + : ai.Info.StructureProductionInactiveDelay + randomFactor; } bool TickQueue(ProductionQueue queue) diff --git a/OpenRA.Mods.Common/AI/HackyAI.cs b/OpenRA.Mods.Common/AI/HackyAI.cs index 191db5831c..af5647f5ad 100644 --- a/OpenRA.Mods.Common/AI/HackyAI.cs +++ b/OpenRA.Mods.Common/AI/HackyAI.cs @@ -55,12 +55,15 @@ namespace OpenRA.Mods.Common.AI [Desc("Minimum excess power the AI should try to maintain.")] public readonly int MinimumExcessPower = 0; - [Desc("How long to wait (in ticks) between structure production checks when there is no active production.")] + [Desc("Minimum delay (in ticks) between structure production checks when there is no active production.")] public readonly int StructureProductionInactiveDelay = 125; - [Desc("How long to wait (in ticks) between structure production checks ticks when actively building things.")] + [Desc("Minimum delay (in ticks) between structure production checks when actively building things.")] public readonly int StructureProductionActiveDelay = 10; + [Desc("A random delay (in ticks) of up to this is added to production delays.")] + public readonly int StructureProductionRandomBonusDelay = 10; + [Desc("How long to wait (in ticks) until retrying to build structure after the last 3 consecutive attempts failed.")] public readonly int StructureProductionResumeDelay = 1500;