BaseBuilderBotModule: add cash constrain on expansion
This commit is contained in:
committed by
Gustas Kažukauskas
parent
9e1f7cad55
commit
efa673d999
@@ -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)}.")]
|
[Desc($"AI will move the only mcv when those numbers of refinery <= productions + tech - {nameof(ForceExpansionTolerate)}.")]
|
||||||
public readonly ImmutableArray<int> ForceExpansionTolerate = [2, 3];
|
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); }
|
public override object Create(ActorInitializer init) { return new BaseBuilderBotModule(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -245,10 +245,12 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
var numTech = playerBuildings.Count(a => baseBuilder.Info.TechTypes.Contains(a.Info.Name))
|
var numTech = playerBuildings.Count(a => baseBuilder.Info.TechTypes.Contains(a.Info.Name))
|
||||||
+ (baseBuilder.Info.TechTypes.Contains(currentBuilding.Item) ? 1 : 0);
|
+ (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
|
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)
|
foreach (var be in baseBuilder.BaseExpansionModules)
|
||||||
be.UpdateExpansionParams(bot, true, undeployEvenNoBase, null);
|
be.UpdateExpansionParams(bot, true, undeployEvenNoBase, null);
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public readonly int BuildMcvInterval = 101;
|
public readonly int BuildMcvInterval = 101;
|
||||||
|
|
||||||
[Desc("Delay (in ticks) for moving a conyard to better expansion. Only work with more than 1 conyard.")]
|
[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.")]
|
[Desc("Should moving the oldest or newest conyard be preferred? Random ordering if unset.")]
|
||||||
public readonly bool? MoveOldConyardFirst = null;
|
public readonly bool? MoveOldConyardFirst = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user