3 /* WEP_##id */ GRENADE_LAUNCHER,
4 /* function */ w_glauncher,
5 /* ammotype */ IT_ROCKETS,
7 /* flags */ WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH,
8 /* rating */ BOT_PICKUP_RATING_MID,
10 /* shortname */ "grenadelauncher",
11 /* fullname */ _("Mortar")
15 .float gl_detonate_later;
18 void W_Grenade_Explode (void)
20 if(other.takedamage == DAMAGE_AIM)
22 if(DIFF_TEAM(self.realowner, other))
23 if(other.deadflag == DEAD_NO)
25 Send_Notification(NOTIF_ONE, self.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_AIRSHOT);
27 self.event_damage = func_null;
28 self.takedamage = DAMAGE_NO;
30 if(self.movetype == MOVETYPE_NONE)
31 self.velocity = self.oldvelocity;
33 RadiusDamage (self, self.realowner, autocvar_g_balance_grenadelauncher_primary_damage, autocvar_g_balance_grenadelauncher_primary_edgedamage, autocvar_g_balance_grenadelauncher_primary_radius, world, autocvar_g_balance_grenadelauncher_primary_force, self.projectiledeathtype, other);
38 void W_Grenade_Explode2 (void)
40 if(other.takedamage == DAMAGE_AIM)
42 if(DIFF_TEAM(self.realowner, other))
43 if(other.deadflag == DEAD_NO)
45 Send_Notification(NOTIF_ONE, self.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_AIRSHOT);
47 self.event_damage = func_null;
48 self.takedamage = DAMAGE_NO;
50 if(self.movetype == MOVETYPE_NONE)
51 self.velocity = self.oldvelocity;
53 RadiusDamage (self, self.realowner, autocvar_g_balance_grenadelauncher_secondary_damage, autocvar_g_balance_grenadelauncher_secondary_edgedamage, autocvar_g_balance_grenadelauncher_secondary_radius, world, autocvar_g_balance_grenadelauncher_secondary_force, self.projectiledeathtype, other);
58 void W_Grenade_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
63 if (!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, -1)) // no exceptions
64 return; // g_projectiles_damage says to halt
66 self.health = self.health - damage;
69 W_PrepareExplosionByDamage(attacker, self.use);
72 void W_Grenade_Think1 (void)
74 self.nextthink = time;
78 self.projectiledeathtype |= HITTYPE_BOUNCE;
82 if(self.gl_detonate_later && self.gl_bouncecnt >= autocvar_g_balance_grenadelauncher_primary_remote_minbouncecnt)
86 void W_Grenade_Touch1 (void)
89 if (other.takedamage == DAMAGE_AIM || autocvar_g_balance_grenadelauncher_primary_type == 0) // always explode when hitting a player, or if normal mortar projectile
93 else if (autocvar_g_balance_grenadelauncher_primary_type == 1) // bounce
98 spamsound (self, CH_SHOTS, "weapons/grenade_bounce1.wav", VOL_BASE, ATTEN_NORM);
100 spamsound (self, CH_SHOTS, "weapons/grenade_bounce2.wav", VOL_BASE, ATTEN_NORM);
102 spamsound (self, CH_SHOTS, "weapons/grenade_bounce3.wav", VOL_BASE, ATTEN_NORM);
104 spamsound (self, CH_SHOTS, "weapons/grenade_bounce4.wav", VOL_BASE, ATTEN_NORM);
106 spamsound (self, CH_SHOTS, "weapons/grenade_bounce5.wav", VOL_BASE, ATTEN_NORM);
108 spamsound (self, CH_SHOTS, "weapons/grenade_bounce6.wav", VOL_BASE, ATTEN_NORM);
109 self.projectiledeathtype |= HITTYPE_BOUNCE;
110 self.gl_bouncecnt += 1;
112 else if(autocvar_g_balance_grenadelauncher_primary_type == 2 && (!other || (other.takedamage != DAMAGE_AIM && other.movetype == MOVETYPE_NONE))) // stick
114 spamsound (self, CH_SHOTS, "weapons/grenade_stick.wav", VOL_BASE, ATTEN_NORM);
116 // let it stick whereever it is
117 self.oldvelocity = self.velocity;
118 self.velocity = '0 0 0';
119 self.movetype = MOVETYPE_NONE; // also disables gravity
120 self.gravity = 0; // nope, it does NOT! maybe a bug in CSQC code? TODO
121 UpdateCSQCProjectile(self);
123 // do not respond to any more touches
124 self.solid = SOLID_NOT;
126 self.nextthink = min(self.nextthink, time + autocvar_g_balance_grenadelauncher_primary_lifetime_stick);
130 void W_Grenade_Touch2 (void)
133 if (other.takedamage == DAMAGE_AIM || autocvar_g_balance_grenadelauncher_secondary_type == 0) // always explode when hitting a player, or if normal mortar projectile
137 else if (autocvar_g_balance_grenadelauncher_secondary_type == 1) // bounce
142 spamsound (self, CH_SHOTS, "weapons/grenade_bounce1.wav", VOL_BASE, ATTEN_NORM);
144 spamsound (self, CH_SHOTS, "weapons/grenade_bounce2.wav", VOL_BASE, ATTEN_NORM);
146 spamsound (self, CH_SHOTS, "weapons/grenade_bounce3.wav", VOL_BASE, ATTEN_NORM);
148 spamsound (self, CH_SHOTS, "weapons/grenade_bounce4.wav", VOL_BASE, ATTEN_NORM);
150 spamsound (self, CH_SHOTS, "weapons/grenade_bounce5.wav", VOL_BASE, ATTEN_NORM);
152 spamsound (self, CH_SHOTS, "weapons/grenade_bounce6.wav", VOL_BASE, ATTEN_NORM);
153 self.projectiledeathtype |= HITTYPE_BOUNCE;
154 self.gl_bouncecnt += 1;
156 if (autocvar_g_balance_grenadelauncher_secondary_lifetime_bounce && self.gl_bouncecnt == 1)
157 self.nextthink = time + autocvar_g_balance_grenadelauncher_secondary_lifetime_bounce;
160 else if(autocvar_g_balance_grenadelauncher_secondary_type == 2 && (!other || (other.takedamage != DAMAGE_AIM && other.movetype == MOVETYPE_NONE))) // stick
162 spamsound (self, CH_SHOTS, "weapons/grenade_stick.wav", VOL_BASE, ATTEN_NORM);
164 // let it stick whereever it is
165 self.oldvelocity = self.velocity;
166 self.velocity = '0 0 0';
167 self.movetype = MOVETYPE_NONE; // also disables gravity
168 self.gravity = 0; // nope, it does NOT! maybe a bug in CSQC code? TODO
169 UpdateCSQCProjectile(self);
171 // do not respond to any more touches
172 self.solid = SOLID_NOT;
174 self.nextthink = min(self.nextthink, time + autocvar_g_balance_grenadelauncher_secondary_lifetime_stick);
178 void W_Grenade_Attack (void)
182 W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_grenadelauncher_primary_ammo, autocvar_g_balance_grenadelauncher_reload_ammo);
184 W_SetupShot_ProjectileSize (self, '-3 -3 -3', '3 3 3', FALSE, 4, "weapons/grenade_fire.wav", CH_WEAPON_A, autocvar_g_balance_grenadelauncher_primary_damage);
185 w_shotdir = v_forward; // no TrueAim for grenades please
187 pointparticles(particleeffectnum("grenadelauncher_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
190 gren.owner = gren.realowner = self;
191 gren.classname = "grenade";
192 gren.bot_dodge = TRUE;
193 gren.bot_dodgerating = autocvar_g_balance_grenadelauncher_primary_damage;
194 gren.movetype = MOVETYPE_BOUNCE;
195 gren.bouncefactor = autocvar_g_balance_grenadelauncher_bouncefactor;
196 gren.bouncestop = autocvar_g_balance_grenadelauncher_bouncestop;
197 PROJECTILE_MAKETRIGGER(gren);
198 gren.projectiledeathtype = WEP_GRENADE_LAUNCHER;
199 setorigin(gren, w_shotorg);
200 setsize(gren, '-3 -3 -3', '3 3 3');
202 gren.cnt = time + autocvar_g_balance_grenadelauncher_primary_lifetime;
203 gren.nextthink = time;
204 gren.think = W_Grenade_Think1;
205 gren.use = W_Grenade_Explode;
206 gren.touch = W_Grenade_Touch1;
208 gren.takedamage = DAMAGE_YES;
209 gren.health = autocvar_g_balance_grenadelauncher_primary_health;
210 gren.damageforcescale = autocvar_g_balance_grenadelauncher_primary_damageforcescale;
211 gren.event_damage = W_Grenade_Damage;
212 gren.damagedbycontents = TRUE;
213 gren.missile_flags = MIF_SPLASH | MIF_ARC;
214 W_SETUPPROJECTILEVELOCITY_UP(gren, g_balance_grenadelauncher_primary);
216 gren.angles = vectoangles (gren.velocity);
217 gren.flags = FL_PROJECTILE;
219 if(autocvar_g_balance_grenadelauncher_primary_type == 0 || autocvar_g_balance_grenadelauncher_primary_type == 2)
220 CSQCProjectile(gren, TRUE, PROJECTILE_GRENADE, TRUE);
222 CSQCProjectile(gren, TRUE, PROJECTILE_GRENADE_BOUNCING, TRUE);
224 other = gren; MUTATOR_CALLHOOK(EditProjectile);
227 void W_Grenade_Attack2 (void)
231 W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_grenadelauncher_secondary_ammo, autocvar_g_balance_grenadelauncher_reload_ammo);
233 W_SetupShot_ProjectileSize (self, '-3 -3 -3', '3 3 3', FALSE, 4, "weapons/grenade_fire.wav", CH_WEAPON_A, autocvar_g_balance_grenadelauncher_secondary_damage);
234 w_shotdir = v_forward; // no TrueAim for grenades please
236 pointparticles(particleeffectnum("grenadelauncher_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
239 gren.owner = gren.realowner = self;
240 gren.classname = "grenade";
241 gren.bot_dodge = TRUE;
242 gren.bot_dodgerating = autocvar_g_balance_grenadelauncher_secondary_damage;
243 gren.movetype = MOVETYPE_BOUNCE;
244 gren.bouncefactor = autocvar_g_balance_grenadelauncher_bouncefactor;
245 gren.bouncestop = autocvar_g_balance_grenadelauncher_bouncestop;
246 PROJECTILE_MAKETRIGGER(gren);
247 gren.projectiledeathtype = WEP_GRENADE_LAUNCHER | HITTYPE_SECONDARY;
248 setorigin(gren, w_shotorg);
249 setsize(gren, '-3 -3 -3', '3 3 3');
251 gren.nextthink = time + autocvar_g_balance_grenadelauncher_secondary_lifetime;
252 gren.think = adaptor_think2use_hittype_splash;
253 gren.use = W_Grenade_Explode2;
254 gren.touch = W_Grenade_Touch2;
256 gren.takedamage = DAMAGE_YES;
257 gren.health = autocvar_g_balance_grenadelauncher_secondary_health;
258 gren.damageforcescale = autocvar_g_balance_grenadelauncher_secondary_damageforcescale;
259 gren.event_damage = W_Grenade_Damage;
260 gren.damagedbycontents = TRUE;
261 gren.missile_flags = MIF_SPLASH | MIF_ARC;
262 W_SETUPPROJECTILEVELOCITY_UP(gren, g_balance_grenadelauncher_secondary);
264 gren.angles = vectoangles (gren.velocity);
265 gren.flags = FL_PROJECTILE;
267 if(autocvar_g_balance_grenadelauncher_secondary_type == 0 || autocvar_g_balance_grenadelauncher_secondary_type == 2)
268 CSQCProjectile(gren, TRUE, PROJECTILE_GRENADE, TRUE);
270 CSQCProjectile(gren, TRUE, PROJECTILE_GRENADE_BOUNCING, TRUE);
272 other = gren; MUTATOR_CALLHOOK(EditProjectile);
275 void spawnfunc_weapon_grenadelauncher (void)
277 weapon_defaultspawnfunc(WEP_GRENADE_LAUNCHER);
280 .float bot_secondary_grenademooth;
281 float w_glauncher(float req)
289 self.BUTTON_ATCK = FALSE;
290 self.BUTTON_ATCK2 = FALSE;
291 if (self.bot_secondary_grenademooth == 0)
293 if(bot_aim(autocvar_g_balance_grenadelauncher_primary_speed, autocvar_g_balance_grenadelauncher_primary_speed_up, autocvar_g_balance_grenadelauncher_primary_lifetime, TRUE))
295 self.BUTTON_ATCK = TRUE;
296 if(random() < 0.01) self.bot_secondary_grenademooth = 1;
301 if(bot_aim(autocvar_g_balance_grenadelauncher_secondary_speed, autocvar_g_balance_grenadelauncher_secondary_speed_up, autocvar_g_balance_grenadelauncher_secondary_lifetime, TRUE))
303 self.BUTTON_ATCK2 = TRUE;
304 if(random() < 0.02) self.bot_secondary_grenademooth = 0;
308 else if (req == WR_THINK)
310 if(autocvar_g_balance_grenadelauncher_reload_ammo && self.clip_load < min(autocvar_g_balance_grenadelauncher_primary_ammo, autocvar_g_balance_grenadelauncher_secondary_ammo)) // forced reload
311 weapon_action(self.weapon, WR_RELOAD);
312 else if (self.BUTTON_ATCK)
314 if (weapon_prepareattack(0, autocvar_g_balance_grenadelauncher_primary_refire))
317 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_grenadelauncher_primary_animtime, w_ready);
320 else if (self.BUTTON_ATCK2)
322 if (cvar("g_balance_grenadelauncher_secondary_remote_detonateprimary"))
325 for(nade = world; (nade = find(nade, classname, "grenade")); ) if(nade.realowner == self)
327 if(!nade.gl_detonate_later)
329 nade.gl_detonate_later = TRUE;
334 sound (self, CH_WEAPON_B, "weapons/rocket_det.wav", VOL_BASE, ATTEN_NORM);
336 else if (weapon_prepareattack(1, autocvar_g_balance_grenadelauncher_secondary_refire))
339 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_grenadelauncher_secondary_animtime, w_ready);
343 else if (req == WR_PRECACHE)
345 precache_model ("models/weapons/g_gl.md3");
346 precache_model ("models/weapons/v_gl.md3");
347 precache_model ("models/weapons/h_gl.iqm");
348 precache_sound ("weapons/grenade_bounce1.wav");
349 precache_sound ("weapons/grenade_bounce2.wav");
350 precache_sound ("weapons/grenade_bounce3.wav");
351 precache_sound ("weapons/grenade_bounce4.wav");
352 precache_sound ("weapons/grenade_bounce5.wav");
353 precache_sound ("weapons/grenade_bounce6.wav");
354 precache_sound ("weapons/grenade_stick.wav");
355 precache_sound ("weapons/grenade_fire.wav");
356 //precache_sound ("weapons/reload.wav"); // until weapons have individual reload sounds, precache the reload sound somewhere else
358 else if (req == WR_SETUP)
360 weapon_setup(WEP_GRENADE_LAUNCHER);
361 self.current_ammo = ammo_rockets;
363 else if (req == WR_CHECKAMMO1)
365 ammo_amount = self.ammo_rockets >= autocvar_g_balance_grenadelauncher_primary_ammo;
366 ammo_amount += self.(weapon_load[WEP_GRENADE_LAUNCHER]) >= autocvar_g_balance_grenadelauncher_primary_ammo;
369 else if (req == WR_CHECKAMMO2)
371 ammo_amount = self.ammo_rockets >= autocvar_g_balance_grenadelauncher_secondary_ammo;
372 ammo_amount += self.(weapon_load[WEP_GRENADE_LAUNCHER]) >= autocvar_g_balance_grenadelauncher_secondary_ammo;
375 else if (req == WR_RELOAD)
377 W_Reload(min(autocvar_g_balance_grenadelauncher_primary_ammo, autocvar_g_balance_grenadelauncher_secondary_ammo), autocvar_g_balance_grenadelauncher_reload_ammo, autocvar_g_balance_grenadelauncher_reload_time, "weapons/reload.wav");
379 else if (req == WR_SUICIDEMESSAGE)
381 if(w_deathtype & HITTYPE_SECONDARY)
382 return WEAPON_MORTAR_SUICIDE_BOUNCE;
384 return WEAPON_MORTAR_SUICIDE_EXPLODE;
386 else if (req == WR_KILLMESSAGE)
388 if(w_deathtype & HITTYPE_SECONDARY)
389 return WEAPON_MORTAR_MURDER_BOUNCE;
391 return WEAPON_MORTAR_MURDER_EXPLODE;
397 float w_glauncher(float req)
399 if(req == WR_IMPACTEFFECT)
402 org2 = w_org + w_backoff * 12;
403 pointparticles(particleeffectnum("grenade_explode"), org2, '0 0 0', 1);
405 sound(self, CH_SHOTS, "weapons/grenade_impact.wav", VOL_BASE, ATTEN_NORM);
407 else if(req == WR_PRECACHE)
409 precache_sound("weapons/grenade_impact.wav");