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_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
28 float is_linkexplode = ( ((inflictor.owner != world) ? (inflictor.owner == self.owner) : TRUE)
29 && (inflictor.projectiledeathtype & HITTYPE_SECONDARY)
30 && (self.projectiledeathtype & HITTYPE_SECONDARY));
33 is_linkexplode = (is_linkexplode && autocvar_g_balance_hagar_secondary_load_linkexplode);
35 is_linkexplode = -1; // not secondary load, so continue as normal without exception.
37 if (!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, is_linkexplode))
38 return; // g_projectiles_damage says to halt
40 self.health = self.health - damage;
41 self.angles = vectoangles(self.velocity);
44 W_PrepareExplosionByDamage(attacker, self.think);
47 void W_Hagar_Touch (void)
53 void W_Hagar_Touch2 (void)
57 if(self.cnt > 0 || other.takedamage == DAMAGE_AIM) {
61 pointparticles(particleeffectnum("hagar_bounce"), self.origin, self.velocity, 1);
62 self.angles = vectoangles (self.velocity);
64 self.projectiledeathtype |= HITTYPE_BOUNCE;
68 void W_Hagar_Attack (void)
72 W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_hagar_primary_ammo, autocvar_g_balance_hagar_reload_ammo);
74 W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CH_WEAPON_A, autocvar_g_balance_hagar_primary_damage);
76 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
79 missile.owner = missile.realowner = self;
80 missile.classname = "missile";
81 missile.bot_dodge = TRUE;
82 missile.bot_dodgerating = autocvar_g_balance_hagar_primary_damage;
84 missile.takedamage = DAMAGE_YES;
85 missile.health = autocvar_g_balance_hagar_primary_health;
86 missile.damageforcescale = autocvar_g_balance_hagar_primary_damageforcescale;
87 missile.event_damage = W_Hagar_Damage;
88 missile.damagedbycontents = TRUE;
90 missile.touch = W_Hagar_Touch;
91 missile.use = W_Hagar_Explode;
92 missile.think = adaptor_think2use_hittype_splash;
93 missile.nextthink = time + autocvar_g_balance_hagar_primary_lifetime;
94 PROJECTILE_MAKETRIGGER(missile);
95 missile.projectiledeathtype = WEP_HAGAR;
96 setorigin (missile, w_shotorg);
97 setsize(missile, '0 0 0', '0 0 0');
99 missile.movetype = MOVETYPE_FLY;
100 W_SETUPPROJECTILEVELOCITY(missile, g_balance_hagar_primary);
102 missile.angles = vectoangles (missile.velocity);
103 missile.flags = FL_PROJECTILE;
105 CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR, TRUE);
107 other = missile; MUTATOR_CALLHOOK(EditProjectile);
110 void W_Hagar_Attack2 (void)
114 W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_hagar_secondary_ammo, autocvar_g_balance_hagar_reload_ammo);
116 W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CH_WEAPON_A, autocvar_g_balance_hagar_secondary_damage);
118 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
121 missile.owner = missile.realowner = self;
122 missile.classname = "missile";
123 missile.bot_dodge = TRUE;
124 missile.bot_dodgerating = autocvar_g_balance_hagar_secondary_damage;
126 missile.takedamage = DAMAGE_YES;
127 missile.health = autocvar_g_balance_hagar_secondary_health;
128 missile.damageforcescale = autocvar_g_balance_hagar_secondary_damageforcescale;
129 missile.event_damage = W_Hagar_Damage;
130 missile.damagedbycontents = TRUE;
132 missile.touch = W_Hagar_Touch2;
134 missile.use = W_Hagar_Explode2;
135 missile.think = adaptor_think2use_hittype_splash;
136 missile.nextthink = time + autocvar_g_balance_hagar_secondary_lifetime_min + random() * autocvar_g_balance_hagar_secondary_lifetime_rand;
137 PROJECTILE_MAKETRIGGER(missile);
138 missile.projectiledeathtype = WEP_HAGAR | HITTYPE_SECONDARY;
139 setorigin (missile, w_shotorg);
140 setsize(missile, '0 0 0', '0 0 0');
142 missile.movetype = MOVETYPE_BOUNCEMISSILE;
143 W_SETUPPROJECTILEVELOCITY(missile, g_balance_hagar_secondary);
145 missile.angles = vectoangles (missile.velocity);
146 missile.flags = FL_PROJECTILE;
148 CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR_BOUNCING, TRUE);
150 other = missile; MUTATOR_CALLHOOK(EditProjectile);
153 .float hagar_loadstep, hagar_loadblock, hagar_loadbeep, hagar_warning;
154 void W_Hagar_Attack2_Load_Release (void)
156 // time to release the rockets we've loaded
159 float counter, shots, spread_pershot;
161 vector forward, right, up;
166 weapon_prepareattack_do(1, autocvar_g_balance_hagar_secondary_refire);
168 W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CH_WEAPON_A, autocvar_g_balance_hagar_secondary_damage);
169 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
175 shots = self.hagar_load;
177 for(counter = 0; counter < shots; ++counter)
180 missile.owner = missile.realowner = self;
181 missile.classname = "missile";
182 missile.bot_dodge = TRUE;
183 missile.bot_dodgerating = autocvar_g_balance_hagar_secondary_damage;
185 missile.takedamage = DAMAGE_YES;
186 missile.health = autocvar_g_balance_hagar_secondary_health;
187 missile.damageforcescale = autocvar_g_balance_hagar_secondary_damageforcescale;
188 missile.event_damage = W_Hagar_Damage;
189 missile.damagedbycontents = TRUE;
191 missile.touch = W_Hagar_Touch; // not bouncy
192 missile.use = W_Hagar_Explode2;
193 missile.think = adaptor_think2use_hittype_splash;
194 missile.nextthink = time + autocvar_g_balance_hagar_secondary_lifetime_min + random() * autocvar_g_balance_hagar_secondary_lifetime_rand;
195 PROJECTILE_MAKETRIGGER(missile);
196 missile.projectiledeathtype = WEP_HAGAR | HITTYPE_SECONDARY;
197 setorigin (missile, w_shotorg);
198 setsize(missile, '0 0 0', '0 0 0');
199 missile.movetype = MOVETYPE_FLY;
201 // per-shot spread calculation: the more shots there are, the less spread is applied (based on the bias cvar)
202 spread_pershot = ((shots - 1) / (autocvar_g_balance_hagar_secondary_load_max - 1));
203 spread_pershot = (1 - (spread_pershot * autocvar_g_balance_hagar_secondary_load_spread_bias));
204 spread_pershot = (autocvar_g_balance_hagar_secondary_spread * spread_pershot * g_weaponspreadfactor);
206 // pattern spread calculation
212 makevectors('0 360 0' * (0.75 + (counter - 0.5) / (shots - 1)));
216 s = s * autocvar_g_balance_hagar_secondary_load_spread * g_weaponspreadfactor;
218 W_SetupProjectileVelocityEx(missile, w_shotdir + right * s_y + up * s_z, v_up, autocvar_g_balance_hagar_secondary_speed, 0, 0, spread_pershot, FALSE);
220 missile.angles = vectoangles (missile.velocity);
221 missile.flags = FL_PROJECTILE;
223 CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR, TRUE);
225 other = missile; MUTATOR_CALLHOOK(EditProjectile);
228 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_hagar_secondary_load_animtime, w_ready);
229 self.hagar_loadstep = time + autocvar_g_balance_hagar_secondary_refire * W_WeaponRateFactor();
233 void W_Hagar_Attack2_Load (void)
235 // loadable hagar secondary attack, must always run each frame
237 float loaded, enough_ammo;
238 loaded = self.hagar_load >= autocvar_g_balance_hagar_secondary_load_max;
240 // this is different than WR_CHECKAMMO when it comes to reloading
241 if(autocvar_g_balance_hagar_reload_ammo)
242 enough_ammo = self.(weapon_load[WEP_HAGAR]) >= autocvar_g_balance_hagar_secondary_ammo;
244 enough_ammo = self.ammo_rockets >= autocvar_g_balance_hagar_secondary_ammo;
246 if(self.BUTTON_ATCK2)
248 if(self.BUTTON_ATCK && autocvar_g_balance_hagar_secondary_load_abort)
252 // if we pressed primary fire while loading, unload all rockets and abort
253 self.weaponentity.state = WS_READY;
254 W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_hagar_secondary_ammo * self.hagar_load * -1, autocvar_g_balance_hagar_reload_ammo); // give back ammo
256 sound(self, CH_WEAPON_A, "weapons/hagar_beep.wav", VOL_BASE, ATTN_NORM);
258 // pause until we can load rockets again, once we re-press the alt fire button
259 self.hagar_loadstep = time + autocvar_g_balance_hagar_secondary_load_speed * W_WeaponRateFactor();
261 // require letting go of the alt fire button before we can load again
262 self.hagar_loadblock = TRUE;
267 // check if we can attempt to load another rocket
268 if(!loaded && enough_ammo)
270 if(!self.hagar_loadblock && self.hagar_loadstep < time)
272 W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_hagar_secondary_ammo, autocvar_g_balance_hagar_reload_ammo);
273 self.weaponentity.state = WS_INUSE;
274 self.hagar_load += 1;
275 sound(self, CH_WEAPON_B, "weapons/hagar_load.wav", VOL_BASE * 0.8, ATTN_NORM); // sound is too loud according to most
277 if (self.hagar_load >= autocvar_g_balance_hagar_secondary_load_max)
278 self.hagar_loadstep = time + autocvar_g_balance_hagar_secondary_load_hold * W_WeaponRateFactor();
280 self.hagar_loadstep = time + autocvar_g_balance_hagar_secondary_load_speed * W_WeaponRateFactor();
283 else if(!self.hagar_loadbeep && self.hagar_load) // prevents the beep from playing each frame
285 // if this is the last rocket we can load, play a beep sound to notify the player
286 sound(self, CH_WEAPON_A, "weapons/hagar_beep.wav", VOL_BASE, ATTN_NORM);
287 self.hagar_loadbeep = TRUE;
291 else if(self.hagar_loadblock)
293 // the alt fire button has been released, so re-enable loading if blocked
294 self.hagar_loadblock = FALSE;
299 // play warning sound if we're about to release
300 if((loaded || !enough_ammo) && self.hagar_loadstep - 0.5 < time && autocvar_g_balance_hagar_secondary_load_hold >= 0)
302 if(!self.hagar_warning && self.hagar_load) // prevents the beep from playing each frame
304 // we're about to automatically release after holding time, play a beep sound to notify the player
305 sound(self, CH_WEAPON_A, "weapons/hagar_beep.wav", VOL_BASE, ATTN_NORM);
306 self.hagar_warning = TRUE;
310 // release if player let go of button or if they've held it in too long
311 if(!self.BUTTON_ATCK2 || ((loaded || !enough_ammo) && self.hagar_loadstep < time && autocvar_g_balance_hagar_secondary_load_hold >= 0))
313 self.weaponentity.state = WS_READY;
314 W_Hagar_Attack2_Load_Release();
319 self.hagar_loadbeep = FALSE;
320 self.hagar_warning = FALSE;
323 // we aren't checking ammo during an attack, so we must do it here
324 if not(weapon_action(self.weapon, WR_CHECKAMMO1) + weapon_action(self.weapon, WR_CHECKAMMO2))
326 // note: this doesn't force the switch
327 W_SwitchToOtherWeapon(self);
332 void spawnfunc_weapon_hagar (void)
334 weapon_defaultspawnfunc(WEP_HAGAR);
337 float w_hagar(float req)
342 self.BUTTON_ATCK = bot_aim(autocvar_g_balance_hagar_primary_speed, 0, autocvar_g_balance_hagar_primary_lifetime, FALSE);
345 // not using secondary_speed since these are only 15% and should cause some ricochets without re-aiming
346 self.BUTTON_ATCK2 = bot_aim(autocvar_g_balance_hagar_primary_speed, 0, autocvar_g_balance_hagar_primary_lifetime, FALSE);
348 else if (req == WR_THINK)
350 float loadable_secondary;
351 loadable_secondary = autocvar_g_balance_hagar_secondary_load && autocvar_g_balance_hagar_secondary;
353 if (loadable_secondary)
354 W_Hagar_Attack2_Load(); // must always run each frame
355 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
356 weapon_action(self.weapon, WR_RELOAD);
357 else if (self.BUTTON_ATCK && !self.hagar_load && !self.hagar_loadblock) // not while secondary is loaded or awaiting reset
359 if (weapon_prepareattack(0, autocvar_g_balance_hagar_primary_refire))
362 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_hagar_primary_refire, w_ready);
365 else if (self.BUTTON_ATCK2 && !loadable_secondary && autocvar_g_balance_hagar_secondary)
367 if (weapon_prepareattack(1, autocvar_g_balance_hagar_secondary_refire))
370 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_hagar_secondary_refire, w_ready);
374 else if (req == WR_GONETHINK)
376 // we lost the weapon and want to prepare switching away
379 self.weaponentity.state = WS_READY;
380 W_Hagar_Attack2_Load_Release();
383 else if (req == WR_PRECACHE)
385 precache_model ("models/weapons/g_hagar.md3");
386 precache_model ("models/weapons/v_hagar.md3");
387 precache_model ("models/weapons/h_hagar.iqm");
388 precache_sound ("weapons/hagar_fire.wav");
389 precache_sound ("weapons/hagar_load.wav");
390 precache_sound ("weapons/hagar_beep.wav");
391 //precache_sound ("weapons/reload.wav"); // until weapons have individual reload sounds, precache the reload sound somewhere else
393 else if (req == WR_SETUP)
395 weapon_setup(WEP_HAGAR);
396 self.current_ammo = ammo_rockets;
397 self.hagar_loadblock = FALSE;
401 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
405 else if (req == WR_CHECKAMMO1)
407 ammo_amount = self.ammo_rockets >= autocvar_g_balance_hagar_primary_ammo;
408 ammo_amount += self.(weapon_load[WEP_HAGAR]) >= autocvar_g_balance_hagar_primary_ammo;
411 else if (req == WR_CHECKAMMO2)
413 ammo_amount = self.ammo_rockets >= autocvar_g_balance_hagar_secondary_ammo;
414 ammo_amount += self.(weapon_load[WEP_HAGAR]) >= autocvar_g_balance_hagar_secondary_ammo;
417 else if (req == WR_RESETPLAYER)
421 else if (req == WR_PLAYERDEATH)
423 // if we have any rockets loaded when we die, release them
424 if(self.hagar_load && autocvar_g_balance_hagar_secondary_load_releasedeath)
425 W_Hagar_Attack2_Load_Release();
427 else if (req == WR_RELOAD)
429 if not(self.hagar_load) // require releasing loaded rockets first
430 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");
436 float w_hagar(float req)
438 if(req == WR_IMPACTEFFECT)
441 org2 = w_org + w_backoff * 6;
442 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
446 sound(self, CH_SHOTS, "weapons/hagexp1.wav", VOL_BASE, ATTN_NORM);
447 else if (w_random<0.7)
448 sound(self, CH_SHOTS, "weapons/hagexp2.wav", VOL_BASE, ATTN_NORM);
450 sound(self, CH_SHOTS, "weapons/hagexp3.wav", VOL_BASE, ATTN_NORM);
453 else if(req == WR_PRECACHE)
455 precache_sound("weapons/hagexp1.wav");
456 precache_sound("weapons/hagexp2.wav");
457 precache_sound("weapons/hagexp3.wav");
459 else if (req == WR_SUICIDEMESSAGE)
460 w_deathtypestring = _("%s played with tiny hagar rockets");
461 else if (req == WR_KILLMESSAGE)
463 if(w_deathtype & HITTYPE_BOUNCE) // must be secondary; unchecked: SPLASH
464 w_deathtypestring = _("%s was pummeled with a burst of hagar rockets by %s");
465 else // unchecked: SPLASH, SECONDARY
466 w_deathtypestring = _("%s was pummeled with hagar rockets by %s");