4 /* function */ W_Hagar,
5 /* ammotype */ ammo_rockets,
7 /* flags */ WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH,
8 /* rating */ BOT_PICKUP_RATING_MID,
11 /* netname */ "hagar",
12 /* fullname */ _("Hagar")
15 #define HAGAR_SETTINGS(w_cvar,w_prop) HAGAR_SETTINGS_LIST(w_cvar, w_prop, HAGAR, hagar)
16 #define HAGAR_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
17 w_cvar(id, sn, BOTH, ammo) \
18 w_cvar(id, sn, BOTH, damage) \
19 w_cvar(id, sn, BOTH, edgedamage) \
20 w_cvar(id, sn, BOTH, force) \
21 w_cvar(id, sn, BOTH, radius) \
22 w_cvar(id, sn, BOTH, refire) \
23 w_cvar(id, sn, BOTH, speed) \
24 w_cvar(id, sn, BOTH, spread) \
25 w_cvar(id, sn, BOTH, damageforcescale) \
26 w_cvar(id, sn, BOTH, health) \
27 w_cvar(id, sn, PRI, lifetime) \
28 w_cvar(id, sn, SEC, load) \
29 w_cvar(id, sn, SEC, load_max) \
30 w_cvar(id, sn, SEC, load_abort) \
31 w_cvar(id, sn, SEC, load_animtime) \
32 w_cvar(id, sn, SEC, load_hold) \
33 w_cvar(id, sn, SEC, load_speed) \
34 w_cvar(id, sn, SEC, load_releasedeath) \
35 w_cvar(id, sn, SEC, load_spread) \
36 w_cvar(id, sn, SEC, load_spread_bias) \
37 w_cvar(id, sn, SEC, load_linkexplode) \
38 w_cvar(id, sn, SEC, lifetime_min) \
39 w_cvar(id, sn, SEC, lifetime_rand) \
40 w_cvar(id, sn, NONE, secondary) \
41 w_prop(id, sn, float, reloading_ammo, reload_ammo) \
42 w_prop(id, sn, float, reloading_time, reload_time) \
43 w_prop(id, sn, float, switchdelay_raise, switchdelay_raise) \
44 w_prop(id, sn, float, switchdelay_drop, switchdelay_drop) \
45 w_prop(id, sn, string, weaponreplace, weaponreplace) \
46 w_prop(id, sn, float, weaponstart, weaponstart) \
47 w_prop(id, sn, float, weaponstartoverride, weaponstartoverride)
50 HAGAR_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
54 void spawnfunc_weapon_hagar() { weapon_defaultspawnfunc(WEP_HAGAR); }
56 // NO bounce protection, as bounces are limited!
58 void W_Hagar_Explode (void)
60 self.event_damage = func_null;
61 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);
66 void W_Hagar_Explode2 (void)
68 self.event_damage = func_null;
69 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);
74 void W_Hagar_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
79 float is_linkexplode = ( ((inflictor.owner != world) ? (inflictor.owner == self.owner) : TRUE)
80 && (inflictor.projectiledeathtype & HITTYPE_SECONDARY)
81 && (self.projectiledeathtype & HITTYPE_SECONDARY));
84 is_linkexplode = (is_linkexplode && WEP_CVAR_SEC(hagar, load_linkexplode));
86 is_linkexplode = -1; // not secondary load, so continue as normal without exception.
88 if (!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, is_linkexplode))
89 return; // g_projectiles_damage says to halt
91 self.health = self.health - damage;
92 self.angles = vectoangles(self.velocity);
95 W_PrepareExplosionByDamage(attacker, self.think);
98 void W_Hagar_Touch (void)
104 void W_Hagar_Touch2 (void)
108 if(self.cnt > 0 || other.takedamage == DAMAGE_AIM) {
112 pointparticles(particleeffectnum("hagar_bounce"), self.origin, self.velocity, 1);
113 self.angles = vectoangles (self.velocity);
115 self.projectiledeathtype |= HITTYPE_BOUNCE;
119 void W_Hagar_Attack (void)
123 W_DecreaseAmmo(WEP_CVAR_PRI(hagar, ammo));
125 W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CH_WEAPON_A, WEP_CVAR_PRI(hagar, damage));
127 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
130 missile.owner = missile.realowner = self;
131 missile.classname = "missile";
132 missile.bot_dodge = TRUE;
133 missile.bot_dodgerating = WEP_CVAR_PRI(hagar, damage);
135 missile.takedamage = DAMAGE_YES;
136 missile.health = WEP_CVAR_PRI(hagar, health);
137 missile.damageforcescale = WEP_CVAR_PRI(hagar, damageforcescale);
138 missile.event_damage = W_Hagar_Damage;
139 missile.damagedbycontents = TRUE;
141 missile.touch = W_Hagar_Touch;
142 missile.use = W_Hagar_Explode;
143 missile.think = adaptor_think2use_hittype_splash;
144 missile.nextthink = time + WEP_CVAR_PRI(hagar, lifetime);
145 PROJECTILE_MAKETRIGGER(missile);
146 missile.projectiledeathtype = WEP_HAGAR;
147 setorigin (missile, w_shotorg);
148 setsize(missile, '0 0 0', '0 0 0');
150 missile.movetype = MOVETYPE_FLY;
151 W_SetupProjVelocity_PRI(missile, hagar);
153 missile.angles = vectoangles (missile.velocity);
154 missile.flags = FL_PROJECTILE;
155 missile.missile_flags = MIF_SPLASH;
157 CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR, TRUE);
159 other = missile; MUTATOR_CALLHOOK(EditProjectile);
162 void W_Hagar_Attack2 (void)
166 W_DecreaseAmmo(WEP_CVAR_SEC(hagar, ammo));
168 W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CH_WEAPON_A, WEP_CVAR_SEC(hagar, damage));
170 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
173 missile.owner = missile.realowner = self;
174 missile.classname = "missile";
175 missile.bot_dodge = TRUE;
176 missile.bot_dodgerating = WEP_CVAR_SEC(hagar, damage);
178 missile.takedamage = DAMAGE_YES;
179 missile.health = WEP_CVAR_SEC(hagar, health);
180 missile.damageforcescale = WEP_CVAR_SEC(hagar, damageforcescale);
181 missile.event_damage = W_Hagar_Damage;
182 missile.damagedbycontents = TRUE;
184 missile.touch = W_Hagar_Touch2;
186 missile.use = W_Hagar_Explode2;
187 missile.think = adaptor_think2use_hittype_splash;
188 missile.nextthink = time + WEP_CVAR_SEC(hagar, lifetime_min) + random() * WEP_CVAR_SEC(hagar, lifetime_rand);
189 PROJECTILE_MAKETRIGGER(missile);
190 missile.projectiledeathtype = WEP_HAGAR | HITTYPE_SECONDARY;
191 setorigin (missile, w_shotorg);
192 setsize(missile, '0 0 0', '0 0 0');
194 missile.movetype = MOVETYPE_BOUNCEMISSILE;
195 W_SetupProjVelocity_SEC(missile, hagar);
197 missile.angles = vectoangles (missile.velocity);
198 missile.flags = FL_PROJECTILE;
199 missile.missile_flags = MIF_SPLASH;
201 CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR_BOUNCING, TRUE);
203 other = missile; MUTATOR_CALLHOOK(EditProjectile);
206 .float hagar_loadstep, hagar_loadblock, hagar_loadbeep, hagar_warning;
207 void W_Hagar_Attack2_Load_Release (void)
209 // time to release the rockets we've loaded
212 float counter, shots, spread_pershot;
214 vector forward, right, up;
219 weapon_prepareattack_do(1, WEP_CVAR_SEC(hagar, refire));
221 W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CH_WEAPON_A, WEP_CVAR_SEC(hagar, damage));
222 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
228 shots = self.hagar_load;
230 for(counter = 0; counter < shots; ++counter)
233 missile.owner = missile.realowner = self;
234 missile.classname = "missile";
235 missile.bot_dodge = TRUE;
236 missile.bot_dodgerating = WEP_CVAR_SEC(hagar, damage);
238 missile.takedamage = DAMAGE_YES;
239 missile.health = WEP_CVAR_SEC(hagar, health);
240 missile.damageforcescale = WEP_CVAR_SEC(hagar, damageforcescale);
241 missile.event_damage = W_Hagar_Damage;
242 missile.damagedbycontents = TRUE;
244 missile.touch = W_Hagar_Touch; // not bouncy
245 missile.use = W_Hagar_Explode2;
246 missile.think = adaptor_think2use_hittype_splash;
247 missile.nextthink = time + WEP_CVAR_SEC(hagar, lifetime_min) + random() * WEP_CVAR_SEC(hagar, lifetime_rand);
248 PROJECTILE_MAKETRIGGER(missile);
249 missile.projectiledeathtype = WEP_HAGAR | HITTYPE_SECONDARY;
250 setorigin (missile, w_shotorg);
251 setsize(missile, '0 0 0', '0 0 0');
252 missile.movetype = MOVETYPE_FLY;
253 missile.missile_flags = MIF_SPLASH;
255 // per-shot spread calculation: the more shots there are, the less spread is applied (based on the bias cvar)
256 spread_pershot = ((shots - 1) / (WEP_CVAR_SEC(hagar, load_max) - 1));
257 spread_pershot = (1 - (spread_pershot * WEP_CVAR_SEC(hagar, load_spread_bias)));
258 spread_pershot = (WEP_CVAR_SEC(hagar, spread) * spread_pershot * g_weaponspreadfactor);
260 // pattern spread calculation
266 makevectors('0 360 0' * (0.75 + (counter - 0.5) / (shots - 1)));
270 s = s * WEP_CVAR_SEC(hagar, load_spread) * g_weaponspreadfactor;
272 W_SetupProjVelocity_Explicit(missile, w_shotdir + right * s_y + up * s_z, v_up, WEP_CVAR_SEC(hagar, speed), 0, 0, spread_pershot, FALSE);
274 missile.angles = vectoangles (missile.velocity);
275 missile.flags = FL_PROJECTILE;
277 CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR, TRUE);
279 other = missile; MUTATOR_CALLHOOK(EditProjectile);
282 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(hagar, load_animtime), w_ready);
283 self.hagar_loadstep = time + WEP_CVAR_SEC(hagar, refire) * W_WeaponRateFactor();
287 void W_Hagar_Attack2_Load (void)
289 // loadable hagar secondary attack, must always run each frame
291 if(time < game_starttime)
294 float loaded, enough_ammo;
295 loaded = self.hagar_load >= WEP_CVAR_SEC(hagar, load_max);
297 // this is different than WR_CHECKAMMO when it comes to reloading
298 if(autocvar_g_balance_hagar_reload_ammo)
299 enough_ammo = self.(weapon_load[WEP_HAGAR]) >= WEP_CVAR_SEC(hagar, ammo);
301 enough_ammo = self.AMMO_VAL(WEP_HAGAR) >= WEP_CVAR_SEC(hagar, ammo);
303 if(self.BUTTON_ATCK2)
305 if(self.BUTTON_ATCK && WEP_CVAR_SEC(hagar, load_abort))
309 // if we pressed primary fire while loading, unload all rockets and abort
310 self.weaponentity.state = WS_READY;
311 W_DecreaseAmmo(WEP_CVAR_SEC(hagar, ammo) * self.hagar_load * -1); // give back ammo
313 sound(self, CH_WEAPON_A, "weapons/hagar_beep.wav", VOL_BASE, ATTN_NORM);
315 // pause until we can load rockets again, once we re-press the alt fire button
316 self.hagar_loadstep = time + WEP_CVAR_SEC(hagar, load_speed) * W_WeaponRateFactor();
318 // require letting go of the alt fire button before we can load again
319 self.hagar_loadblock = TRUE;
324 // check if we can attempt to load another rocket
325 if(!loaded && enough_ammo)
327 if(!self.hagar_loadblock && self.hagar_loadstep < time)
329 W_DecreaseAmmo(WEP_CVAR_SEC(hagar, ammo));
330 self.weaponentity.state = WS_INUSE;
331 self.hagar_load += 1;
332 sound(self, CH_WEAPON_B, "weapons/hagar_load.wav", VOL_BASE * 0.8, ATTN_NORM); // sound is too loud according to most
334 if (self.hagar_load >= WEP_CVAR_SEC(hagar, load_max))
335 self.hagar_loadstep = time + WEP_CVAR_SEC(hagar, load_hold) * W_WeaponRateFactor();
337 self.hagar_loadstep = time + WEP_CVAR_SEC(hagar, load_speed) * W_WeaponRateFactor();
340 else if(!self.hagar_loadbeep && self.hagar_load) // prevents the beep from playing each frame
342 // if this is the last rocket we can load, play a beep sound to notify the player
343 sound(self, CH_WEAPON_A, "weapons/hagar_beep.wav", VOL_BASE, ATTN_NORM);
344 self.hagar_loadbeep = TRUE;
348 else if(self.hagar_loadblock)
350 // the alt fire button has been released, so re-enable loading if blocked
351 self.hagar_loadblock = FALSE;
356 // play warning sound if we're about to release
357 if((loaded || !enough_ammo) && self.hagar_loadstep - 0.5 < time && WEP_CVAR_SEC(hagar, load_hold) >= 0)
359 if(!self.hagar_warning && self.hagar_load) // prevents the beep from playing each frame
361 // we're about to automatically release after holding time, play a beep sound to notify the player
362 sound(self, CH_WEAPON_A, "weapons/hagar_beep.wav", VOL_BASE, ATTN_NORM);
363 self.hagar_warning = TRUE;
367 // release if player let go of button or if they've held it in too long
368 if(!self.BUTTON_ATCK2 || ((loaded || !enough_ammo) && self.hagar_loadstep < time && WEP_CVAR_SEC(hagar, load_hold) >= 0))
370 self.weaponentity.state = WS_READY;
371 W_Hagar_Attack2_Load_Release();
376 self.hagar_loadbeep = FALSE;
377 self.hagar_warning = FALSE;
380 // we aren't checking ammo during an attack, so we must do it here
381 if(!(WEP_ACTION(self.weapon, WR_CHECKAMMO1) + WEP_ACTION(self.weapon, WR_CHECKAMMO2)))
383 // note: this doesn't force the switch
384 W_SwitchToOtherWeapon(self);
389 float W_Hagar(float req)
397 self.BUTTON_ATCK = bot_aim(WEP_CVAR_PRI(hagar, speed), 0, WEP_CVAR_PRI(hagar, lifetime), FALSE);
398 else // not using secondary_speed since these are only 15% and should cause some ricochets without re-aiming
399 self.BUTTON_ATCK2 = bot_aim(WEP_CVAR_PRI(hagar, speed), 0, WEP_CVAR_PRI(hagar, lifetime), FALSE);
405 float loadable_secondary;
406 loadable_secondary = (WEP_CVAR_SEC(hagar, load) && WEP_CVAR(hagar, secondary));
408 if (loadable_secondary)
409 W_Hagar_Attack2_Load(); // must always run each frame
410 if(autocvar_g_balance_hagar_reload_ammo && self.clip_load < min(WEP_CVAR_PRI(hagar, ammo), WEP_CVAR_SEC(hagar, ammo))) // forced reload
411 WEP_ACTION(self.weapon, WR_RELOAD);
412 else if (self.BUTTON_ATCK && !self.hagar_load && !self.hagar_loadblock) // not while secondary is loaded or awaiting reset
414 if (weapon_prepareattack(0, WEP_CVAR_PRI(hagar, refire)))
417 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(hagar, refire), w_ready);
420 else if (self.BUTTON_ATCK2 && !loadable_secondary && WEP_CVAR(hagar, secondary))
422 if (weapon_prepareattack(1, WEP_CVAR_SEC(hagar, refire)))
425 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(hagar, refire), w_ready);
433 // we lost the weapon and want to prepare switching away
436 self.weaponentity.state = WS_READY;
437 W_Hagar_Attack2_Load_Release();
444 precache_model ("models/weapons/g_hagar.md3");
445 precache_model ("models/weapons/v_hagar.md3");
446 precache_model ("models/weapons/h_hagar.iqm");
447 precache_sound ("weapons/hagar_fire.wav");
448 precache_sound ("weapons/hagar_load.wav");
449 precache_sound ("weapons/hagar_beep.wav");
450 HAGAR_SETTINGS(WEP_SKIPCVAR, WEP_SET_PROP)
455 self.hagar_loadblock = FALSE;
459 W_DecreaseAmmo(WEP_CVAR_SEC(hagar, ammo) * self.hagar_load * -1); // give back ammo if necessary
467 ammo_amount = self.AMMO_VAL(WEP_HAGAR) >= WEP_CVAR_PRI(hagar, ammo);
468 ammo_amount += self.(weapon_load[WEP_HAGAR]) >= WEP_CVAR_PRI(hagar, ammo);
473 ammo_amount = self.AMMO_VAL(WEP_HAGAR) >= WEP_CVAR_SEC(hagar, ammo);
474 ammo_amount += self.(weapon_load[WEP_HAGAR]) >= WEP_CVAR_SEC(hagar, ammo);
479 HAGAR_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS)
489 // if we have any rockets loaded when we die, release them
490 if(self.hagar_load && WEP_CVAR_SEC(hagar, load_releasedeath))
491 W_Hagar_Attack2_Load_Release();
497 if(!self.hagar_load) // require releasing loaded rockets first
498 W_Reload(min(WEP_CVAR_PRI(hagar, ammo), WEP_CVAR_SEC(hagar, ammo)), "weapons/reload.wav");
502 case WR_SUICIDEMESSAGE:
504 return WEAPON_HAGAR_SUICIDE;
508 if(w_deathtype & HITTYPE_SECONDARY)
509 return WEAPON_HAGAR_MURDER_BURST;
511 return WEAPON_HAGAR_MURDER_SPRAY;
518 float W_Hagar(float req)
522 case WR_IMPACTEFFECT:
525 org2 = w_org + w_backoff * 6;
526 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
530 sound(self, CH_SHOTS, "weapons/hagexp1.wav", VOL_BASE, ATTN_NORM);
531 else if (w_random<0.7)
532 sound(self, CH_SHOTS, "weapons/hagexp2.wav", VOL_BASE, ATTN_NORM);
534 sound(self, CH_SHOTS, "weapons/hagexp3.wav", VOL_BASE, ATTN_NORM);
541 precache_sound("weapons/hagexp1.wav");
542 precache_sound("weapons/hagexp2.wav");
543 precache_sound("weapons/hagexp3.wav");