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 */
foreach (var m in Info.BaseBuildUnit)
{
var mcv = self.World.Actors
.FirstOrDefault(a => a.Owner == p && a.Info == Rules.Info["mcv"]);
.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 the MCV.");
BotDebug("AI: Can't find BaseBuildUnit {0}.", m);
}
}
internal IEnumerable<ProductionQueue> FindQueues(string category)

View File

@@ -36,44 +36,48 @@ Player:
InitialCash: 5000
ActorGroupProxy:
DeveloperMode:
# HackyAI@EasyAI:
# Name:Easy AI
# BuildingFractions:
# refa: 30%
# refh: 30%
# refo: 30%
# powra: 35%
# powrh: 35%
# powro: 35%
# barra: 1%
# barrh: 1%
# barro: 1%
# lighta: 1%
# lighth: 1%
# lighto: 1%
# heavya: 1%
# heavyh: 1%
# heavyo: 1%
# researcha: 1%
# researchh: 1%
# researcho: 1%
# repaira: 0.1%
# repairh: 0.1%
# repairo: 0.1%
# radara: 10%
# radaro: 10%
# radarh: 10%
# UnitsToBuild:
# trike: 30%
# raider: 30%
# quad: 40%
# siege: 15%
# combata: 70%
# combath: 70%
# sonic: 25%
# devast: 25%
# deviator: 25%
# SquadSize: 10
HackyAI@EasyAI:
Name:Easy AI
RallypointTestBuilding: conyarda
HarvesterUnit: harvester
BaseBuildUnit: mcva,mcvh,mcvo
BuildingFractions:
refa: 30%
refh: 30%
refo: 30%
powra: 35%
powrh: 35%
powro: 35%
barra: 1%
barrh: 1%
barro: 1%
lighta: 1%
lighth: 1%
lighto: 1%
heavya: 1%
heavyh: 1%
heavyo: 1%
researcha: 1%
researchh: 1%
researcho: 1%
repaira: 0.1%
repairh: 0.1%
repairo: 0.1%
radara: 10%
radaro: 10%
radarh: 10%
UnitsToBuild:
trike: 30%
raider: 30%
quad: 40%
siege: 15%
combata: 70%
combath: 70%
combato: 70%
sonic: 25%
devast: 25%
deviator: 25%
SquadSize: 10
PlayerColorPalette:
BasePalette: d2k
PaletteFormat: d2k