Don't allow one grabber firing button to block the other off
[voretournament/voretournament.git] / data / qcsrc / server / w_grabber.qc
index 1d2266b..4e39d09 100644 (file)
@@ -74,30 +74,39 @@ 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\r
                {\r
-                       if (weapon_prepareattack(1, cvar("g_balance_grabber_secondary_refire")))\r
+                       if (self.BUTTON_ATCK || (!(self.items & IT_JETPACK) && self.BUTTON_JETPACK))\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
+                                       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)\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
+                               }\r
                        }\r
                }\r
 \r
@@ -119,8 +128,7 @@ 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
@@ -135,8 +143,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