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_SetAmmoCounter()
18 // this weapon doesn't have a reload system, so always set the clip to 0 when switching to it
19 self.clip_load = self.clip_size = 0; // also keeps crosshair ammo from displaying
22 void W_Hook_ExplodeThink (void)
24 float dt, dmg_remaining_next, f;
26 dt = time - self.teleport_time;
27 dmg_remaining_next = pow(bound(0, 1 - dt / self.dmg_duration, 1), self.dmg_power);
29 f = self.dmg_last - dmg_remaining_next;
30 self.dmg_last = dmg_remaining_next;
32 RadiusDamage (self, self.owner, self.dmg * f, self.dmg_edge * f, self.dmg_radius, self.owner, self.dmg_force * f, self.projectiledeathtype, world);
33 self.projectiledeathtype |= HITTYPE_BOUNCE;
34 //RadiusDamage (self, world, self.dmg * f, self.dmg_edge * f, self.dmg_radius, world, self.dmg_force * f, self.projectiledeathtype, world);
36 if(dt < self.dmg_duration)
37 self.nextthink = time + 0.05; // soon
42 void W_Hook_Explode2 (void)
44 self.event_damage = SUB_Null;
45 self.touch = SUB_Null;
46 self.effects |= EF_NODRAW;
48 self.think = W_Hook_ExplodeThink;
49 self.nextthink = time;
50 self.dmg = autocvar_g_balance_hook_secondary_damage;
51 self.dmg_edge = autocvar_g_balance_hook_secondary_edgedamage;
52 self.dmg_radius = autocvar_g_balance_hook_secondary_radius;
53 self.dmg_force = autocvar_g_balance_hook_secondary_force;
54 self.dmg_power = autocvar_g_balance_hook_secondary_power;
55 self.dmg_duration = autocvar_g_balance_hook_secondary_duration;
56 self.teleport_time = time;
58 self.movetype = MOVETYPE_NONE;
61 void W_Hook_Touch2 (void)
71 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
72 self.ammo_cells = self.ammo_cells - autocvar_g_balance_hook_secondary_ammo;
73 W_SetupShot (self, FALSE, 4, "weapons/hookbomb_fire.wav", CHAN_WEAPON, autocvar_g_balance_hook_secondary_damage);
77 gren.classname = "hookbomb";
78 gren.bot_dodge = TRUE;
79 gren.bot_dodgerating = autocvar_g_balance_hook_secondary_damage;
80 gren.movetype = MOVETYPE_TOSS;
81 PROJECTILE_MAKETRIGGER(gren);
82 gren.projectiledeathtype = WEP_HOOK | HITTYPE_SECONDARY;
83 setorigin(gren, w_shotorg);
84 setsize(gren, '0 0 0', '0 0 0');
86 gren.nextthink = time + autocvar_g_balance_hook_secondary_lifetime;
87 gren.think = adaptor_think2use_hittype_splash;
88 gren.use = W_Hook_Explode2;
89 gren.touch = W_Hook_Touch2;
91 gren.velocity = '0 0 1' * autocvar_g_balance_hook_secondary_speed;
92 if(autocvar_g_projectiles_newton_style)
93 gren.velocity = gren.velocity + self.velocity;
95 gren.gravity = autocvar_g_balance_hook_secondary_gravity;
96 //W_SetupProjectileVelocity(gren); // just falling down!
98 gren.angles = '0 0 0';
99 gren.flags = FL_PROJECTILE;
101 CSQCProjectile(gren, TRUE, PROJECTILE_HOOKBOMB, TRUE);
103 other = gren; MUTATOR_CALLHOOK(EditProjectile);
106 void spawnfunc_weapon_hook (void)
108 if(g_grappling_hook) // offhand hook
110 startitem_failed = TRUE;
114 weapon_defaultspawnfunc(WEP_HOOK);
117 float w_hook(float req)
119 float hooked_time_max, hooked_fuel;
125 else if (req == WR_THINK)
127 if (self.BUTTON_ATCK || (!(self.items & IT_JETPACK) && self.BUTTON_HOOK))
130 if not(self.hook_state & HOOK_WAITING_FOR_RELEASE)
131 if not(self.hook_state & HOOK_FIRING)
132 if (time > self.hook_refire)
133 if (weapon_prepareattack(0, -1))
135 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
136 self.ammo_fuel = self.ammo_fuel - autocvar_g_balance_hook_primary_fuel;
137 self.hook_state |= HOOK_FIRING;
138 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_hook_primary_animtime, w_ready);
142 if (self.BUTTON_ATCK2)
144 if (weapon_prepareattack(1, autocvar_g_balance_hook_secondary_refire))
147 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_hook_secondary_animtime, w_ready);
153 // if hooked, no bombs, and increase the timer
154 self.hook_refire = max(self.hook_refire, time + autocvar_g_balance_hook_primary_refire);
156 // hook also inhibits health regeneration, but only for 1 second
157 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
158 self.pauseregen_finished = max(self.pauseregen_finished, time + autocvar_g_balance_pause_fuel_regen);
161 if(self.hook && self.hook.state == 1)
163 hooked_time_max = autocvar_g_balance_hook_primary_hooked_time_max;
164 if (hooked_time_max > 0)
166 if ( time > self.hook_time_hooked + hooked_time_max )
167 self.hook_state |= HOOK_REMOVING;
170 hooked_fuel = autocvar_g_balance_hook_primary_hooked_fuel;
173 if ( time > self.hook_time_fueldecrease )
175 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
177 if ( self.ammo_fuel >= (time - self.hook_time_fueldecrease) * hooked_fuel )
179 self.ammo_fuel -= (time - self.hook_time_fueldecrease) * hooked_fuel;
180 self.hook_time_fueldecrease = time;
181 // decrease next frame again
186 self.hook_state |= HOOK_REMOVING;
187 W_SwitchWeapon_Force(self, w_getbestweapon(self));
195 self.hook_time_hooked = time;
196 self.hook_time_fueldecrease = time + autocvar_g_balance_hook_primary_hooked_time_free;
199 if (self.BUTTON_CROUCH)
201 self.hook_state &~= HOOK_PULLING;
202 if (self.BUTTON_ATCK || (!(self.items & IT_JETPACK) && self.BUTTON_HOOK))
203 self.hook_state &~= HOOK_RELEASING;
205 self.hook_state |= HOOK_RELEASING;
209 self.hook_state |= HOOK_PULLING;
210 self.hook_state &~= HOOK_RELEASING;
212 if (self.BUTTON_ATCK || (!(self.items & IT_JETPACK) && self.BUTTON_HOOK))
216 self.hook_state |= HOOK_WAITING_FOR_RELEASE;
220 self.hook_state |= HOOK_REMOVING;
221 self.hook_state &~= HOOK_WAITING_FOR_RELEASE;
225 else if (req == WR_PRECACHE)
227 precache_model ("models/weapons/g_hookgun.md3");
228 precache_model ("models/weapons/v_hookgun.md3");
229 precache_model ("models/weapons/h_hookgun.iqm");
230 precache_sound ("weapons/hook_impact.wav"); // done by g_hook.qc
231 precache_sound ("weapons/hook_fire.wav");
232 precache_sound ("weapons/hookbomb_fire.wav");
234 else if (req == WR_SETUP)
236 weapon_setup(WEP_HOOK);
237 W_Hook_SetAmmoCounter();
238 self.hook_state &~= HOOK_WAITING_FOR_RELEASE;
240 else if (req == WR_CHECKAMMO1)
243 return self.ammo_fuel > 0;
245 return self.ammo_fuel >= autocvar_g_balance_hook_primary_fuel;
247 else if (req == WR_CHECKAMMO2)
249 return self.ammo_cells >= autocvar_g_balance_hook_secondary_ammo;
251 else if (req == WR_RESETPLAYER)
253 self.hook_refire = time;
259 float w_hook(float req)
261 if(req == WR_IMPACTEFFECT)
264 org2 = w_org + w_backoff * 2;
265 pointparticles(particleeffectnum("hookbomb_explode"), org2, '0 0 0', 1);
267 sound(self, CHAN_PROJECTILE, "weapons/hookbomb_impact.wav", VOL_BASE, ATTN_NORM);
269 else if(req == WR_PRECACHE)
271 precache_sound("weapons/hookbomb_impact.wav");
273 else if (req == WR_SUICIDEMESSAGE)
274 w_deathtypestring = _("%s did the impossible");
275 else if (req == WR_KILLMESSAGE)
276 w_deathtypestring = _("%s has run into %s's gravity bomb");