From 98f7995d00c1f2f046223c3c3ab7ded2465de89f Mon Sep 17 00:00:00 2001 From: reaperrr Date: Sat, 4 Jan 2014 01:16:00 +0100 Subject: [PATCH 1/2] Un-hardcoded excess power factor and excess power minimum --- OpenRA.Mods.RA/AI/HackyAI.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.RA/AI/HackyAI.cs b/OpenRA.Mods.RA/AI/HackyAI.cs index a5e8a46e68..acedd5831d 100644 --- a/OpenRA.Mods.RA/AI/HackyAI.cs +++ b/OpenRA.Mods.RA/AI/HackyAI.cs @@ -30,6 +30,10 @@ namespace OpenRA.Mods.RA.AI public readonly int RushInterval = 600; public readonly int AttackForceInterval = 30; + [Desc("By what factor should power output exceed power consumption.")] + public readonly float ExcessPowerFactor = 1.2f; + [Desc("By what minimum amount should power output exceed power consumption.")] + public readonly int MinimumExcessPower = 50; // Temporary hack to maintain previous rallypoint behavior. public readonly string RallypointTestBuilding = "fact"; public readonly string[] UnitQueues = { "Vehicle", "Infantry", "Plane", "Ship", "Aircraft" }; @@ -223,8 +227,8 @@ namespace OpenRA.Mods.RA.AI bool HasAdequatePower() { // note: CNC `fact` provides a small amount of power. don't get jammed because of that. - return playerPower.PowerProvided > 50 && - playerPower.PowerProvided > playerPower.PowerDrained * 1.2; + return playerPower.PowerProvided > Info.MinimumExcessPower && + playerPower.PowerProvided > playerPower.PowerDrained * Info.ExcessPowerFactor; } bool HasAdequateFact() From 16fd5559e9e8896d6d4622ab8bbcaafa028ce061 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Sat, 4 Jan 2014 01:19:03 +0100 Subject: [PATCH 2/2] Un-hardcoded several radiuses and production-related count for units hanging around base --- OpenRA.Mods.RA/AI/HackyAI.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/OpenRA.Mods.RA/AI/HackyAI.cs b/OpenRA.Mods.RA/AI/HackyAI.cs index acedd5831d..c554822bcc 100644 --- a/OpenRA.Mods.RA/AI/HackyAI.cs +++ b/OpenRA.Mods.RA/AI/HackyAI.cs @@ -34,6 +34,15 @@ namespace OpenRA.Mods.RA.AI public readonly float ExcessPowerFactor = 1.2f; [Desc("By what minimum amount should power output exceed power consumption.")] public readonly int MinimumExcessPower = 50; + [Desc("Produce units as long as there are less than this amount of units inside the base.")] + public readonly int IdleBaseUnitsMinimum = 12; + [Desc("Radius in cells where AI scans for targets to rush.")] + public readonly int RushAttackScanRadius = 15; + [Desc("Radius in cells around a unit that should be protected where AI will send support.")] + public readonly int ProtectUnitScanRadius = 15; + [Desc("Radius in cells around a factory scanned for rally points by the AI.")] + public readonly int RallyPointScanRadius = 8; + // Temporary hack to maintain previous rallypoint behavior. public readonly string RallypointTestBuilding = "fact"; public readonly string[] UnitQueues = { "Vehicle", "Infantry", "Plane", "Ship", "Aircraft" }; @@ -621,7 +630,7 @@ namespace OpenRA.Mods.RA.AI foreach (var b in allEnemyBaseBuilder) { - var enemies = world.FindActorsInCircle(b.CenterPosition, WRange.FromCells(15)) + var enemies = world.FindActorsInCircle(b.CenterPosition, WRange.FromCells(Info.RushAttackScanRadius)) .Where(unit => p.Stances[unit.Owner] == Stance.Enemy && unit.HasTrait()).ToList(); if (rushFuzzy.CanAttack(ownUnits, enemies)) @@ -650,7 +659,7 @@ namespace OpenRA.Mods.RA.AI if (!protectSq.IsValid) { - var ownUnits = world.FindActorsInCircle(baseCenter.CenterPosition, WRange.FromCells(15)) + var ownUnits = world.FindActorsInCircle(baseCenter.CenterPosition, WRange.FromCells(Info.ProtectUnitScanRadius)) .Where(unit => unit.Owner == p && !unit.HasTrait() && unit.HasTrait()).ToList(); @@ -683,7 +692,7 @@ namespace OpenRA.Mods.RA.AI // Won't work for shipyards... CPos ChooseRallyLocationNear(CPos startPos) { - var possibleRallyPoints = world.FindTilesInCircle(startPos, 8) + var possibleRallyPoints = world.FindTilesInCircle(startPos, Info.RallyPointScanRadius) .Where(IsRallyPointValid); if (!possibleRallyPoints.Any()) @@ -816,7 +825,7 @@ namespace OpenRA.Mods.RA.AI BuildUnit("Vehicle", GetUnitInfoByCommonName("Mcv", p).Name); foreach (var q in Info.UnitQueues) - BuildUnit(q, unitsHangingAroundTheBase.Count < 12); + BuildUnit(q, unitsHangingAroundTheBase.Count < Info.IdleBaseUnitsMinimum); } void BuildUnit(string category, bool buildRandom)