diff --git a/OpenRA.FileFormats/Session.cs b/OpenRA.FileFormats/Session.cs index bcaceb2576..686c6bba9d 100644 --- a/OpenRA.FileFormats/Session.cs +++ b/OpenRA.FileFormats/Session.cs @@ -58,15 +58,10 @@ namespace OpenRA.FileFormats public class Manifest { - public readonly string[] Folders = { }; - public readonly string[] Packages = { }; - public readonly string[] LegacyRules = { }; - public readonly string[] Rules = { }; - public readonly string[] Sequences = { }; - public readonly string[] Chrome = { }; - public readonly string[] Assemblies = { }; - public readonly string[] ChromeLayout = { }; - public readonly string[] Weapons = { }; + public readonly string[] + Folders, Packages, LegacyRules, Rules, + Sequences, Chrome, Assemblies, ChromeLayout, + Weapons, Voices; public Manifest(string[] mods) { @@ -83,6 +78,7 @@ namespace OpenRA.FileFormats Assemblies = YamlList(yaml, "Assemblies"); ChromeLayout = YamlList(yaml, "ChromeLayout"); Weapons = YamlList(yaml, "Weapons"); + Voices = YamlList(yaml, "Voices"); } static string[] YamlList(Dictionary ys, string key) { return ys[key].Nodes.Keys.ToArray(); } diff --git a/OpenRA.Game/Combat.cs b/OpenRA.Game/Combat.cs index 986e08d3d8..07cefee7c7 100644 --- a/OpenRA.Game/Combat.cs +++ b/OpenRA.Game/Combat.cs @@ -27,7 +27,7 @@ using OpenRA.FileFormats; namespace OpenRA { - static class Combat /* some utility bits that are shared between various things */ + public static class Combat /* some utility bits that are shared between various things */ { static string GetImpactSound(WarheadInfo warhead, bool isWater) { @@ -82,6 +82,23 @@ namespace OpenRA } } + public static void DoExplosion(Actor attacker, string weapontype, int2 location, int altitude) + { + var args = new ProjectileArgs + { + src = location, + dest = location, + srcAltitude = altitude, + destAltitude = altitude, + firedBy = attacker, + target = null, + weapon = Rules.Weapons[ weapontype.ToLowerInvariant() ], + facing = 0 + }; + + DoImpacts(args, location); + } + static float GetDamageToInflict(Actor target, ProjectileArgs args, WarheadInfo warhead, float modifier) { var distance = (target.CenterLocation - args.dest).Length; diff --git a/OpenRA.Game/GameRules/InfoLoader.cs b/OpenRA.Game/GameRules/InfoLoader.cs deleted file mode 100644 index e382db71ab..0000000000 --- a/OpenRA.Game/GameRules/InfoLoader.cs +++ /dev/null @@ -1,51 +0,0 @@ -#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; -using System.Collections; -using System.Collections.Generic; -using OpenRA.FileFormats; - -namespace OpenRA.GameRules -{ - public class InfoLoader : IEnumerable> - { - readonly Dictionary infos = new Dictionary(); - - public InfoLoader(params Pair>[] srcs) - { - foreach (var src in srcs) - foreach (var name in Rules.Categories[src.First]) - { - var t = src.Second(name); - FieldLoader.Load(t, Rules.AllRules.GetSection(name)); - infos[name] = t; - } - } - - public T this[string name] - { - get { return infos[name.ToLowerInvariant()]; } - } - - public IEnumerator> GetEnumerator() { return infos.GetEnumerator(); } - IEnumerator IEnumerable.GetEnumerator() { return infos.GetEnumerator(); } - } -} diff --git a/OpenRA.Game/GameRules/Rules.cs b/OpenRA.Game/GameRules/Rules.cs index 172736956a..0a4635dee0 100755 --- a/OpenRA.Game/GameRules/Rules.cs +++ b/OpenRA.Game/GameRules/Rules.cs @@ -29,13 +29,11 @@ namespace OpenRA public static class Rules { public static IniFile AllRules; - public static Dictionary> Categories = new Dictionary>(); - public static InfoLoader WarheadInfo; - public static InfoLoader VoiceInfo; public static TechTree TechTree; public static Dictionary Info; public static Dictionary Weapons; + public static Dictionary Voices; public static void LoadRules(string map, Manifest m) { @@ -43,38 +41,21 @@ namespace OpenRA legacyRules.Insert(0, map); AllRules = new IniFile(legacyRules.Select(a => FileSystem.Open(a)).ToArray()); - LoadCategories( - "Weapon", - "Warhead", - "Projectile", - "Voice"); - - WarheadInfo = new InfoLoader( - Pair.New>("Warhead", _ => new WarheadInfo())); - VoiceInfo = new InfoLoader( - Pair.New>("Voice", _ => new VoiceInfo())); - Log.Write("Using rules files: "); foreach (var y in m.Rules) 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 WeaponInfo(kv.Key.ToLowerInvariant(), kv.Value)); + Info = LoadYamlRules(m.Rules, (k, y) => new ActorInfo(k.Key.ToLowerInvariant(), k.Value, y)); + Weapons = LoadYamlRules(m.Weapons, (k, _) => new WeaponInfo(k.Key.ToLowerInvariant(), k.Value)); + Voices = LoadYamlRules(m.Voices, (k, _) => new VoiceInfo(k.Value)); TechTree = new TechTree(); } - static void LoadCategories(params string[] types) + static Dictionary LoadYamlRules(string[] files, Func, Dictionary, T> f) { - foreach (var t in types) - Categories[t] = AllRules.GetSection(t + "Types").Select(x => x.Key.ToLowerInvariant()).ToList(); + var y = files.Select(a => MiniYaml.FromFile(a)).Aggregate(MiniYaml.Merge); + return y.ToDictionary(kv => kv.Key.ToLowerInvariant(), kv => f(kv, y)); } } } diff --git a/OpenRA.Game/GameRules/VoiceInfo.cs b/OpenRA.Game/GameRules/VoiceInfo.cs index fbe335f44e..1cf9a947dd 100644 --- a/OpenRA.Game/GameRules/VoiceInfo.cs +++ b/OpenRA.Game/GameRules/VoiceInfo.cs @@ -34,8 +34,10 @@ namespace OpenRA.GameRules public readonly Lazy> Pools; - public VoiceInfo() + public VoiceInfo( MiniYaml y ) { + FieldLoader.Load(this, y); + Pools = Lazy.New(() => new Dictionary { diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj index 00f2e22832..a0e3841592 100755 --- a/OpenRA.Game/OpenRA.Game.csproj +++ b/OpenRA.Game/OpenRA.Game.csproj @@ -153,7 +153,6 @@ - diff --git a/OpenRA.Game/Sound.cs b/OpenRA.Game/Sound.cs index b2d15fb330..19da51e902 100644 --- a/OpenRA.Game/Sound.cs +++ b/OpenRA.Game/Sound.cs @@ -102,16 +102,6 @@ namespace OpenRA music.Volume = value; } } - - //public static void SeekMusic(uint delta) - //{ - // if (music != null) - // { - // music.PlayPosition += delta; - // if (music.PlayPosition < 0 || music.PlayPosition > music.PlayLength) - // music.PlayPosition = 0; - // } - //} public static void PlayVoice(string phrase, Actor voicedUnit) { @@ -120,7 +110,7 @@ namespace OpenRA var mi = voicedUnit.Info.Traits.GetOrDefault(); if (mi == null) return; - var vi = Rules.VoiceInfo[mi.Voice]; + var vi = Rules.Voices[mi.Voice.ToLowerInvariant()]; var clip = vi.Pools.Value[phrase].GetNext(); if (clip == null) diff --git a/OpenRA.Game/Traits/AI/SelfHealing.cs b/OpenRA.Game/Traits/AI/SelfHealing.cs index fb65a9969b..19e2a5defa 100644 --- a/OpenRA.Game/Traits/AI/SelfHealing.cs +++ b/OpenRA.Game/Traits/AI/SelfHealing.cs @@ -44,7 +44,7 @@ namespace OpenRA.Traits if (--ticks <= 0) { ticks = info.Ticks; - self.InflictDamage(self, -info.Step, Rules.WarheadInfo["Super"]); + self.InflictDamage(self, -info.Step, null); } } } diff --git a/OpenRA.Game/Traits/Activities/Repair.cs b/OpenRA.Game/Traits/Activities/Repair.cs index 1b6cc12e4e..9cee11846c 100644 --- a/OpenRA.Game/Traits/Activities/Repair.cs +++ b/OpenRA.Game/Traits/Activities/Repair.cs @@ -51,7 +51,7 @@ namespace OpenRA.Traits.Activities return this; } - self.InflictDamage(self, -hpToRepair, Rules.WarheadInfo["Super"]); + self.InflictDamage(self, -hpToRepair, null); if (self.Health == hp) return NextActivity; diff --git a/OpenRA.Game/Traits/Building.cs b/OpenRA.Game/Traits/Building.cs index eda691decf..257a985f1e 100644 --- a/OpenRA.Game/Traits/Building.cs +++ b/OpenRA.Game/Traits/Building.cs @@ -135,7 +135,7 @@ namespace OpenRA.Traits } self.World.AddFrameEndTask(w => w.Add(new RepairIndicator(self))); - self.InflictDamage(self, -hpToRepair, Rules.WarheadInfo["Super"]); + self.InflictDamage(self, -hpToRepair, null); if (self.Health == maxHP) { isRepairing = false; diff --git a/OpenRA.Game/Traits/SquishByTank.cs b/OpenRA.Game/Traits/SquishByTank.cs index cd18e21a69..642338b95d 100644 --- a/OpenRA.Game/Traits/SquishByTank.cs +++ b/OpenRA.Game/Traits/SquishByTank.cs @@ -35,7 +35,8 @@ namespace OpenRA.Traits public void OnCrush(Actor crusher) { - self.InflictDamage(crusher, self.Health, Rules.WarheadInfo["Crush"]); + // ... this wasnt working ANYWAY ... + // self.InflictDamage(crusher, self.Health, Rules.WarheadInfo["Crush"]); } public bool IsPathableCrush(UnitMovementType umt, Player player) diff --git a/OpenRA.Mods.RA/Activities/CaptureBuilding.cs b/OpenRA.Mods.RA/Activities/CaptureBuilding.cs index 19f2501b37..ddd9ba783e 100644 --- a/OpenRA.Mods.RA/Activities/CaptureBuilding.cs +++ b/OpenRA.Mods.RA/Activities/CaptureBuilding.cs @@ -35,23 +35,21 @@ namespace OpenRA.Mods.RA.Activities { if (target == null || target.IsDead) return NextActivity; - var warhead = Rules.WarheadInfo["Super"]; - if (self.Owner.Stances[ target.Owner ] == Stance.Ally) { if (target.Health == target.Info.Traits.Get().HP) return NextActivity; - target.InflictDamage(self, -EngineerCapture.EngineerDamage, warhead); + target.InflictDamage(self, -EngineerCapture.EngineerDamage, null); } else { if (target.Health - EngineerCapture.EngineerDamage <= 0) { target.Owner = self.Owner; - target.InflictDamage(self, target.Health - EngineerCapture.EngineerDamage, warhead); + target.InflictDamage(self, target.Health - EngineerCapture.EngineerDamage, null); } else - target.InflictDamage(self, EngineerCapture.EngineerDamage, warhead); + target.InflictDamage(self, EngineerCapture.EngineerDamage, null); } // the engineer is sacrificed. diff --git a/OpenRA.Mods.RA/Activities/Demolish.cs b/OpenRA.Mods.RA/Activities/Demolish.cs index 6aa0dd4678..8aa97ccb97 100644 --- a/OpenRA.Mods.RA/Activities/Demolish.cs +++ b/OpenRA.Mods.RA/Activities/Demolish.cs @@ -36,8 +36,8 @@ namespace OpenRA.Mods.RA.Activities public IActivity Tick(Actor self) { if (target == null || target.IsDead) return NextActivity; - self.World.AddFrameEndTask(w => w.Add(new DelayedAction(25*2, - () => target.InflictDamage(self, target.Health, Rules.WarheadInfo["DemolishWarhead"])))); + self.World.AddFrameEndTask(w => w.Add(new DelayedAction(25 * 2, + () => target.InflictDamage(self, target.Health, null)))); return NextActivity; } diff --git a/OpenRA.Mods.RA/Mine.cs b/OpenRA.Mods.RA/Mine.cs index 0daad0d68b..33e406679d 100644 --- a/OpenRA.Mods.RA/Mine.cs +++ b/OpenRA.Mods.RA/Mine.cs @@ -22,6 +22,7 @@ using System.Collections.Generic; using System.Linq; using OpenRA.Effects; using OpenRA.Traits; +using OpenRA.Traits.Activities; namespace OpenRA.Mods.RA { @@ -50,14 +51,8 @@ namespace OpenRA.Mods.RA return; var info = self.Info.Traits.Get(); - var warhead = Rules.WarheadInfo[info.Warhead]; - - self.World.AddFrameEndTask(w => - { - w.Remove(self); - w.Add(new Explosion(w, self.CenterLocation.ToInt2(), warhead.Explosion, false)); - crusher.InflictDamage(crusher, info.Damage, warhead); - }); + Combat.DoExplosion(self, info.Warhead, self.CenterLocation.ToInt2(), 0); + self.QueueActivity(new RemoveSelf()); } public bool IsPathableCrush(UnitMovementType umt, Player player) diff --git a/mods/ra/mod.yaml b/mods/ra/mod.yaml index f7fdd2ea67..36f0a263dd 100644 --- a/mods/ra/mod.yaml +++ b/mods/ra/mod.yaml @@ -40,4 +40,7 @@ ChromeLayout: mods/ra/menus.yaml: Weapons: - mods/ra/weapons.yaml \ No newline at end of file + mods/ra/weapons.yaml + +Voices: + mods/ra/voices.yaml \ No newline at end of file diff --git a/mods/ra/voices.yaml b/mods/ra/voices.yaml new file mode 100644 index 0000000000..f4c790e87a --- /dev/null +++ b/mods/ra/voices.yaml @@ -0,0 +1,59 @@ +# Classic Red Alert Mod -- Package Manifest + +GenericVoice: + SovietVariants: .r01,.r03 + AlliedVariants: .v01,.v03 + Select: await1,ready,report1,yessir1 + Move: ackno,affirm1,noprob,overout,ritaway,roger,ugotit + Die: dedman1.aud,dedman2.aud,dedman3.aud,dedman4.aud,dedman5.aud,dedman6.aud,dedman7.aud,dedman8.aud,dedman10.aud + +VehicleVoice: + SovietVariants: .r00,.r02 + AlliedVariants: .v00,.v02 + Select: vehic1,yessir1,report1,await1 + Move: ackno,affirm1 + +EngineerVoice: + Select: eengin1,eyessir1 + Move: eaffirm1,emovout1 + Die: dedman1,dedman2,dedman3,dedman4,dedman5,dedman6,dedman7,dedman8,dedman10 + +MedicVoice: + Select: mrespon1,myessir1 + Move: maffirm1,mmovout1 + Die: dedman1,dedman2,dedman3,dedman4,dedman5,dedman6,dedman7,dedman8,dedman10 + +TanyaVoice: + Select: yo1,yes1,yeah1 + Move: rokroll1,onit1,cmon1 + Attack: tuffguy1,bombit1,gotit1 + Die: tandeth1 + +DogVoice: + Select: + Move: dogy1 + Attack: dogg5p,dogw3px + Die: dogw5,dogw6,dogw7 + +SpyVoice: + Select: syessir1,scomnd1 + Move: sonway1,sindeed1 + Attack: sking1 + Die: dedman1,dedman2,dedman3,dedman4,dedman5,dedman6,dedman7,dedman8,dedman10 + +ThiefVoice: + Select: swhat1,syeah1 + Move: saffirm1,smout1,sokay1 + Die: dedman1,dedman2,dedman3,dedman4,dedman5,dedman6,dedman7,dedman8,dedman10 + +CivilianMaleVoice: + Select: guyyeah1 + Move: guyokay1 + +CivilianFemaleVoice: + Select: girlyeah + Move: girlokay + +EinsteinVoice: + Select: einah1,einok1,einyes1 + Move: einah1,einok1,einyes1 \ No newline at end of file