diff --git a/AUTHORS b/AUTHORS index e405bda155..c7b9a9fd81 100644 --- a/AUTHORS +++ b/AUTHORS @@ -61,6 +61,7 @@ Also thanks to: * Pavlos Touboulidis (pav) * Pizzaoverhead * Psydev + * Raymond Bedrossian (Squiggles211) * Raymond Martineau (mart0258) * Reaperrr * Riderr3 diff --git a/OpenRA.Mods.RA/LimitedAmmo.cs b/OpenRA.Mods.RA/LimitedAmmo.cs index aad0afcf4f..079063deb0 100644 --- a/OpenRA.Mods.RA/LimitedAmmo.cs +++ b/OpenRA.Mods.RA/LimitedAmmo.cs @@ -58,6 +58,8 @@ namespace OpenRA.Mods.RA public void Attacking(Actor self, Target target, Armament a, Barrel barrel) { TakeAmmo(); } + public int GetAmmoCount() { return ammo; } + public IEnumerable GetPips(Actor self) { var pips = Info.PipCount != 0 ? Info.PipCount : Info.Ammo; diff --git a/OpenRA.Mods.RA/Reloads.cs b/OpenRA.Mods.RA/Reloads.cs index 124567da2f..482fa6a6cc 100644 --- a/OpenRA.Mods.RA/Reloads.cs +++ b/OpenRA.Mods.RA/Reloads.cs @@ -20,6 +20,8 @@ namespace OpenRA.Mods.RA public readonly int Count = 0; [Desc("How long it takes to do so.")] public readonly int Period = 50; + [Desc("Whether or not reload counter should be reset when ammo has been fired.")] + public readonly bool ResetOnFire = false; public object Create(ActorInitializer init) { return new Reloads(init.self, this); } } @@ -29,21 +31,33 @@ namespace OpenRA.Mods.RA [Sync] int remainingTicks; ReloadsInfo Info; LimitedAmmo la; + int previousAmmo; public Reloads(Actor self, ReloadsInfo info) { Info = info; remainingTicks = info.Period; la = self.Trait(); + previousAmmo = la.GetAmmoCount(); } public void Tick(Actor self) { - if (--remainingTicks == 0) + if (!la.FullAmmo() && --remainingTicks == 0) { remainingTicks = Info.Period; + for (var i = 0; i < Info.Count; i++) la.GiveAmmo(); + + previousAmmo = la.GetAmmoCount(); + } + + // Resets the tick counter if ammo was fired. + if (Info.ResetOnFire && la.GetAmmoCount() < previousAmmo) + { + remainingTicks = Info.Period; + previousAmmo = la.GetAmmoCount(); } } }