2 REGISTER_WEAPON(GRENADE_LAUNCHER, w_glauncher, IT_ROCKETS, 4, WEP_FLAG_NORMAL | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH, BOT_PICKUP_RATING_MID, "gl", "grenadelauncher", "Mortar");
5 .float gl_detonate_later;
8 void W_Grenade_Explode (void)
10 if(other.takedamage == DAMAGE_AIM)
11 if(other.classname == "player")
12 if(IsDifferentTeam(self.owner, other))
13 if(other.deadflag == DEAD_NO)
15 AnnounceTo(self.owner, "airshot");
17 self.event_damage = SUB_Null;
18 self.takedamage = DAMAGE_NO;
20 if(self.movetype == MOVETYPE_NONE)
21 self.velocity = self.oldvelocity;
23 RadiusDamage (self, self.owner, 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);
28 void W_Grenade_Explode2 (void)
30 if(other.takedamage == DAMAGE_AIM)
31 if(other.classname == "player")
32 if(IsDifferentTeam(self.owner, other))
34 AnnounceTo(self.owner, "airshot");
36 self.event_damage = SUB_Null;
37 self.takedamage = DAMAGE_NO;
39 if(self.movetype == MOVETYPE_NONE)
40 self.velocity = self.oldvelocity;
42 RadiusDamage (self, self.owner, 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);
47 void W_Grenade_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
51 self.health = self.health - damage;
54 W_PrepareExplosionByDamage(attacker, self.think);
58 void W_Grenade_Think1 (void)
60 self.nextthink = time;
64 self.projectiledeathtype |= HITTYPE_BOUNCE;
68 if(self.gl_detonate_later && self.gl_bouncecnt >= autocvar_g_balance_grenadelauncher_primary_remote_minbouncecnt)
72 void W_Grenade_Touch1 (void)
75 if (other.takedamage == DAMAGE_AIM || autocvar_g_balance_grenadelauncher_primary_type == 0) // always explode when hitting a player, or if normal mortar projectile
79 else if (autocvar_g_balance_grenadelauncher_primary_type == 1) // bounce
84 spamsound (self, CHAN_PROJECTILE, "weapons/grenade_bounce1.wav", VOL_BASE, ATTN_NORM);
86 spamsound (self, CHAN_PROJECTILE, "weapons/grenade_bounce2.wav", VOL_BASE, ATTN_NORM);
88 spamsound (self, CHAN_PROJECTILE, "weapons/grenade_bounce3.wav", VOL_BASE, ATTN_NORM);
90 spamsound (self, CHAN_PROJECTILE, "weapons/grenade_bounce4.wav", VOL_BASE, ATTN_NORM);
92 spamsound (self, CHAN_PROJECTILE, "weapons/grenade_bounce5.wav", VOL_BASE, ATTN_NORM);
94 spamsound (self, CHAN_PROJECTILE, "weapons/grenade_bounce6.wav", VOL_BASE, ATTN_NORM);
95 self.projectiledeathtype |= HITTYPE_BOUNCE;
96 self.gl_bouncecnt += 1;
98 else if(autocvar_g_balance_grenadelauncher_primary_type == 2 && (!other || (other.takedamage != DAMAGE_AIM && other.movetype == MOVETYPE_NONE))) // stick
100 spamsound (self, CHAN_PROJECTILE, "weapons/grenade_stick.wav", VOL_BASE, ATTN_NORM);
102 // let it stick whereever it is
103 self.oldvelocity = self.velocity;
104 self.velocity = '0 0 0';
105 self.movetype = MOVETYPE_NONE; // also disables gravity
106 self.gravity = 0; // nope, it does NOT! maybe a bug in CSQC code? TODO
107 UpdateCSQCProjectile(self);
109 // do not respond to any more touches
110 self.solid = SOLID_NOT;
112 self.nextthink = min(self.nextthink, time + autocvar_g_balance_grenadelauncher_primary_lifetime2);
116 void W_Grenade_Touch2 (void)
119 if (other.takedamage == DAMAGE_AIM || autocvar_g_balance_grenadelauncher_secondary_type == 0) // always explode when hitting a player, or if normal mortar projectile
123 else if (autocvar_g_balance_grenadelauncher_secondary_type == 1) // bounce
128 spamsound (self, CHAN_PROJECTILE, "weapons/grenade_bounce1.wav", VOL_BASE, ATTN_NORM);
130 spamsound (self, CHAN_PROJECTILE, "weapons/grenade_bounce2.wav", VOL_BASE, ATTN_NORM);
132 spamsound (self, CHAN_PROJECTILE, "weapons/grenade_bounce3.wav", VOL_BASE, ATTN_NORM);
134 spamsound (self, CHAN_PROJECTILE, "weapons/grenade_bounce4.wav", VOL_BASE, ATTN_NORM);
136 spamsound (self, CHAN_PROJECTILE, "weapons/grenade_bounce5.wav", VOL_BASE, ATTN_NORM);
138 spamsound (self, CHAN_PROJECTILE, "weapons/grenade_bounce6.wav", VOL_BASE, ATTN_NORM);
139 self.projectiledeathtype |= HITTYPE_BOUNCE;
140 self.gl_bouncecnt += 1;
142 else if(autocvar_g_balance_grenadelauncher_secondary_type == 2 && (!other || (other.takedamage != DAMAGE_AIM && other.movetype == MOVETYPE_NONE))) // stick
144 spamsound (self, CHAN_PROJECTILE, "weapons/grenade_stick.wav", VOL_BASE, ATTN_NORM);
146 // let it stick whereever it is
147 self.oldvelocity = self.velocity;
148 self.velocity = '0 0 0';
149 self.movetype = MOVETYPE_NONE; // also disables gravity
150 self.gravity = 0; // nope, it does NOT! maybe a bug in CSQC code? TODO
151 UpdateCSQCProjectile(self);
153 // do not respond to any more touches
154 self.solid = SOLID_NOT;
156 self.nextthink = min(self.nextthink, time + autocvar_g_balance_grenadelauncher_secondary_lifetime2);
160 void W_Grenade_Attack (void)
164 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
165 self.ammo_rockets = self.ammo_rockets - autocvar_g_balance_grenadelauncher_primary_ammo;
166 W_SetupShot_ProjectileSize (self, '-3 -3 -3', '3 3 3', FALSE, 4, "weapons/grenade_fire.wav", CHAN_WEAPON, autocvar_g_balance_grenadelauncher_primary_damage);
167 w_shotdir = v_forward; // no TrueAim for grenades please
169 pointparticles(particleeffectnum("grenadelauncher_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
173 gren.classname = "grenade";
174 gren.bot_dodge = TRUE;
175 gren.bot_dodgerating = autocvar_g_balance_grenadelauncher_primary_damage;
176 gren.movetype = MOVETYPE_BOUNCE;
177 gren.bouncefactor = autocvar_g_balance_grenadelauncher_bouncefactor;
178 gren.bouncestop = autocvar_g_balance_grenadelauncher_bouncestop;
179 PROJECTILE_MAKETRIGGER(gren);
180 gren.projectiledeathtype = WEP_GRENADE_LAUNCHER;
181 setorigin(gren, w_shotorg);
182 setsize(gren, '-3 -3 -3', '3 3 3');
184 gren.cnt = time + autocvar_g_balance_grenadelauncher_primary_lifetime;
185 gren.nextthink = time;
186 gren.think = W_Grenade_Think1;
187 gren.use = W_Grenade_Explode;
188 gren.touch = W_Grenade_Touch1;
190 gren.takedamage = DAMAGE_YES;
191 gren.health = autocvar_g_balance_grenadelauncher_primary_health;
192 gren.damageforcescale = autocvar_g_balance_grenadelauncher_primary_damageforcescale;
193 gren.event_damage = W_Grenade_Damage;
194 W_SETUPPROJECTILEVELOCITY_UP(gren, g_balance_grenadelauncher_primary);
196 gren.angles = vectoangles (gren.velocity);
197 gren.flags = FL_PROJECTILE;
199 if(autocvar_g_balance_grenadelauncher_primary_type == 0 || autocvar_g_balance_grenadelauncher_primary_type == 2)
200 CSQCProjectile(gren, TRUE, PROJECTILE_GRENADE, TRUE);
202 CSQCProjectile(gren, TRUE, PROJECTILE_GRENADE_BOUNCING, TRUE);
204 other = gren; MUTATOR_CALLHOOK(EditProjectile);
207 void W_Grenade_Attack2 (void)
211 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
212 self.ammo_rockets = self.ammo_rockets - autocvar_g_balance_grenadelauncher_secondary_ammo;
213 W_SetupShot_ProjectileSize (self, '-3 -3 -3', '3 3 3', FALSE, 4, "weapons/grenade_fire.wav", CHAN_WEAPON, autocvar_g_balance_grenadelauncher_secondary_damage);
214 w_shotdir = v_forward; // no TrueAim for grenades please
216 pointparticles(particleeffectnum("grenadelauncher_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
220 gren.classname = "grenade";
221 gren.bot_dodge = TRUE;
222 gren.bot_dodgerating = autocvar_g_balance_grenadelauncher_secondary_damage;
223 gren.movetype = MOVETYPE_BOUNCE;
224 gren.bouncefactor = autocvar_g_balance_grenadelauncher_bouncefactor;
225 gren.bouncestop = autocvar_g_balance_grenadelauncher_bouncestop;
226 PROJECTILE_MAKETRIGGER(gren);
227 gren.projectiledeathtype = WEP_GRENADE_LAUNCHER | HITTYPE_SECONDARY;
228 setorigin(gren, w_shotorg);
229 setsize(gren, '-3 -3 -3', '3 3 3');
231 gren.nextthink = time + autocvar_g_balance_grenadelauncher_secondary_lifetime;
232 gren.think = adaptor_think2use_hittype_splash;
233 gren.use = W_Grenade_Explode2;
234 gren.touch = W_Grenade_Touch2;
236 gren.takedamage = DAMAGE_YES;
237 gren.health = autocvar_g_balance_grenadelauncher_secondary_health;
238 gren.damageforcescale = autocvar_g_balance_grenadelauncher_secondary_damageforcescale;
239 gren.event_damage = W_Grenade_Damage;
240 W_SETUPPROJECTILEVELOCITY_UP(gren, g_balance_grenadelauncher_secondary);
242 gren.angles = vectoangles (gren.velocity);
243 gren.flags = FL_PROJECTILE;
245 if(autocvar_g_balance_grenadelauncher_secondary_type == 0 || autocvar_g_balance_grenadelauncher_secondary_type == 2)
246 CSQCProjectile(gren, TRUE, PROJECTILE_GRENADE, TRUE);
248 CSQCProjectile(gren, TRUE, PROJECTILE_GRENADE_BOUNCING, TRUE);
250 other = gren; MUTATOR_CALLHOOK(EditProjectile);
253 void spawnfunc_weapon_grenadelauncher (void)
255 weapon_defaultspawnfunc(WEP_GRENADE_LAUNCHER);
258 .float bot_secondary_grenademooth;
259 float w_glauncher(float req)
266 self.BUTTON_ATCK = FALSE;
267 self.BUTTON_ATCK2 = FALSE;
268 if (self.bot_secondary_grenademooth == 0)
270 if(bot_aim(autocvar_g_balance_grenadelauncher_primary_speed, autocvar_g_balance_grenadelauncher_primary_speed_up, autocvar_g_balance_grenadelauncher_primary_lifetime, TRUE))
272 self.BUTTON_ATCK = TRUE;
273 if(random() < 0.01) self.bot_secondary_grenademooth = 1;
278 if(bot_aim(autocvar_g_balance_grenadelauncher_secondary_speed, autocvar_g_balance_grenadelauncher_secondary_speed_up, autocvar_g_balance_grenadelauncher_secondary_lifetime, TRUE))
280 self.BUTTON_ATCK2 = TRUE;
281 if(random() < 0.02) self.bot_secondary_grenademooth = 0;
285 else if (req == WR_THINK)
287 if (self.BUTTON_ATCK)
288 if (weapon_prepareattack(0, autocvar_g_balance_grenadelauncher_primary_refire))
291 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_grenadelauncher_primary_animtime, w_ready);
293 if (self.BUTTON_ATCK2)
295 if (cvar("g_balance_grenadelauncher_secondary_remote_detonateprimary"))
298 for(nade = world; (nade = find(nade, classname, "grenade")); ) if(nade.owner == self)
300 if(!nade.gl_detonate_later)
302 nade.gl_detonate_later = TRUE;
307 sound (self, CHAN_WEAPON2, "weapons/rocket_det.wav", VOL_BASE, ATTN_NORM);
309 else if (weapon_prepareattack(1, autocvar_g_balance_grenadelauncher_secondary_refire))
312 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_grenadelauncher_secondary_animtime, w_ready);
316 else if (req == WR_PRECACHE)
318 precache_model ("models/weapons/g_gl.md3");
319 precache_model ("models/weapons/v_gl.md3");
320 precache_model ("models/weapons/h_gl.iqm");
321 precache_sound ("weapons/grenade_bounce1.wav");
322 precache_sound ("weapons/grenade_bounce2.wav");
323 precache_sound ("weapons/grenade_bounce3.wav");
324 precache_sound ("weapons/grenade_bounce4.wav");
325 precache_sound ("weapons/grenade_bounce5.wav");
326 precache_sound ("weapons/grenade_bounce6.wav");
327 precache_sound ("weapons/grenade_stick.wav");
328 precache_sound ("weapons/grenade_fire.wav");
330 else if (req == WR_SETUP)
331 weapon_setup(WEP_GRENADE_LAUNCHER);
332 else if (req == WR_CHECKAMMO1)
333 return self.ammo_rockets >= autocvar_g_balance_grenadelauncher_primary_ammo;
334 else if (req == WR_CHECKAMMO2)
335 return self.ammo_rockets >= autocvar_g_balance_grenadelauncher_secondary_ammo;
340 float w_glauncher(float req)
342 if(req == WR_IMPACTEFFECT)
345 org2 = w_org + w_backoff * 12;
346 pointparticles(particleeffectnum("grenade_explode"), org2, '0 0 0', 1);
348 sound(self, CHAN_PROJECTILE, "weapons/grenade_impact.wav", VOL_BASE, ATTN_NORM);
350 else if(req == WR_PRECACHE)
352 precache_sound("weapons/grenade_impact.wav");
354 else if (req == WR_SUICIDEMESSAGE)
356 if(w_deathtype & HITTYPE_SECONDARY)
357 w_deathtypestring = "%s tried out his own grenade";
359 w_deathtypestring = "%s detonated";
361 else if (req == WR_KILLMESSAGE)
363 if(w_deathtype & HITTYPE_SPLASH)
364 if(w_deathtype & HITTYPE_BOUNCE) // (must be secondary then)
365 w_deathtypestring = "%s didn't see %s's grenade";
366 else // unchecked: SECONDARY
367 w_deathtypestring = "%s almost dodged %s's grenade";
368 else // unchecked: SECONDARY, BOUNCE
369 w_deathtypestring = "%s ate %s's grenade";