Add NewProductionChance so bot won't only build production when too much cash

This commit is contained in:
dnqbob
2025-11-24 15:56:02 +08:00
committed by Gustas Kažukauskas
parent 9478548bdb
commit 62e692063a
2 changed files with 5 additions and 1 deletions

View File

@@ -110,6 +110,9 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Try to build another production building if there is too much cash.")]
public readonly int NewProductionCashThreshold = 5000;
[Desc("Chance to build another production building if there is too much cash.")]
public readonly int NewProductionChance = 50;
[Desc("Radius in cells around a factory scanned for rally points by the AI.")]
public readonly int RallyPointScanRadius = 8;

View File

@@ -321,7 +321,8 @@ namespace OpenRA.Mods.Common.Traits
}
// Make sure that we can spend as fast as we are earning
if (baseBuilder.Info.NewProductionCashThreshold > 0 && playerResources.GetCashAndResources() > baseBuilder.Info.NewProductionCashThreshold)
if (baseBuilder.Info.NewProductionCashThreshold > 0 && playerResources.GetCashAndResources() > baseBuilder.Info.NewProductionCashThreshold
&& world.LocalRandom.Next(100) < baseBuilder.Info.NewProductionChance)
{
var production = GetProducibleBuilding(baseBuilder.Info.ProductionTypes, buildableThings);
if (production != null && HasSufficientPowerForActor(production))