]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Offhand: fix machinegun (still needs .clip_load > 0)
authorTimePath <andrew.hardaker1995@gmail.com>
Tue, 29 Sep 2015 08:20:40 +0000 (18:20 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Tue, 29 Sep 2015 08:20:40 +0000 (18:20 +1000)
13 files changed:
qcsrc/common/weapons/weapon/arc.qc
qcsrc/common/weapons/weapon/electro.qc
qcsrc/common/weapons/weapon/fireball.qc
qcsrc/common/weapons/weapon/hlac.qc
qcsrc/common/weapons/weapon/hmg.qc
qcsrc/common/weapons/weapon/machinegun.qc
qcsrc/common/weapons/weapon/rifle.qc
qcsrc/common/weapons/weapon/shockwave.qc
qcsrc/common/weapons/weapon/shotgun.qc
qcsrc/server/defs.qh
qcsrc/server/mutators/mutator_overkill.qc
qcsrc/server/weapons/weaponsystem.qc
qcsrc/server/weapons/weaponsystem.qh

index 2853d857d5af51524d047f91a71409cf7eaf5459..df5e88f69dd0084317cddee729863a9b45eb52b7 100644 (file)
@@ -84,7 +84,7 @@ const int ARC_SF_LOCALMASK =   14;
 #ifdef SVQC
 ARC_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
 .entity arc_beam;
-.float arc_BUTTON_ATCK_prev; // for better animation control
+.bool arc_BUTTON_ATCK_prev; // for better animation control
 .float beam_prev;
 .float beam_initialized;
 .float beam_bursting;
@@ -662,8 +662,8 @@ void Arc_Smoke()
                        Arc_Player_SetHeat(self);
                        Arc_Smoke();
 
-                       if ( self.arc_overheat <= time )
-                       if(fire1 || fire2 || self.arc_beam.beam_bursting )
+                       if (time >= self.arc_overheat)
+                       if (fire1 || fire2 || self.arc_beam.beam_bursting)
                        {
 
                                if(self.arc_BUTTON_ATCK_prev)
@@ -685,7 +685,7 @@ void Arc_Smoke()
                                                if(!self.arc_BUTTON_ATCK_prev)
                                                {
                                                        weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(arc, beam_animtime), w_ready);
-                                                       self.arc_BUTTON_ATCK_prev = 1;
+                                                       self.arc_BUTTON_ATCK_prev = true;
                                                }
                                        }
                                }
@@ -693,13 +693,13 @@ void Arc_Smoke()
                                return true;
                        }
 
-                       if(self.arc_BUTTON_ATCK_prev != 0)
+                       if(self.arc_BUTTON_ATCK_prev)
                        {
                                sound(self, CH_WEAPON_A, SND_ARC_STOP, VOL_BASE, ATTN_NORM);
                                weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(arc, beam_animtime), w_ready);
                                ATTACK_FINISHED(self) = time + WEP_CVAR(arc, beam_refire) * W_WeaponRateFactor();
                        }
-                       self.arc_BUTTON_ATCK_prev = 0;
+                       self.arc_BUTTON_ATCK_prev = false;
 
                        #if 0
                        if(fire2)
index dbcbb76b9d3c497cc12f3d07b9d36c4f378e016a..420305d051cd882576474196162aa46263e01d85 100644 (file)
@@ -406,7 +406,7 @@ void W_Electro_Attack_Orb(Weapon thiswep)
        MUTATOR_CALLHOOK(EditProjectile, self, proj);
 }
 
-void W_Electro_CheckAttack(void)
+void W_Electro_CheckAttack(Weapon thiswep, bool fire1, bool fire2)
 {SELFPARAM();
        if(self.electro_count > 1)
        if(self.BUTTON_ATCK2)
@@ -418,7 +418,7 @@ void W_Electro_CheckAttack(void)
                return;
        }
        // WEAPONTODO: when the player releases the button, cut down the length of refire2?
-       w_ready();
+       w_ready(thiswep, fire1, fire2);
 }
 
 .float bot_secondary_electromooth;
index 13d5ed3e40a7c521819d06374ba4975741780b4a..df1c3c669d1b6f296e8ef49e96ff309c74b374e7 100644 (file)
@@ -226,31 +226,31 @@ void W_Fireball_AttackEffect(float i, vector f_diff)
        Send_Effect(EFFECT_FIREBALL_PRE_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
 }
 
