]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Apply some math to only fire the (rounded) fraction of clip_load divided by burst_ammo.
authorDavid Knapp <mazecraze96@gmail.com>
Fri, 19 Jul 2019 23:11:41 +0000 (19:11 -0400)
committerDavid Knapp <mazecraze96@gmail.com>
Fri, 19 Jul 2019 23:11:41 +0000 (19:11 -0400)
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

index 04f20e0c206d53a79a89551d872f1018d9dfa3a4..3405b79fc0f050c80c7b56f3f3888689a1a20319 100644 (file)
@@ -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);
         }
     }