From: David Knapp Date: Fri, 19 Jul 2019 23:11:41 +0000 (-0400) Subject: Apply some math to only fire the (rounded) fraction of clip_load divided by burst_ammo. X-Git-Tag: xonotic-v0.8.5~1287^2~10 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=22940c9052680d1c4e177a316f7db0aa8738fa41;p=xonotic%2Fxonotic-data.pk3dir.git 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. --- 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); } }