-void W_Fireball_Attack1_Frame4(void)
+void W_Fireball_Attack1_Frame4(Weapon thiswep, bool fire1, bool fire2)
 {
        W_Fireball_Attack1();
        weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), w_ready);
 }
 
-void W_Fireball_Attack1_Frame3(void)
+void W_Fireball_Attack1_Frame3(Weapon thiswep, bool fire1, bool fire2)
 {
        W_Fireball_AttackEffect(0, '+1.25 +3.75 0');
        weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame4);
 }
 
-void W_Fireball_Attack1_Frame2(void)
+void W_Fireball_Attack1_Frame2(Weapon thiswep, bool fire1, bool fire2)
 {
        W_Fireball_AttackEffect(0, '-1.25 +3.75 0');
        weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame3);
 }
 
-void W_Fireball_Attack1_Frame1(void)
+void W_Fireball_Attack1_Frame1(Weapon thiswep, bool fire1, bool fire2)
 {
        W_Fireball_AttackEffect(1, '+1.25 -3.75 0');
        weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(fireball, animtime), W_Fireball_Attack1_Frame2);
 }
 
-void W_Fireball_Attack1_Frame0(void)
+void W_Fireball_Attack1_Frame0(Weapon thiswep, bool fire1, bool fire2)
 {SELFPARAM();
        W_Fireball_AttackEffect(0, '-1.25 -3.75 0');
        sound(self, CH_WEAPON_SINGLE, SND_FIREBALL_PREFIRE2, VOL_BASE, ATTEN_NORM);
@@ -380,7 +380,7 @@ void W_Fireball_Attack2(void)
                                if(time >= self.fireball_primarytime)
                                if(weapon_prepareattack(0, WEP_CVAR_PRI(fireball, refire)))
                                {
-                                       W_Fireball_Attack1_Frame0();
+                                       W_Fireball_Attack1_Frame0(thiswep, fire1, fire2);
                                        self.fireball_primarytime = time + WEP_CVAR_PRI(fireball, refire2) * W_WeaponRateFactor();
                                }
                        }
index ad21fd9ca8b775cec7053f195491c362de36debb..b8cf3485e30418165cfc027cbfae13cffe9fef95 100644 (file)
@@ -161,11 +161,11 @@ void W_HLAC_Attack2(void)
 }
 
 // weapon frames
-void W_HLAC_Attack_Frame(void)
+void W_HLAC_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;
        }
 
@@ -175,7 +175,7 @@ void W_HLAC_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;
                }
 
index bb35d6783f3991503a33dfd8a4ee80d35bf07584..5e48c2840999f6f814349ab64d7678bd523bc584 100644 (file)
@@ -45,11 +45,11 @@ HMG_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
 
 void spawnfunc_weapon_hmg() { weapon_defaultspawnfunc(WEP_HMG.m_id); }
 
-void W_HeavyMachineGun_Attack_Auto()
+void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, bool fire1, bool fire2)
 {SELFPARAM();
        if (!self.BUTTON_ATCK)
        {
-               w_ready();
+               w_ready(thiswep, fire1, fire2);
                return;
        }
 
@@ -57,7 +57,7 @@ void W_HeavyMachineGun_Attack_Auto()
        if(!(self.items & IT_UNLIMITED_WEAPON_AMMO))
        {
                W_SwitchWeapon_Force(self, w_getbestweapon(self));
-               w_ready();
+               w_ready(thiswep, fire1, fire2);
                return;
        }
 
@@ -107,7 +107,7 @@ void W_HeavyMachineGun_Attack_Auto()
                                if (weapon_prepareattack(0, 0))
                                {
                                        self.misc_bulletcounter = 0;
-                                       W_HeavyMachineGun_Attack_Auto();
+                                       W_HeavyMachineGun_Attack_Auto(thiswep, fire1, fire2);
                                }
                        }
 
index a8437586f21ae84bd9c136089910d9c46a64c677..7eb09b22bab792a1a3abf41ed93354e643fdca4e 100644 (file)
@@ -137,11 +137,11 @@ void W_MachineGun_Attack(Weapon thiswep, int deathtype)
 }
 
 // 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,7 +150,7 @@ 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;
@@ -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,7 +176,7 @@ 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;
        }
 
