From 07edf2f7c6d3daee79c3368c92903c5f87b32829 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Sat, 24 Jun 2017 19:37:16 +0200 Subject: [PATCH] Reset burst counter if ReloadDelay has passed since last shot This fixes the following issues: - units like mammoth tanks sometimes at first only fired 1 shot on new encounter because they only depleted 1 burst before previous target was killed - weapons that use strafing logic would not reset the offset multiplier after passing the target once, leading to wrong offsets on following attacks --- OpenRA.Mods.Common/Traits/Armament.cs | 10 ++++++++++ mods/ra/weapons/smallcaliber.yaml | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Armament.cs b/OpenRA.Mods.Common/Traits/Armament.cs index e5a8e7da0c..c31c0bfad0 100644 --- a/OpenRA.Mods.Common/Traits/Armament.cs +++ b/OpenRA.Mods.Common/Traits/Armament.cs @@ -113,6 +113,8 @@ namespace OpenRA.Mods.Common.Traits IEnumerable damageModifiers; IEnumerable inaccuracyModifiers; + int ticksSinceLastShot; + List> delayedActions = new List>(); public WDist Recoil; @@ -169,6 +171,9 @@ namespace OpenRA.Mods.Common.Traits if (IsTraitDisabled) return; + if (ticksSinceLastShot < Weapon.ReloadDelay) + ++ticksSinceLastShot; + if (FireDelay > 0) --FireDelay; @@ -221,6 +226,11 @@ namespace OpenRA.Mods.Common.Traits if (!Weapon.IsValidAgainst(target, self.World, self)) return null; + if (ticksSinceLastShot >= Weapon.ReloadDelay) + Burst = Weapon.Burst; + + ticksSinceLastShot = 0; + var barrel = Barrels[Burst % Barrels.Length]; Func muzzlePosition = () => self.CenterPosition + MuzzleOffset(self, barrel); var legacyFacing = MuzzleOrientation(self, barrel).Yaw.Angle / 4; diff --git a/mods/ra/weapons/smallcaliber.yaml b/mods/ra/weapons/smallcaliber.yaml index 73af355121..eda0c40034 100644 --- a/mods/ra/weapons/smallcaliber.yaml +++ b/mods/ra/weapons/smallcaliber.yaml @@ -23,8 +23,8 @@ ZSU-23: Inherits: ^AACannon Burst: 2 - BurstDelay: 5 - ReloadDelay: 0 + BurstDelay: 0 + ReloadDelay: 5 Range: 10c0 Projectile: Bullet Speed: 3c340