9 .float hook_time_hooked;
10 .float hook_time_fueldecrease;
12 void W_Hook_ExplodeThink (void)
14 float dt, dmg_remaining_next, f;
16 dt = time - self.teleport_time;
17 dmg_remaining_next = pow(bound(0, 1 - dt / self.dmg_duration, 1), self.dmg_power);
19 f = self.dmg_last - dmg_remaining_next;
20 self.dmg_last = dmg_remaining_next;
22 RadiusDamage (self, self.owner, self.dmg * f, self.dmg_edge * f, self.dmg_radius, self.owner, self.dmg_force * f, self.projectiledeathtype, world);
23 self.projectiledeathtype |= HITTYPE_BOUNCE;
24 //RadiusDamage (self, world, self.dmg * f, self.dmg_edge * f, self.dmg_radius, world, self.dmg_force * f, self.projectiledeathtype, world);
26 if(dt < self.dmg_duration)
27 self.nextthink = time + 0.05; // soon
32 void W_Hook_Explode2 (void)
34 self.event_damage = SUB_Null;
35 self.touch = SUB_Null;
36 self.effects |= EF_NODRAW;
38 self.think = W_Hook_ExplodeThink;
39 self.nextthink = time;
40 self.dmg = cvar("g_balance_hook_secondary_damage");
41 self.dmg_edge = cvar("g_balance_hook_secondary_edgedamage");
42 self.dmg_radius = cvar("g_balance_hook_secondary_radius");
43 self.dmg_force = cvar("g_balance_hook_secondary_force");
44 self.dmg_power = cvar("g_balance_hook_secondary_power");
45 self.dmg_duration = cvar("g_balance_hook_secondary_duration");
46 self.teleport_time = time;
48 self.movetype = MOVETYPE_NONE;
51 void W_Hook_Touch2 (void)
61 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
62 self.ammo_cells = self.ammo_cells - cvar("g_balance_hook_secondary_ammo");
63 W_SetupShot (self, FALSE, 4, "weapons/hookbomb_fire.wav");
67 gren.classname = "hookbomb";
68 gren.bot_dodge = TRUE;
69 gren.bot_dodgerating = cvar("g_balance_hook_secondary_damage");
70 gren.movetype = MOVETYPE_TOSS;
71 gren.solid = SOLID_BBOX;
72 gren.projectiledeathtype = WEP_HOOK | HITTYPE_SECONDARY;
73 setorigin(gren, w_shotorg);
75 gren.nextthink = time + cvar("g_balance_hook_secondary_lifetime");
76 gren.think = adaptor_think2use;
77 gren.use = W_Hook_Explode2;
78 gren.touch = W_Hook_Touch2;
80 gren.velocity = '0 0 1' * cvar("g_balance_hook_secondary_speed");
81 if(cvar("g_projectiles_newton_style"))
82 gren.velocity = gren.velocity + self.velocity;
84 gren.gravity = cvar("g_balance_hook_secondary_gravity");
85 //W_SetupProjectileVelocity(gren); // just falling down!
87 gren.angles = '0 0 0';
88 gren.flags = FL_PROJECTILE;
90 CSQCProjectile(gren, TRUE, PROJECTILE_HOOKBOMB, TRUE);
93 void spawnfunc_weapon_hook (void)
95 if(g_grappling_hook) // offhand hook
97 startitem_failed = TRUE;
101 weapon_defaultspawnfunc(WEP_HOOK);
104 float w_hook(float req)
106 float hooked_time_max, hooked_fuel;
112 else if (req == WR_THINK)
114 if (self.BUTTON_ATCK || (!(self.items & IT_JETPACK) && self.BUTTON_HOOK))
117 if not(self.hook_state & HOOK_WAITING_FOR_RELEASE)
118 if not(self.hook_state & HOOK_FIRING)
119 if (time > self.hook_refire)
120 if (weapon_prepareattack(0, -1))
122 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
123 self.ammo_fuel = self.ammo_fuel - cvar("g_balance_hook_primary_fuel");
124 self.hook_state |= HOOK_FIRING;
125 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_hook_primary_animtime"), w_ready);
129 if (self.BUTTON_ATCK2)
131 if (weapon_prepareattack(1, cvar("g_balance_hook_secondary_refire")))
134 weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_hook_secondary_animtime"), w_ready);
140 // if hooked, no bombs, and increase the timer
141 self.hook_refire = max(self.hook_refire, time + cvar("g_balance_hook_primary_refire"));
143 // hook also inhibits health regeneration, but only for 1 second
144 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
145 self.pauseregen_finished = max(self.pauseregen_finished, time + cvar("g_balance_pause_fuel_regen"));
148 if(self.hook && self.hook.state == 1)
150 hooked_time_max = cvar("g_balance_hook_primary_hooked_time_max");
151 if (hooked_time_max > 0)
153 if ( time > self.hook_time_hooked + hooked_time_max )
154 self.hook_state |= HOOK_REMOVING;
157 hooked_fuel = cvar("g_balance_hook_primary_hooked_fuel");
160 if ( time > self.hook_time_fueldecrease )
162 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
164 if ( self.ammo_fuel >= (time - self.hook_time_fueldecrease) * hooked_fuel )
166 self.ammo_fuel -= (time - self.hook_time_fueldecrease) * hooked_fuel;
167 self.hook_time_fueldecrease = time;
168 // decrease next frame again
173 self.hook_state |= HOOK_REMOVING;
174 W_SwitchWeapon_Force(self, w_getbestweapon(self));
182 self.hook_time_hooked = time;
183 self.hook_time_fueldecrease = time + cvar("g_balance_hook_primary_hooked_time_free");
186 if (self.BUTTON_CROUCH)
188 self.hook_state &~= HOOK_PULLING;
189 if (self.BUTTON_ATCK || (!(self.items & IT_JETPACK) && self.BUTTON_HOOK))
190 self.hook_state &~= HOOK_RELEASING;
192 self.hook_state |= HOOK_RELEASING;
196 self.hook_state |= HOOK_PULLING;
197 self.hook_state &~= HOOK_RELEASING;
199 if (self.BUTTON_ATCK || (!(self.items & IT_JETPACK) && self.BUTTON_HOOK))
203 self.hook_state |= HOOK_WAITING_FOR_RELEASE;
207 self.hook_state |= HOOK_REMOVING;
208 self.hook_state &~= HOOK_WAITING_FOR_RELEASE;
212 else if (req == WR_PRECACHE)
214 precache_model ("models/weapons/g_hookgun.md3");
215 precache_model ("models/weapons/v_hookgun.md3");
216 precache_model ("models/weapons/h_hookgun.dpm");
217 precache_sound ("weapons/hook_impact.wav"); // done by g_hook.qc
218 precache_sound ("weapons/hook_fire.wav");
219 precache_sound ("weapons/hookbomb_fire.wav");
221 else if (req == WR_SETUP)
223 weapon_setup(WEP_HOOK);
224 self.hook_state &~= HOOK_WAITING_FOR_RELEASE;
226 else if (req == WR_CHECKAMMO1)
229 return self.ammo_fuel > 0;
231 return self.ammo_fuel >= cvar("g_balance_hook_primary_fuel");
233 else if (req == WR_CHECKAMMO2)
235 return self.ammo_cells >= cvar("g_balance_hook_secondary_ammo");
237 else if (req == WR_SUICIDEMESSAGE)
238 w_deathtypestring = "did the impossible";
239 else if (req == WR_KILLMESSAGE)
240 w_deathtypestring = "has run into #'s gravity bomb";