]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Apply the fraction to an integer and use it for the ammo decrease and
authorDavid Knapp <mazecraze96@gmail.com>
Mon, 22 Jul 2019 03:17:22 +0000 (23:17 -0400)
committerDavid Knapp <mazecraze96@gmail.com>
Mon, 22 Jul 2019 03:17:22 +0000 (23:17 -0400)
firing.

Renamed the fraction appropriately.

Minor formatting improvement.

qcsrc/common/weapons/weapon/machinegun.qc

index 3340a1635fc9bb9bb68c7ab5328be1789ee466eb..132f1c480c4920900207b75a4313477adc364f44 100644 (file)
@@ -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);
         }
     }