HackyAI supports teams (Fixes #917).

This commit is contained in:
Paul Chote
2011-06-23 17:41:38 +12:00
parent 6ed0c574be
commit ec3d467858
2 changed files with 4 additions and 14 deletions

View File

@@ -507,7 +507,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
factionflag.GetImageCollection = () => "flags";
var team = template.GetWidget<DropDownButtonWidget>("TEAM");
team.IsDisabled = () => slot.LockTeam || ready || client.Bot != null;
team.IsDisabled = () => slot.LockTeam || ready;
team.OnMouseDown = _ => team.IsDisabled() ? true : ShowTeamDropDown(team, client);
team.GetText = () => (client.Team == 0) ? "-" : client.Team.ToString();

View File

@@ -246,24 +246,14 @@ namespace OpenRA.Mods.RA
//Units that the ai already knows about. Any unit not on this list needs to be given a role.
List<Actor> activeUnits = new List<Actor>();
bool IsHumanPlayer(Player p) { return !p.IsBot && !p.NonCombatant; }
bool HasHumanPlayers()
{
return p.World.Players.Any(a => !a.IsBot && !a.NonCombatant);
}
int2? ChooseEnemyTarget()
{
// Criteria for picking an enemy:
// 1. not ourself.
// 2. human.
// 2. enemy.
// 3. not dead.
var possibleTargets = world.WorldActor.Trait<MPStartLocations>().Start
.Where(kv => kv.Key != p && (!HasHumanPlayers() || IsHumanPlayer(kv.Key))
.Where(kv => kv.Key != p && p.Stances[kv.Key] == Stance.Enemy
&& p.WinState == WinState.Undefined)
.Select(kv => kv.Value);
@@ -325,7 +315,7 @@ namespace OpenRA.Mods.RA
foreach (var a1 in attackForce)
{
var enemyUnits = world.FindUnitsInCircle(a1.CenterLocation, Game.CellSize * 10)
.Where(unit => IsHumanPlayer(unit.Owner)).ToList();
.Where(unit => p.Stances[unit.Owner] == Stance.Enemy).ToList();
if (enemyUnits.Count > 0)
{