From: David Knapp Date: Mon, 22 Jul 2019 03:17:22 +0000 (-0400) Subject: Apply the fraction to an integer and use it for the ammo decrease and X-Git-Tag: xonotic-v0.8.5~1287^2~8 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=b9a1ed6cf37dd1a66274a76ccbccf65e2eb3d48e;p=xonotic%2Fxonotic-data.pk3dir.git Apply the fraction to an integer and use it for the ammo decrease and firing. Renamed the fraction appropriately. Minor formatting improvement. --- 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); } }