working game with bots; stop bots from trying to order husks around
This commit is contained in:
@@ -58,7 +58,8 @@ namespace OpenRA
|
||||
PlayerName = InternalName = pr.Name;
|
||||
NonCombatant = pr.NonCombatant;
|
||||
Country = world.GetCountries()
|
||||
.FirstOrDefault(c => pr.Race == c.Race);
|
||||
.FirstOrDefault(c => pr.Race == c.Race)
|
||||
?? world.GetCountries().Random(world.SharedRandom);
|
||||
|
||||
PlayerRef = pr;
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System;
|
||||
using OpenRA.FileFormats;
|
||||
using OpenRA.Network;
|
||||
|
||||
namespace OpenRA.Traits
|
||||
{
|
||||
@@ -30,10 +31,19 @@ namespace OpenRA.Traits
|
||||
var available = world.Map.SpawnPoints.Except(taken).ToList();
|
||||
|
||||
// Set spawn
|
||||
foreach (var client in Game.LobbyInfo.Clients)
|
||||
Start.Add(world.players[client.Index],(client.SpawnPoint == 0)
|
||||
foreach (var slot in Game.LobbyInfo.Slots)
|
||||
{
|
||||
var client = Game.LobbyInfo.Clients.FirstOrDefault(c => c.Slot == slot.Index);
|
||||
var player = FindPlayerInSlot(world, slot);
|
||||
|
||||
if (player == null) continue;
|
||||
|
||||
var spid = (client == null || client.SpawnPoint == 0)
|
||||
? ChooseSpawnPoint(world, available, taken)
|
||||
: world.Map.SpawnPoints.ElementAt(client.SpawnPoint - 1));
|
||||
: world.Map.SpawnPoints.ElementAt(client.SpawnPoint - 1);
|
||||
|
||||
Start.Add(player, spid);
|
||||
}
|
||||
|
||||
// Explore allied shroud
|
||||
foreach (var p in Start)
|
||||
@@ -46,6 +56,11 @@ namespace OpenRA.Traits
|
||||
Game.viewport.Center(Start[world.LocalPlayer]);
|
||||
}
|
||||
|
||||
static Player FindPlayerInSlot(World world, Session.Slot slot)
|
||||
{
|
||||
return world.players.Values.FirstOrDefault(p => p.PlayerRef.Name == slot.MapPlayer);
|
||||
}
|
||||
|
||||
static int2 ChooseSpawnPoint(World world, List<int2> available, List<int2> taken)
|
||||
{
|
||||
if (available.Count == 0)
|
||||
|
||||
@@ -200,10 +200,8 @@ namespace OpenRA.Mods.RA
|
||||
// which is a leading cause of blocking the spawn points :(
|
||||
int2 attackTarget = spawnPoints[random.Next(0, spawnPoints.Length)];
|
||||
foreach (var a in unitsHangingAroundTheBase)
|
||||
{
|
||||
if (TryToMove(a, attackTarget))
|
||||
attackForce.Add(a);
|
||||
tryToMove(a, attackTarget);
|
||||
}
|
||||
unitsHangingAroundTheBase.Clear();
|
||||
}
|
||||
}
|
||||
@@ -235,8 +233,11 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
//try very hard to find a valid move destination near the target.
|
||||
//(Don't accept a move onto the subject's current position. maybe this is already not allowed? )
|
||||
private bool tryToMove(Actor a, int2 desiredMoveTarget)
|
||||
private bool TryToMove(Actor a, int2 desiredMoveTarget)
|
||||
{
|
||||
if (!a.HasTrait<IMove>())
|
||||
return false;
|
||||
|
||||
int2 xy;
|
||||
int loopCount = 0; //avoid infinite loops.
|
||||
int range = 2;
|
||||
|
||||
Reference in New Issue
Block a user