hackyai should only attack humans
This commit is contained in:
@@ -223,7 +223,29 @@ namespace OpenRA.Mods.RA
|
|||||||
//This is purely to identify production buildings that don't have a rally point set.
|
//This is purely to identify production buildings that don't have a rally point set.
|
||||||
List<Actor> activeProductionBuildings = new List<Actor>();
|
List<Actor> activeProductionBuildings = new List<Actor>();
|
||||||
|
|
||||||
private void AssignRolesToIdleUnits(Actor self)
|
bool IsHumanPlayer(Player p)
|
||||||
|
{
|
||||||
|
/* hack hack: this actually detects 'is not HackyAI' -- possibly actually a good thing. */
|
||||||
|
var hackyAI = p.PlayerActor.Trait<HackyAI>();
|
||||||
|
return !hackyAI.enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
int2? ChooseEnemyTarget()
|
||||||
|
{
|
||||||
|
// Criteria for picking an enemy:
|
||||||
|
// 1. not ourself.
|
||||||
|
// 2. human.
|
||||||
|
// 3. not dead.
|
||||||
|
|
||||||
|
var possibleTargets = Game.world.WorldActor.Trait<MPStartLocations>().Start
|
||||||
|
.Where(kv => kv.Key != p && IsHumanPlayer(kv.Key)
|
||||||
|
&& p.WinState == WinState.Undefined)
|
||||||
|
.Select(kv => kv.Value);
|
||||||
|
|
||||||
|
return possibleTargets.Any() ? possibleTargets.Random(random) : (int2?) null;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AssignRolesToIdleUnits(Actor self)
|
||||||
{
|
{
|
||||||
//HACK: trim these lists -- we really shouldn't be hanging onto all this state
|
//HACK: trim these lists -- we really shouldn't be hanging onto all this state
|
||||||
//when it's invalidated so easily, but that's Matthew/Alli's problem.
|
//when it's invalidated so easily, but that's Matthew/Alli's problem.
|
||||||
@@ -250,13 +272,14 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
Game.Debug("Launch an attack.");
|
Game.Debug("Launch an attack.");
|
||||||
|
|
||||||
int2 attackTarget = Game.world.WorldActor.Trait<MPStartLocations>().Start
|
var attackTarget = ChooseEnemyTarget();
|
||||||
.Where(kv => kv.Key != p)
|
if (attackTarget == null)
|
||||||
.Select(kv => kv.Value)
|
return;
|
||||||
.Random(random);
|
|
||||||
foreach (var a in unitsHangingAroundTheBase)
|
foreach (var a in unitsHangingAroundTheBase)
|
||||||
if (TryToMove(a, attackTarget))
|
if (TryToMove(a, attackTarget.Value))
|
||||||
attackForce.Add(a);
|
attackForce.Add(a);
|
||||||
|
|
||||||
unitsHangingAroundTheBase.Clear();
|
unitsHangingAroundTheBase.Clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user