made HackyAI more flexible for Dune 2000 mod

This commit is contained in:
Matthias Mailänder
2012-05-28 10:36:17 +02:00
parent 2a312911cb
commit 4984d07960
2 changed files with 61 additions and 50 deletions

View File

@@ -34,8 +34,10 @@ namespace OpenRA.Mods.RA.AI
public readonly int SquadSize = 8;
public readonly int AssignRolesInterval = 20;
public readonly string RallypointTestBuilding = "fact"; // temporary hack to maintain previous rallypoint behavior.
public readonly string[] UnitQueues = { "Vehicle", "Infantry", "Plane" };
public readonly string[] UnitQueues = {"Vehicle", "Infantry", "Plane"};
public readonly bool ShouldRepairBuildings = true;
public readonly string HarvesterUnit = "harv";
public readonly string[] BaseBuildUnit = {"mcv"};
string IBotInfo.Name { get { return this.Name; } }
@@ -66,6 +68,7 @@ namespace OpenRA.Mods.RA.AI
{
bool enabled;
public int ticks;
public string FoundBaseBuildUnit;
public Player p;
PowerManager playerPower;
readonly BuildingInfo rallypointTestBuilding; // temporary hack
@@ -182,7 +185,7 @@ namespace OpenRA.Mods.RA.AI
ticks++;
if (ticks == 10)
if (ticks == 1)
DeployMcv(self);
if (ticks % feedbackTime == 0)
@@ -261,14 +264,14 @@ namespace OpenRA.Mods.RA.AI
assignRolesTicks = Info.AssignRolesInterval;
var newUnits = self.World.ActorsWithTrait<IMove>()
.Where(a => a.Actor.Owner == p && a.Actor.Info != Rules.Info["mcv"]
.Where(a => a.Actor.Owner == p && a.Actor.Info != Rules.Info[FoundBaseBuildUnit]
&& !activeUnits.Contains(a.Actor))
.Select(a => a.Actor).ToArray();
foreach (var a in newUnits)
{
BotDebug("AI: Found a newly built unit");
if (a.Info == Rules.Info["harv"])
if (a.Info == Rules.Info[Info.HarvesterUnit])
world.IssueOrder( new Order( "Harvest", a, false ) );
else
unitsHangingAroundTheBase.Add(a);
@@ -418,16 +421,20 @@ namespace OpenRA.Mods.RA.AI
void DeployMcv(Actor self)
{
/* find our mcv and deploy it */
var mcv = self.World.Actors
.FirstOrDefault(a => a.Owner == p && a.Info == Rules.Info["mcv"]);
if (mcv != null)
foreach (var m in Info.BaseBuildUnit)
{
baseCenter = mcv.Location;
world.IssueOrder(new Order("DeployTransform", mcv, false));
var mcv = self.World.Actors
.FirstOrDefault(a => a.Owner == p && a.Info == Rules.Info[m]);
if (mcv != null)
{
baseCenter = mcv.Location;
world.IssueOrder(new Order("DeployTransform", mcv, false));
FoundBaseBuildUnit = m; //remember the type to exclude it from attack forces
}
else
BotDebug("AI: Can't find BaseBuildUnit {0}.", m);
}
else
BotDebug("AI: Can't find the MCV.");
}
internal IEnumerable<ProductionQueue> FindQueues(string category)