Many fixes and adaptations to the Accuracy Stats window, and get the Grabber to prope...
[voretournament/voretournament.git] / data / qcsrc / server / w_grabber.qc
index 2df141a..0f5a818 100644 (file)
@@ -1,5 +1,5 @@
 #ifdef REGISTER_WEAPON\r
-REGISTER_WEAPON(GRABBER, w_grabber, IT_FUEL, 0, WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH, 0, "grabber", "grabber", "Grabber");\r
+REGISTER_WEAPON(GRABBER, w_grabber, IT_FUEL, 0, WEP_FLAG_CANCLIMB | WEP_TYPE_HITSCAN, 0, "grabber", "grabber", "Grabber");\r
 #else\r
 .float dmg;\r
 .float dmg_edge;\r
@@ -9,6 +9,22 @@ REGISTER_WEAPON(GRABBER, w_grabber, IT_FUEL, 0, WEP_FLAG_CANCLIMB | WEP_TYPE_SPL
 .float grabber_time_grabbered;\r
 .float grabber_time_fueldecrease;\r
 \r
+void W_Grabber_UpdateStats(entity e, float shot, float hit)\r
+{\r
+       // this may not be entierly right, but for the time being we're recording the hook accuracy here\r
+       // this is likely needed for detecting if the hook has hit (linked to) another person though\r
+       if(shot)\r
+       {\r
+               e.stats_fired[e.weapon - 1] += 1;\r
+               e.stat_fired = e.weapon + 64 * floor(e.stats_fired[e.weapon - 1]);\r
+       }\r
+       if(hit)\r
+       {\r
+               e.stats_hit[e.weapon - 1] += 1;\r
+               e.stat_hit = e.weapon + 64 * floor(e.stats_hit[e.weapon - 1]);\r
+       }\r
+}\r
+\r
 void W_Grabber_Touch2 (void)\r
 {\r
        PROJECTILE_TOUCH;\r
@@ -17,14 +33,21 @@ void W_Grabber_Touch2 (void)
 \r
 void W_Grabber_Attack2()\r
 {\r
+       if(time < self.weapon_delay)\r
+               return;\r
+\r
        W_SetupShot (self, TRUE, 0, "weapons/grabber_altfire.wav", cvar("g_balance_grabber_secondary_damage"));\r
+       W_Grabber_UpdateStats(self, TRUE, FALSE); // the hit is recorded below\r
 \r
        WarpZone_traceline_antilag(self, w_shotorg, w_shotorg + w_shotdir * cvar("g_balance_grabber_secondary_radius"), FALSE, self, ANTILAG_LATENCY(self));\r
 \r
        pointparticles(particleeffectnum("grabber_melee"), w_shotorg + w_shotdir * cvar("g_balance_grabber_secondary_radius"), '0 0 0', 1);\r
 \r
        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
+               W_Grabber_UpdateStats(self, FALSE, TRUE); // the shot is recorded above\r
+       }\r
 \r
        if not(self.items & IT_UNLIMITED_WEAPON_AMMO)\r
                self.ammo_fuel = self.ammo_fuel - cvar("g_balance_grabber_secondary_ammo");\r
@@ -37,7 +60,7 @@ void spawnfunc_weapon_grabber (void)
 \r
 float w_grabber(float req)\r
 {\r
-       if(self.eater.classname == "player") // we can't use weapons while in the stomach\r
+       if(self.predator.classname == "player") // we can't use weapons while in the stomach\r
        {\r
                self.grabber_state |= GRABBER_REMOVING;\r
                return FALSE;\r
@@ -51,7 +74,7 @@ float w_grabber(float req)
        }\r
        else if (req == WR_THINK)\r
        {\r
-               if (self.BUTTON_ATCK || (!(self.items & IT_JETPACK) && self.BUTTON_GRABBER))\r
+               if (self.BUTTON_ATCK || (!(self.items & IT_JETPACK) && self.BUTTON_JETPACK))\r
                {\r
                        if(time < self.weapon_delay)\r
                                return FALSE;\r
@@ -129,7 +152,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_GRABBER))\r
+                       if (self.BUTTON_ATCK || (!(self.items & IT_JETPACK) && self.BUTTON_JETPACK))\r
                                self.grabber_state &~= GRABBER_RELEASING;\r
                        else\r
                                self.grabber_state |= GRABBER_RELEASING;\r
@@ -139,7 +162,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_GRABBER))\r
+                       if (self.BUTTON_ATCK || (!(self.items & IT_JETPACK) && self.BUTTON_JETPACK))\r
                        {\r
                                // already fired\r
                                if(self.grabber)\r
@@ -159,6 +182,7 @@ float w_grabber(float req)
                precache_model ("models/weapons/h_grabber.dpm");\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
        }\r
        else if (req == WR_SETUP)\r
        {\r