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 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;
37 self.think = W_Hook_ExplodeThink;
38 self.nextthink = time;
39 self.dmg = cvar("g_balance_hook_secondary_damage");
40 self.dmg_edge = cvar("g_balance_hook_secondary_edgedamage");
41 self.dmg_radius = cvar("g_balance_hook_secondary_radius");
42 self.dmg_force = cvar("g_balance_hook_secondary_force");
43 self.dmg_power = cvar("g_balance_hook_secondary_power");
44 self.dmg_duration = cvar("g_balance_hook_secondary_duration");
45 self.teleport_time = time;
47 self.movetype = MOVETYPE_NONE;
50 void W_Hook_Touch2 (void)
60 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
61 self.ammo_cells = self.ammo_cells - cvar("g_balance_hook_secondary_ammo");
62 W_SetupShot (self, '25 6 -8', FALSE, 4, "weapons/hookbomb_fire.wav");
66 gren.classname = "hookbomb";
67 gren.bot_dodge = TRUE;
68 gren.bot_dodgerating = cvar("g_balance_hook_secondary_damage");
69 gren.movetype = MOVETYPE_TOSS;
70 gren.solid = SOLID_BBOX;
71 gren.projectiledeathtype = WEP_HOOK | HITTYPE_SECONDARY;
72 setmodel(gren, "null"); // precision set above // FIXME replace
73 setsize(gren, '0 0 0', '0 0 0');
74 setorigin(gren, w_shotorg);
76 gren.nextthink = time + cvar("g_balance_hook_secondary_lifetime");
77 gren.think = adaptor_think2use;
78 gren.use = W_Hook_Explode2;
79 gren.touch = W_Hook_Touch2;
81 gren.velocity = '0 0 1' * cvar("g_balance_hook_secondary_speed");
82 if(cvar("g_projectiles_newton_style"))
83 gren.velocity = gren.velocity + self.velocity;
85 gren.gravity = cvar("g_balance_hook_secondary_gravity");
86 //W_SetupProjectileVelocity(gren); // just falling down!
88 gren.angles = '0 0 0';
89 gren.flags = FL_PROJECTILE;
91 CSQCProjectile(gren, TRUE, PROJECTILE_HOOKBOMB);
94 void spawnfunc_weapon_hook (void)
96 if(g_grappling_hook) // offhand hook
98 startitem_failed = TRUE;
102 weapon_defaultspawnfunc(WEP_HOOK);
105 float w_hook(float req)
107 float hooked_time_max, hooked_ammodecrease_delay;
113 else if (req == WR_THINK)
115 if (self.BUTTON_ATCK || self.BUTTON_HOOK)
118 if not(self.hook_state & HOOK_WAITING_FOR_RELEASE)
119 if (time > self.hook_refire)
120 if (weapon_prepareattack(0, -1))
122 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
123 self.ammo_cells = self.ammo_cells - cvar("g_balance_hook_primary_ammo");
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_FIRE1, 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"));
144 if(self.hook && self.hook.state == 1)
146 hooked_time_max = cvar("g_balance_hook_primary_hooked_time_max");
147 if (hooked_time_max > 0)
149 if ( time > self.hook_time_hooked + hooked_time_max )
150 self.hook_state |= HOOK_REMOVING;
153 hooked_ammodecrease_delay = cvar("g_balance_hook_primary_hooked_ammodecrease_delay");
154 if (hooked_ammodecrease_delay > 0)
156 if ( time > self.hook_time_ammodecrease )
158 if ( self.ammo_cells >= 1 )
160 self.ammo_cells -= 1;
161 self.hook_time_ammodecrease = time + hooked_ammodecrease_delay;
165 self.hook_state |= HOOK_REMOVING;
166 W_SwitchWeapon_Force(self, w_getbestweapon(self));
173 self.hook_time_hooked = time;
174 self.hook_time_ammodecrease = time + cvar("g_balance_hook_primary_hooked_time_free");
177 if (self.BUTTON_CROUCH)
179 self.hook_state &~= HOOK_PULLING;
180 if (self.BUTTON_ATCK || self.BUTTON_HOOK)
181 self.hook_state &~= HOOK_RELEASING;
183 self.hook_state |= HOOK_RELEASING;
187 self.hook_state |= HOOK_PULLING;
188 self.hook_state &~= HOOK_RELEASING;
190 if (self.BUTTON_ATCK || self.BUTTON_HOOK)
194 self.hook_state |= HOOK_WAITING_FOR_RELEASE;
198 self.hook_state |= HOOK_REMOVING;
199 self.hook_state &~= HOOK_WAITING_FOR_RELEASE;
203 else if (req == WR_PRECACHE)
205 precache_model ("models/weapons/g_hookgun.md3");
206 precache_model ("models/weapons/v_hookgun.md3");
207 precache_model ("models/weapons/w_hookgun.zym");
208 precache_sound ("weapons/hook_impact.wav"); // done by g_hook.qc
209 precache_sound ("weapons/hook_fire.wav");
210 precache_sound ("weapons/hookbomb_fire.wav");
212 else if (req == WR_SETUP)
214 weapon_setup(WEP_HOOK);
215 self.hook_state &~= HOOK_WAITING_FOR_RELEASE;
217 else if (req == WR_CHECKAMMO1)
219 return self.ammo_cells >= cvar("g_balance_hook_primary_ammo");
221 else if (req == WR_CHECKAMMO2)
223 return self.ammo_cells >= cvar("g_balance_hook_secondary_ammo");
225 else if (req == WR_SUICIDEMESSAGE)
226 w_deathtypestring = "did the impossible";
227 else if (req == WR_KILLMESSAGE)
228 w_deathtypestring = "has run into #'s gravity bomb";