Merge pull request #8094 from reaperrr/hackyai-tweaks

Make HackyAI squad creation a little more flexible and controllable
This commit is contained in:
Pavel Penev
2015-05-17 17:28:02 +03:00

View File

@@ -28,6 +28,9 @@ namespace OpenRA.Mods.Common.AI
[Desc("Minimum number of units AI must have before attacking.")] [Desc("Minimum number of units AI must have before attacking.")]
public readonly int SquadSize = 8; public readonly int SquadSize = 8;
[Desc("Random number of up to this many units is added to squad size when creating an attack squad.")]
public readonly int SquadSizeRandomBonus = 30;
[Desc("Production queues AI uses for buildings.")] [Desc("Production queues AI uses for buildings.")]
public readonly string[] BuildingQueues = { "Building" }; public readonly string[] BuildingQueues = { "Building" };
@@ -43,6 +46,9 @@ namespace OpenRA.Mods.Common.AI
[Desc("Delay (in ticks) between updating squads.")] [Desc("Delay (in ticks) between updating squads.")]
public readonly int AttackForceInterval = 30; public readonly int AttackForceInterval = 30;
[Desc("Minimum delay (in ticks) between creating squads.")]
public readonly int MinimumAttackForceDelay = 0;
[Desc("How long to wait (in ticks) between structure production checks when there is no active production.")] [Desc("How long to wait (in ticks) between structure production checks when there is no active production.")]
public readonly int StructureProductionInactiveDelay = 125; public readonly int StructureProductionInactiveDelay = 125;
@@ -514,6 +520,7 @@ namespace OpenRA.Mods.Common.AI
int assignRolesTicks = 0; int assignRolesTicks = 0;
int rushTicks = 0; int rushTicks = 0;
int attackForceTicks = 0; int attackForceTicks = 0;
int minAttackForceDelayTicks = 0;
void AssignRolesToIdleUnits(Actor self) void AssignRolesToIdleUnits(Actor self)
{ {
@@ -541,7 +548,12 @@ namespace OpenRA.Mods.Common.AI
GiveOrdersToIdleHarvesters(); GiveOrdersToIdleHarvesters();
FindNewUnits(self); FindNewUnits(self);
CreateAttackForce(); if (--minAttackForceDelayTicks <= 0)
{
minAttackForceDelayTicks = Info.MinimumAttackForceDelay;
CreateAttackForce();
}
FindAndDeployBackupMcv(self); FindAndDeployBackupMcv(self);
} }
@@ -603,7 +615,7 @@ namespace OpenRA.Mods.Common.AI
{ {
// Create an attack force when we have enough units around our base. // Create an attack force when we have enough units around our base.
// (don't bother leaving any behind for defense) // (don't bother leaving any behind for defense)
var randomizedSquadSize = Info.SquadSize + Random.Next(30); var randomizedSquadSize = Info.SquadSize + Random.Next(Info.SquadSizeRandomBonus);
if (unitsHangingAroundTheBase.Count >= randomizedSquadSize) if (unitsHangingAroundTheBase.Count >= randomizedSquadSize)
{ {