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 = cvar("g_balance_hook_secondary_damage");
45 self.dmg_edge = cvar("g_balance_hook_secondary_edgedamage");
46 self.dmg_radius = cvar("g_balance_hook_secondary_radius");
47 self.dmg_force = cvar("g_balance_hook_secondary_force");
48 self.dmg_power = cvar("g_balance_hook_secondary_power");
49 self.dmg_duration = cvar("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 self.ammo_cells = self.ammo_cells - cvar("g_balance_hook_secondary_ammo");
67 W_SetupShot (self, FALSE, 4, "weapons/hookbomb_fire.wav", cvar("g_balance_hook_secondary_damage"));
71 gren.classname = "hookbomb";
72 gren.bot_dodge = TRUE;
73 gren.bot_dodgerating = cvar("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 + cvar("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' * cvar("g_balance_hook_secondary_speed");
86 if(cvar("g_projectiles_newton_style"))
87 gren.velocity = gren.velocity + self.velocity;
89 gren.gravity = cvar("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 self.ammo_fuel = self.ammo_fuel - cvar("g_balance_hook_primary_fuel");
131 self.hook_state |= HOOK_FIRING;
132 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_hook_primary_animtime"), w_ready);
136 if (self.BUTTON_ATCK2)
138 if (weapon_prepareattack(1, cvar("g_balance_hook_secondary_refire")))
141 weapon_thinkf(WFRAME_FIRE2, cvar("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 + cvar("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 + cvar("g_balance_pause_fuel_regen"));
155 if(self.hook && self.hook.state == 1)
157 hooked_time_max = cvar("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 = cvar("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 self.ammo_fuel -= (time - self.hook_time_fueldecrease) * hooked_fuel;
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 + cvar("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.hook_state &~= HOOK_WAITING_FOR_RELEASE;
233 else if (req == WR_CHECKAMMO1)
236 return self.ammo_fuel > 0;
238 return self.ammo_fuel >= cvar("g_balance_hook_primary_fuel");
240 else if (req == WR_CHECKAMMO2)
242 return self.ammo_cells >= cvar("g_balance_hook_secondary_ammo");
244 else if (req == WR_RESETPLAYER)
246 self.hook_refire = time;
252 float w_hook(float req)
254 if(req == WR_IMPACTEFFECT)
257 org2 = w_org + w_backoff * 2;
258 pointparticles(particleeffectnum("hookbomb_explode"), org2, '0 0 0', 1);
260 sound(self, CHAN_PROJECTILE, "weapons/hookbomb_impact.wav", VOL_BASE, ATTN_NORM);
262 else if(req == WR_PRECACHE)
264 precache_sound("weapons/hookbomb_impact.wav");
266 else if (req == WR_SUICIDEMESSAGE)
267 w_deathtypestring = "%s did the impossible";
268 else if (req == WR_KILLMESSAGE)
269 w_deathtypestring = "%s has run into %s's gravity bomb";