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.
This commit is contained in:
reaperrr
2015-07-25 12:30:07 +02:00
parent c7af9c180e
commit 76f2145db2
2 changed files with 10 additions and 3 deletions

View File

@@ -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)