From 22940c9052680d1c4e177a316f7db0aa8738fa41 Mon Sep 17 00:00:00 2001 From: David Knapp Date: Fri, 19 Jul 2019 19:11:41 -0400 Subject: [PATCH] Apply some math to only fire the (rounded) fraction of clip_load divided by burst_ammo. This means if each burst costs 3 rounds, fires 10, and there's only 2 left, it'll only fire 6 rounds. --- qcsrc/common/weapons/weapon/machinegun.qc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/qcsrc/common/weapons/weapon/machinegun.qc b/qcsrc/common/weapons/weapon/machinegun.qc index 04f20e0c2..3405b79fc 100644 --- a/qcsrc/common/weapons/weapon/machinegun.qc +++ b/qcsrc/common/weapons/weapon/machinegun.qc @@ -222,9 +222,13 @@ METHOD(MachineGun, wr_think, void(entity thiswep, entity actor, .entity weaponen return; } + float burst_percent = actor.(weaponentity).clip_load / WEP_CVAR(machinegun, burst_ammo); + if (burst_percent > 1) + burst_percent = 1; + W_DecreaseAmmo(thiswep, actor, WEP_CVAR(machinegun, burst_ammo), weaponentity); - actor.(weaponentity).misc_bulletcounter = WEP_CVAR(machinegun, burst) * -1; + actor.(weaponentity).misc_bulletcounter = floor(WEP_CVAR(machinegun, burst) * burst_percent) * -1; W_MachineGun_Attack_Burst(thiswep, actor, weaponentity, fire); } } -- 2.39.2