Skip to content

Commit

Permalink
#2048 fixed: make AI behavior more varied
Browse files Browse the repository at this point in the history
  • Loading branch information
earthpig authored and chrisforbes committed Apr 29, 2012
1 parent 9a3aae6 commit a544bc9
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions OpenRA.Mods.RA/AI/HackyAI.cs
Expand Up @@ -275,10 +275,13 @@ void AssignRolesToIdleUnits(Actor self)

activeUnits.Add(a);
}

/* Create an attack force when we have enough units around our base. */
// (don't bother leaving any behind for defense.)
if (unitsHangingAroundTheBase.Count >= Info.SquadSize)

int randomizedSquadSize = Info.SquadSize - 4 + random.Next(200);

if (unitsHangingAroundTheBase.Count >= randomizedSquadSize)
{
BotDebug("Launch an attack.");

Expand Down Expand Up @@ -314,7 +317,7 @@ void AssignRolesToIdleUnits(Actor self)
// Check how many own units we have gathered nearby...
var ownUnits = world.FindUnitsInCircle(a1.CenterLocation, Game.CellSize * 2)
.Where(unit => unit.Owner == p).ToList();
if (ownUnits.Count < Info.SquadSize)
if (ownUnits.Count < randomizedSquadSize)
{
// Not enough to attack. Send more units.
world.IssueOrder(new Order("Stop", a1, false));
Expand Down Expand Up @@ -464,4 +467,4 @@ public void Damaged(Actor self, AttackInfo e)
aggro[e.Attacker.Owner].Aggro += e.Damage;
}
}
}
}

0 comments on commit a544bc9

Please sign in to comment.