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);
98 void spawnfunc_weapon_hook (void)
100 if(g_grappling_hook) // offhand hook
102 startitem_failed = TRUE;
106 weapon_defaultspawnfunc(WEP_HOOK);
109 float w_hook(float req)
111 float hooked_time_max, hooked_fuel;
117 else if (req == WR_THINK)
119 if (self.BUTTON_ATCK || (!(self.items & IT_JETPACK) && self.BUTTON_HOOK))
122 if not(self.hook_state & HOOK_WAITING_FOR_RELEASE)
123 if not(self.hook_state & HOOK_FIRING)
124 if (time > self.hook_refire)
125 if (weapon_prepareattack(0, -1))
127 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
128 self.ammo_fuel = self.ammo_fuel - cvar("g_balance_hook_primary_fuel");
129 self.hook_state |= HOOK_FIRING;
130 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_hook_primary_animtime"), w_ready);
134 if (self.BUTTON_ATCK2)
136 if (weapon_prepareattack(1, cvar("g_balance_hook_secondary_refire")))
139 weapon_thinkf(WFRAME_FIRE2, cvar("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 + cvar("g_balance_hook_primary_refire"));
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 + cvar("g_balance_pause_fuel_regen"));
153 if(self.hook && self.hook.state == 1)
155 hooked_time_max = cvar("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 = cvar("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 self.ammo_fuel -= (time - self.hook_time_fueldecrease) * hooked_fuel;
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 + cvar("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.hook_state &~= HOOK_WAITING_FOR_RELEASE;
231 else if (req == WR_CHECKAMMO1)
234 return self.ammo_fuel > 0;
236 return self.ammo_fuel >= cvar("g_balance_hook_primary_fuel");
238 else if (req == WR_CHECKAMMO2)
240 return self.ammo_cells >= cvar("g_balance_hook_secondary_ammo");
242 else if (req == WR_RESETPLAYER)
244 self.hook_refire = time;
250 float w_hook(float req)
252 if(req == WR_IMPACTEFFECT)
255 org2 = w_org + w_backoff * 2;
256 pointparticles(particleeffectnum("hookbomb_explode"), org2, '0 0 0', 1);
258 sound(self, CHAN_PROJECTILE, "weapons/hookbomb_impact.wav", VOL_BASE, ATTN_NORM);
260 else if(req == WR_PRECACHE)
262 precache_sound("weapons/hookbomb_impact.wav");
264 else if (req == WR_SUICIDEMESSAGE)
265 w_deathtypestring = "did the impossible";
266 else if (req == WR_KILLMESSAGE)
267 w_deathtypestring = "has run into #'s gravity bomb";