From 3d4508d1964cdc6e28390fe02952bab2c5a07333 Mon Sep 17 00:00:00 2001 From: soul Date: Thu, 22 Oct 2026 21:39:02 +0200 Subject: [PATCH] ChargedWeapon: a failed charge's cooldown restarts through InstantWeapon.StartCountdown and carries its overshoot Co-Authored-By: Claude Sonnet 5.5 --- Assets/Scripts/ServerShared/Behaviors/ChargedWeapon.cs | 3 +-- Assets/Scripts/ServerShared/Behaviors/InstantWeapon.cs | 7 +++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/ServerShared/Behaviors/ChargedWeapon.cs b/Assets/Scripts/ServerShared/Behaviors/ChargedWeapon.cs index 4d2bb5647..c3229622c 100644 --- a/Assets/Scripts/ServerShared/Behaviors/ChargedWeapon.cs +++ b/Assets/Scripts/ServerShared/Behaviors/ChargedWeapon.cs @@ -157,8 +157,7 @@ public class ChargedWeapon : InstantWeapon if (_data.FailureCharge > 1 && _charge > _data.FailureCharge) { _charging = false; - _cooldown = 1; - _coolingDown = true; + StartCountdown(); _charge = 0; OnFailed?.Invoke(); CauseDamage(_data.FailureDamage); diff --git a/Assets/Scripts/ServerShared/Behaviors/InstantWeapon.cs b/Assets/Scripts/ServerShared/Behaviors/InstantWeapon.cs index 84e6dd5c2..eaf739ce0 100644 --- a/Assets/Scripts/ServerShared/Behaviors/InstantWeapon.cs +++ b/Assets/Scripts/ServerShared/Behaviors/InstantWeapon.cs @@ -203,6 +203,13 @@ public class InstantWeapon : Weapon, IProgressBehavior, IEventBehavior, IPowerCo private float CountdownSpan => _data.MagazineSize > 0 && _ammo == 0 ? _data.ReloadTime : Cooldown; + // A countdown that starts outside a round (a charge failing) carries the last one's overshoot like every restart. + protected void StartCountdown() + { + _cooldown = 1 - TakeOvershoot() / CountdownSpan; + _coolingDown = true; + } + private float TakeOvershoot() { var overshoot = _overshoot;