From 4469b5f5ca7f0303d192f0dec0df6da22dd1be12 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Sat, 26 Jul 2014 21:41:56 +0200 Subject: [PATCH] Introduces ReloadModifier and renames ROF -> ReloadDelay --- OpenRA.Game/GameRules/WeaponInfo.cs | 4 ++-- OpenRA.Game/Traits/TraitsInterfaces.cs | 1 + OpenRA.Mods.Cnc/PoisonedByTiberium.cs | 2 +- OpenRA.Mods.D2k/DamagedWithoutFoundation.cs | 2 +- OpenRA.Mods.RA/Armament.cs | 4 +++- OpenRA.Mods.RA/GainsExperience.cs | 8 ++++---- OpenRA.Mods.RA/GainsStatUpgrades.cs | 18 +++++++++++++++--- 7 files changed, 27 insertions(+), 12 deletions(-) diff --git a/OpenRA.Game/GameRules/WeaponInfo.cs b/OpenRA.Game/GameRules/WeaponInfo.cs index 23ba47a914..4f8f46c98b 100644 --- a/OpenRA.Game/GameRules/WeaponInfo.cs +++ b/OpenRA.Game/GameRules/WeaponInfo.cs @@ -37,8 +37,8 @@ namespace OpenRA.GameRules [Desc("The sound played when the weapon is fired.")] public readonly string[] Report = null; - [Desc("Rate of Fire = Delay in ticks between reloading ammo magazines.")] - public readonly int ROF = 1; + [Desc("Delay in ticks between reloading ammo magazines.")] + public readonly int ReloadDelay = 1; [Desc("Number of shots in a single ammo magazine.")] public readonly int Burst = 1; diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index be008b25ba..47b17e3a23 100644 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -170,6 +170,7 @@ namespace OpenRA.Traits public interface IDamageModifier { int GetDamageModifier(Actor attacker, DamageWarhead warhead); } public interface ISpeedModifier { int GetSpeedModifier(); } public interface IFirepowerModifier { int GetFirepowerModifier(); } + public interface IReloadModifier { int GetReloadModifier(); } public interface ILoadsPalettes { void LoadPalettes(WorldRenderer wr); } public interface IPaletteModifier { void AdjustPalette(IReadOnlyDictionary b); } public interface IPips { IEnumerable GetPips(Actor self); } diff --git a/OpenRA.Mods.Cnc/PoisonedByTiberium.cs b/OpenRA.Mods.Cnc/PoisonedByTiberium.cs index 967589b6fb..2b5d795f51 100644 --- a/OpenRA.Mods.Cnc/PoisonedByTiberium.cs +++ b/OpenRA.Mods.Cnc/PoisonedByTiberium.cs @@ -44,7 +44,7 @@ namespace OpenRA.Mods.Cnc var weapon = self.World.Map.Rules.Weapons[info.Weapon.ToLowerInvariant()]; weapon.Impact(self.CenterPosition, self.World.WorldActor, 1f); - poisonTicks = weapon.ROF; + poisonTicks = weapon.ReloadDelay; } } } diff --git a/OpenRA.Mods.D2k/DamagedWithoutFoundation.cs b/OpenRA.Mods.D2k/DamagedWithoutFoundation.cs index 51d9b001db..c30edebde6 100644 --- a/OpenRA.Mods.D2k/DamagedWithoutFoundation.cs +++ b/OpenRA.Mods.D2k/DamagedWithoutFoundation.cs @@ -66,7 +66,7 @@ namespace OpenRA.Mods.D2k return; weapon.Impact(self.CenterPosition, self.World.WorldActor, 1f); - damageTicks = weapon.ROF; + damageTicks = weapon.ReloadDelay; } } } diff --git a/OpenRA.Mods.RA/Armament.cs b/OpenRA.Mods.RA/Armament.cs index 176488022e..397bab0986 100644 --- a/OpenRA.Mods.RA/Armament.cs +++ b/OpenRA.Mods.RA/Armament.cs @@ -187,7 +187,9 @@ namespace OpenRA.Mods.RA FireDelay = Weapon.BurstDelay; else { - FireDelay = Weapon.ROF; + var modifiers = self.TraitsImplementing() + .Select(m => m.GetReloadModifier()); + FireDelay = Util.ApplyPercentageModifiers(Weapon.ReloadDelay, modifiers); Burst = Weapon.Burst; } diff --git a/OpenRA.Mods.RA/GainsExperience.cs b/OpenRA.Mods.RA/GainsExperience.cs index d8d179ea1c..8ba0de8ec5 100644 --- a/OpenRA.Mods.RA/GainsExperience.cs +++ b/OpenRA.Mods.RA/GainsExperience.cs @@ -43,10 +43,10 @@ namespace OpenRA.Mods.RA { return new Dictionary() { - { 200, new[] { "firepower", "armor", "speed" } }, - { 400, new[] { "firepower", "armor", "speed" } }, - { 800, new[] { "firepower", "armor", "speed" } }, - { 1600, new[] { "firepower", "armor", "speed" } } + { 200, new[] { "firepower", "armor", "speed", "reload" } }, + { 400, new[] { "firepower", "armor", "speed", "reload" } }, + { 800, new[] { "firepower", "armor", "speed", "reload" } }, + { 1600, new[] { "firepower", "armor", "speed", "reload" } } }; } diff --git a/OpenRA.Mods.RA/GainsStatUpgrades.cs b/OpenRA.Mods.RA/GainsStatUpgrades.cs index 2e1527ed70..bf54966c0b 100644 --- a/OpenRA.Mods.RA/GainsStatUpgrades.cs +++ b/OpenRA.Mods.RA/GainsStatUpgrades.cs @@ -19,7 +19,7 @@ namespace OpenRA.Mods.RA public class GainsStatUpgradesInfo : ITraitInfo { public readonly string FirepowerUpgrade = "firepower"; - public readonly int[] FirepowerModifier = { 110, 115, 120, 150 }; + public readonly int[] FirepowerModifier = { 110, 115, 120, 130 }; public readonly string ArmorUpgrade = "armor"; public readonly int[] ArmorModifier = { 110, 120, 130, 150 }; @@ -27,15 +27,19 @@ namespace OpenRA.Mods.RA public readonly string SpeedUpgrade = "speed"; public readonly int[] SpeedModifier = { 110, 115, 120, 150 }; + public readonly string ReloadUpgrade = "reload"; + public readonly int[] ReloadModifier = { 95, 90, 85, 75 }; + public object Create(ActorInitializer init) { return new GainsStatUpgrades(this); } } - public class GainsStatUpgrades : IUpgradable, IFirepowerModifier, IDamageModifier, ISpeedModifier + public class GainsStatUpgrades : IUpgradable, IFirepowerModifier, IDamageModifier, ISpeedModifier, IReloadModifier { readonly GainsStatUpgradesInfo info; [Sync] int firepowerLevel = 0; [Sync] int speedLevel = 0; [Sync] int armorLevel = 0; + [Sync] int reloadLevel = 0; public GainsStatUpgrades(GainsStatUpgradesInfo info) { @@ -46,7 +50,8 @@ namespace OpenRA.Mods.RA { return (type == info.FirepowerUpgrade && firepowerLevel < info.FirepowerModifier.Length) || (type == info.ArmorUpgrade && armorLevel < info.ArmorModifier.Length) - || (type == info.SpeedUpgrade && speedLevel < info.SpeedModifier.Length); + || (type == info.SpeedUpgrade && speedLevel < info.SpeedModifier.Length) + || (type == info.ReloadUpgrade && reloadLevel < info.ReloadModifier.Length); } public void UpgradeAvailable(Actor self, string type, bool available) @@ -58,6 +63,8 @@ namespace OpenRA.Mods.RA armorLevel = (armorLevel + mod).Clamp(0, info.ArmorModifier.Length); else if (type == info.SpeedUpgrade) speedLevel = (speedLevel + mod).Clamp(0, info.SpeedModifier.Length); + else if (type == info.ReloadUpgrade) + reloadLevel = (reloadLevel + mod).Clamp(0, info.ReloadModifier.Length); } public int GetDamageModifier(Actor attacker, DamageWarhead warhead) @@ -74,5 +81,10 @@ namespace OpenRA.Mods.RA { return speedLevel > 0 ? info.SpeedModifier[speedLevel - 1] : 100; } + + public int GetReloadModifier() + { + return reloadLevel > 0 ? info.ReloadModifier[reloadLevel - 1] : 100; + } } }