Better Grabber impact effects
[voretournament/voretournament.git] / data / qcsrc / server / w_grabber.qc
index 126f424..dbf470f 100644 (file)
@@ -46,9 +46,13 @@ void W_Grabber_Attack2()
        if (trace_fraction < 1)\r
        {\r
                Damage(trace_ent, self, self, cvar("g_balance_grabber_secondary_damage"), WEP_GRABBER | HITTYPE_SECONDARY, trace_endpos, cvar("g_balance_grabber_secondary_force") * w_shotdir);\r
+               pointparticles(particleeffectnum("grabber_impact2"), trace_endpos, '0 0 0', 1);\r
                W_Grabber_UpdateStats(self, FALSE, TRUE); // the shot is recorded above\r
        }\r
 \r
+       if (!g_norecoil)\r
+               self.punchangle_x -= cvar("g_balance_grabber_secondary_recoil");\r
+\r
        W_DecreaseAmmo(ammo_fuel, cvar("g_balance_grabber_secondary_ammo"), cvar("g_balance_grabber_reload_ammo"));\r
 }\r
 \r
@@ -59,7 +63,7 @@ void spawnfunc_weapon_grabber (void)
 \r
 float w_grabber(float req)\r
 {\r
-       if(self.predator.classname == "player") // we can't use weapons while in the stomach\r
+       if(self.stat_eaten) // we can't use weapons while in the stomach\r
        {\r
                self.grabber_state |= GRABBER_REMOVING;\r
                return FALSE;\r
@@ -74,30 +78,42 @@ float w_grabber(float req)
        }\r
        else if (req == WR_THINK)\r
        {\r
-               if(cvar("g_balance_grabber_reload_ammo") && self.clip_load < min(cvar("g_balance_grabber_primary_ammo"), cvar("g_balance_grabber_secondary_ammo"))) // forced reload\r
-                       weapon_action(self.weapon, WR_RELOAD);\r
-               else if (self.BUTTON_ATCK || (!(self.items & IT_JETPACK) && self.BUTTON_JETPACK))\r
+               grabbered_fuel = cvar("g_balance_grabber_primary_grabbered_fuel");\r
+               // forced reload\r
+               if(cvar("g_balance_grabber_reload_ammo") && self.clip_load < min(cvar("g_balance_grabber_primary_ammo"), cvar("g_balance_grabber_secondary_ammo"))\r
+               && !(self.clip_load >= (time - self.grabber_time_fueldecrease) * grabbered_fuel && self.BUTTON_ATCK)) // not while hooked and still have ammo to stay hooked\r
                {\r
-                       if(time < self.weapon_delay)\r
-                               return FALSE;\r
-\r
-                       if(!self.grabber)\r
-                       if not(self.grabber_state & GRABBER_WAITING_FOR_RELEASE)\r
-                       if not(self.grabber_state & GRABBER_FIRING)\r
-                       if (time > self.grabber_refire)\r
-                       if (weapon_prepareattack(0, -1))\r
-                       {\r
-                               W_DecreaseAmmo(ammo_fuel, cvar("g_balance_grabber_primary_ammo"), cvar("g_balance_grabber_reload_ammo"));\r
-                               self.grabber_state |= GRABBER_FIRING;\r
-                               weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_grabber_primary_animtime"), w_ready);                               \r
-                       }\r
+                       if(self.ammo_fuel >= 1) // we only have one weapon in VT, so nothing else to switch to if we're out of ammo\r
+                               weapon_action(self.weapon, WR_RELOAD);\r
                }\r
-               else if (self.BUTTON_ATCK2)\r
+               else if not(self.clip_load < 0) // we're not currently reloading\r
                {\r
-                       if (weapon_prepareattack(1, cvar("g_balance_grabber_secondary_refire")))\r
+                       if (self.BUTTON_ATCK && weapon_action(self.weapon, WR_CHECKAMMO1))\r
                        {\r
-                               W_Grabber_Attack2();\r
-                               weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_grabber_secondary_animtime"), w_ready);\r
+                               if(time < self.weapon_delay)\r
+                                       return FALSE;\r
+\r
+                               if(!self.grabber)\r
+                               if not(self.grabber_state & GRABBER_WAITING_FOR_RELEASE)\r
+                               if not(self.grabber_state & GRABBER_FIRING)\r
+                               if (time > self.grabber_refire)\r
+                               if (weapon_prepareattack(0, -1))\r
+                               {\r
+                                       if (!g_norecoil)\r
+                                               self.punchangle_x -= cvar("g_balance_grabber_primary_recoil");\r
+                                       W_DecreaseAmmo(ammo_fuel, cvar("g_balance_grabber_primary_ammo"), cvar("g_balance_grabber_reload_ammo"));\r
+                                       self.grabber_state |= GRABBER_FIRING;\r
+                                       weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_grabber_primary_animtime"), w_ready);                               \r
+                               }\r
+                       }\r
+                       if (self.BUTTON_ATCK2 && weapon_action(self.weapon, WR_CHECKAMMO2))\r
+                       {\r
+                               if (weapon_prepareattack(1, cvar("g_balance_grabber_secondary_refire")))\r
+                               {\r
+                                       W_Grabber_Attack2();\r
+                                       weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_grabber_secondary_animtime"), w_ready);\r
+                                       sound (self, CHAN_WEAPON2, "weapons/grabber_swing.wav", VOL_BASE, ATTN_NORM);\r
+                               }\r
                        }\r
                }\r
 \r
@@ -119,15 +135,20 @@ float w_grabber(float req)
                                if ( time > self.grabber_time_grabbered + grabbered_time_max )\r
                                        self.grabber_state |= GRABBER_REMOVING;\r
                        }\r
-                       \r
-                       grabbered_fuel = cvar("g_balance_grabber_primary_grabbered_fuel");\r
+\r
                        if (grabbered_fuel > 0)\r
                        {\r
                                if ( time > self.grabber_time_fueldecrease )\r
                                {\r
                                        if not(self.items & IT_UNLIMITED_WEAPON_AMMO)\r
                                        {\r
-                                               if ( self.ammo_fuel >= (time - self.grabber_time_fueldecrease) * grabbered_fuel )\r
+                                               float active_ammo;\r
+                                               if(cvar("g_balance_grabber_reload_ammo"))\r
+                                                       active_ammo = self.clip_load;\r
+                                               else\r
+                                                       active_ammo = self.ammo_fuel;\r
+\r
+                                               if (active_ammo >= (time - self.grabber_time_fueldecrease) * grabbered_fuel )\r
                                                {\r
                                                        W_DecreaseAmmo(ammo_fuel, (time - self.grabber_time_fueldecrease) * grabbered_fuel, cvar("g_balance_grabber_reload_ammo"));\r
                                                        self.grabber_time_fueldecrease = time;\r
@@ -135,8 +156,6 @@ float w_grabber(float req)
                                                }\r
                                                else\r
                                                {\r
-                                                       self.ammo_fuel = 0;\r
-                                                       self.weapon_load[WEP_GRABBER] = 0;\r
                                                        self.grabber_state |= GRABBER_REMOVING;\r
                                                        W_SwitchWeapon_Force(self, w_getbestweapon(self));\r
                                                }\r
@@ -153,7 +172,7 @@ float w_grabber(float req)
                if (self.BUTTON_CROUCH)\r
                {\r
                        self.grabber_state &~= GRABBER_PULLING;\r
-                       if (self.BUTTON_ATCK || (!(self.items & IT_JETPACK) && self.BUTTON_JETPACK))\r
+                       if (self.BUTTON_ATCK)\r
                                self.grabber_state &~= GRABBER_RELEASING;\r
                        else\r
                                self.grabber_state |= GRABBER_RELEASING;\r
@@ -163,7 +182,7 @@ float w_grabber(float req)
                        self.grabber_state |= GRABBER_PULLING;\r
                        self.grabber_state &~= GRABBER_RELEASING;\r
 \r
-                       if (self.BUTTON_ATCK || (!(self.items & IT_JETPACK) && self.BUTTON_JETPACK))\r
+                       if (self.BUTTON_ATCK)\r
                        {\r
                                // already fired\r
                                if(self.grabber)\r
@@ -180,10 +199,11 @@ float w_grabber(float req)
        {\r
                precache_model ("models/weapons/g_grabber.md3");\r
                precache_model ("models/weapons/v_grabber.md3");\r
-               precache_model ("models/weapons/h_grabber.dpm");\r
+               precache_model ("models/weapons/h_grabber.iqm");\r
                precache_sound ("weapons/grabber_impact.wav"); // done by g_grabber.qc\r
                precache_sound ("weapons/grabber_fire.wav");\r
                precache_sound ("weapons/grabber_altfire.wav");\r
+               precache_sound ("weapons/grabber_swing.wav");\r
                precache_sound ("weapons/reload.wav");\r
        }\r
        else if (req == WR_SETUP)\r
@@ -214,6 +234,7 @@ float w_grabber(float req)
        }\r
        else if (req == WR_RELOAD)\r
        {\r
+               self.grabber_state |= GRABBER_REMOVING;\r
                W_Reload(min(cvar("g_balance_grabber_primary_ammo"), cvar("g_balance_grabber_secondary_ammo")), cvar("g_balance_grabber_reload_ammo"), cvar("g_balance_grabber_reload_time"), "weapons/reload.wav");\r
        }\r
        else if (req == WR_SUICIDEMESSAGE)\r