- // forced reload - wait until the bulletcounter is 0 so a burst loop can finish
- if(WEP_CVAR(machinegun, reload_ammo)
- && actor.(weaponentity).clip_load < min(max(WEP_CVAR(machinegun, sustained_ammo), WEP_CVAR(machinegun, first_ammo)), WEP_CVAR(machinegun, burst_ammo))
- && actor.(weaponentity).misc_bulletcounter >= 0)
- {
- thiswep.wr_reload(thiswep, actor, weaponentity);
- }
- else if(WEP_CVAR(machinegun, mode) == 1)
- {
- if(fire & 1)
- if(weapon_prepareattack(thiswep, actor, weaponentity, false, 0))
- {
- actor.(weaponentity).misc_bulletcounter = 0;
- W_MachineGun_Attack_Auto(thiswep, actor, weaponentity, fire);
- }
-
- // You can "shoot" more rounds than what's "used", and vice versa.
- if(fire & 2)
- if(weapon_prepareattack(thiswep, actor, weaponentity, true, 0))
- {
- if(!thiswep.wr_checkammo2(thiswep, actor, weaponentity))
- if(!(actor.items & IT_UNLIMITED_AMMO))
- {
- W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity);
- w_ready(thiswep, actor, weaponentity, fire);
- return;
- }
-
- float ammo_available;
- if (WEP_CVAR(machinegun, reload_ammo) > 0)
- {
- ammo_available = actor.(weaponentity).clip_load;
- }
- else
- {
- ammo_available = GetResource(actor, thiswep.ammo_type);
- }
-
- // 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(machinegun, burst_ammo));
- int to_shoot = floor(WEP_CVAR(machinegun, burst) * burst_fraction);
-
- // We also don't want to use 3 rounds if there's only 2 left.
- int to_use = min(WEP_CVAR(machinegun, burst_ammo), ammo_available);
- W_DecreaseAmmo(thiswep, actor, to_use, weaponentity);
-
- // Bursting counts up to 0 from a negative.
- actor.(weaponentity).misc_bulletcounter = -to_shoot;
- W_MachineGun_Attack_Burst(thiswep, actor, weaponentity, fire);
- }
- }
- else
- {
-
- if(fire & 1)
- if(weapon_prepareattack(thiswep, actor, weaponentity, false, 0))
- {
- actor.(weaponentity).misc_bulletcounter = 1;
- W_MachineGun_Attack(thiswep, thiswep.m_id, actor, weaponentity); // sets attack_finished
- weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(machinegun, sustained_refire), W_MachineGun_Attack_Frame);
- }
-
- if((fire & 2) && WEP_CVAR(machinegun, first))
- if(weapon_prepareattack(thiswep, actor, weaponentity, true, 0))
- {
- actor.(weaponentity).misc_bulletcounter = 1;
- W_MachineGun_Attack(thiswep, thiswep.m_id | HITTYPE_SECONDARY, actor, weaponentity); // sets attack_finished
- weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(machinegun, first_refire), w_ready);
- }
- }
+ // forced reload - wait until the bulletcounter is 0 so a burst loop can finish
+ if (WEP_CVAR(WEP_MACHINEGUN, reload_ammo)
+ && actor.(weaponentity).clip_load < min(max(WEP_CVAR(WEP_MACHINEGUN, sustained_ammo), WEP_CVAR(WEP_MACHINEGUN, first_ammo)), WEP_CVAR(WEP_MACHINEGUN, burst_ammo))
+ && actor.(weaponentity).misc_bulletcounter >= 0)
+ {
+ thiswep.wr_reload(thiswep, actor, weaponentity);
+ }
+ else if(WEP_CVAR(WEP_MACHINEGUN, mode) == 1)
+ {
+ if(fire & 1)
+ if(weapon_prepareattack(thiswep, actor, weaponentity, false, 0))
+ {
+ actor.(weaponentity).misc_bulletcounter = 0;
+ W_MachineGun_Attack_Auto(thiswep, actor, weaponentity, fire);
+ }
+
+ // You can "shoot" more rounds than what's "used", and vice versa.
+ if(fire & 2)
+ if(weapon_prepareattack(thiswep, actor, weaponentity, true, 0))
+ {
+ if(!thiswep.wr_checkammo2(thiswep, actor, weaponentity))
+ if(!(actor.items & IT_UNLIMITED_AMMO))
+ {
+ W_SwitchWeapon_Force(actor, w_getbestweapon(actor, weaponentity), weaponentity);
+ w_ready(thiswep, actor, weaponentity, fire);
+ return;
+ }
+
+ float ammo_available;
+ if (WEP_CVAR(WEP_MACHINEGUN, reload_ammo) > 0)
+ {
+ ammo_available = actor.(weaponentity).clip_load;
+ }
+ else
+ {
+ ammo_available = GetResource(actor, thiswep.ammo_type);
+ }
+
+ int to_shoot = WEP_CVAR(WEP_MACHINEGUN, burst);
+ if(!(actor.items & IT_UNLIMITED_AMMO))
+ {
+ // 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));
+ to_shoot = floor(to_shoot * burst_fraction);
+
+ // We also don't want to use 3 rounds if there's only 2 left.
+ int to_use = min(WEP_CVAR(WEP_MACHINEGUN, burst_ammo), ammo_available);
+ W_DecreaseAmmo(thiswep, actor, to_use, weaponentity);
+ }
+
+ // Bursting counts up to 0 from a negative.
+ actor.(weaponentity).misc_bulletcounter = -to_shoot;
+ W_MachineGun_Attack_Burst(thiswep, actor, weaponentity, fire);
+ }
+ }
+ else
+ {
+
+ if(fire & 1)
+ if(weapon_prepareattack(thiswep, actor, weaponentity, false, 0))
+ {
+ actor.(weaponentity).misc_bulletcounter = 1;
+ W_MachineGun_Attack(thiswep, thiswep.m_id, actor, weaponentity); // sets attack_finished
+ weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(WEP_MACHINEGUN, sustained_refire), W_MachineGun_Attack_Frame);
+ }
+
+ if((fire & 2) && WEP_CVAR(WEP_MACHINEGUN, first))
+ if(weapon_prepareattack(thiswep, actor, weaponentity, true, 0))
+ {
+ actor.(weaponentity).misc_bulletcounter = 1;
+ W_MachineGun_Attack(thiswep, thiswep.m_id | HITTYPE_SECONDARY, actor, weaponentity); // sets attack_finished
+ weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(WEP_MACHINEGUN, first_refire), w_ready);
+ }
+ }