diff --git a/OpenRA.FileFormats/Map/PlayerReference.cs b/OpenRA.FileFormats/Map/PlayerReference.cs index 2534ba58d4..b102c0b04b 100644 --- a/OpenRA.FileFormats/Map/PlayerReference.cs +++ b/OpenRA.FileFormats/Map/PlayerReference.cs @@ -20,6 +20,7 @@ namespace OpenRA.FileFormats public bool OwnsWorld = false; public bool NonCombatant = false; public bool Playable = false; + public string Bot = null; public bool DefaultStartingUnits = false; public bool AllowBots = true; diff --git a/OpenRA.Game/Player.cs b/OpenRA.Game/Player.cs index 7c9021e2f2..6db8f01e79 100644 --- a/OpenRA.Game/Player.cs +++ b/OpenRA.Game/Player.cs @@ -63,13 +63,19 @@ namespace OpenRA ColorRamp = pr.ColorRamp; PlayerName = pr.Name; NonCombatant = pr.NonCombatant; - + IsBot = pr.Bot != null; + Country = world.GetCountries() .FirstOrDefault(c => pr.Race == c.Race) ?? world.GetCountries().Random(world.SharedRandom); } PlayerActor = world.CreateActor("Player", new TypeDictionary { new OwnerInit(this) }); + + if (IsBot) + PlayerActor.TraitsImplementing() + .Single(b => b.Info.Name == pr.Bot) + .Activate(this); } public void GiveAdvice(string advice) diff --git a/OpenRA.Mods.RA/CreateMPPlayers.cs b/OpenRA.Mods.RA/CreateMPPlayers.cs index a9a67acb19..5cfb154f2a 100644 --- a/OpenRA.Mods.RA/CreateMPPlayers.cs +++ b/OpenRA.Mods.RA/CreateMPPlayers.cs @@ -45,6 +45,7 @@ namespace OpenRA.Mods.RA if (client.Index == Game.LocalClientId) w.SetLocalPlayer(player.Index); // bind this one to the local player. } + // TODO: This is shit. Merge it up into Player ctor? else if (slot.Bot != null && slot.MapPlayer != null) { /* spawn a bot in this slot, "owned" by the host */