From 0d3dd28a3f4021987066c06f9deef65906283c68 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Tue, 5 May 2015 22:39:23 +0200 Subject: [PATCH] Unharcode squad randomization, add minimum delay for creating attack force --- OpenRA.Mods.Common/AI/HackyAI.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/AI/HackyAI.cs b/OpenRA.Mods.Common/AI/HackyAI.cs index 724dec9dd2..1de4747a55 100644 --- a/OpenRA.Mods.Common/AI/HackyAI.cs +++ b/OpenRA.Mods.Common/AI/HackyAI.cs @@ -28,6 +28,9 @@ namespace OpenRA.Mods.Common.AI [Desc("Minimum number of units AI must have before attacking.")] public readonly int SquadSize = 8; + [Desc("Random number of up to this many units is added to squad size when creating an attack squad.")] + public readonly int SquadSizeRandomBonus = 30; + [Desc("Production queues AI uses for buildings.")] public readonly string[] BuildingQueues = { "Building" }; @@ -43,6 +46,9 @@ namespace OpenRA.Mods.Common.AI [Desc("Delay (in ticks) between updating squads.")] public readonly int AttackForceInterval = 30; + [Desc("Minimum delay (in ticks) between creating squads.")] + public readonly int MinimumAttackForceDelay = 0; + [Desc("How long to wait (in ticks) between structure production checks when there is no active production.")] public readonly int StructureProductionInactiveDelay = 125; @@ -514,6 +520,7 @@ namespace OpenRA.Mods.Common.AI int assignRolesTicks = 0; int rushTicks = 0; int attackForceTicks = 0; + int minAttackForceDelayTicks = 0; void AssignRolesToIdleUnits(Actor self) { @@ -541,7 +548,12 @@ namespace OpenRA.Mods.Common.AI GiveOrdersToIdleHarvesters(); FindNewUnits(self); - CreateAttackForce(); + if (--minAttackForceDelayTicks <= 0) + { + minAttackForceDelayTicks = Info.MinimumAttackForceDelay; + CreateAttackForce(); + } + FindAndDeployBackupMcv(self); } @@ -603,7 +615,7 @@ namespace OpenRA.Mods.Common.AI { // Create an attack force when we have enough units around our base. // (don't bother leaving any behind for defense) - var randomizedSquadSize = Info.SquadSize + Random.Next(30); + var randomizedSquadSize = Info.SquadSize + Random.Next(Info.SquadSizeRandomBonus); if (unitsHangingAroundTheBase.Count >= randomizedSquadSize) {