Un-hardcoded several radiuses and production-related count for units hanging around base

This commit is contained in:
reaperrr
2014-01-04 01:19:03 +01:00
parent 98f7995d00
commit 16fd5559e9

View File

@@ -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<AttackBase>()).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<Building>()
&& unit.HasTrait<AttackBase>()).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)