@@ -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(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
index 8aad95ef6240dc40f66d077b16e38c0acfc88090..dc11b0158acc7c07df1b4e56bf37800d98e473e2 100644 (file)
@@ -90,7 +90,7 @@ void W_Rifle_Attack2(void)
 .float rifle_bullethail_frame;
 .float rifle_bullethail_animtime;
 .float rifle_bullethail_refire;
-void W_Rifle_BulletHail_Continue(void)
+void W_Rifle_BulletHail_Continue(Weapon thiswep, bool fire1, bool fire2)
 {SELFPARAM();
        float r, sw, af;
 
index 713ac59c75ed8aa122de7d00e65a3e0eecb1806a..79262411e5918d946c1c961601097c9370f02d88 100644 (file)
@@ -229,7 +229,7 @@ void W_Shockwave_Melee_Think(void)
        }
 }
 
-void W_Shockwave_Melee(void)
+void W_Shockwave_Melee(Weapon thiswep, bool fire1, bool fire2)
 {SELFPARAM();
        sound(self, CH_WEAPON_A, SND_SHOTGUN_MELEE, VOL_BASE, ATTN_NORM);
        weapon_thinkf(WFRAME_FIRE2, WEP_CVAR(shockwave, melee_animtime), w_ready);
index 809542a483dadab6733a95791380e32af09f5cfe..42c12fd7e3f2bcd5cc3b3562df170fa005cd7b44 100644 (file)
@@ -181,7 +181,7 @@ void W_Shotgun_Melee_Think(void)
        }
 }
 
-void W_Shotgun_Attack2(void)
+void W_Shotgun_Attack2(Weapon thiswep, bool fire1, bool fire2)
 {SELFPARAM();
        sound(self, CH_WEAPON_A, SND_SHOTGUN_MELEE, VOL_BASE, ATTEN_NORM);
        weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(shotgun, animtime), w_ready);
@@ -195,13 +195,13 @@ void W_Shotgun_Attack2(void)
 }
 
 // alternate secondary weapon frames
-void W_Shotgun_Attack3_Frame2()
+void W_Shotgun_Attack3_Frame2(Weapon thiswep, bool fire1, bool fire2)
 {SELFPARAM();
        if (!_WEP_ACTION(self.weapon, WR_CHECKAMMO2))
        if (!(self.items & IT_UNLIMITED_WEAPON_AMMO))
        {
                W_SwitchWeapon_Force(self, w_getbestweapon(self));
-               w_ready();
+               w_ready(thiswep, fire1, fire2);
                return;
        }
 
@@ -209,13 +209,13 @@ void W_Shotgun_Attack3_Frame2()
        W_Shotgun_Attack(WEP_SHOTGUN, true); // actually is secondary, but we trick the last shot into playing full reload sound
        weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_SEC(shotgun, alt_animtime), w_ready);
 }
-void W_Shotgun_Attack3_Frame1()
+void W_Shotgun_Attack3_Frame1(Weapon thiswep, bool fire1, bool fire2)
 {SELFPARAM();
        if (!_WEP_ACTION(self.weapon, WR_CHECKAMMO2))
        if (!(self.items & IT_UNLIMITED_WEAPON_AMMO))
        {
                W_SwitchWeapon_Force(self, w_getbestweapon(self));
-               w_ready();
+               w_ready(thiswep, fire1, fire2);
                return;
        }
 
index a165f9d440042c6aca7aee62cb388e3e2433a8a4..f6f3d1b7a0cab833b6b5322ee8c85a8b24da7387 100644 (file)
@@ -166,11 +166,11 @@ const float MAX_DAMAGEEXTRARADIUS = 16;
 .float autoswitch;
 //float _WEP_ACTION(float wpn, float wrequest);
 float client_hasweapon(entity cl, float wpn, float andammo, float complain);
-void w_clear();
-void w_ready();
+void w_clear(Weapon thiswep, bool fire1, bool fire2);
+void w_ready(Weapon thiswep, bool fire1, bool fire2);
 // VorteX: standalone think for weapons, so normal think on weaponentity can be reserved by weaponflashes (which needs update even player dies)
 .float weapon_nextthink;
-.void() weapon_think;
+.void(Weapon thiswep, bool fire1, bool fire2) weapon_think;
 
 
 // weapon states (self.weaponentity.state)
index 3bc1e79589355e376e712199ee3925e1105cff8d..69c9fffd793116502e0127cf7be6679ad5c62172 100644 (file)
@@ -176,8 +176,9 @@ MUTATOR_HOOKFUNCTION(ok_PlayerPreThink)
                        self.ok_notice_time = time + 2;
                        play2(self, SND(DRYFIRE));
                }
