From b9a1ed6cf37dd1a66274a76ccbccf65e2eb3d48e Mon Sep 17 00:00:00 2001 From: David Knapp Date: Sun, 21 Jul 2019 23:17:22 -0400 Subject: [PATCH] Apply the fraction to an integer and use it for the ammo decrease and firing. Renamed the fraction appropriately. Minor formatting improvement. --- qcsrc/common/weapons/weapon/machinegun.qc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/qcsrc/common/weapons/weapon/machinegun.qc b/qcsrc/common/weapons/weapon/machinegun.qc index 3340a1635..132f1c480 100644 --- a/qcsrc/common/weapons/weapon/machinegun.qc +++ b/qcsrc/common/weapons/weapon/machinegun.qc @@ -222,14 +222,15 @@ METHOD(MachineGun, wr_think, void(entity thiswep, entity actor, .entity weaponen return; } - // We don't want to shoot 3 rounds if there's 2 left in the mag. So calculate a fraction... - float burst_percent = min(1,actor.(weaponentity).clip_load / WEP_CVAR(machinegun, burst_ammo)); - - // ...before we decrease ammo. + // We don't want to shoot 3 rounds if there's 2 left in the mag. So calculate a fraction. + float burst_fraction = min(1, actor.(weaponentity).clip_load / WEP_CVAR(machinegun, burst_ammo)); + int to_shoot = floor(WEP_CVAR(machinegun, burst) * burst_fraction); + + // Apply it here to take the right amount of ammo. W_DecreaseAmmo(thiswep, actor, WEP_CVAR(machinegun, burst_ammo), weaponentity); // Then apply it to the bullet counter before firing. - actor.(weaponentity).misc_bulletcounter = floor(WEP_CVAR(machinegun, burst) * burst_percent) * -1; + actor.(weaponentity).misc_bulletcounter = to_shoot * -1; W_MachineGun_Attack_Burst(thiswep, actor, weaponentity, fire); } } -- 2.39.5