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.owner, self.dmg * f, self.dmg_edge * f, self.dmg_radius, self.owner, 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 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
66 W_DecreaseAmmo(ammo_cells, autocvar_g_balance_hook_secondary_ammo, FALSE);
67 W_SetupShot (self, FALSE, 4, "weapons/hookbomb_fire.wav", CHAN_WEAPON, autocvar_g_balance_hook_secondary_damage);
71 gren.classname = "hookbomb";
72 gren.bot_dodge = TRUE;
73 gren.bot_dodgerating = autocvar_g_balance_hook_secondary_damage;
74 gren.movetype = MOVETYPE_TOSS;
75 PROJECTILE_MAKETRIGGER(gren);
76 gren.projectiledeathtype = WEP_HOOK | HITTYPE_SECONDARY;
77 setorigin(gren, w_shotorg);
78 setsize(gren, '0 0 0', '0 0 0');
80 gren.nextthink = time + autocvar_g_balance_hook_secondary_lifetime;
81 gren.think = adaptor_think2use_hittype_splash;
82 gren.use = W_Hook_Explode2;
83 gren.touch = W_Hook_Touch2;
85 gren.velocity = '0 0 1' * autocvar_g_balance_hook_secondary_speed;
86 if(autocvar_g_projectiles_newton_style)
87 gren.velocity = gren.velocity + self.velocity;
89 gren.gravity = autocvar_g_balance_hook_secondary_gravity;
90 //W_SetupProjectileVelocity(gren); // just falling down!
92 gren.angles = '0 0 0';
93 gren.flags = FL_PROJECTILE;
95 CSQCProjectile(gren, TRUE, PROJECTILE_HOOKBOMB, TRUE);
97 other = gren; MUTATOR_CALLHOOK(EditProjectile);
100 void spawnfunc_weapon_hook (void)
102 if(g_grappling_hook) // offhand hook
104 startitem_failed = TRUE;
108 weapon_defaultspawnfunc(WEP_HOOK);
111 float w_hook(float req)
113 float hooked_time_max, hooked_fuel;
119 else if (req == WR_THINK)
121 if (self.BUTTON_ATCK || (!(self.items & IT_JETPACK) && self.BUTTON_HOOK))
124 if not(self.hook_state & HOOK_WAITING_FOR_RELEASE)
125 if not(self.hook_state & HOOK_FIRING)
126 if (time > self.hook_refire)
127 if (weapon_prepareattack(0, -1))
129 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
130 W_DecreaseAmmo(ammo_fuel, autocvar_g_balance_hook_primary_fuel, FALSE);
131 self.hook_state |= HOOK_FIRING;
132 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_hook_primary_animtime, w_ready);
136 if (self.BUTTON_ATCK2)
138 if (weapon_prepareattack(1, autocvar_g_balance_hook_secondary_refire))
141 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_hook_secondary_animtime, w_ready);
147 // if hooked, no bombs, and increase the timer
148 self.hook_refire = max(self.hook_refire, time + autocvar_g_balance_hook_primary_refire);
150 // hook also inhibits health regeneration, but only for 1 second
151 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
152 self.pauseregen_finished = max(self.pauseregen_finished, time + autocvar_g_balance_pause_fuel_regen);
155 if(self.hook && self.hook.state == 1)
157 hooked_time_max = autocvar_g_balance_hook_primary_hooked_time_max;
158 if (hooked_time_max > 0)
160 if ( time > self.hook_time_hooked + hooked_time_max )
161 self.hook_state |= HOOK_REMOVING;
164 hooked_fuel = autocvar_g_balance_hook_primary_hooked_fuel;
167 if ( time > self.hook_time_fueldecrease )
169 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
171 if ( self.ammo_fuel >= (time - self.hook_time_fueldecrease) * hooked_fuel )
173 W_DecreaseAmmo(ammo_fuel, (time - self.hook_time_fueldecrease) * hooked_fuel, FALSE);
174 self.hook_time_fueldecrease = time;
175 // decrease next frame again
180 self.hook_state |= HOOK_REMOVING;
181 W_SwitchWeapon_Force(self, w_getbestweapon(self));
189 self.hook_time_hooked = time;
190 self.hook_time_fueldecrease = time + autocvar_g_balance_hook_primary_hooked_time_free;
193 if (self.BUTTON_CROUCH)
195 self.hook_state &~= HOOK_PULLING;
196 if (self.BUTTON_ATCK || (!(self.items & IT_JETPACK) && self.BUTTON_HOOK))
197 self.hook_state &~= HOOK_RELEASING;
199 self.hook_state |= HOOK_RELEASING;
203 self.hook_state |= HOOK_PULLING;
204 self.hook_state &~= HOOK_RELEASING;
206 if (self.BUTTON_ATCK || (!(self.items & IT_JETPACK) && self.BUTTON_HOOK))
210 self.hook_state |= HOOK_WAITING_FOR_RELEASE;
214 self.hook_state |= HOOK_REMOVING;
215 self.hook_state &~= HOOK_WAITING_FOR_RELEASE;
219 else if (req == WR_PRECACHE)
221 precache_model ("models/weapons/g_hookgun.md3");
222 precache_model ("models/weapons/v_hookgun.md3");
223 precache_model ("models/weapons/h_hookgun.iqm");
224 precache_sound ("weapons/hook_impact.wav"); // done by g_hook.qc
225 precache_sound ("weapons/hook_fire.wav");
226 precache_sound ("weapons/hookbomb_fire.wav");
228 else if (req == WR_SETUP)
230 weapon_setup(WEP_HOOK);
231 self.current_ammo = ammo_fuel;
232 self.hook_state &~= HOOK_WAITING_FOR_RELEASE;
234 else if (req == WR_CHECKAMMO1)
237 return self.ammo_fuel > 0;
239 return self.ammo_fuel >= autocvar_g_balance_hook_primary_fuel;
241 else if (req == WR_CHECKAMMO2)
243 return self.ammo_cells >= autocvar_g_balance_hook_secondary_ammo;
245 else if (req == WR_RESETPLAYER)
247 self.hook_refire = time;
253 float w_hook(float req)
255 if(req == WR_IMPACTEFFECT)
258 org2 = w_org + w_backoff * 2;
259 pointparticles(particleeffectnum("hookbomb_explode"), org2, '0 0 0', 1);
261 sound(self, CHAN_PROJECTILE, "weapons/hookbomb_impact.wav", VOL_BASE, ATTN_NORM);
263 else if(req == WR_PRECACHE)
265 precache_sound("weapons/hookbomb_impact.wav");
267 else if (req == WR_SUICIDEMESSAGE)
268 w_deathtypestring = _("%s did the impossible");
269 else if (req == WR_KILLMESSAGE)
270 w_deathtypestring = _("%s has run into %s's gravity bomb");