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 void W_Grenade_Explode (void)
7 if(other.takedamage == DAMAGE_AIM)
8 if(other.classname == "player")
9 if(IsDifferentTeam(self.owner, other))
10 if(other.deadflag == DEAD_NO)
12 AnnounceTo(self.owner, "airshot");
14 self.event_damage = SUB_Null;
15 self.takedamage = DAMAGE_NO;
16 RadiusDamage (self, self.owner, cvar("g_balance_grenadelauncher_primary_damage"), cvar("g_balance_grenadelauncher_primary_edgedamage"), cvar("g_balance_grenadelauncher_primary_radius"), world, cvar("g_balance_grenadelauncher_primary_force"), self.projectiledeathtype, other);
21 void W_Grenade_Explode2 (void)
23 if(other.takedamage == DAMAGE_AIM)
24 if(other.classname == "player")
25 if(IsDifferentTeam(self.owner, other))
27 AnnounceTo(self.owner, "airshot");
29 self.event_damage = SUB_Null;
30 self.takedamage = DAMAGE_NO;
31 RadiusDamage (self, self.owner, cvar("g_balance_grenadelauncher_secondary_damage"), cvar("g_balance_grenadelauncher_secondary_edgedamage"), cvar("g_balance_grenadelauncher_secondary_radius"), world, cvar("g_balance_grenadelauncher_secondary_force"), self.projectiledeathtype, other);
36 void W_Grenade_Touch1 (void)
42 void W_Grenade_Touch2 (void)
45 if (other.takedamage == DAMAGE_AIM)
54 spamsound (self, CHAN_PROJECTILE, "weapons/grenade_bounce1.wav", VOL_BASE, ATTN_NORM);
56 spamsound (self, CHAN_PROJECTILE, "weapons/grenade_bounce2.wav", VOL_BASE, ATTN_NORM);
58 spamsound (self, CHAN_PROJECTILE, "weapons/grenade_bounce3.wav", VOL_BASE, ATTN_NORM);
60 spamsound (self, CHAN_PROJECTILE, "weapons/grenade_bounce4.wav", VOL_BASE, ATTN_NORM);
62 spamsound (self, CHAN_PROJECTILE, "weapons/grenade_bounce5.wav", VOL_BASE, ATTN_NORM);
64 spamsound (self, CHAN_PROJECTILE, "weapons/grenade_bounce6.wav", VOL_BASE, ATTN_NORM);
65 self.projectiledeathtype |= HITTYPE_BOUNCE;
69 void W_Grenade_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
73 self.health = self.health - damage;
76 W_PrepareExplosionByDamage(attacker, self.think);
80 void W_Grenade_Attack (void)
84 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
85 self.ammo_rockets = self.ammo_rockets - cvar("g_balance_grenadelauncher_primary_ammo");
86 W_SetupShot_ProjectileSize (self, '0 0 -3', '0 0 -3', FALSE, 4, "weapons/grenade_fire.wav", cvar("g_balance_grenadelauncher_primary_damage"));
87 w_shotdir = v_forward; // no TrueAim for grenades please
89 pointparticles(particleeffectnum("grenadelauncher_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
93 gren.classname = "grenade";
94 gren.bot_dodge = TRUE;
95 gren.bot_dodgerating = cvar("g_balance_grenadelauncher_primary_damage");
96 gren.movetype = MOVETYPE_BOUNCE;
97 PROJECTILE_MAKETRIGGER(gren);
98 gren.projectiledeathtype = WEP_GRENADE_LAUNCHER;
99 setorigin(gren, w_shotorg);
100 setsize(gren, '0 0 -3', '0 0 -3');
102 gren.nextthink = time + cvar("g_balance_grenadelauncher_primary_lifetime");
103 gren.think = adaptor_think2use_hittype_splash;
104 gren.use = W_Grenade_Explode;
105 gren.touch = W_Grenade_Touch1;
106 W_SETUPPROJECTILEVELOCITY_UP(gren, g_balance_grenadelauncher_primary);
108 gren.angles = vectoangles (gren.velocity);
109 gren.flags = FL_PROJECTILE;
111 CSQCProjectile(gren, TRUE, PROJECTILE_GRENADE, TRUE);
114 void W_Grenade_Attack2 (void)
118 if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
119 self.ammo_rockets = self.ammo_rockets - cvar("g_balance_grenadelauncher_secondary_ammo");
120 W_SetupShot_ProjectileSize (self, '0 0 -3', '0 0 -3', FALSE, 4, "weapons/grenade_fire.wav", cvar("g_balance_grenadelauncher_secondary_damage"));
121 w_shotdir = v_forward; // no TrueAim for grenades please
123 pointparticles(particleeffectnum("grenadelauncher_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
127 gren.classname = "grenade";
128 gren.bot_dodge = TRUE;
129 gren.bot_dodgerating = cvar("g_balance_grenadelauncher_secondary_damage");
130 gren.movetype = MOVETYPE_BOUNCE;
131 gren.bouncefactor = cvar("g_balance_grenadelauncher_secondary_bouncefactor");
132 gren.bouncestop = cvar("g_balance_grenadelauncher_secondary_bouncestop");
133 PROJECTILE_MAKETRIGGER(gren);
134 gren.projectiledeathtype = WEP_GRENADE_LAUNCHER | HITTYPE_SECONDARY;
135 setsize(gren, '0 0 -3', '0 0 -3');
136 setorigin(gren, w_shotorg);
138 gren.nextthink = time + cvar("g_balance_grenadelauncher_secondary_lifetime");
139 gren.think = adaptor_think2use_hittype_splash;
140 gren.use = W_Grenade_Explode2;
141 gren.touch = W_Grenade_Touch2;
142 gren.takedamage = DAMAGE_YES;
143 gren.health = cvar("g_balance_grenadelauncher_secondary_health");
144 gren.damageforcescale = cvar("g_balance_grenadelauncher_secondary_damageforcescale");
145 gren.event_damage = W_Grenade_Damage;
146 W_SETUPPROJECTILEVELOCITY_UP(gren, g_balance_grenadelauncher_secondary);
148 gren.angles = vectoangles (gren.velocity);
149 gren.flags = FL_PROJECTILE;
151 CSQCProjectile(gren, TRUE, PROJECTILE_GRENADE_BOUNCING, TRUE);
154 void spawnfunc_weapon_grenadelauncher (void)
156 weapon_defaultspawnfunc(WEP_GRENADE_LAUNCHER);
159 .float bot_secondary_grenademooth;
160 float w_glauncher(float req)
164 self.BUTTON_ATCK = FALSE;
165 self.BUTTON_ATCK2 = FALSE;
166 if (self.bot_secondary_grenademooth == 0)
168 if(bot_aim(cvar("g_balance_grenadelauncher_primary_speed"), cvar("g_balance_grenadelauncher_primary_speed_up"), cvar("g_balance_grenadelauncher_primary_lifetime"), TRUE))
170 self.BUTTON_ATCK = TRUE;
171 if(random() < 0.01) self.bot_secondary_grenademooth = 1;
176 if(bot_aim(cvar("g_balance_grenadelauncher_secondary_speed"), cvar("g_balance_grenadelauncher_secondary_speed_up"), cvar("g_balance_grenadelauncher_secondary_lifetime"), TRUE))
178 self.BUTTON_ATCK2 = TRUE;
179 if(random() < 0.02) self.bot_secondary_grenademooth = 0;
183 else if (req == WR_THINK)
185 if (self.BUTTON_ATCK)
186 if (weapon_prepareattack(0, cvar("g_balance_grenadelauncher_primary_refire")))
188 if(cvar("g_balance_grenadelauncher_primary2secondary"))
192 weapon_thinkf(WFRAME_FIRE1, cvar("g_balance_grenadelauncher_primary_animtime"), w_ready);
194 if (self.BUTTON_ATCK2 && !cvar("g_balance_grenadelauncher_primary2secondary"))
195 if (weapon_prepareattack(1, cvar("g_balance_grenadelauncher_secondary_refire")))
198 weapon_thinkf(WFRAME_FIRE2, cvar("g_balance_grenadelauncher_secondary_animtime"), w_ready);
201 else if (req == WR_PRECACHE)
203 precache_model ("models/weapons/g_gl.md3");
204 precache_model ("models/weapons/v_gl.md3");
205 precache_model ("models/weapons/h_gl.iqm");
206 precache_sound ("weapons/grenade_bounce1.wav");
207 precache_sound ("weapons/grenade_bounce2.wav");
208 precache_sound ("weapons/grenade_bounce3.wav");
209 precache_sound ("weapons/grenade_bounce4.wav");
210 precache_sound ("weapons/grenade_bounce5.wav");
211 precache_sound ("weapons/grenade_bounce6.wav");
212 precache_sound ("weapons/grenade_fire.wav");
214 else if (req == WR_SETUP)
215 weapon_setup(WEP_GRENADE_LAUNCHER);
216 else if (req == WR_CHECKAMMO1)
217 return self.ammo_rockets >= cvar("g_balance_grenadelauncher_primary_ammo");
218 else if (req == WR_CHECKAMMO2)
219 return self.ammo_rockets >= cvar("g_balance_grenadelauncher_secondary_ammo");
224 float w_glauncher(float req)
226 if(req == WR_IMPACTEFFECT)
229 org2 = w_org + w_backoff * 12;
230 pointparticles(particleeffectnum("grenade_explode"), org2, '0 0 0', 1);
232 sound(self, CHAN_PROJECTILE, "weapons/grenade_impact.wav", VOL_BASE, ATTN_NORM);
234 else if(req == WR_PRECACHE)
236 precache_sound("weapons/grenade_impact.wav");
238 else if (req == WR_SUICIDEMESSAGE)
240 if(w_deathtype & HITTYPE_SECONDARY)
241 w_deathtypestring = "tried out his own grenade";
243 w_deathtypestring = "detonated";
245 else if (req == WR_KILLMESSAGE)
247 if(w_deathtype & HITTYPE_SPLASH)
248 if(w_deathtype & HITTYPE_BOUNCE) // (must be secondary then)
249 w_deathtypestring = "didn't see #'s grenade";
250 else // unchecked: SECONDARY
251 w_deathtypestring = "almost dodged #'s grenade";
252 else // unchecked: SECONDARY, BOUNCE
253 w_deathtypestring = "ate #'s grenade";