#ifdef REGISTER_WEAPON REGISTER_WEAPON(GRABBER, w_grabber, IT_FUEL, 0, WEP_FLAG_CANCLIMB | WEP_TYPE_HITSCAN | WEP_FLAG_RELOADABLE, 0, "grabber", "grabber", "Grabber"); #else .float dmg; .float dmg_edge; .float dmg_radius; .float dmg_force; .float grabber_refire; .float grabber_time_grabbered; .float grabber_time_fueldecrease; void W_Grabber_UpdateStats(entity e, float shot, float hit) { // this may not be entierly right, but for the time being we're handling grabber accuracy here // this is likely needed for detecting if the hook has hit (linked to) another player, which is counted as a hit if(shot) { e.stats_fired[e.weapon - 1] += 1; e.stat_fired = e.weapon + 64 * floor(e.stats_fired[e.weapon - 1]); } if(hit) { e.stats_hit[e.weapon - 1] += 1; e.stat_hit = e.weapon + 64 * floor(e.stats_hit[e.weapon - 1]); } } void W_Grabber_Touch2 (void) { PROJECTILE_TOUCH; self.use(); } void W_Grabber_Attack2() { if(time < self.weapon_delay) return; W_SetupShot (self, TRUE, 0, "weapons/grabber_altfire.wav", cvar("g_balance_grabber_secondary_damage")); W_Grabber_UpdateStats(self, TRUE, FALSE); // the hit is recorded below WarpZone_traceline_antilag(self, w_shotorg, w_shotorg + w_shotdir * cvar("g_balance_grabber_secondary_radius"), FALSE, self, ANTILAG_LATENCY(self)); pointparticles(particleeffectnum("grabber_melee"), w_shotorg + w_shotdir * cvar("g_balance_grabber_secondary_radius"), '0 0 0', 1); if (trace_fraction < 1) { 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); pointparticles(particleeffectnum("grabber_impact2"), trace_endpos, '0 0 0', 1); if(trace_ent.classname == "player") sound (self, CHAN_PROJECTILE, "weapons/grabber_impact2_player.wav", VOL_BASE, ATTN_NORM); else sound (self, CHAN_PROJECTILE, "weapons/grabber_impact2_world.wav", VOL_BASE, ATTN_NORM); W_Grabber_UpdateStats(self, FALSE, TRUE); // the shot is recorded above } if (!g_norecoil) self.punchangle_x -= cvar("g_balance_grabber_secondary_recoil"); W_DecreaseAmmo(ammo_fuel, cvar("g_balance_grabber_secondary_ammo"), cvar("g_balance_grabber_reload_ammo")); } void spawnfunc_weapon_grabber (void) { weapon_defaultspawnfunc(WEP_GRABBER); } float w_grabber(float req) { if(self.stat_eaten) // we can't use weapons while in the stomach { self.grabber_state |= GRABBER_REMOVING; return FALSE; } float ammo_amount; float grabbered_time_max, grabbered_fuel; if (req == WR_AIM) { // ... sorry ... } else if (req == WR_THINK) { grabbered_fuel = cvar("g_balance_grabber_primary_grabbered_fuel"); // forced reload if(cvar("g_balance_grabber_reload_ammo") && self.clip_load < min(cvar("g_balance_grabber_primary_ammo"), cvar("g_balance_grabber_secondary_ammo")) && !(self.clip_load >= (time - self.grabber_time_fueldecrease) * grabbered_fuel && self.BUTTON_ATCK)) // not while hooked and still have ammo to stay hooked { if(self.ammo_fuel >= 1) // we only have one weapon in VT, so nothing else to switch to if we're out of ammo weapon_action(self.weapon, WR_RELOAD); } else if not(self.clip_load < 0) // we're not currently reloading { if (self.BUTTON_ATCK && weapon_action(self.weapon, WR_CHECKAMMO1)) { if(time < self.weapon_delay) return FALSE; if(!self.grabber) if not(self.grabber_state & GRABBER_WAITING_FOR_RELEASE) if not(self.grabber_state & GRABBER_FIRING) if (time > self.grabber_refire) if (weapon_prepareattack(0, -1)) { if (!g_norecoil) self.punchangle_x -= cvar("g_balance_grabber_primary_recoil"); W_DecreaseAmmo(ammo_fuel, cvar("g_balance_grabber_primary_ammo"), cvar("g_balance_grabber_reload_ammo")); self.grabber_state |= GRABBER_FIRING; weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_grabber_primary_animtime"), w_ready); } } if (self.BUTTON_ATCK2 && weapon_action(self.weapon, WR_CHECKAMMO2)) { if (weapon_prepareattack(1, cvar("g_balance_grabber_secondary_refire"))) { W_Grabber_Attack2(); weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_grabber_secondary_animtime"), w_ready); sound (self, CHAN_WEAPON2, "weapons/grabber_swing.wav", VOL_BASE, ATTN_NORM); } } } if(self.grabber) { // if grabbered, no melee attacks, and increase the timer self.grabber_refire = max(self.grabber_refire, time + cvar("g_balance_grabber_primary_refire")); // grabber also inhibits health regeneration, but only for 1 second if not(self.items & IT_UNLIMITED_WEAPON_AMMO) self.pauseregenhealth_finished = max(self.pauseregenhealth_finished, time + cvar("g_balance_pause_fuel_regen")); } if(self.grabber && self.grabber.state == 1) { grabbered_time_max = cvar("g_balance_grabber_primary_grabbered_time_max"); if (grabbered_time_max > 0) { if ( time > self.grabber_time_grabbered + grabbered_time_max ) self.grabber_state |= GRABBER_REMOVING; } if (grabbered_fuel > 0) { if ( time > self.grabber_time_fueldecrease ) { if not(self.items & IT_UNLIMITED_WEAPON_AMMO) { float active_ammo; if(cvar("g_balance_grabber_reload_ammo")) active_ammo = self.clip_load; else active_ammo = self.ammo_fuel; if (active_ammo >= (time - self.grabber_time_fueldecrease) * grabbered_fuel ) { W_DecreaseAmmo(ammo_fuel, (time - self.grabber_time_fueldecrease) * grabbered_fuel, cvar("g_balance_grabber_reload_ammo")); self.grabber_time_fueldecrease = time; // decrease next frame again } else { self.grabber_state |= GRABBER_REMOVING; W_SwitchWeapon_Force(self, w_getbestweapon(self)); } } } } } else { self.grabber_time_grabbered = time; self.grabber_time_fueldecrease = time + cvar("g_balance_grabber_primary_grabbered_time_free"); } self.grabber_state |= GRABBER_PULLING; self.grabber_state &~= GRABBER_RELEASING; if (self.BUTTON_ATCK) { // already fired if(self.grabber) self.grabber_state |= GRABBER_WAITING_FOR_RELEASE; } else { self.grabber_state |= GRABBER_REMOVING; self.grabber_state &~= GRABBER_WAITING_FOR_RELEASE; } } else if (req == WR_PRECACHE) { precache_model ("models/weapons/g_grabber.md3"); precache_model ("models/weapons/v_grabber.md3"); precache_model ("models/weapons/h_grabber.iqm"); precache_sound ("weapons/grabber_impact_player.wav"); precache_sound ("weapons/grabber_impact_world.wav"); precache_sound ("weapons/grabber_impact2_player.wav"); precache_sound ("weapons/grabber_impact2_world.wav"); precache_sound ("weapons/grabber_fire.wav"); precache_sound ("weapons/grabber_altfire.wav"); precache_sound ("weapons/grabber_swing.wav"); precache_sound ("weapons/reload.wav"); } else if (req == WR_SETUP) { weapon_setup(WEP_GRABBER); self.grabber_state &~= GRABBER_WAITING_FOR_RELEASE; self.current_ammo = ammo_fuel; } else if (req == WR_CHECKAMMO1) { if(self.grabber) { ammo_amount = self.ammo_fuel > 0; ammo_amount += self.weapon_load[WEP_GRABBER] > 0; } else { ammo_amount = self.ammo_fuel >= cvar("g_balance_grabber_primary_ammo"); ammo_amount += self.weapon_load[WEP_GRABBER] >= cvar("g_balance_grabber_primary_ammo"); } return ammo_amount; } else if (req == WR_CHECKAMMO2) { ammo_amount = self.ammo_fuel >= cvar("g_balance_grabber_secondary_ammo"); ammo_amount += self.weapon_load[WEP_GRABBER] >= cvar("g_balance_grabber_secondary_ammo"); return ammo_amount; } else if (req == WR_RELOAD) { self.grabber_state |= GRABBER_REMOVING; 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"); } else if (req == WR_SUICIDEMESSAGE) w_deathtypestring = "did the impossible"; else if (req == WR_KILLMESSAGE) w_deathtypestring = "has run into #'s paws"; else if (req == WR_RESETPLAYER) { self.grabber_refire = time; } return TRUE; }; #endif