self.muzzle_flash.owner = self.muzzle_flash.realowner = self;
}
-void W_MachineGun_Attack(int deathtype)
+void W_MachineGun_Attack(Weapon thiswep, int deathtype)
{SELFPARAM();
W_SetupShot(self, true, 0, SND(UZI_FIRE), CH_WEAPON_A, ((self.misc_bulletcounter == 1) ? WEP_CVAR(machinegun, first_damage) : WEP_CVAR(machinegun, sustained_damage)));
if(!autocvar_g_norecoil)
SpawnCasing(((random() * 50 + 50) * v_right) - (v_forward * (random() * 25 + 25)) - ((random() * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, self);
if(self.misc_bulletcounter == 1)
- W_DecreaseAmmo(WEP_CVAR(machinegun, first_ammo));
+ W_DecreaseAmmo(thiswep, WEP_CVAR(machinegun, first_ammo));
else
- W_DecreaseAmmo(WEP_CVAR(machinegun, sustained_ammo));
+ W_DecreaseAmmo(thiswep, WEP_CVAR(machinegun, sustained_ammo));
}
// weapon frames
-void W_MachineGun_Attack_Frame(void)
+void W_MachineGun_Attack_Frame(Weapon thiswep, bool fire1, bool fire2)
{SELFPARAM();
if(self.weapon != self.switchweapon) // abort immediately if switching
{
- w_ready();
+ w_ready(thiswep, fire1, fire2);
return;
}
if(self.BUTTON_ATCK)
if(!(self.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(self, w_getbestweapon(self));
- w_ready();
+ w_ready(thiswep, fire1, fire2);
return;
}
self.misc_bulletcounter = self.misc_bulletcounter + 1;
- W_MachineGun_Attack(WEP_MACHINEGUN.m_id);
+ W_MachineGun_Attack(WEP_MACHINEGUN, WEP_MACHINEGUN.m_id);
weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(machinegun, sustained_refire), W_MachineGun_Attack_Frame);
}
else
}
-void W_MachineGun_Attack_Auto(void)
+void W_MachineGun_Attack_Auto(Weapon thiswep, bool fire1, bool fire2)
{SELFPARAM();
float machinegun_spread;
- if(!self.BUTTON_ATCK)
+ if(!fire1)
{
- w_ready();
+ w_ready(thiswep, fire1, fire2);
return;
}
if(!(self.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(self, w_getbestweapon(self));
- w_ready();
+ w_ready(thiswep, fire1, fire2);
return;
}
- W_DecreaseAmmo(WEP_CVAR(machinegun, sustained_ammo));
+ W_DecreaseAmmo(WEP_MACHINEGUN, WEP_CVAR(machinegun, sustained_ammo));
W_SetupShot(self, true, 0, SND(UZI_FIRE), CH_WEAPON_A, WEP_CVAR(machinegun, sustained_damage));
if(!autocvar_g_norecoil)
weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(machinegun, sustained_refire), W_MachineGun_Attack_Auto);
}
-void W_MachineGun_Attack_Burst(void)
+void W_MachineGun_Attack_Burst(Weapon thiswep, bool fire1, bool fire2)
{SELFPARAM();
W_SetupShot(self, true, 0, SND(UZI_FIRE), CH_WEAPON_A, WEP_CVAR(machinegun, sustained_damage));
if(!autocvar_g_norecoil)
{
if(WEP_CVAR(machinegun, reload_ammo) && self.clip_load < min(max(WEP_CVAR(machinegun, sustained_ammo), WEP_CVAR(machinegun, first_ammo)), WEP_CVAR(machinegun, burst_ammo))) // forced reload
_WEP_ACTION(self.weapon, WR_RELOAD);
- else if(WEP_CVAR(machinegun, mode) == 1)
+ else
+ if(WEP_CVAR(machinegun, mode) == 1)
{
if(fire1)
if(weapon_prepareattack(0, 0))
{
self.misc_bulletcounter = 0;
- W_MachineGun_Attack_Auto();
+ W_MachineGun_Attack_Auto(thiswep, fire1, fire2);
}
if(fire2)
if(!(self.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(self, w_getbestweapon(self));
- w_ready();
+ w_ready(thiswep, fire1, fire2);
return false;
}
- W_DecreaseAmmo(WEP_CVAR(machinegun, burst_ammo));
+ W_DecreaseAmmo(thiswep, WEP_CVAR(machinegun, burst_ammo));
self.misc_bulletcounter = WEP_CVAR(machinegun, burst) * -1;
- W_MachineGun_Attack_Burst();
+ W_MachineGun_Attack_Burst(thiswep, fire1, fire2);
}
}
else
if(weapon_prepareattack(0, 0))
{
self.misc_bulletcounter = 1;
- W_MachineGun_Attack(WEP_MACHINEGUN.m_id); // sets attack_finished
+ W_MachineGun_Attack(WEP_MACHINEGUN, WEP_MACHINEGUN.m_id); // sets attack_finished
weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(machinegun, sustained_refire), W_MachineGun_Attack_Frame);
}
if(weapon_prepareattack(1, 0))
{
self.misc_bulletcounter = 1;
- W_MachineGun_Attack(WEP_MACHINEGUN.m_id | HITTYPE_SECONDARY); // sets attack_finished
+ W_MachineGun_Attack(WEP_MACHINEGUN, WEP_MACHINEGUN.m_id | HITTYPE_SECONDARY); // sets attack_finished
weapon_thinkf(WFRAME_FIRE2, WEP_CVAR(machinegun, first_refire), w_ready);
}
}