]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/weapons/weapon/machinegun.qc
Offhand: fix machinegun (still needs .clip_load > 0)
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / weapon / machinegun.qc
index 784b9a43523ea181e3e3dc6aa9becec77a3677eb..7eb09b22bab792a1a3abf41ed93354e643fdca4e 100644 (file)
@@ -104,7 +104,7 @@ void W_MachineGun_MuzzleFlash(void)
        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)
@@ -131,17 +131,17 @@ void W_MachineGun_Attack(int deathtype)
                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)
@@ -150,11 +150,11 @@ void W_MachineGun_Attack_Frame(void)
                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
@@ -162,13 +162,13 @@ void W_MachineGun_Attack_Frame(void)
 }
 
 
-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;
        }
 
@@ -176,11 +176,11 @@ void W_MachineGun_Attack_Auto(void)
        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)
@@ -206,7 +206,7 @@ void W_MachineGun_Attack_Auto(void)
        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)
@@ -251,13 +251,14 @@ void W_MachineGun_Attack_Burst(void)
                {
                        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)
@@ -267,14 +268,14 @@ void W_MachineGun_Attack_Burst(void)
                                        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
@@ -284,7 +285,7 @@ void W_MachineGun_Attack_Burst(void)
                                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);
                                }
 
@@ -292,7 +293,7 @@ void W_MachineGun_Attack_Burst(void)
                                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);
                                }
                        }