2 REGISTER_WEAPON(HAGAR, w_hagar, IT_ROCKETS, 8, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH, BOT_PICKUP_RATING_MID, "hagar", "hagar", _("Hagar"))
5 // NO bounce protection, as bounces are limited!
7 void W_Hagar_Explode (void)
9 self.event_damage = SUB_Null;
10 RadiusDamage (self, self.realowner, autocvar_g_balance_hagar_primary_damage, autocvar_g_balance_hagar_primary_edgedamage, autocvar_g_balance_hagar_primary_radius, world, autocvar_g_balance_hagar_primary_force, self.projectiledeathtype, other);
15 void W_Hagar_Explode2 (void)
17 self.event_damage = SUB_Null;
18 RadiusDamage (self, self.realowner, autocvar_g_balance_hagar_secondary_damage, autocvar_g_balance_hagar_secondary_edgedamage, autocvar_g_balance_hagar_secondary_radius, world, autocvar_g_balance_hagar_secondary_force, self.projectiledeathtype, other);
23 void W_Hagar_Touch (void)
29 void W_Hagar_Touch2 (void)
33 if(self.cnt > 0 || other.takedamage == DAMAGE_AIM) {
37 pointparticles(particleeffectnum("hagar_bounce"), self.origin, self.velocity, 1);
38 self.angles = vectoangles (self.velocity);
40 self.projectiledeathtype |= HITTYPE_BOUNCE;
44 void W_Hagar_Attack (void)
48 W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_hagar_primary_ammo, autocvar_g_balance_hagar_reload_ammo);
50 W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CH_WEAPON_A, autocvar_g_balance_hagar_primary_damage);
52 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
55 missile.owner = missile.realowner = self;
56 missile.classname = "missile";
57 missile.bot_dodge = TRUE;
58 missile.bot_dodgerating = autocvar_g_balance_hagar_primary_damage;
59 missile.touch = W_Hagar_Touch;
60 missile.use = W_Hagar_Explode;
61 missile.think = adaptor_think2use_hittype_splash;
62 missile.nextthink = time + autocvar_g_balance_hagar_primary_lifetime;
63 PROJECTILE_MAKETRIGGER(missile);
64 missile.projectiledeathtype = WEP_HAGAR;
65 setorigin (missile, w_shotorg);
66 setsize(missile, '0 0 0', '0 0 0');
68 missile.movetype = MOVETYPE_FLY;
69 W_SETUPPROJECTILEVELOCITY(missile, g_balance_hagar_primary);
71 missile.angles = vectoangles (missile.velocity);
72 missile.flags = FL_PROJECTILE;
74 CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR, TRUE);
76 other = missile; MUTATOR_CALLHOOK(EditProjectile);
79 void W_Hagar_Attack2 (void)
83 W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_hagar_secondary_ammo, autocvar_g_balance_hagar_reload_ammo);
85 W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CH_WEAPON_A, autocvar_g_balance_hagar_secondary_damage);
87 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
90 missile.owner = missile.realowner = self;
91 missile.classname = "missile";
92 missile.bot_dodge = TRUE;
93 missile.bot_dodgerating = autocvar_g_balance_hagar_secondary_damage;
94 missile.touch = W_Hagar_Touch2;
96 missile.use = W_Hagar_Explode2;
97 missile.think = adaptor_think2use_hittype_splash;
98 missile.nextthink = time + autocvar_g_balance_hagar_secondary_lifetime_min + random() * autocvar_g_balance_hagar_secondary_lifetime_rand;
99 PROJECTILE_MAKETRIGGER(missile);
100 missile.projectiledeathtype = WEP_HAGAR | HITTYPE_SECONDARY;
101 setorigin (missile, w_shotorg);
102 setsize(missile, '0 0 0', '0 0 0');
104 missile.movetype = MOVETYPE_BOUNCEMISSILE;
105 W_SETUPPROJECTILEVELOCITY(missile, g_balance_hagar_secondary);
107 missile.angles = vectoangles (missile.velocity);
108 missile.flags = FL_PROJECTILE;
110 CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR_BOUNCING, TRUE);
112 other = missile; MUTATOR_CALLHOOK(EditProjectile);
115 .float hagar_loadstep, hagar_loadblock, hagar_loadbeep;
116 void W_Hagar_Attack2_Load_Release (void)
118 // time to release the rockets we've loaded
120 local entity missile;
121 local float counter, shots;
123 vector forward, right, up;
128 weapon_prepareattack_do(1, autocvar_g_balance_hagar_secondary_refire);
130 W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CH_WEAPON_A, autocvar_g_balance_hagar_secondary_damage);
131 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
137 shots = self.hagar_load;
139 while (counter < shots)
142 missile.owner = missile.realowner = self;
143 missile.classname = "missile";
144 missile.bot_dodge = TRUE;
145 missile.bot_dodgerating = autocvar_g_balance_hagar_secondary_damage;
147 missile.touch = W_Hagar_Touch; // not bouncy
148 missile.use = W_Hagar_Explode2;
149 missile.think = adaptor_think2use_hittype_splash;
150 missile.nextthink = time + autocvar_g_balance_hagar_secondary_lifetime_min + random() * autocvar_g_balance_hagar_secondary_lifetime_rand;
151 PROJECTILE_MAKETRIGGER(missile);
152 missile.projectiledeathtype = WEP_HAGAR;
153 setorigin (missile, w_shotorg);
154 setsize(missile, '0 0 0', '0 0 0');
155 missile.movetype = MOVETYPE_FLY;
162 makevectors('0 360 0' * (0.75 + (counter - 0.5) / (shots - 1)));
166 s = s * cvar("g_balance_hagar_secondary_spread") * g_weaponspreadfactor;
167 W_SetupProjectileVelocityEx(missile, w_shotdir + right * s_y + up * s_z, v_up, cvar("g_balance_hagar_secondary_speed"), 0, 0, 0, FALSE);
169 missile.angles = vectoangles (missile.velocity);
170 missile.flags = FL_PROJECTILE;
172 CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR, TRUE);
174 other = missile; MUTATOR_CALLHOOK(EditProjectile);
176 counter = counter + 1;
179 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_hagar_secondary_refire, w_ready);
180 self.hagar_loadstep = time + autocvar_g_balance_hagar_secondary_refire * W_WeaponRateFactor();
184 void W_Hagar_Attack2_Load (void)
186 // loadable hagar secondary attack, must always run each frame
188 local float loaded, enough_ammo;
189 loaded = self.hagar_load >= autocvar_g_balance_hagar_secondary_load_max;
191 // this is different than WR_CHECKAMMO when it comes to reloading
192 if(autocvar_g_balance_hagar_reload_ammo)
193 enough_ammo = self.weapon_load[WEP_HAGAR] >= autocvar_g_balance_hagar_secondary_ammo;
195 enough_ammo = self.ammo_rockets >= autocvar_g_balance_hagar_secondary_ammo;
197 if(self.BUTTON_ATCK2)
199 if(self.BUTTON_ATCK && autocvar_g_balance_hagar_secondary_load_abort)
203 // if we pressed primary fire while loading, unload all rockets and abort
204 self.weaponentity.state = WS_READY;
205 W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_hagar_secondary_ammo * self.hagar_load * -1, autocvar_g_balance_hagar_reload_ammo); // give back ammo
207 sound(self, CH_WEAPON_A, "weapons/hagar_beep.wav", VOL_BASE, ATTN_NORM);
209 // pause until we can load rockets again, once we re-press the alt fire button
210 self.hagar_loadstep = time + autocvar_g_balance_hagar_secondary_load_speed * W_WeaponRateFactor();
212 // require letting go of the alt fire button before we can load again
213 self.hagar_loadblock = TRUE;
218 // check if we can attempt to load another rocket
219 if(!loaded && enough_ammo)
221 if(!self.hagar_loadblock && self.hagar_loadstep < time)
223 W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_hagar_secondary_ammo, autocvar_g_balance_hagar_reload_ammo);
224 self.weaponentity.state = WS_INUSE;
225 self.hagar_load += 1;
226 sound(self, CH_WEAPON_B, "weapons/hagar_load.wav", VOL_BASE, ATTN_NORM);
228 self.hagar_loadstep = time + autocvar_g_balance_hagar_secondary_load_speed * W_WeaponRateFactor();
231 else if(!self.hagar_loadbeep && self.hagar_load) // prevents the beep from playing each frame
233 // if this is the last rocket we can load, play a beep sound to notify the player
234 sound(self, CH_WEAPON_A, "weapons/hagar_beep.wav", VOL_BASE, ATTN_NORM);
235 self.hagar_loadbeep = TRUE;
239 else if(self.hagar_loadblock)
241 // the alt fire button has been released, so re-enable loading if blocked
242 self.hagar_loadblock = FALSE;
247 if(!self.BUTTON_ATCK2 || ((loaded || !enough_ammo) && self.hagar_loadstep < time && !autocvar_g_balance_hagar_secondary_load_hold))
249 self.weaponentity.state = WS_READY;
250 W_Hagar_Attack2_Load_Release();
255 self.hagar_loadbeep = FALSE;
258 // we aren't checking ammo during an attack, so we must do it here
259 if not(weapon_action(self.weapon, WR_CHECKAMMO1) + weapon_action(self.weapon, WR_CHECKAMMO2))
261 // note: this doesn't force the switch
262 W_SwitchToOtherWeapon(self);
267 void spawnfunc_weapon_hagar (void)
269 weapon_defaultspawnfunc(WEP_HAGAR);
272 float w_hagar(float req)
277 self.BUTTON_ATCK = bot_aim(autocvar_g_balance_hagar_primary_speed, 0, autocvar_g_balance_hagar_primary_lifetime, FALSE);
280 // not using secondary_speed since these are only 15% and should cause some ricochets without re-aiming
281 self.BUTTON_ATCK2 = bot_aim(autocvar_g_balance_hagar_primary_speed, 0, autocvar_g_balance_hagar_primary_lifetime, FALSE);
283 else if (req == WR_THINK)
285 local float loadable_secondary;
286 loadable_secondary = autocvar_g_balance_hagar_secondary_load && autocvar_g_balance_hagar_secondary;
288 if (loadable_secondary)
289 W_Hagar_Attack2_Load(); // must always run each frame
290 if(autocvar_g_balance_hagar_reload_ammo && self.clip_load < min(autocvar_g_balance_hagar_primary_ammo, autocvar_g_balance_hagar_secondary_ammo)) // forced reload
291 weapon_action(self.weapon, WR_RELOAD);
292 else if (self.BUTTON_ATCK && !self.hagar_load && !self.hagar_loadblock) // not while secondary is loaded or awaiting reset
294 if (weapon_prepareattack(0, autocvar_g_balance_hagar_primary_refire))
297 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_hagar_primary_refire, w_ready);
300 else if (self.BUTTON_ATCK2 && !loadable_secondary && autocvar_g_balance_hagar_secondary)
302 if (weapon_prepareattack(1, autocvar_g_balance_hagar_secondary_refire))
305 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_hagar_secondary_refire, w_ready);
309 else if (req == WR_GONETHINK)
311 // we lost the weapon and want to prepare switching away
314 self.weaponentity.state = WS_READY;
315 W_Hagar_Attack2_Load_Release();
318 else if (req == WR_PRECACHE)
320 precache_model ("models/weapons/g_hagar.md3");
321 precache_model ("models/weapons/v_hagar.md3");
322 precache_model ("models/weapons/h_hagar.iqm");
323 precache_sound ("weapons/hagar_fire.wav");
324 precache_sound ("weapons/hagar_load.wav");
325 precache_sound ("weapons/hagar_beep.wav");
326 //precache_sound ("weapons/reload.wav"); // until weapons have individual reload sounds, precache the reload sound somewhere else
328 else if (req == WR_SETUP)
330 weapon_setup(WEP_HAGAR);
331 self.current_ammo = ammo_rockets;
332 self.hagar_loadblock = FALSE;
336 W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_hagar_secondary_ammo * self.hagar_load * -1, autocvar_g_balance_hagar_reload_ammo); // give back ammo if necessary
340 else if (req == WR_CHECKAMMO1)
342 ammo_amount = self.ammo_rockets >= autocvar_g_balance_hagar_primary_ammo;
343 ammo_amount += self.weapon_load[WEP_HAGAR] >= autocvar_g_balance_hagar_primary_ammo;
346 else if (req == WR_CHECKAMMO2)
348 ammo_amount = self.ammo_rockets >= autocvar_g_balance_hagar_secondary_ammo;
349 ammo_amount += self.weapon_load[WEP_HAGAR] >= autocvar_g_balance_hagar_secondary_ammo;
352 else if (req == WR_RESETPLAYER)
356 else if (req == WR_PLAYERDEATH)
358 // if we have any rockets loaded when we die, release them
359 if(self.hagar_load && autocvar_g_balance_hagar_secondary_load_releasedeath)
360 W_Hagar_Attack2_Load_Release();
362 else if (req == WR_RELOAD)
364 if not(self.hagar_load) // require releasing loaded rockets first
365 W_Reload(min(autocvar_g_balance_hagar_primary_ammo, autocvar_g_balance_hagar_secondary_ammo), autocvar_g_balance_hagar_reload_ammo, autocvar_g_balance_hagar_reload_time, "weapons/reload.wav");
371 float w_hagar(float req)
373 if(req == WR_IMPACTEFFECT)
376 org2 = w_org + w_backoff * 6;
377 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
381 sound(self, CH_SHOTS, "weapons/hagexp1.wav", VOL_BASE, ATTN_NORM);
382 else if (w_random<0.7)
383 sound(self, CH_SHOTS, "weapons/hagexp2.wav", VOL_BASE, ATTN_NORM);
385 sound(self, CH_SHOTS, "weapons/hagexp3.wav", VOL_BASE, ATTN_NORM);
388 else if(req == WR_PRECACHE)
390 precache_sound("weapons/hagexp1.wav");
391 precache_sound("weapons/hagexp2.wav");
392 precache_sound("weapons/hagexp3.wav");
394 else if (req == WR_SUICIDEMESSAGE)
395 w_deathtypestring = _("%s played with tiny rockets");
396 else if (req == WR_KILLMESSAGE)
398 if(w_deathtype & HITTYPE_BOUNCE) // must be secondary; unchecked: SPLASH
399 w_deathtypestring = _("%s hoped %s's missiles wouldn't bounce");
400 else // unchecked: SPLASH, SECONDARY
401 w_deathtypestring = _("%s was pummeled by %s");