diff --git a/OpenRA.Mods.Common/AI/BaseBuilder.cs b/OpenRA.Mods.Common/AI/BaseBuilder.cs index 137014e4ae..79f269fe05 100644 --- a/OpenRA.Mods.Common/AI/BaseBuilder.cs +++ b/OpenRA.Mods.Common/AI/BaseBuilder.cs @@ -116,7 +116,7 @@ namespace OpenRA.Mods.Common.AI // 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); + var randomFactor = ai.Random.Next(0, ai.Info.StructureProductionRandomBonusDelay); waitTicks = active ? ai.Info.StructureProductionActiveDelay + randomFactor : ai.Info.StructureProductionInactiveDelay + randomFactor; } diff --git a/OpenRA.Mods.Common/AI/HackyAI.cs b/OpenRA.Mods.Common/AI/HackyAI.cs index dd1cfeed5f..4a9bac7ccd 100644 --- a/OpenRA.Mods.Common/AI/HackyAI.cs +++ b/OpenRA.Mods.Common/AI/HackyAI.cs @@ -230,15 +230,6 @@ namespace OpenRA.Mods.Common.AI Info = info; World = init.World; - // Avoid all AIs trying to rush in the same tick, randomize their initial rush a little. - var smallFractionOfRushInterval = Info.RushInterval / 20; - rushTicks = World.SharedRandom.Next(Info.RushInterval - smallFractionOfRushInterval, Info.RushInterval + smallFractionOfRushInterval); - - // Avoid all AIs reevaluating assignments on the same tick, randomize their initial evaluation delay. - assignRolesTicks = World.SharedRandom.Next(0, Info.AssignRolesInterval); - attackForceTicks = World.SharedRandom.Next(0, Info.AttackForceInterval); - minAttackForceDelayTicks = World.SharedRandom.Next(0, Info.MinimumAttackForceDelay); - foreach (var decision in info.PowerDecisions) powerDecisions.Add(decision.OrderName, decision); } @@ -265,6 +256,15 @@ namespace OpenRA.Mods.Common.AI Random = new MersenneTwister((int)p.PlayerActor.ActorID); + // Avoid all AIs trying to rush in the same tick, randomize their initial rush a little. + var smallFractionOfRushInterval = Info.RushInterval / 20; + rushTicks = Random.Next(Info.RushInterval - smallFractionOfRushInterval, Info.RushInterval + smallFractionOfRushInterval); + + // Avoid all AIs reevaluating assignments on the same tick, randomize their initial evaluation delay. + assignRolesTicks = Random.Next(0, Info.AssignRolesInterval); + attackForceTicks = Random.Next(0, Info.AttackForceInterval); + minAttackForceDelayTicks = Random.Next(0, Info.MinimumAttackForceDelay); + resourceTypeIndices = new BitArray(World.TileSet.TerrainInfo.Length); // Big enough foreach (var t in Map.Rules.Actors["world"].Traits.WithInterface()) resourceTypeIndices.Set(World.TileSet.GetTerrainIndex(t.TerrainType), true);