+               Weapon wpn = get_weaponinfo(self.weapon);
                if(self.weaponentity.state != WS_CLEAR)
-                       w_ready();
+                       w_ready(wpn, self.BUTTON_ATCK, self.BUTTON_ATCK2);
 
                self.weapon_blocked = true;
        }
index b682ab8fe1b6e568338ef76efe0c53fd51bb3d4e..a6961aec87196383bb63f383e850fc873c7f92fb 100644 (file)
@@ -47,7 +47,7 @@ float W_WeaponSpeedFactor()
 }
 
 
-void(float fr, float t, void() func) weapon_thinkf;
+void weapon_thinkf(float fr, float t, void(Weapon thiswep, bool fire1, bool fire2) func);
 
 float CL_Weaponentity_CustomizeEntityForClient()
 {SELFPARAM();
@@ -434,7 +434,7 @@ void CL_SpawnWeaponentity(entity e)
 }
 
 // Weapon subs
-void w_clear()
+void w_clear(Weapon thiswep, bool fire1, bool fire2)
 {SELFPARAM();
        if (self.weapon != -1)
        {
@@ -448,7 +448,7 @@ void w_clear()
        }
 }
 
-void w_ready()
+void w_ready(Weapon thiswep, bool fire1, bool fire2)
 {SELFPARAM();
        if (self.weaponentity)
                self.weaponentity.state = WS_READY;
@@ -565,7 +565,7 @@ float weapon_prepareattack(float secondary, float attacktime)
                return false;
 }
 
-void weapon_thinkf(float fr, float t, void() func)
+void weapon_thinkf(float fr, float t, void(Weapon thiswep, bool fire1, bool fire2) func)
 {SELFPARAM();
        vector a;
        vector of, or, ou;
@@ -669,7 +669,8 @@ void W_WeaponFrame()
        if(forbidWeaponUse(self))
        if(self.weaponentity.state != WS_CLEAR)
        {
-               w_ready();
+               Weapon wpn = get_weaponinfo(self.weapon);
+               w_ready(wpn, self.BUTTON_ATCK, self.BUTTON_ATCK2);
                return;
        }
 
@@ -769,8 +770,8 @@ void W_WeaponFrame()
 
                {
                        bool key_pressed = self.BUTTON_HOOK;
-               entity e = self.offhand;
-               if (e.offhand_think) e.offhand_think(e, self, key_pressed);
+               Weapon wpn = self.offhand;
+               if (wpn.offhand_think) wpn.offhand_think(wpn, self, key_pressed);
         }
 
                if (w) {
@@ -787,7 +788,8 @@ void W_WeaponFrame()
                                v_forward = fo;
                                v_right = ri;
                                v_up = up;
-                               self.weapon_think();
+                               Weapon wpn = get_weaponinfo(self.weapon);
+                               self.weapon_think(wpn, self.BUTTON_ATCK, self.BUTTON_ATCK2);
                        }
                        else
                                bprint("\{1}^1ERROR: undefined weapon think function for ", self.netname, "\n");
@@ -870,7 +872,7 @@ void W_DecreaseAmmo(Weapon wep, float ammo_use)
 .float reload_complain;
 .string reload_sound;
 
-void W_ReloadedAndReady()
+void W_ReloadedAndReady(Weapon thiswep, bool fire1, bool fire2)
 {SELFPARAM();
        // finish the reloading process, and do the ammo transfer
 
@@ -894,7 +896,8 @@ void W_ReloadedAndReady()
 
        //ATTACK_FINISHED(self) -= self.reload_time - 1;
 
-       w_ready();
+       Weapon wpn = get_weaponinfo(self.weapon);
+       w_ready(wpn, self.BUTTON_ATCK, self.BUTTON_ATCK2);
 }
 
 void W_Reload(float sent_ammo_min, string sent_sound)
index 8ee65bb2693cfed784c9c774327028f923265900..6bb2d656e3f4aa54d854b692c875b669a9d92ec7 100644 (file)
@@ -40,6 +40,6 @@ float weapon_prepareattack_check(float secondary, float attacktime);
 
 float weapon_prepareattack_do(float secondary, float attacktime);
 
-void weapon_thinkf(float fr, float t, void() func);
+void weapon_thinkf(float fr, float t, void(Weapon thiswep, bool fire1, bool fire2) func);
 
 #endif