From 834a40b18d878447aacc1c494c1e519a7e4fae44 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Sun, 16 Jul 2017 15:03:40 +0200 Subject: [PATCH] Refactor BurstDelay to BurstDelays Allowing to set custom per-burst delays. --- OpenRA.Game/GameRules/WeaponInfo.cs | 5 +++-- OpenRA.Mods.Common/Traits/Armament.cs | 10 +++++++++- OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs | 5 +++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/OpenRA.Game/GameRules/WeaponInfo.cs b/OpenRA.Game/GameRules/WeaponInfo.cs index ab2c4de4bc..ef4bc37b43 100644 --- a/OpenRA.Game/GameRules/WeaponInfo.cs +++ b/OpenRA.Game/GameRules/WeaponInfo.cs @@ -69,8 +69,9 @@ namespace OpenRA.GameRules [Desc("What types of targets are unaffected.", "Overrules ValidTargets.")] public readonly HashSet InvalidTargets = new HashSet(); - [Desc("Delay in ticks between firing shots from the same ammo magazine.")] - public readonly int BurstDelay = 5; + [Desc("Delay in ticks between firing shots from the same ammo magazine. If one entry, it will be used for all bursts.", + "If multiple entries, their number needs to match Burst - 1.")] + public readonly int[] BurstDelays = { 5 }; [Desc("The minimum range the weapon can fire.")] public readonly WDist MinRange = WDist.Zero; diff --git a/OpenRA.Mods.Common/Traits/Armament.cs b/OpenRA.Mods.Common/Traits/Armament.cs index 498d653a4b..173a2bdf3d 100644 --- a/OpenRA.Mods.Common/Traits/Armament.cs +++ b/OpenRA.Mods.Common/Traits/Armament.cs @@ -92,6 +92,9 @@ namespace OpenRA.Mods.Common.Traits WeaponInfo.Range.Length, ai.TraitInfos().Select(m => m.GetRangeModifierDefault()))); + if (WeaponInfo.Burst > 1 && WeaponInfo.BurstDelays.Length > 1 && (WeaponInfo.BurstDelays.Length != WeaponInfo.Burst - 1)) + throw new YamlException("Weapon '{0}' has an invalid number of BurstDelays, must be single entry or Burst - 1.".F(weaponToLower)); + base.RulesetLoaded(rules, ai); } } @@ -311,7 +314,12 @@ namespace OpenRA.Mods.Common.Traits protected virtual void UpdateBurst(Actor self, Target target) { if (--Burst > 0) - FireDelay = Weapon.BurstDelay; + { + if (Weapon.BurstDelays.Length == 1) + FireDelay = Weapon.BurstDelays[0]; + else + FireDelay = Weapon.BurstDelays[Weapon.Burst - (Burst + 1)]; + } else { var modifiers = reloadModifiers.ToArray(); diff --git a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs index 79119ba3de..4b7911e4ad 100644 --- a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs +++ b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs @@ -1092,6 +1092,11 @@ namespace OpenRA.Mods.Common.UtilityCommands } } + // Rename BurstDelay to BurstDelays + if (engineVersion < 20170818) + if (node.Key == "BurstDelay") + node.Key = "BurstDelays"; + UpgradeWeaponRules(modData, engineVersion, ref node.Value.Nodes, node, depth + 1); } }