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,
10 /* netname */ "hagar",
11 /* fullname */ _("Hagar")
14 #define HAGAR_SETTINGS(w_cvar,w_prop) HAGAR_SETTINGS_LIST(w_cvar, w_prop, HAGAR, hagar)
15 #define HAGAR_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
16 w_cvar(id, sn, MO_BOTH, ammo) \
17 w_cvar(id, sn, MO_BOTH, damage) \
18 w_cvar(id, sn, MO_BOTH, edgedamage) \
19 w_cvar(id, sn, MO_BOTH, force) \
20 w_cvar(id, sn, MO_BOTH, radius) \
21 w_cvar(id, sn, MO_BOTH, refire) \
22 w_cvar(id, sn, MO_BOTH, speed) \
23 w_cvar(id, sn, MO_BOTH, spread) \
24 w_cvar(id, sn, MO_BOTH, damageforcescale) \
25 w_cvar(id, sn, MO_BOTH, health) \
26 w_cvar(id, sn, MO_PRI, lifetime) \
27 w_cvar(id, sn, MO_SEC, load) \
28 w_cvar(id, sn, MO_SEC, load_max) \
29 w_cvar(id, sn, MO_SEC, load_abort) \
30 w_cvar(id, sn, MO_SEC, load_animtime) \
31 w_cvar(id, sn, MO_SEC, load_hold) \
32 w_cvar(id, sn, MO_SEC, load_speed) \
33 w_cvar(id, sn, MO_SEC, load_releasedeath) \
34 w_cvar(id, sn, MO_SEC, load_spread) \
35 w_cvar(id, sn, MO_SEC, load_spread_bias) \
36 w_cvar(id, sn, MO_SEC, load_linkexplode) \
37 w_cvar(id, sn, MO_SEC, lifetime_min) \
38 w_cvar(id, sn, MO_SEC, lifetime_rand) \
39 w_cvar(id, sn, MO_NONE, secondary) \
40 w_prop(id, sn, float, reloading_ammo, reload_ammo) \
41 w_prop(id, sn, float, reloading_time, reload_time) \
42 w_prop(id, sn, float, switchdelay_raise, switchdelay_raise) \
43 w_prop(id, sn, float, switchdelay_drop, switchdelay_drop) \
44 w_prop(id, sn, string, weaponreplace, weaponreplace) \
45 w_prop(id, sn, float, weaponstart, weaponstart) \
46 w_prop(id, sn, float, weaponstartoverride, weaponstartoverride)
49 HAGAR_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
53 void spawnfunc_weapon_hagar() { weapon_defaultspawnfunc(WEP_HAGAR); }
55 // NO bounce protection, as bounces are limited!
57 void W_Hagar_Explode (void)
59 self.event_damage = func_null;
60 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);
65 void W_Hagar_Explode2 (void)
67 self.event_damage = func_null;
68 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);
73 void W_Hagar_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
78 float is_linkexplode = ( ((inflictor.owner != world) ? (inflictor.owner == self.owner) : TRUE)
79 && (inflictor.projectiledeathtype & HITTYPE_SECONDARY)
80 && (self.projectiledeathtype & HITTYPE_SECONDARY));
83 is_linkexplode = (is_linkexplode && WEP_CVAR_SEC(hagar, load_linkexplode));
85 is_linkexplode = -1; // not secondary load, so continue as normal without exception.
87 if (!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, is_linkexplode))
88 return; // g_projectiles_damage says to halt
90 self.health = self.health - damage;
91 self.angles = vectoangles(self.velocity);
94 W_PrepareExplosionByDamage(attacker, self.think);
97 void W_Hagar_Touch (void)
103 void W_Hagar_Touch2 (void)
107 if(self.cnt > 0 || other.takedamage == DAMAGE_AIM) {
111 pointparticles(particleeffectnum("hagar_bounce"), self.origin, self.velocity, 1);
112 self.angles = vectoangles (self.velocity);
114 self.projectiledeathtype |= HITTYPE_BOUNCE;
118 void W_Hagar_Attack (void)
122 W_DecreaseAmmo(ammo_rockets, WEP_CVAR_PRI(hagar, ammo), autocvar_g_balance_hagar_reload_ammo);
124 W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CH_WEAPON_A, WEP_CVAR_PRI(hagar, damage));
126 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
129 missile.owner = missile.realowner = self;
130 missile.classname = "missile";
131 missile.bot_dodge = TRUE;
132 missile.bot_dodgerating = WEP_CVAR_PRI(hagar, damage);
134 missile.takedamage = DAMAGE_YES;
135 missile.health = WEP_CVAR_PRI(hagar, health);
136 missile.damageforcescale = WEP_CVAR_PRI(hagar, damageforcescale);
137 missile.event_damage = W_Hagar_Damage;
138 missile.damagedbycontents = TRUE;
140 missile.touch = W_Hagar_Touch;
141 missile.use = W_Hagar_Explode;
142 missile.think = adaptor_think2use_hittype_splash;
143 missile.nextthink = time + WEP_CVAR_PRI(hagar, lifetime);
144 PROJECTILE_MAKETRIGGER(missile);
145 missile.projectiledeathtype = WEP_HAGAR;
146 setorigin (missile, w_shotorg);
147 setsize(missile, '0 0 0', '0 0 0');
149 missile.movetype = MOVETYPE_FLY;
150 WEP_SETUPPROJVELOCITY_PRI(missile, hagar);
152 missile.angles = vectoangles (missile.velocity);
153 missile.flags = FL_PROJECTILE;
154 missile.missile_flags = MIF_SPLASH;
156 CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR, TRUE);
158 other = missile; MUTATOR_CALLHOOK(EditProjectile);
161 void W_Hagar_Attack2 (void)
165 W_DecreaseAmmo(ammo_rockets, WEP_CVAR_SEC(hagar, ammo), autocvar_g_balance_hagar_reload_ammo);
167 W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CH_WEAPON_A, WEP_CVAR_SEC(hagar, damage));
169 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
172 missile.owner = missile.realowner = self;
173 missile.classname = "missile";
174 missile.bot_dodge = TRUE;
175 missile.bot_dodgerating = WEP_CVAR_SEC(hagar, damage);
177 missile.takedamage = DAMAGE_YES;
178 missile.health = WEP_CVAR_SEC(hagar, health);
179 missile.damageforcescale = WEP_CVAR_SEC(hagar, damageforcescale);
180 missile.event_damage = W_Hagar_Damage;
181 missile.damagedbycontents = TRUE;
183 missile.touch = W_Hagar_Touch2;
185 missile.use = W_Hagar_Explode2;
186 missile.think = adaptor_think2use_hittype_splash;
187 missile.nextthink = time + WEP_CVAR_SEC(hagar, lifetime_min) + random() * WEP_CVAR_SEC(hagar, lifetime_rand);
188 PROJECTILE_MAKETRIGGER(missile);
189 missile.projectiledeathtype = WEP_HAGAR | HITTYPE_SECONDARY;
190 setorigin (missile, w_shotorg);
191 setsize(missile, '0 0 0', '0 0 0');
193 missile.movetype = MOVETYPE_BOUNCEMISSILE;
194 WEP_SETUPPROJVELOCITY_SEC(missile, hagar);
196 missile.angles = vectoangles (missile.velocity);
197 missile.flags = FL_PROJECTILE;
198 missile.missile_flags = MIF_SPLASH;
200 CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR_BOUNCING, TRUE);
202 other = missile; MUTATOR_CALLHOOK(EditProjectile);
205 .float hagar_loadstep, hagar_loadblock, hagar_loadbeep, hagar_warning;
206 void W_Hagar_Attack2_Load_Release (void)
208 // time to release the rockets we've loaded
211 float counter, shots, spread_pershot;
213 vector forward, right, up;
218 weapon_prepareattack_do(1, WEP_CVAR_SEC(hagar, refire));
220 W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CH_WEAPON_A, WEP_CVAR_SEC(hagar, damage));
221 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
227 shots = self.hagar_load;
229 for(counter = 0; counter < shots; ++counter)
232 missile.owner = missile.realowner = self;
233 missile.classname = "missile";
234 missile.bot_dodge = TRUE;
235 missile.bot_dodgerating = WEP_CVAR_SEC(hagar, damage);
237 missile.takedamage = DAMAGE_YES;
238 missile.health = WEP_CVAR_SEC(hagar, health);
239 missile.damageforcescale = WEP_CVAR_SEC(hagar, damageforcescale);
240 missile.event_damage = W_Hagar_Damage;
241 missile.damagedbycontents = TRUE;
243 missile.touch = W_Hagar_Touch; // not bouncy
244 missile.use = W_Hagar_Explode2;
245 missile.think = adaptor_think2use_hittype_splash;
246 missile.nextthink = time + WEP_CVAR_SEC(hagar, lifetime_min) + random() * WEP_CVAR_SEC(hagar, lifetime_rand);
247 PROJECTILE_MAKETRIGGER(missile);
248 missile.projectiledeathtype = WEP_HAGAR | HITTYPE_SECONDARY;
249 setorigin (missile, w_shotorg);
250 setsize(missile, '0 0 0', '0 0 0');
251 missile.movetype = MOVETYPE_FLY;
252 missile.missile_flags = MIF_SPLASH;
254 // per-shot spread calculation: the more shots there are, the less spread is applied (based on the bias cvar)
255 spread_pershot = ((shots - 1) / (WEP_CVAR_SEC(hagar, load_max) - 1));
256 spread_pershot = (1 - (spread_pershot * WEP_CVAR_SEC(hagar, load_spread_bias)));
257 spread_pershot = (WEP_CVAR_SEC(hagar, spread) * spread_pershot * g_weaponspreadfactor);
259 // pattern spread calculation
265 makevectors('0 360 0' * (0.75 + (counter - 0.5) / (shots - 1)));
269 s = s * WEP_CVAR_SEC(hagar, load_spread) * g_weaponspreadfactor;
271 W_SetupProjectileVelocityEx(missile, w_shotdir + right * s_y + up * s_z, v_up, WEP_CVAR_SEC(hagar, speed), 0, 0, spread_pershot, FALSE);
273 missile.angles = vectoangles (missile.velocity);
274 missile.flags = FL_PROJECTILE;
276 CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR, TRUE);
278 other = missile; MUTATOR_CALLHOOK(EditProjectile);
281 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(hagar, load_animtime), w_ready);
282 self.hagar_loadstep = time + WEP_CVAR_SEC(hagar, refire) * W_WeaponRateFactor();
286 void W_Hagar_Attack2_Load (void)
288 // loadable hagar secondary attack, must always run each frame
290 if(time < game_starttime)
293 float loaded, enough_ammo;
294 loaded = self.hagar_load >= WEP_CVAR_SEC(hagar, load_max);
296 // this is different than WR_CHECKAMMO when it comes to reloading
297 if(autocvar_g_balance_hagar_reload_ammo)
298 enough_ammo = self.(weapon_load[WEP_HAGAR]) >= WEP_CVAR_SEC(hagar, ammo);
300 enough_ammo = self.ammo_rockets >= WEP_CVAR_SEC(hagar, ammo);
302 if(self.BUTTON_ATCK2)
304 if(self.BUTTON_ATCK && WEP_CVAR_SEC(hagar, load_abort))
308 // if we pressed primary fire while loading, unload all rockets and abort
309 self.weaponentity.state = WS_READY;
310 W_DecreaseAmmo(ammo_rockets, WEP_CVAR_SEC(hagar, ammo) * self.hagar_load * -1, autocvar_g_balance_hagar_reload_ammo); // give back ammo
312 sound(self, CH_WEAPON_A, "weapons/hagar_beep.wav", VOL_BASE, ATTN_NORM);
314 // pause until we can load rockets again, once we re-press the alt fire button
315 self.hagar_loadstep = time + WEP_CVAR_SEC(hagar, load_speed) * W_WeaponRateFactor();
317 // require letting go of the alt fire button before we can load again
318 self.hagar_loadblock = TRUE;
323 // check if we can attempt to load another rocket
324 if(!loaded && enough_ammo)
326 if(!self.hagar_loadblock && self.hagar_loadstep < time)
328 W_DecreaseAmmo(ammo_rockets, WEP_CVAR_SEC(hagar, ammo), autocvar_g_balance_hagar_reload_ammo);
329 self.weaponentity.state = WS_INUSE;
330 self.hagar_load += 1;
331 sound(self, CH_WEAPON_B, "weapons/hagar_load.wav", VOL_BASE * 0.8, ATTN_NORM); // sound is too loud according to most
333 if (self.hagar_load >= WEP_CVAR_SEC(hagar, load_max))
334 self.hagar_loadstep = time + WEP_CVAR_SEC(hagar, load_hold) * W_WeaponRateFactor();
336 self.hagar_loadstep = time + WEP_CVAR_SEC(hagar, load_speed) * W_WeaponRateFactor();
339 else if(!self.hagar_loadbeep && self.hagar_load) // prevents the beep from playing each frame
341 // if this is the last rocket we can load, play a beep sound to notify the player
342 sound(self, CH_WEAPON_A, "weapons/hagar_beep.wav", VOL_BASE, ATTN_NORM);
343 self.hagar_loadbeep = TRUE;
347 else if(self.hagar_loadblock)
349 // the alt fire button has been released, so re-enable loading if blocked
350 self.hagar_loadblock = FALSE;
355 // play warning sound if we're about to release
356 if((loaded || !enough_ammo) && self.hagar_loadstep - 0.5 < time && WEP_CVAR_SEC(hagar, load_hold) >= 0)
358 if(!self.hagar_warning && self.hagar_load) // prevents the beep from playing each frame
360 // we're about to automatically release after holding time, play a beep sound to notify the player
361 sound(self, CH_WEAPON_A, "weapons/hagar_beep.wav", VOL_BASE, ATTN_NORM);
362 self.hagar_warning = TRUE;
366 // release if player let go of button or if they've held it in too long
367 if(!self.BUTTON_ATCK2 || ((loaded || !enough_ammo) && self.hagar_loadstep < time && WEP_CVAR_SEC(hagar, load_hold) >= 0))
369 self.weaponentity.state = WS_READY;
370 W_Hagar_Attack2_Load_Release();
375 self.hagar_loadbeep = FALSE;
376 self.hagar_warning = FALSE;
379 // we aren't checking ammo during an attack, so we must do it here
380 if(!(WEP_ACTION(self.weapon, WR_CHECKAMMO1) + WEP_ACTION(self.weapon, WR_CHECKAMMO2)))
382 // note: this doesn't force the switch
383 W_SwitchToOtherWeapon(self);
388 float w_hagar(float req)
396 self.BUTTON_ATCK = bot_aim(WEP_CVAR_PRI(hagar, speed), 0, WEP_CVAR_PRI(hagar, lifetime), FALSE);
397 else // not using secondary_speed since these are only 15% and should cause some ricochets without re-aiming
398 self.BUTTON_ATCK2 = bot_aim(WEP_CVAR_PRI(hagar, speed), 0, WEP_CVAR_PRI(hagar, lifetime), FALSE);
404 float loadable_secondary;
405 loadable_secondary = (WEP_CVAR_SEC(hagar, load) && WEP_CVAR(hagar, secondary));
407 if (loadable_secondary)
408 W_Hagar_Attack2_Load(); // must always run each frame
409 if(autocvar_g_balance_hagar_reload_ammo && self.clip_load < min(WEP_CVAR_PRI(hagar, ammo), WEP_CVAR_SEC(hagar, ammo))) // forced reload
410 WEP_ACTION(self.weapon, WR_RELOAD);
411 else if (self.BUTTON_ATCK && !self.hagar_load && !self.hagar_loadblock) // not while secondary is loaded or awaiting reset
413 if (weapon_prepareattack(0, WEP_CVAR_PRI(hagar, refire)))
416 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(hagar, refire), w_ready);
419 else if (self.BUTTON_ATCK2 && !loadable_secondary && WEP_CVAR(hagar, secondary))
421 if (weapon_prepareattack(1, WEP_CVAR_SEC(hagar, refire)))
424 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(hagar, refire), w_ready);
432 // we lost the weapon and want to prepare switching away
435 self.weaponentity.state = WS_READY;
436 W_Hagar_Attack2_Load_Release();
443 precache_model ("models/weapons/g_hagar.md3");
444 precache_model ("models/weapons/v_hagar.md3");
445 precache_model ("models/weapons/h_hagar.iqm");
446 precache_sound ("weapons/hagar_fire.wav");
447 precache_sound ("weapons/hagar_load.wav");
448 precache_sound ("weapons/hagar_beep.wav");
449 HAGAR_SETTINGS(WEP_SKIPCVAR, WEP_SET_PROP)
454 self.current_ammo = ammo_rockets;
455 self.hagar_loadblock = FALSE;
459 W_DecreaseAmmo(ammo_rockets, WEP_CVAR_SEC(hagar, ammo) * self.hagar_load * -1, autocvar_g_balance_hagar_reload_ammo); // give back ammo if necessary
467 ammo_amount = self.ammo_rockets >= WEP_CVAR_PRI(hagar, ammo);
468 ammo_amount += self.(weapon_load[WEP_HAGAR]) >= WEP_CVAR_PRI(hagar, ammo);
473 ammo_amount = self.ammo_rockets >= 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");