2 REGISTER_WEAPON(HOOK, w_hook, IT_CELLS|IT_FUEL, 0, WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH, 0, "hookgun", "hook", _("Grappling Hook"))
13 .float hook_time_hooked;
14 .float hook_time_fueldecrease;
16 void W_Hook_ExplodeThink (void)
18 float dt, dmg_remaining_next, f;
20 dt = time - self.teleport_time;
21 dmg_remaining_next = pow(bound(0, 1 - dt / self.dmg_duration, 1), self.dmg_power);
23 f = self.dmg_last - dmg_remaining_next;
24 self.dmg_last = dmg_remaining_next;
26 RadiusDamage (self, self.realowner, self.dmg * f, self.dmg_edge * f, self.dmg_radius, self.realowner, self.dmg_force * f, self.projectiledeathtype, world);
27 self.projectiledeathtype |= HITTYPE_BOUNCE;
28 //RadiusDamage (self, world, self.dmg * f, self.dmg_edge * f, self.dmg_radius, world, self.dmg_force * f, self.projectiledeathtype, world);
30 if(dt < self.dmg_duration)
31 self.nextthink = time + 0.05; // soon
36 void W_Hook_Explode2 (void)
38 self.event_damage = SUB_Null;
39 self.touch = SUB_Null;
40 self.effects |= EF_NODRAW;
42 self.think = W_Hook_ExplodeThink;
43 self.nextthink = time;
44 self.dmg = autocvar_g_balance_hook_secondary_damage;
45 self.dmg_edge = autocvar_g_balance_hook_secondary_edgedamage;
46 self.dmg_radius = autocvar_g_balance_hook_secondary_radius;
47 self.dmg_force = autocvar_g_balance_hook_secondary_force;
48 self.dmg_power = autocvar_g_balance_hook_secondary_power;
49 self.dmg_duration = autocvar_g_balance_hook_secondary_duration;
50 self.teleport_time = time;
52 self.movetype = MOVETYPE_NONE;
55 void W_Hook_Touch2 (void)
65 W_DecreaseAmmo(ammo_cells, autocvar_g_balance_hook_secondary_ammo, FALSE);
66 W_SetupShot (self, FALSE, 4, "weapons/hookbomb_fire.wav", CH_WEAPON_A, autocvar_g_balance_hook_secondary_damage);
69 gren.owner = gren.realowner = self;
70 gren.classname = "hookbomb";
71 gren.bot_dodge = TRUE;
72 gren.bot_dodgerating = autocvar_g_balance_hook_secondary_damage;
73 gren.movetype = MOVETYPE_TOSS;
74 PROJECTILE_MAKETRIGGER(gren);
75 gren.projectiledeathtype = WEP_HOOK | HITTYPE_SECONDARY;
76 setorigin(gren, w_shotorg);
77 setsize(gren, '0 0 0', '0 0 0');
79 gren.nextthink = time + autocvar_g_balance_hook_secondary_lifetime;
80 gren.think = adaptor_think2use_hittype_splash;
81 gren.use = W_Hook_Explode2;
82 gren.touch = W_Hook_Touch2;
84 gren.velocity = '0 0 1' * autocvar_g_balance_hook_secondary_speed;
85 if(autocvar_g_projectiles_newton_style)
86 gren.velocity = gren.velocity + self.velocity;
88 gren.gravity = autocvar_g_balance_hook_secondary_gravity;
89 //W_SetupProjectileVelocity(gren); // just falling down!
91 gren.angles = '0 0 0';
92 gren.flags = FL_PROJECTILE;
94 CSQCProjectile(gren, TRUE, PROJECTILE_HOOKBOMB, TRUE);
96 other = gren; MUTATOR_CALLHOOK(EditProjectile);
99 void spawnfunc_weapon_hook (void)
101 if(g_grappling_hook) // offhand hook
103 startitem_failed = TRUE;
107 weapon_defaultspawnfunc(WEP_HOOK);
110 float w_hook(float req)
112 float hooked_time_max, hooked_fuel;
118 else if (req == WR_THINK)
120 if (self.BUTTON_ATCK || (!(self.items & IT_JETPACK) && self.BUTTON_HOOK))
123 if not(self.hook_state & HOOK_WAITING_FOR_RELEASE)
124 if not(self.hook_state & HOOK_FIRING)
125 if (time > self.hook_refire)
126 if (weapon_prepareattack(0, -1))
128 W_DecreaseAmmo(ammo_fuel, autocvar_g_balance_hook_primary_fuel, FALSE);
129 self.hook_state |= HOOK_FIRING;
130 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_hook_primary_animtime, w_ready);
134 if (self.BUTTON_ATCK2)
136 if (weapon_prepareattack(1, autocvar_g_balance_hook_secondary_refire))
139 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_hook_secondary_animtime, w_ready);
145 // if hooked, no bombs, and increase the timer
146 self.hook_refire = max(self.hook_refire, time + autocvar_g_balance_hook_primary_refire * W_WeaponRateFactor());
148 // hook also inhibits health regeneration, but only for 1 second
149 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
150 self.pauseregen_finished = max(self.pauseregen_finished, time + autocvar_g_balance_pause_fuel_regen);
153 if(self.hook && self.hook.state == 1)
155 hooked_time_max = autocvar_g_balance_hook_primary_hooked_time_max;
156 if (hooked_time_max > 0)
158 if ( time > self.hook_time_hooked + hooked_time_max )
159 self.hook_state |= HOOK_REMOVING;
162 hooked_fuel = autocvar_g_balance_hook_primary_hooked_fuel;
165 if ( time > self.hook_time_fueldecrease )
167 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
169 if ( self.ammo_fuel >= (time - self.hook_time_fueldecrease) * hooked_fuel )
171 W_DecreaseAmmo(ammo_fuel, (time - self.hook_time_fueldecrease) * hooked_fuel, FALSE);
172 self.hook_time_fueldecrease = time;
173 // decrease next frame again
178 self.hook_state |= HOOK_REMOVING;
179 W_SwitchWeapon_Force(self, w_getbestweapon(self));
187 self.hook_time_hooked = time;
188 self.hook_time_fueldecrease = time + autocvar_g_balance_hook_primary_hooked_time_free;
191 if (self.BUTTON_CROUCH)
193 self.hook_state &~= HOOK_PULLING;
194 if (self.BUTTON_ATCK || (!(self.items & IT_JETPACK) && self.BUTTON_HOOK))
195 self.hook_state &~= HOOK_RELEASING;
197 self.hook_state |= HOOK_RELEASING;
201 self.hook_state |= HOOK_PULLING;
202 self.hook_state &~= HOOK_RELEASING;
204 if (self.BUTTON_ATCK || (!(self.items & IT_JETPACK) && self.BUTTON_HOOK))
208 self.hook_state |= HOOK_WAITING_FOR_RELEASE;
212 self.hook_state |= HOOK_REMOVING;
213 self.hook_state &~= HOOK_WAITING_FOR_RELEASE;
217 else if (req == WR_PRECACHE)
219 precache_model ("models/weapons/g_hookgun.md3");
220 precache_model ("models/weapons/v_hookgun.md3");
221 precache_model ("models/weapons/h_hookgun.iqm");
222 precache_sound ("weapons/hook_impact.wav"); // done by g_hook.qc
223 precache_sound ("weapons/hook_fire.wav");
224 precache_sound ("weapons/hookbomb_fire.wav");
226 else if (req == WR_SETUP)
228 weapon_setup(WEP_HOOK);
229 self.current_ammo = ammo_fuel;
230 self.hook_state &~= HOOK_WAITING_FOR_RELEASE;
232 else if (req == WR_CHECKAMMO1)
235 return self.ammo_fuel > 0;
237 return self.ammo_fuel >= autocvar_g_balance_hook_primary_fuel;
239 else if (req == WR_CHECKAMMO2)
241 return self.ammo_cells >= autocvar_g_balance_hook_secondary_ammo;
243 else if (req == WR_RESETPLAYER)
245 self.hook_refire = time;
251 float w_hook(float req)
253 if(req == WR_IMPACTEFFECT)
256 org2 = w_org + w_backoff * 2;
257 pointparticles(particleeffectnum("hookbomb_explode"), org2, '0 0 0', 1);
259 sound(self, CH_SHOTS, "weapons/hookbomb_impact.wav", VOL_BASE, ATTN_NORM);
261 else if(req == WR_PRECACHE)
263 precache_sound("weapons/hookbomb_impact.wav");
265 else if (req == WR_SUICIDEMESSAGE)
266 w_deathtypestring = _("%s did the impossible");
267 else if (req == WR_KILLMESSAGE)
268 w_deathtypestring = _("%s has run into %s's gravity bomb");