4 /* function */ w_hagar,
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 /* netname */ "hagar",
11 /* fullname */ _("Hagar")
14 #define HAGAR_SETTINGS(w_cvar,w_prop) \
15 w_cvar(WEP_HAGAR, hagar, MO_BOTH, ammo) \
16 w_cvar(WEP_HAGAR, hagar, MO_BOTH, damage) \
17 w_cvar(WEP_HAGAR, hagar, MO_BOTH, edgedamage) \
18 w_cvar(WEP_HAGAR, hagar, MO_BOTH, force) \
19 w_cvar(WEP_HAGAR, hagar, MO_BOTH, radius) \
20 w_cvar(WEP_HAGAR, hagar, MO_BOTH, refire) \
21 w_cvar(WEP_HAGAR, hagar, MO_BOTH, speed) \
22 w_cvar(WEP_HAGAR, hagar, MO_BOTH, spread) \
23 w_cvar(WEP_HAGAR, hagar, MO_BOTH, damageforcescale) \
24 w_cvar(WEP_HAGAR, hagar, MO_BOTH, health) \
25 w_cvar(WEP_HAGAR, hagar, MO_PRI, lifetime) \
26 w_cvar(WEP_HAGAR, hagar, MO_SEC, load) \
27 w_cvar(WEP_HAGAR, hagar, MO_SEC, load_max) \
28 w_cvar(WEP_HAGAR, hagar, MO_SEC, load_abort) \
29 w_cvar(WEP_HAGAR, hagar, MO_SEC, load_animtime) \
30 w_cvar(WEP_HAGAR, hagar, MO_SEC, load_hold) \
31 w_cvar(WEP_HAGAR, hagar, MO_SEC, load_speed) \
32 w_cvar(WEP_HAGAR, hagar, MO_SEC, load_releasedeath) \
33 w_cvar(WEP_HAGAR, hagar, MO_SEC, load_spread) \
34 w_cvar(WEP_HAGAR, hagar, MO_SEC, load_spread_bias) \
35 w_cvar(WEP_HAGAR, hagar, MO_SEC, load_linkexplode) \
36 w_cvar(WEP_HAGAR, hagar, MO_SEC, lifetime_min) \
37 w_cvar(WEP_HAGAR, hagar, MO_SEC, lifetime_rand) \
38 w_cvar(WEP_HAGAR, hagar, MO_NONE, secondary) \
39 w_prop(WEP_HAGAR, hagar, float, reloading_ammo, reload_ammo) \
40 w_prop(WEP_HAGAR, hagar, float, reloading_time, reload_time) \
41 w_prop(WEP_HAGAR, hagar, float, switchdelay_raise, switchdelay_raise) \
42 w_prop(WEP_HAGAR, hagar, float, switchdelay_drop, switchdelay_drop) \
43 w_prop(WEP_HAGAR, hagar, string, weaponreplace, weaponreplace) \
44 w_prop(WEP_HAGAR, hagar, float, weaponstart, weaponstart) \
45 w_prop(WEP_HAGAR, hagar, float, weaponstartoverride, weaponstartoverride)
48 HAGAR_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
52 void spawnfunc_weapon_hagar() { weapon_defaultspawnfunc(WEP_HAGAR); }
54 // NO bounce protection, as bounces are limited!
56 void W_Hagar_Explode (void)
58 self.event_damage = func_null;
59 RadiusDamage (self, self.realowner, WEP_CVAR_PRI(hagar, damage), WEP_CVAR_PRI(hagar, edgedamage), WEP_CVAR_PRI(hagar, radius), world, world, WEP_CVAR_PRI(hagar, force), self.projectiledeathtype, other);
64 void W_Hagar_Explode2 (void)
66 self.event_damage = func_null;
67 RadiusDamage (self, self.realowner, WEP_CVAR_SEC(hagar, damage), WEP_CVAR_SEC(hagar, edgedamage), WEP_CVAR_SEC(hagar, radius), world, world, WEP_CVAR_SEC(hagar, force), self.projectiledeathtype, other);
72 void W_Hagar_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
77 float is_linkexplode = ( ((inflictor.owner != world) ? (inflictor.owner == self.owner) : TRUE)
78 && (inflictor.projectiledeathtype & HITTYPE_SECONDARY)
79 && (self.projectiledeathtype & HITTYPE_SECONDARY));
82 is_linkexplode = (is_linkexplode && WEP_CVAR_SEC(hagar, load_linkexplode));
84 is_linkexplode = -1; // not secondary load, so continue as normal without exception.
86 if (!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, is_linkexplode))
87 return; // g_projectiles_damage says to halt
89 self.health = self.health - damage;
90 self.angles = vectoangles(self.velocity);
93 W_PrepareExplosionByDamage(attacker, self.think);
96 void W_Hagar_Touch (void)
102 void W_Hagar_Touch2 (void)
106 if(self.cnt > 0 || other.takedamage == DAMAGE_AIM) {
110 pointparticles(particleeffectnum("hagar_bounce"), self.origin, self.velocity, 1);
111 self.angles = vectoangles (self.velocity);
113 self.projectiledeathtype |= HITTYPE_BOUNCE;
117 void W_Hagar_Attack (void)
121 W_DecreaseAmmo(ammo_rockets, WEP_CVAR_PRI(hagar, ammo), autocvar_g_balance_hagar_reload_ammo);
123 W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CH_WEAPON_A, WEP_CVAR_PRI(hagar, damage));
125 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
128 missile.owner = missile.realowner = self;
129 missile.classname = "missile";
130 missile.bot_dodge = TRUE;
131 missile.bot_dodgerating = WEP_CVAR_PRI(hagar, damage);
133 missile.takedamage = DAMAGE_YES;
134 missile.health = WEP_CVAR_PRI(hagar, health);
135 missile.damageforcescale = WEP_CVAR_PRI(hagar, damageforcescale);
136 missile.event_damage = W_Hagar_Damage;
137 missile.damagedbycontents = TRUE;
139 missile.touch = W_Hagar_Touch;
140 missile.use = W_Hagar_Explode;
141 missile.think = adaptor_think2use_hittype_splash;
142 missile.nextthink = time + WEP_CVAR_PRI(hagar, lifetime);
143 PROJECTILE_MAKETRIGGER(missile);
144 missile.projectiledeathtype = WEP_HAGAR;
145 setorigin (missile, w_shotorg);
146 setsize(missile, '0 0 0', '0 0 0');
148 missile.movetype = MOVETYPE_FLY;
149 WEP_SETUPPROJVELOCITY_PRI(missile, hagar);
151 missile.angles = vectoangles (missile.velocity);
152 missile.flags = FL_PROJECTILE;
153 missile.missile_flags = MIF_SPLASH;
155 CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR, TRUE);
157 other = missile; MUTATOR_CALLHOOK(EditProjectile);
160 void W_Hagar_Attack2 (void)
164 W_DecreaseAmmo(ammo_rockets, WEP_CVAR_SEC(hagar, ammo), autocvar_g_balance_hagar_reload_ammo);
166 W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CH_WEAPON_A, WEP_CVAR_SEC(hagar, damage));
168 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
171 missile.owner = missile.realowner = self;
172 missile.classname = "missile";
173 missile.bot_dodge = TRUE;
174 missile.bot_dodgerating = WEP_CVAR_SEC(hagar, damage);
176 missile.takedamage = DAMAGE_YES;
177 missile.health = WEP_CVAR_SEC(hagar, health);
178 missile.damageforcescale = WEP_CVAR_SEC(hagar, damageforcescale);
179 missile.event_damage = W_Hagar_Damage;
180 missile.damagedbycontents = TRUE;
182 missile.touch = W_Hagar_Touch2;
184 missile.use = W_Hagar_Explode2;
185 missile.think = adaptor_think2use_hittype_splash;
186 missile.nextthink = time + WEP_CVAR_SEC(hagar, lifetime_min) + random() * WEP_CVAR_SEC(hagar, lifetime_rand);
187 PROJECTILE_MAKETRIGGER(missile);
188 missile.projectiledeathtype = WEP_HAGAR | HITTYPE_SECONDARY;
189 setorigin (missile, w_shotorg);
190 setsize(missile, '0 0 0', '0 0 0');
192 missile.movetype = MOVETYPE_BOUNCEMISSILE;
193 WEP_SETUPPROJVELOCITY_SEC(missile, hagar);
195 missile.angles = vectoangles (missile.velocity);
196 missile.flags = FL_PROJECTILE;
197 missile.missile_flags = MIF_SPLASH;
199 CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR_BOUNCING, TRUE);
201 other = missile; MUTATOR_CALLHOOK(EditProjectile);
204 .float hagar_loadstep, hagar_loadblock, hagar_loadbeep, hagar_warning;
205 void W_Hagar_Attack2_Load_Release (void)
207 // time to release the rockets we've loaded
210 float counter, shots, spread_pershot;
212 vector forward, right, up;
217 weapon_prepareattack_do(1, WEP_CVAR_SEC(hagar, refire));
219 W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CH_WEAPON_A, WEP_CVAR_SEC(hagar, damage));
220 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
226 shots = self.hagar_load;
228 for(counter = 0; counter < shots; ++counter)
231 missile.owner = missile.realowner = self;
232 missile.classname = "missile";
233 missile.bot_dodge = TRUE;
234 missile.bot_dodgerating = WEP_CVAR_SEC(hagar, damage);
236 missile.takedamage = DAMAGE_YES;
237 missile.health = WEP_CVAR_SEC(hagar, health);
238 missile.damageforcescale = WEP_CVAR_SEC(hagar, damageforcescale);
239 missile.event_damage = W_Hagar_Damage;
240 missile.damagedbycontents = TRUE;
242 missile.touch = W_Hagar_Touch; // not bouncy
243 missile.use = W_Hagar_Explode2;
244 missile.think = adaptor_think2use_hittype_splash;
245 missile.nextthink = time + WEP_CVAR_SEC(hagar, lifetime_min) + random() * WEP_CVAR_SEC(hagar, lifetime_rand);
246 PROJECTILE_MAKETRIGGER(missile);
247 missile.projectiledeathtype = WEP_HAGAR | HITTYPE_SECONDARY;
248 setorigin (missile, w_shotorg);
249 setsize(missile, '0 0 0', '0 0 0');
250 missile.movetype = MOVETYPE_FLY;
251 missile.missile_flags = MIF_SPLASH;
253 // per-shot spread calculation: the more shots there are, the less spread is applied (based on the bias cvar)
254 spread_pershot = ((shots - 1) / (WEP_CVAR_SEC(hagar, load_max) - 1));
255 spread_pershot = (1 - (spread_pershot * WEP_CVAR_SEC(hagar, load_spread_bias)));
256 spread_pershot = (WEP_CVAR_SEC(hagar, spread) * spread_pershot * g_weaponspreadfactor);
258 // pattern spread calculation
264 makevectors('0 360 0' * (0.75 + (counter - 0.5) / (shots - 1)));
268 s = s * WEP_CVAR_SEC(hagar, load_spread) * g_weaponspreadfactor;
270 W_SetupProjectileVelocityEx(missile, w_shotdir + right * s_y + up * s_z, v_up, WEP_CVAR_SEC(hagar, speed), 0, 0, spread_pershot, FALSE);
272 missile.angles = vectoangles (missile.velocity);
273 missile.flags = FL_PROJECTILE;
275 CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR, TRUE);
277 other = missile; MUTATOR_CALLHOOK(EditProjectile);
280 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(hagar, load_animtime), w_ready);
281 self.hagar_loadstep = time + WEP_CVAR_SEC(hagar, refire) * W_WeaponRateFactor();
285 void W_Hagar_Attack2_Load (void)
287 // loadable hagar secondary attack, must always run each frame
289 if(time < game_starttime)
292 float loaded, enough_ammo;
293 loaded = self.hagar_load >= WEP_CVAR_SEC(hagar, load_max);
295 // this is different than WR_CHECKAMMO when it comes to reloading
296 if(autocvar_g_balance_hagar_reload_ammo)
297 enough_ammo = self.(weapon_load[WEP_HAGAR]) >= WEP_CVAR_SEC(hagar, ammo);
299 enough_ammo = self.ammo_rockets >= WEP_CVAR_SEC(hagar, ammo);
301 if(self.BUTTON_ATCK2)
303 if(self.BUTTON_ATCK && WEP_CVAR_SEC(hagar, load_abort))
307 // if we pressed primary fire while loading, unload all rockets and abort
308 self.weaponentity.state = WS_READY;
309 W_DecreaseAmmo(ammo_rockets, WEP_CVAR_SEC(hagar, ammo) * self.hagar_load * -1, autocvar_g_balance_hagar_reload_ammo); // give back ammo
311 sound(self, CH_WEAPON_A, "weapons/hagar_beep.wav", VOL_BASE, ATTN_NORM);
313 // pause until we can load rockets again, once we re-press the alt fire button
314 self.hagar_loadstep = time + WEP_CVAR_SEC(hagar, load_speed) * W_WeaponRateFactor();
316 // require letting go of the alt fire button before we can load again
317 self.hagar_loadblock = TRUE;
322 // check if we can attempt to load another rocket
323 if(!loaded && enough_ammo)
325 if(!self.hagar_loadblock && self.hagar_loadstep < time)
327 W_DecreaseAmmo(ammo_rockets, WEP_CVAR_SEC(hagar, ammo), autocvar_g_balance_hagar_reload_ammo);
328 self.weaponentity.state = WS_INUSE;
329 self.hagar_load += 1;
330 sound(self, CH_WEAPON_B, "weapons/hagar_load.wav", VOL_BASE * 0.8, ATTN_NORM); // sound is too loud according to most
332 if (self.hagar_load >= WEP_CVAR_SEC(hagar, load_max))
333 self.hagar_loadstep = time + WEP_CVAR_SEC(hagar, load_hold) * W_WeaponRateFactor();
335 self.hagar_loadstep = time + WEP_CVAR_SEC(hagar, load_speed) * W_WeaponRateFactor();
338 else if(!self.hagar_loadbeep && self.hagar_load) // prevents the beep from playing each frame
340 // if this is the last rocket we can load, play a beep sound to notify the player
341 sound(self, CH_WEAPON_A, "weapons/hagar_beep.wav", VOL_BASE, ATTN_NORM);
342 self.hagar_loadbeep = TRUE;
346 else if(self.hagar_loadblock)
348 // the alt fire button has been released, so re-enable loading if blocked
349 self.hagar_loadblock = FALSE;
354 // play warning sound if we're about to release
355 if((loaded || !enough_ammo) && self.hagar_loadstep - 0.5 < time && WEP_CVAR_SEC(hagar, load_hold) >= 0)
357 if(!self.hagar_warning && self.hagar_load) // prevents the beep from playing each frame
359 // we're about to automatically release after holding time, play a beep sound to notify the player
360 sound(self, CH_WEAPON_A, "weapons/hagar_beep.wav", VOL_BASE, ATTN_NORM);
361 self.hagar_warning = TRUE;
365 // release if player let go of button or if they've held it in too long
366 if(!self.BUTTON_ATCK2 || ((loaded || !enough_ammo) && self.hagar_loadstep < time && WEP_CVAR_SEC(hagar, load_hold) >= 0))
368 self.weaponentity.state = WS_READY;
369 W_Hagar_Attack2_Load_Release();
374 self.hagar_loadbeep = FALSE;
375 self.hagar_warning = FALSE;
378 // we aren't checking ammo during an attack, so we must do it here
379 if(!(WEP_ACTION(self.weapon, WR_CHECKAMMO1) + WEP_ACTION(self.weapon, WR_CHECKAMMO2)))
381 // note: this doesn't force the switch
382 W_SwitchToOtherWeapon(self);
387 float w_hagar(float req)
395 self.BUTTON_ATCK = bot_aim(WEP_CVAR_PRI(hagar, speed), 0, WEP_CVAR_PRI(hagar, lifetime), FALSE);
396 else // not using secondary_speed since these are only 15% and should cause some ricochets without re-aiming
397 self.BUTTON_ATCK2 = bot_aim(WEP_CVAR_PRI(hagar, speed), 0, WEP_CVAR_PRI(hagar, lifetime), FALSE);
403 float loadable_secondary;
404 loadable_secondary = (WEP_CVAR_SEC(hagar, load) && WEP_CVAR(hagar, secondary));
406 if (loadable_secondary)
407 W_Hagar_Attack2_Load(); // must always run each frame
408 if(autocvar_g_balance_hagar_reload_ammo && self.clip_load < min(WEP_CVAR_PRI(hagar, ammo), WEP_CVAR_SEC(hagar, ammo))) // forced reload
409 WEP_ACTION(self.weapon, WR_RELOAD);
410 else if (self.BUTTON_ATCK && !self.hagar_load && !self.hagar_loadblock) // not while secondary is loaded or awaiting reset
412 if (weapon_prepareattack(0, WEP_CVAR_PRI(hagar, refire)))
415 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(hagar, refire), w_ready);
418 else if (self.BUTTON_ATCK2 && !loadable_secondary && WEP_CVAR(hagar, secondary))
420 if (weapon_prepareattack(1, WEP_CVAR_SEC(hagar, refire)))
423 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(hagar, refire), w_ready);
431 // we lost the weapon and want to prepare switching away
434 self.weaponentity.state = WS_READY;
435 W_Hagar_Attack2_Load_Release();
442 precache_model ("models/weapons/g_hagar.md3");
443 precache_model ("models/weapons/v_hagar.md3");
444 precache_model ("models/weapons/h_hagar.iqm");
445 precache_sound ("weapons/hagar_fire.wav");
446 precache_sound ("weapons/hagar_load.wav");
447 precache_sound ("weapons/hagar_beep.wav");
448 HAGAR_SETTINGS(WEP_SKIPCVAR, WEP_SET_PROP)
453 self.current_ammo = ammo_rockets;
454 self.hagar_loadblock = FALSE;
458 W_DecreaseAmmo(ammo_rockets, WEP_CVAR_SEC(hagar, ammo) * self.hagar_load * -1, autocvar_g_balance_hagar_reload_ammo); // give back ammo if necessary
466 ammo_amount = self.ammo_rockets >= WEP_CVAR_PRI(hagar, ammo);
467 ammo_amount += self.(weapon_load[WEP_HAGAR]) >= WEP_CVAR_PRI(hagar, ammo);
472 ammo_amount = self.ammo_rockets >= WEP_CVAR_SEC(hagar, ammo);
473 ammo_amount += self.(weapon_load[WEP_HAGAR]) >= WEP_CVAR_SEC(hagar, ammo);
478 HAGAR_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS)
488 // if we have any rockets loaded when we die, release them
489 if(self.hagar_load && WEP_CVAR_SEC(hagar, load_releasedeath))
490 W_Hagar_Attack2_Load_Release();
496 if(!self.hagar_load) // require releasing loaded rockets first
497 W_Reload(min(WEP_CVAR_PRI(hagar, ammo), WEP_CVAR_SEC(hagar, ammo)), "weapons/reload.wav");
501 case WR_SUICIDEMESSAGE:
503 return WEAPON_HAGAR_SUICIDE;
507 if(w_deathtype & HITTYPE_SECONDARY)
508 return WEAPON_HAGAR_MURDER_BURST;
510 return WEAPON_HAGAR_MURDER_SPRAY;
517 float w_hagar(float req)
521 case WR_IMPACTEFFECT:
524 org2 = w_org + w_backoff * 6;
525 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
529 sound(self, CH_SHOTS, "weapons/hagexp1.wav", VOL_BASE, ATTN_NORM);
530 else if (w_random<0.7)
531 sound(self, CH_SHOTS, "weapons/hagexp2.wav", VOL_BASE, ATTN_NORM);
533 sound(self, CH_SHOTS, "weapons/hagexp3.wav", VOL_BASE, ATTN_NORM);
540 precache_sound("weapons/hagexp1.wav");
541 precache_sound("weapons/hagexp2.wav");
542 precache_sound("weapons/hagexp3.wav");