BaseBuilderBotModule: add cash constrain on expansion

This commit is contained in:
dnqbob
2025-12-25 11:49:13 +08:00
committed by Gustas Kažukauskas
parent 9e1f7cad55
commit efa673d999
3 changed files with 8 additions and 3 deletions

View File

@@ -162,6 +162,9 @@ namespace OpenRA.Mods.Common.Traits
[Desc($"AI will move the only mcv when those numbers of refinery <= productions + tech - {nameof(ForceExpansionTolerate)}.")]
public readonly ImmutableArray<int> ForceExpansionTolerate = [2, 3];
[Desc("Decrease the expansion tolerate by Cash / this. Used to prevent AI from expanding when it has enough cash.")]
public readonly int PerExpansionTolerateOnCash = 12000;
public override object Create(ActorInitializer init) { return new BaseBuilderBotModule(init.Self, this); }
}

View File

@@ -245,10 +245,12 @@ namespace OpenRA.Mods.Common.Traits
var numTech = playerBuildings.Count(a => baseBuilder.Info.TechTypes.Contains(a.Info.Name))
+ (baseBuilder.Info.TechTypes.Contains(currentBuilding.Item) ? 1 : 0);
var tolerateOnCash = playerResources.GetCashAndResources() / Math.Max(baseBuilder.Info.PerExpansionTolerateOnCash, 1);
if (numRef >= baseBuilder.Info.InititalMinimumRefineryCount + baseBuilder.Info.AdditionalMinimumRefineryCount
&& numProd > 0 && numProd - baseBuilder.Info.ExpansionTolerate.Random(world.LocalRandom) + numTech >= numRef)
&& numProd > 0 && numProd + numTech - baseBuilder.Info.ExpansionTolerate.Random(world.LocalRandom) - tolerateOnCash >= numRef)
{
var undeployEvenNoBase = numProd - baseBuilder.Info.ForceExpansionTolerate.Random(world.LocalRandom) + numTech >= numRef;
var undeployEvenNoBase = numProd + numTech - baseBuilder.Info.ForceExpansionTolerate.Random(world.LocalRandom) - tolerateOnCash >= numRef;
foreach (var be in baseBuilder.BaseExpansionModules)
be.UpdateExpansionParams(bot, true, undeployEvenNoBase, null);

View File

@@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Traits
public readonly int BuildMcvInterval = 101;
[Desc("Delay (in ticks) for moving a conyard to better expansion. Only work with more than 1 conyard.")]
public readonly int MoveConyardTick = 4000;
public readonly int MoveConyardTick = 5700;
[Desc("Should moving the oldest or newest conyard be preferred? Random ordering if unset.")]
public readonly bool? MoveOldConyardFirst = null;