HackyAI supports teams (Fixes #917).
This commit is contained in:
@@ -507,7 +507,7 @@ namespace OpenRA.Mods.Cnc.Widgets.Logic
|
|||||||
factionflag.GetImageCollection = () => "flags";
|
factionflag.GetImageCollection = () => "flags";
|
||||||
|
|
||||||
var team = template.GetWidget<DropDownButtonWidget>("TEAM");
|
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.OnMouseDown = _ => team.IsDisabled() ? true : ShowTeamDropDown(team, client);
|
||||||
team.GetText = () => (client.Team == 0) ? "-" : client.Team.ToString();
|
team.GetText = () => (client.Team == 0) ? "-" : client.Team.ToString();
|
||||||
|
|
||||||
|
|||||||
@@ -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.
|
//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>();
|
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()
|
int2? ChooseEnemyTarget()
|
||||||
{
|
{
|
||||||
// Criteria for picking an enemy:
|
// Criteria for picking an enemy:
|
||||||
// 1. not ourself.
|
// 1. not ourself.
|
||||||
// 2. human.
|
// 2. enemy.
|
||||||
// 3. not dead.
|
// 3. not dead.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var possibleTargets = world.WorldActor.Trait<MPStartLocations>().Start
|
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)
|
&& p.WinState == WinState.Undefined)
|
||||||
.Select(kv => kv.Value);
|
.Select(kv => kv.Value);
|
||||||
|
|
||||||
@@ -325,7 +315,7 @@ namespace OpenRA.Mods.RA
|
|||||||
foreach (var a1 in attackForce)
|
foreach (var a1 in attackForce)
|
||||||
{
|
{
|
||||||
var enemyUnits = world.FindUnitsInCircle(a1.CenterLocation, Game.CellSize * 10)
|
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)
|
if (enemyUnits.Count > 0)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user