Harvs built by HackyAI now call FindResources

This commit is contained in:
Curtis S
2011-09-10 22:40:06 -06:00
parent 460696192b
commit 2cc6a67a95

View File

@@ -14,6 +14,7 @@ using System.Linq;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.Mods.RA.Buildings; using OpenRA.Mods.RA.Buildings;
using OpenRA.Traits; using OpenRA.Traits;
using OpenRA.Mods.RA.Activities;
using XRandom = OpenRA.Thirdparty.Random; using XRandom = OpenRA.Thirdparty.Random;
@@ -239,19 +240,24 @@ namespace OpenRA.Mods.RA
else else
assignRolesTicks = Info.AssignRolesInterval; assignRolesTicks = Info.AssignRolesInterval;
// don't select harvesters.
var newUnits = self.World.ActorsWithTrait<IMove>() var newUnits = self.World.ActorsWithTrait<IMove>()
.Where(a => a.Actor.Owner == p && a.Actor.Info != Rules.Info["harv"] && a.Actor.Info != Rules.Info["mcv"] .Where(a => a.Actor.Owner == p && a.Actor.Info != Rules.Info["mcv"]
&& !activeUnits.Contains(a.Actor)) && !activeUnits.Contains(a.Actor))
.Select(a => a.Actor).ToArray(); .Select(a => a.Actor).ToArray();
foreach (var a in newUnits) foreach (var a in newUnits)
{ {
BotDebug("AI: Found a newly built unit"); BotDebug("AI: Found a newly built unit");
unitsHangingAroundTheBase.Add(a); if (a.Info == Rules.Info["harv"])
a.QueueActivity(new FindResources());
else
unitsHangingAroundTheBase.Add(a);
activeUnits.Add(a); activeUnits.Add(a);
} }
/* 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.)
if (unitsHangingAroundTheBase.Count >= Info.SquadSize) if (unitsHangingAroundTheBase.Count >= Info.SquadSize)