// We don't want to shoot 3 rounds if there's 2 left in the mag, so we'll use a fraction.
// Also keep the fraction <= 1 otherwise we'd mag dump in one burst.
- float burst_fraction = min(1, ammo_available / WEP_CVAR(WEP_MACHINEGUN, burst_ammo));
+ float burst_fraction = 1;
+ if(WEP_CVAR(WEP_MACHINEGUN, burst_ammo)) // avoid div by 0
+ burst_fraction = min(1, ammo_available / WEP_CVAR(WEP_MACHINEGUN, burst_ammo));
int to_shoot = floor(WEP_CVAR(WEP_MACHINEGUN, burst) * burst_fraction);
// We also don't want to use 3 rounds if there's only 2 left.
METHOD(MachineGun, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
{
- float ammo_amount;
- float burst_ammo_per_shot = WEP_CVAR(WEP_MACHINEGUN, burst_ammo) / WEP_CVAR(WEP_MACHINEGUN, burst);
+ float burst_ammo_per_shot = 1;
+ if (WEP_CVAR(WEP_MACHINEGUN, burst)) // avoid div by 0
+ burst_ammo_per_shot = WEP_CVAR(WEP_MACHINEGUN, burst_ammo) / WEP_CVAR(WEP_MACHINEGUN, burst);
+ float ammo_amount;
if(WEP_CVAR(WEP_MACHINEGUN, mode) == 1)
ammo_amount = GetResource(actor, thiswep.ammo_type) >= burst_ammo_per_shot;
else