Add support for a "Creeps" faction that is hostile to all combatant players. Add a mod field to be used for map installation.
This commit is contained in:
@@ -321,6 +321,7 @@ namespace OpenRA.Editor
|
|||||||
map.ResizeCordon((int)nmd.cordonLeft.Value, (int)nmd.cordonTop.Value,
|
map.ResizeCordon((int)nmd.cordonLeft.Value, (int)nmd.cordonTop.Value,
|
||||||
(int)nmd.cordonRight.Value, (int)nmd.cordonBottom.Value);
|
(int)nmd.cordonRight.Value, (int)nmd.cordonBottom.Value);
|
||||||
map.Players.Add("Neutral", new PlayerReference("Neutral", Rules.Info["world"].Traits.WithInterface<CountryInfo>().First().Race, true, true));
|
map.Players.Add("Neutral", new PlayerReference("Neutral", Rules.Info["world"].Traits.WithInterface<CountryInfo>().First().Race, true, true));
|
||||||
|
map.Players.Add("Creeps", new PlayerReference("Creeps", Rules.Info["world"].Traits.WithInterface<CountryInfo>().First().Race, true, true));
|
||||||
NewMap(map);
|
NewMap(map);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -372,7 +373,10 @@ namespace OpenRA.Editor
|
|||||||
var map = LegacyMapImporter.Import(ofd.FileName);
|
var map = LegacyMapImporter.Import(ofd.FileName);
|
||||||
map.Players.Add("Neutral", new PlayerReference("Neutral",
|
map.Players.Add("Neutral", new PlayerReference("Neutral",
|
||||||
Rules.Info["world"].Traits.WithInterface<CountryInfo>().First().Race, true, true));
|
Rules.Info["world"].Traits.WithInterface<CountryInfo>().First().Race, true, true));
|
||||||
|
|
||||||
|
map.Players.Add("Creeps", new PlayerReference("Creeps",
|
||||||
|
Rules.Info["world"].Traits.WithInterface<CountryInfo>().First().Race, true, true));
|
||||||
|
|
||||||
map.Save(savePath);
|
map.Save(savePath);
|
||||||
LoadMap(savePath);
|
LoadMap(savePath);
|
||||||
loadedMapName = null; /* editor needs to think this hasnt been saved */
|
loadedMapName = null; /* editor needs to think this hasnt been saved */
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ namespace OpenRA.FileFormats
|
|||||||
// Yaml map data
|
// Yaml map data
|
||||||
public string Uid { get; protected set; }
|
public string Uid { get; protected set; }
|
||||||
[FieldLoader.Load] public bool Selectable;
|
[FieldLoader.Load] public bool Selectable;
|
||||||
[FieldLoader.Load] public bool UseAsShellmap;
|
[FieldLoader.Load] public bool UseAsShellmap;
|
||||||
|
[FieldLoader.Load] public string RequiresMod;
|
||||||
|
|
||||||
[FieldLoader.Load] public string Title;
|
[FieldLoader.Load] public string Title;
|
||||||
[FieldLoader.Load] public string Type = "Conquest";
|
[FieldLoader.Load] public string Type = "Conquest";
|
||||||
|
|||||||
@@ -140,6 +140,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
case 4:
|
case 4:
|
||||||
|
case 5:
|
||||||
{
|
{
|
||||||
foreach (var kv in yaml.NodesDict["Players"].NodesDict)
|
foreach (var kv in yaml.NodesDict["Players"].NodesDict)
|
||||||
{
|
{
|
||||||
@@ -165,21 +166,40 @@ namespace OpenRA
|
|||||||
Name = "Multi{0}".F(index),
|
Name = "Multi{0}".F(index),
|
||||||
Race = "Random",
|
Race = "Random",
|
||||||
Playable = true,
|
Playable = true,
|
||||||
DefaultStartingUnits = true
|
DefaultStartingUnits = true,
|
||||||
|
Enemies = new[]{"Creeps"}
|
||||||
};
|
};
|
||||||
Players.Add(p.Name, p);
|
Players.Add(p.Name, p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Color1/Color2 -> ColorRamp
|
// Color1/Color2 -> ColorRamp
|
||||||
if (MapFormat == 3)
|
if (MapFormat < 4)
|
||||||
foreach (var mp in Players)
|
foreach (var mp in Players)
|
||||||
mp.Value.ColorRamp = new ColorRamp(
|
mp.Value.ColorRamp = new ColorRamp(
|
||||||
(byte)((mp.Value.Color.GetHue() / 360.0f) * 255),
|
(byte)((mp.Value.Color.GetHue() / 360.0f) * 255),
|
||||||
(byte)(mp.Value.Color.GetSaturation() * 255),
|
(byte)(mp.Value.Color.GetSaturation() * 255),
|
||||||
(byte)(mp.Value.Color.GetBrightness() * 255),
|
(byte)(mp.Value.Color.GetBrightness() * 255),
|
||||||
(byte)(mp.Value.Color2.GetBrightness() * 255));
|
(byte)(mp.Value.Color2.GetBrightness() * 255));
|
||||||
|
|
||||||
|
|
||||||
|
// Creep player / Required Mod
|
||||||
|
if (MapFormat < 5)
|
||||||
|
{
|
||||||
|
RequiresMod = Game.CurrentMods.Keys.First();
|
||||||
|
|
||||||
|
foreach (var mp in Players.Where(p => !p.Value.NonCombatant && !p.Value.Enemies.Contains("Creeps")))
|
||||||
|
mp.Value.Enemies = mp.Value.Enemies.Concat(new[] {"Creeps"}).ToArray();
|
||||||
|
|
||||||
|
Players.Add("Creeps", new PlayerReference
|
||||||
|
{
|
||||||
|
Name = "Creeps",
|
||||||
|
Race = "Random",
|
||||||
|
NonCombatant = true,
|
||||||
|
Enemies = Players.Keys.Where(k => k != "Neutral").ToArray()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Smudges
|
// Smudges
|
||||||
foreach (var kv in yaml.NodesDict["Smudges"].NodesDict)
|
foreach (var kv in yaml.NodesDict["Smudges"].NodesDict)
|
||||||
{
|
{
|
||||||
@@ -206,12 +226,10 @@ namespace OpenRA
|
|||||||
|
|
||||||
public void Save(string toPath)
|
public void Save(string toPath)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Saving map to path {0}",toPath);
|
MapFormat = 5;
|
||||||
// Todo: save to a zip file in the support dir by default
|
|
||||||
MapFormat = 4;
|
|
||||||
|
|
||||||
var root = new List<MiniYamlNode>();
|
var root = new List<MiniYamlNode>();
|
||||||
foreach (var field in new string[] {"Selectable", "MapFormat", "Title", "Description", "Author", "PlayerCount", "Tileset", "MapSize", "TopLeft", "BottomRight", "UseAsShellmap", "Type"})
|
foreach (var field in new string[] {"Selectable", "MapFormat", "RequiresMod", "Title", "Description", "Author", "PlayerCount", "Tileset", "MapSize", "TopLeft", "BottomRight", "UseAsShellmap", "Type"})
|
||||||
{
|
{
|
||||||
var f = this.GetType().GetField(field);
|
var f = this.GetType().GetField(field);
|
||||||
if (f.GetValue(this) == null) continue;
|
if (f.GetValue(this) == null) continue;
|
||||||
|
|||||||
Reference in New Issue
Block a user