diff --git a/OpenRA.FileFormats/Session.cs b/OpenRA.FileFormats/Session.cs index a661477e0e..bcaceb2576 100644 --- a/OpenRA.FileFormats/Session.cs +++ b/OpenRA.FileFormats/Session.cs @@ -66,6 +66,7 @@ namespace OpenRA.FileFormats public readonly string[] Chrome = { }; public readonly string[] Assemblies = { }; public readonly string[] ChromeLayout = { }; + public readonly string[] Weapons = { }; public Manifest(string[] mods) { @@ -81,6 +82,7 @@ namespace OpenRA.FileFormats Chrome = YamlList(yaml, "Chrome"); Assemblies = YamlList(yaml, "Assemblies"); ChromeLayout = YamlList(yaml, "ChromeLayout"); + Weapons = YamlList(yaml, "Weapons"); } static string[] YamlList(Dictionary ys, string key) { return ys[key].Nodes.Keys.ToArray(); } diff --git a/OpenRA.Game/GameRules/NewWeaponInfo.cs b/OpenRA.Game/GameRules/NewWeaponInfo.cs new file mode 100644 index 0000000000..0314f1732f --- /dev/null +++ b/OpenRA.Game/GameRules/NewWeaponInfo.cs @@ -0,0 +1,70 @@ +#region Copyright & License Information +/* + * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. + * This file is part of OpenRA. + * + * OpenRA is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OpenRA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with OpenRA. If not, see . + */ +#endregion + +using System.Collections.Generic; +using OpenRA.FileFormats; +using OpenRA.Effects; + +namespace OpenRA.GameRules +{ + public interface IProjectileInfo + { + IEffect Create(); // todo: args for this + } + + public class NewWeaponInfo + { + public readonly float Range = 0; + public readonly string Report = null; + public readonly int ROF = 1; + + public IProjectileInfo Projectile; + public List Warheads = new List(); + + public NewWeaponInfo(string name, MiniYaml content) + { + foreach (var kv in content.Nodes) + { + var key = kv.Key.Split('@')[0]; + switch (key) + { + case "Range": FieldLoader.LoadField(this, "Range", content.Nodes["Range"].Value); break; + case "ROF": FieldLoader.LoadField(this, "ROF", content.Nodes["ROF"].Value); break; + case "Report": FieldLoader.LoadField(this, "Report", content.Nodes["Report"].Value); break; + + case "Warhead": + { + var warhead = new WarheadInfo(); + FieldLoader.Load(warhead, kv.Value); + Warheads.Add(warhead); + } break; + + // in this case, it's an implementation of IProjectileInfo + default: + { + // todo: create the right implementation! + // fill it with the args + // etc etc + } break; + } + } + } + } +} diff --git a/OpenRA.Game/GameRules/Rules.cs b/OpenRA.Game/GameRules/Rules.cs index 61b16f06d3..cba40800be 100755 --- a/OpenRA.Game/GameRules/Rules.cs +++ b/OpenRA.Game/GameRules/Rules.cs @@ -37,6 +37,7 @@ namespace OpenRA public static TechTree TechTree; public static Dictionary Info; + public static Dictionary Weapons; public static void LoadRules(string map, Manifest m) { @@ -64,11 +65,15 @@ namespace OpenRA Log.Write(" -- {0}", y); var yamlRules = m.Rules.Select(a => MiniYaml.FromFile(a)).Aggregate(MiniYaml.Merge); - Info = new Dictionary(); foreach( var kv in yamlRules ) Info.Add(kv.Key.ToLowerInvariant(), new ActorInfo(kv.Key.ToLowerInvariant(), kv.Value, yamlRules)); + var weaponsYaml = m.Weapons.Select(a => MiniYaml.FromFile(a)).Aggregate(MiniYaml.Merge); + Weapons = new Dictionary(); + foreach (var kv in weaponsYaml) + Weapons.Add(kv.Key.ToLowerInvariant(), new NewWeaponInfo(kv.Key.ToLowerInvariant(), kv.Value)); + TechTree = new TechTree(); } diff --git a/OpenRA.Game/GameRules/WarheadInfo.cs b/OpenRA.Game/GameRules/WarheadInfo.cs index ef101666ba..3a82865e83 100644 --- a/OpenRA.Game/GameRules/WarheadInfo.cs +++ b/OpenRA.Game/GameRules/WarheadInfo.cs @@ -33,6 +33,7 @@ namespace OpenRA.GameRules public readonly int InfDeath = 0; public readonly string ImpactSound = null; public readonly string WaterImpactSound = null; + public readonly int Damage = 0; // for new weapons infrastructure public float EffectivenessAgainst(ArmorType at) { return Verses[ (int)at ]; } } diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj index 32629474f2..26f1317686 100755 --- a/OpenRA.Game/OpenRA.Game.csproj +++ b/OpenRA.Game/OpenRA.Game.csproj @@ -75,6 +75,7 @@ + diff --git a/mods/ra/mod.yaml b/mods/ra/mod.yaml index 12b5f926b4..f7fdd2ea67 100644 --- a/mods/ra/mod.yaml +++ b/mods/ra/mod.yaml @@ -26,7 +26,6 @@ LegacyRules: Rules: mods/ra/defaults.yaml: Basic stuff mods/ra/rules.yaml: OpenRA actorinfos - mods/ra/weapons.yaml: Weapon definitions Sequences: mods/ra/sequences.xml: Original animation sequences @@ -39,3 +38,6 @@ Assemblies: ChromeLayout: mods/ra/menus.yaml: + +Weapons: + mods/ra/weapons.yaml \ No newline at end of file diff --git a/mods/ra/weapons.yaml b/mods/ra/weapons.yaml index 3a207fe462..478f5a5027 100644 --- a/mods/ra/weapons.yaml +++ b/mods/ra/weapons.yaml @@ -21,7 +21,7 @@ ZSU-23: Speed: 100 Warhead: Spread: 3 - Versus: 30%,75%,75%,100%,50% + Verses: 30%,75%,75%,100%,50% Explosion: 4 Damage: 25