9 .float hook_time_hooked;
10 .float hook_time_ammodecrease;
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 //RadiusDamage (self, world, self.dmg * f, self.dmg_edge * f, self.dmg_radius, world, self.dmg_force * f, self.projectiledeathtype, world);
25 if(dt < self.dmg_duration)
26 self.nextthink = time + 0.05; // soon
31 void W_Hook_Explode2 (void)
35 org2 = findbetterlocation (self.origin, 12);
36 pointparticles(particleeffectnum("hookbomb_explode"), org2, '0 0 0', 1);
37 sound (self, CHAN_PROJECTILE, "weapons/hookbomb_impact.wav", VOL_BASE, ATTN_NORM);
39 self.event_damage = SUB_Null;
40 self.touch = SUB_Null;
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, '25 6 -8', FALSE, 4, "weapons/hookbomb_fire.wav");
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 gren.solid = SOLID_BBOX;
76 gren.effects = EF_LOWPRECISION;
77 gren.modelflags = MF_TRACER2;
78 gren.projectiledeathtype = WEP_HOOK | HITTYPE_SECONDARY;
79 setmodel(gren, "models/grenademodel.md3"); // precision set above // FIXME replace
80 setsize(gren, '0 0 0', '0 0 0');
81 setorigin(gren, w_shotorg);
83 gren.nextthink = time + cvar("g_balance_hook_secondary_lifetime");
84 gren.think = adaptor_think2use;
85 gren.use = W_Hook_Explode2;
86 gren.touch = W_Hook_Touch2;
88 gren.velocity = '0 0 1' * cvar("g_balance_hook_secondary_speed");
89 if(cvar("g_projectiles_newton_style"))
90 gren.velocity = gren.velocity + self.velocity;
92 gren.gravity = cvar("g_balance_hook_secondary_gravity");
93 //W_SetupProjectileVelocity(gren); // just falling down!
95 gren.angles = '0 0 0';
96 gren.flags = FL_PROJECTILE;
99 void spawnfunc_weapon_hook (void)
101 if(g_grappling_hook) // offhand hook
103 startitem_failed = TRUE;
107 weapon_defaultspawnfunc(WEP_HOOK);
110 float w_hook(float req)
112 float hooked_time_max, hooked_ammodecrease_delay;
118 else if (req == WR_THINK)
120 if (self.BUTTON_ATCK || self.BUTTON_HOOK)
123 if not(self.hook_state & HOOK_WAITING_FOR_RELEASE)
124 if (time > self.hook_refire)
125 if (weapon_prepareattack(0, -1))
127 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
128 self.ammo_cells = self.ammo_cells - cvar("g_balance_hook_primary_ammo");
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_FIRE1, 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"));
149 if(self.hook && self.hook.state == 1)
151 hooked_time_max = cvar("g_balance_hook_primary_hooked_time_max");
152 if (hooked_time_max > 0)
154 if ( time > self.hook_time_hooked + hooked_time_max )
155 self.hook_state |= HOOK_REMOVING;
158 hooked_ammodecrease_delay = cvar("g_balance_hook_primary_hooked_ammodecrease_delay");
159 if (hooked_ammodecrease_delay > 0)
161 if ( time > self.hook_time_ammodecrease )
163 if ( self.ammo_cells >= 1 )
165 self.ammo_cells -= 1;
166 self.hook_time_ammodecrease = time + hooked_ammodecrease_delay;
170 self.hook_state |= HOOK_REMOVING;
171 W_SwitchWeapon_Force(self, w_getbestweapon(self));
178 self.hook_time_hooked = time;
179 self.hook_time_ammodecrease = time + cvar("g_balance_hook_primary_hooked_time_free");
182 if (self.BUTTON_CROUCH)
184 self.hook_state &~= HOOK_PULLING;
185 if (self.BUTTON_ATCK || self.BUTTON_HOOK)
186 self.hook_state &~= HOOK_RELEASING;
188 self.hook_state |= HOOK_RELEASING;
192 self.hook_state |= HOOK_PULLING;
193 self.hook_state &~= HOOK_RELEASING;
195 if (self.BUTTON_ATCK || self.BUTTON_HOOK)
199 self.hook_state |= HOOK_WAITING_FOR_RELEASE;
203 self.hook_state |= HOOK_REMOVING;
204 self.hook_state &~= HOOK_WAITING_FOR_RELEASE;
208 else if (req == WR_PRECACHE)
210 precache_model ("models/weapons/g_hookgun.md3");
211 precache_model ("models/weapons/v_hookgun.md3");
212 precache_model ("models/weapons/w_hookgun.zym");
213 precache_sound ("weapons/hook_fire.wav");
214 precache_sound ("weapons/hook_impact.wav");
215 precache_sound ("weapons/hookbomb_fire.wav");
216 precache_sound ("weapons/hookbomb_impact.wav");
218 else if (req == WR_SETUP)
220 weapon_setup(WEP_HOOK);
221 self.hook_state &~= HOOK_WAITING_FOR_RELEASE;
223 else if (req == WR_CHECKAMMO1)
225 return self.ammo_cells >= cvar("g_balance_hook_primary_ammo");
227 else if (req == WR_CHECKAMMO2)
229 return self.ammo_cells >= cvar("g_balance_hook_secondary_ammo");
231 else if (req == WR_SUICIDEMESSAGE)
232 w_deathtypestring = "did the impossible";
233 else if (req == WR_KILLMESSAGE)
234 w_deathtypestring = "has run into #'s gravity bomb";