2 REGISTER_WEAPON(HOOK, w_hook, IT_CELLS|IT_FUEL, 0, WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH, 0, "hookgun", "hook", "Grappling Hook");
12 .float hook_time_hooked;
13 .float hook_time_fueldecrease;
15 void W_Hook_ExplodeThink (void)
17 float dt, dmg_remaining_next, f;
19 dt = time - self.teleport_time;
20 dmg_remaining_next = pow(bound(0, 1 - dt / self.dmg_duration, 1), self.dmg_power);
22 f = self.dmg_last - dmg_remaining_next;
23 self.dmg_last = dmg_remaining_next;
25 RadiusDamage (self, self.owner, self.dmg * f, self.dmg_edge * f, self.dmg_radius, self.owner, self.dmg_force * f, self.projectiledeathtype, world);
26 self.projectiledeathtype |= HITTYPE_BOUNCE;
27 //RadiusDamage (self, world, self.dmg * f, self.dmg_edge * f, self.dmg_radius, world, self.dmg_force * f, self.projectiledeathtype, world);
29 if(dt < self.dmg_duration)
30 self.nextthink = time + 0.05; // soon
35 void W_Hook_Explode2 (void)
37 self.event_damage = SUB_Null;
38 self.touch = SUB_Null;
39 self.effects |= EF_NODRAW;
41 self.think = W_Hook_ExplodeThink;
42 self.nextthink = time;
43 self.dmg = cvar("g_balance_hook_secondary_damage");
44 self.dmg_edge = cvar("g_balance_hook_secondary_edgedamage");
45 self.dmg_radius = cvar("g_balance_hook_secondary_radius");
46 self.dmg_force = cvar("g_balance_hook_secondary_force");
47 self.dmg_power = cvar("g_balance_hook_secondary_power");
48 self.dmg_duration = cvar("g_balance_hook_secondary_duration");
49 self.teleport_time = time;
51 self.movetype = MOVETYPE_NONE;
54 void W_Hook_Touch2 (void)
64 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
65 self.ammo_cells = self.ammo_cells - cvar("g_balance_hook_secondary_ammo");
66 W_SetupShot (self, FALSE, 4, "weapons/hookbomb_fire.wav", cvar("g_balance_hook_secondary_damage"));
70 gren.classname = "hookbomb";
71 gren.bot_dodge = TRUE;
72 gren.bot_dodgerating = cvar("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 + cvar("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' * cvar("g_balance_hook_secondary_speed");
85 if(cvar("g_projectiles_newton_style"))
86 gren.velocity = gren.velocity + self.velocity;
88 gren.gravity = cvar("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);
97 void spawnfunc_weapon_hook (void)
99 if(g_grappling_hook) // offhand hook
101 startitem_failed = TRUE;
105 weapon_defaultspawnfunc(WEP_HOOK);
108 float w_hook(float req)
110 float hooked_time_max, hooked_fuel;
116 else if (req == WR_THINK)
118 if (self.BUTTON_ATCK || (!(self.items & IT_JETPACK) && self.BUTTON_HOOK))
121 if not(self.hook_state & HOOK_WAITING_FOR_RELEASE)
122 if not(self.hook_state & HOOK_FIRING)
123 if (time > self.hook_refire)
124 if (weapon_prepareattack(0, -1))
126 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
127 self.ammo_fuel = self.ammo_fuel - cvar("g_balance_hook_primary_fuel");
128 self.hook_state |= HOOK_FIRING;
129 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_hook_primary_animtime"), w_ready);
133 if (self.BUTTON_ATCK2)
135 if (weapon_prepareattack(1, cvar("g_balance_hook_secondary_refire")))
138 weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_hook_secondary_animtime"), w_ready);
144 // if hooked, no bombs, and increase the timer
145 self.hook_refire = max(self.hook_refire, time + cvar("g_balance_hook_primary_refire"));
147 // hook also inhibits health regeneration, but only for 1 second
148 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
149 self.pauseregen_finished = max(self.pauseregen_finished, time + cvar("g_balance_pause_fuel_regen"));
152 if(self.hook && self.hook.state == 1)
154 hooked_time_max = cvar("g_balance_hook_primary_hooked_time_max");
155 if (hooked_time_max > 0)
157 if ( time > self.hook_time_hooked + hooked_time_max )
158 self.hook_state |= HOOK_REMOVING;
161 hooked_fuel = cvar("g_balance_hook_primary_hooked_fuel");
164 if ( time > self.hook_time_fueldecrease )
166 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
168 if ( self.ammo_fuel >= (time - self.hook_time_fueldecrease) * hooked_fuel )
170 self.ammo_fuel -= (time - self.hook_time_fueldecrease) * hooked_fuel;
171 self.hook_time_fueldecrease = time;
172 // decrease next frame again
177 self.hook_state |= HOOK_REMOVING;
178 W_SwitchWeapon_Force(self, w_getbestweapon(self));
186 self.hook_time_hooked = time;
187 self.hook_time_fueldecrease = time + cvar("g_balance_hook_primary_hooked_time_free");
190 if (self.BUTTON_CROUCH)
192 self.hook_state &~= HOOK_PULLING;
193 if (self.BUTTON_ATCK || (!(self.items & IT_JETPACK) && self.BUTTON_HOOK))
194 self.hook_state &~= HOOK_RELEASING;
196 self.hook_state |= HOOK_RELEASING;
200 self.hook_state |= HOOK_PULLING;
201 self.hook_state &~= HOOK_RELEASING;
203 if (self.BUTTON_ATCK || (!(self.items & IT_JETPACK) && self.BUTTON_HOOK))
207 self.hook_state |= HOOK_WAITING_FOR_RELEASE;
211 self.hook_state |= HOOK_REMOVING;
212 self.hook_state &~= HOOK_WAITING_FOR_RELEASE;
216 else if (req == WR_PRECACHE)
218 precache_model ("models/weapons/g_hookgun.md3");
219 precache_model ("models/weapons/v_hookgun.md3");
220 precache_model ("models/weapons/h_hookgun.iqm");
221 precache_sound ("weapons/hook_impact.wav"); // done by g_hook.qc
222 precache_sound ("weapons/hook_fire.wav");
223 precache_sound ("weapons/hookbomb_fire.wav");
225 else if (req == WR_SETUP)
227 weapon_setup(WEP_HOOK);
228 self.hook_state &~= HOOK_WAITING_FOR_RELEASE;
230 else if (req == WR_CHECKAMMO1)
233 return self.ammo_fuel > 0;
235 return self.ammo_fuel >= cvar("g_balance_hook_primary_fuel");
237 else if (req == WR_CHECKAMMO2)
239 return self.ammo_cells >= cvar("g_balance_hook_secondary_ammo");
241 else if (req == WR_SUICIDEMESSAGE)
242 w_deathtypestring = "did the impossible";
243 else if (req == WR_KILLMESSAGE)
244 w_deathtypestring = "has run into #'s gravity bomb";
245 else if (req == WR_RESETPLAYER)
247 self.hook_refire = time;