Merge pull request #9486 from reaperrr/fix-9403

Fix AI queueing structure build orders twice at higher game speeds due to lag
This commit is contained in:
abcdefg30
2015-10-11 13:51:02 +02:00
2 changed files with 8 additions and 6 deletions

View File

@@ -117,7 +117,9 @@ namespace OpenRA.Mods.Common.AI
// Add a random factor so not every AI produces at the same tick early in the game. // 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. // Minimum should not be negative as delays in HackyAI could be zero.
var randomFactor = ai.Random.Next(0, ai.Info.StructureProductionRandomBonusDelay); var randomFactor = ai.Random.Next(0, ai.Info.StructureProductionRandomBonusDelay);
waitTicks = active ? ai.Info.StructureProductionActiveDelay + randomFactor
// Needs to be at least 4 * OrderLatency because otherwise the AI frequently duplicates build orders (i.e. makes the same build decision twice)
waitTicks = active ? 4 * world.LobbyInfo.GlobalSettings.OrderLatency + ai.Info.StructureProductionActiveDelay + randomFactor
: ai.Info.StructureProductionInactiveDelay + randomFactor; : ai.Info.StructureProductionInactiveDelay + randomFactor;
} }

View File

@@ -56,13 +56,13 @@ namespace OpenRA.Mods.Common.AI
[Desc("Minimum excess power the AI should try to maintain.")] [Desc("Minimum excess power the AI should try to maintain.")]
public readonly int MinimumExcessPower = 0; public readonly int MinimumExcessPower = 0;
[Desc("Delay (in ticks) between structure production checks when there is no active production.", [Desc("Additional delay (in ticks) between structure production checks when there is no active production.",
"A StructureProductionRandomBonusDelay is added to this.")] "StructureProductionRandomBonusDelay is added to this.")]
public readonly int StructureProductionInactiveDelay = 125; public readonly int StructureProductionInactiveDelay = 125;
[Desc("Delay (in ticks) between structure production checks when actively building things.", [Desc("Additional delay (in ticks) added between structure production checks when actively building things.",
"A StructureProductionRandomBonusDelay is added to this.")] "Note: The total delay is gamespeed OrderLatency x 4 + this + StructureProductionRandomBonusDelay.")]
public readonly int StructureProductionActiveDelay = 10; public readonly int StructureProductionActiveDelay = 0;
[Desc("A random delay (in ticks) of up to this is added to active/inactive production delays.")] [Desc("A random delay (in ticks) of up to this is added to active/inactive production delays.")]
public readonly int StructureProductionRandomBonusDelay = 10; public readonly int StructureProductionRandomBonusDelay = 10;