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)
47 HAGAR_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
51 void spawnfunc_weapon_hagar() { weapon_defaultspawnfunc(WEP_HAGAR); }
53 // NO bounce protection, as bounces are limited!
55 void W_Hagar_Explode (void)
57 self.event_damage = func_null;
58 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);
63 void W_Hagar_Explode2 (void)
65 self.event_damage = func_null;
66 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);
71 void W_Hagar_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
76 float is_linkexplode = ( ((inflictor.owner != world) ? (inflictor.owner == self.owner) : TRUE)
77 && (inflictor.projectiledeathtype & HITTYPE_SECONDARY)
78 && (self.projectiledeathtype & HITTYPE_SECONDARY));
81 is_linkexplode = (is_linkexplode && WEP_CVAR_SEC(hagar, load_linkexplode));
83 is_linkexplode = -1; // not secondary load, so continue as normal without exception.
85 if (!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, is_linkexplode))
86 return; // g_projectiles_damage says to halt
88 self.health = self.health - damage;
89 self.angles = vectoangles(self.velocity);
92 W_PrepareExplosionByDamage(attacker, self.think);
95 void W_Hagar_Touch (void)
101 void W_Hagar_Touch2 (void)
105 if(self.cnt > 0 || other.takedamage == DAMAGE_AIM) {
109 pointparticles(particleeffectnum("hagar_bounce"), self.origin, self.velocity, 1);
110 self.angles = vectoangles (self.velocity);
112 self.projectiledeathtype |= HITTYPE_BOUNCE;
116 void W_Hagar_Attack (void)
120 W_DecreaseAmmo(ammo_rockets, WEP_CVAR_PRI(hagar, ammo), autocvar_g_balance_hagar_reload_ammo);
122 W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CH_WEAPON_A, WEP_CVAR_PRI(hagar, damage));
124 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
127 missile.owner = missile.realowner = self;
128 missile.classname = "missile";
129 missile.bot_dodge = TRUE;
130 missile.bot_dodgerating = WEP_CVAR_PRI(hagar, damage);
132 missile.takedamage = DAMAGE_YES;
133 missile.health = WEP_CVAR_PRI(hagar, health);
134 missile.damageforcescale = WEP_CVAR_PRI(hagar, damageforcescale);
135 missile.event_damage = W_Hagar_Damage;
136 missile.damagedbycontents = TRUE;
138 missile.touch = W_Hagar_Touch;
139 missile.use = W_Hagar_Explode;
140 missile.think = adaptor_think2use_hittype_splash;
141 missile.nextthink = time + WEP_CVAR_PRI(hagar, lifetime);
142 PROJECTILE_MAKETRIGGER(missile);
143 missile.projectiledeathtype = WEP_HAGAR;
144 setorigin (missile, w_shotorg);
145 setsize(missile, '0 0 0', '0 0 0');
147 missile.movetype = MOVETYPE_FLY;
148 WEP_SETUPPROJVELOCITY_PRI(missile, hagar);
150 missile.angles = vectoangles (missile.velocity);
151 missile.flags = FL_PROJECTILE;
152 missile.missile_flags = MIF_SPLASH;
154 CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR, TRUE);
156 other = missile; MUTATOR_CALLHOOK(EditProjectile);
159 void W_Hagar_Attack2 (void)
163 W_DecreaseAmmo(ammo_rockets, WEP_CVAR_SEC(hagar, ammo), autocvar_g_balance_hagar_reload_ammo);
165 W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CH_WEAPON_A, WEP_CVAR_SEC(hagar, damage));
167 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
170 missile.owner = missile.realowner = self;
171 missile.classname = "missile";
172 missile.bot_dodge = TRUE;
173 missile.bot_dodgerating = WEP_CVAR_SEC(hagar, damage);
175 missile.takedamage = DAMAGE_YES;
176 missile.health = WEP_CVAR_SEC(hagar, health);
177 missile.damageforcescale = WEP_CVAR_SEC(hagar, damageforcescale);
178 missile.event_damage = W_Hagar_Damage;
179 missile.damagedbycontents = TRUE;
181 missile.touch = W_Hagar_Touch2;
183 missile.use = W_Hagar_Explode2;
184 missile.think = adaptor_think2use_hittype_splash;
185 missile.nextthink = time + WEP_CVAR_SEC(hagar, lifetime_min) + random() * WEP_CVAR_SEC(hagar, lifetime_rand);
186 PROJECTILE_MAKETRIGGER(missile);
187 missile.projectiledeathtype = WEP_HAGAR | HITTYPE_SECONDARY;
188 setorigin (missile, w_shotorg);
189 setsize(missile, '0 0 0', '0 0 0');
191 missile.movetype = MOVETYPE_BOUNCEMISSILE;
192 WEP_SETUPPROJVELOCITY_SEC(missile, hagar);
194 missile.angles = vectoangles (missile.velocity);
195 missile.flags = FL_PROJECTILE;
196 missile.missile_flags = MIF_SPLASH;
198 CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR_BOUNCING, TRUE);
200 other = missile; MUTATOR_CALLHOOK(EditProjectile);
203 .float hagar_loadstep, hagar_loadblock, hagar_loadbeep, hagar_warning;
204 void W_Hagar_Attack2_Load_Release (void)
206 // time to release the rockets we've loaded
209 float counter, shots, spread_pershot;
211 vector forward, right, up;
216 weapon_prepareattack_do(1, WEP_CVAR_SEC(hagar, refire));
218 W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CH_WEAPON_A, WEP_CVAR_SEC(hagar, damage));
219 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
225 shots = self.hagar_load;
227 for(counter = 0; counter < shots; ++counter)
230 missile.owner = missile.realowner = self;
231 missile.classname = "missile";
232 missile.bot_dodge = TRUE;
233 missile.bot_dodgerating = WEP_CVAR_SEC(hagar, damage);
235 missile.takedamage = DAMAGE_YES;
236 missile.health = WEP_CVAR_SEC(hagar, health);
237 missile.damageforcescale = WEP_CVAR_SEC(hagar, damageforcescale);
238 missile.event_damage = W_Hagar_Damage;
239 missile.damagedbycontents = TRUE;
241 missile.touch = W_Hagar_Touch; // not bouncy
242 missile.use = W_Hagar_Explode2;
243 missile.think = adaptor_think2use_hittype_splash;
244 missile.nextthink = time + WEP_CVAR_SEC(hagar, lifetime_min) + random() * WEP_CVAR_SEC(hagar, lifetime_rand);
245 PROJECTILE_MAKETRIGGER(missile);
246 missile.projectiledeathtype = WEP_HAGAR | HITTYPE_SECONDARY;
247 setorigin (missile, w_shotorg);
248 setsize(missile, '0 0 0', '0 0 0');
249 missile.movetype = MOVETYPE_FLY;
250 missile.missile_flags = MIF_SPLASH;
252 // per-shot spread calculation: the more shots there are, the less spread is applied (based on the bias cvar)
253 spread_pershot = ((shots - 1) / (WEP_CVAR_SEC(hagar, load_max) - 1));
254 spread_pershot = (1 - (spread_pershot * WEP_CVAR_SEC(hagar, load_spread_bias)));
255 spread_pershot = (WEP_CVAR_SEC(hagar, spread) * spread_pershot * g_weaponspreadfactor);
257 // pattern spread calculation
263 makevectors('0 360 0' * (0.75 + (counter - 0.5) / (shots - 1)));
267 s = s * WEP_CVAR_SEC(hagar, load_spread) * g_weaponspreadfactor;
269 W_SetupProjectileVelocityEx(missile, w_shotdir + right * s_y + up * s_z, v_up, WEP_CVAR_SEC(hagar, speed), 0, 0, spread_pershot, FALSE);
271 missile.angles = vectoangles (missile.velocity);
272 missile.flags = FL_PROJECTILE;
274 CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR, TRUE);
276 other = missile; MUTATOR_CALLHOOK(EditProjectile);
279 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(hagar, load_animtime), w_ready);
280 self.hagar_loadstep = time + WEP_CVAR_SEC(hagar, refire) * W_WeaponRateFactor();
284 void W_Hagar_Attack2_Load (void)
286 // loadable hagar secondary attack, must always run each frame
288 if(time < game_starttime)
291 float loaded, enough_ammo;
292 loaded = self.hagar_load >= WEP_CVAR_SEC(hagar, load_max);
294 // this is different than WR_CHECKAMMO when it comes to reloading
295 if(autocvar_g_balance_hagar_reload_ammo)
296 enough_ammo = self.(weapon_load[WEP_HAGAR]) >= WEP_CVAR_SEC(hagar, ammo);
298 enough_ammo = self.ammo_rockets >= WEP_CVAR_SEC(hagar, ammo);
300 if(self.BUTTON_ATCK2)
302 if(self.BUTTON_ATCK && WEP_CVAR_SEC(hagar, load_abort))
306 // if we pressed primary fire while loading, unload all rockets and abort
307 self.weaponentity.state = WS_READY;
308 W_DecreaseAmmo(ammo_rockets, WEP_CVAR_SEC(hagar, ammo) * self.hagar_load * -1, autocvar_g_balance_hagar_reload_ammo); // give back ammo
310 sound(self, CH_WEAPON_A, "weapons/hagar_beep.wav", VOL_BASE, ATTN_NORM);
312 // pause until we can load rockets again, once we re-press the alt fire button
313 self.hagar_loadstep = time + WEP_CVAR_SEC(hagar, load_speed) * W_WeaponRateFactor();
315 // require letting go of the alt fire button before we can load again
316 self.hagar_loadblock = TRUE;
321 // check if we can attempt to load another rocket
322 if(!loaded && enough_ammo)
324 if(!self.hagar_loadblock && self.hagar_loadstep < time)
326 W_DecreaseAmmo(ammo_rockets, WEP_CVAR_SEC(hagar, ammo), autocvar_g_balance_hagar_reload_ammo);
327 self.weaponentity.state = WS_INUSE;
328 self.hagar_load += 1;
329 sound(self, CH_WEAPON_B, "weapons/hagar_load.wav", VOL_BASE * 0.8, ATTN_NORM); // sound is too loud according to most
331 if (self.hagar_load >= WEP_CVAR_SEC(hagar, load_max))
332 self.hagar_loadstep = time + WEP_CVAR_SEC(hagar, load_hold) * W_WeaponRateFactor();
334 self.hagar_loadstep = time + WEP_CVAR_SEC(hagar, load_speed) * W_WeaponRateFactor();
337 else if(!self.hagar_loadbeep && self.hagar_load) // prevents the beep from playing each frame
339 // if this is the last rocket we can load, play a beep sound to notify the player
340 sound(self, CH_WEAPON_A, "weapons/hagar_beep.wav", VOL_BASE, ATTN_NORM);
341 self.hagar_loadbeep = TRUE;
345 else if(self.hagar_loadblock)
347 // the alt fire button has been released, so re-enable loading if blocked
348 self.hagar_loadblock = FALSE;
353 // play warning sound if we're about to release
354 if((loaded || !enough_ammo) && self.hagar_loadstep - 0.5 < time && WEP_CVAR_SEC(hagar, load_hold) >= 0)
356 if(!self.hagar_warning && self.hagar_load) // prevents the beep from playing each frame
358 // we're about to automatically release after holding time, play a beep sound to notify the player
359 sound(self, CH_WEAPON_A, "weapons/hagar_beep.wav", VOL_BASE, ATTN_NORM);
360 self.hagar_warning = TRUE;
364 // release if player let go of button or if they've held it in too long
365 if(!self.BUTTON_ATCK2 || ((loaded || !enough_ammo) && self.hagar_loadstep < time && WEP_CVAR_SEC(hagar, load_hold) >= 0))
367 self.weaponentity.state = WS_READY;
368 W_Hagar_Attack2_Load_Release();
373 self.hagar_loadbeep = FALSE;
374 self.hagar_warning = FALSE;
377 // we aren't checking ammo during an attack, so we must do it here
378 if(!(WEP_ACTION(self.weapon, WR_CHECKAMMO1) + WEP_ACTION(self.weapon, WR_CHECKAMMO2)))
380 // note: this doesn't force the switch
381 W_SwitchToOtherWeapon(self);
386 float w_hagar(float req)
394 self.BUTTON_ATCK = bot_aim(WEP_CVAR_PRI(hagar, speed), 0, WEP_CVAR_PRI(hagar, lifetime), FALSE);
395 else // not using secondary_speed since these are only 15% and should cause some ricochets without re-aiming
396 self.BUTTON_ATCK2 = bot_aim(WEP_CVAR_PRI(hagar, speed), 0, WEP_CVAR_PRI(hagar, lifetime), FALSE);
402 float loadable_secondary;
403 loadable_secondary = (WEP_CVAR_SEC(hagar, load) && WEP_CVAR(hagar, secondary));
405 if (loadable_secondary)
406 W_Hagar_Attack2_Load(); // must always run each frame
407 if(autocvar_g_balance_hagar_reload_ammo && self.clip_load < min(WEP_CVAR_PRI(hagar, ammo), WEP_CVAR_SEC(hagar, ammo))) // forced reload
408 WEP_ACTION(self.weapon, WR_RELOAD);
409 else if (self.BUTTON_ATCK && !self.hagar_load && !self.hagar_loadblock) // not while secondary is loaded or awaiting reset
411 if (weapon_prepareattack(0, WEP_CVAR_PRI(hagar, refire)))
414 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(hagar, refire), w_ready);
417 else if (self.BUTTON_ATCK2 && !loadable_secondary && WEP_CVAR(hagar, secondary))
419 if (weapon_prepareattack(1, WEP_CVAR_SEC(hagar, refire)))
422 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(hagar, refire), w_ready);
430 // we lost the weapon and want to prepare switching away
433 self.weaponentity.state = WS_READY;
434 W_Hagar_Attack2_Load_Release();
441 precache_model ("models/weapons/g_hagar.md3");
442 precache_model ("models/weapons/v_hagar.md3");
443 precache_model ("models/weapons/h_hagar.iqm");
444 precache_sound ("weapons/hagar_fire.wav");
445 precache_sound ("weapons/hagar_load.wav");
446 precache_sound ("weapons/hagar_beep.wav");
447 HAGAR_SETTINGS(WEP_SKIPCVAR, WEP_SET_PROP)
452 self.current_ammo = ammo_rockets;
453 self.hagar_loadblock = FALSE;
457 W_DecreaseAmmo(ammo_rockets, WEP_CVAR_SEC(hagar, ammo) * self.hagar_load * -1, autocvar_g_balance_hagar_reload_ammo); // give back ammo if necessary
465 ammo_amount = self.ammo_rockets >= WEP_CVAR_PRI(hagar, ammo);
466 ammo_amount += self.(weapon_load[WEP_HAGAR]) >= WEP_CVAR_PRI(hagar, ammo);
471 ammo_amount = self.ammo_rockets >= WEP_CVAR_SEC(hagar, ammo);
472 ammo_amount += self.(weapon_load[WEP_HAGAR]) >= WEP_CVAR_SEC(hagar, ammo);
477 HAGAR_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS)
487 // if we have any rockets loaded when we die, release them
488 if(self.hagar_load && WEP_CVAR_SEC(hagar, load_releasedeath))
489 W_Hagar_Attack2_Load_Release();
495 if(!self.hagar_load) // require releasing loaded rockets first
496 W_Reload(min(WEP_CVAR_PRI(hagar, ammo), WEP_CVAR_SEC(hagar, ammo)), "weapons/reload.wav");
500 case WR_SUICIDEMESSAGE:
502 return WEAPON_HAGAR_SUICIDE;
506 if(w_deathtype & HITTYPE_SECONDARY)
507 return WEAPON_HAGAR_MURDER_BURST;
509 return WEAPON_HAGAR_MURDER_SPRAY;
516 float w_hagar(float req)
520 case WR_IMPACTEFFECT:
523 org2 = w_org + w_backoff * 6;
524 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
528 sound(self, CH_SHOTS, "weapons/hagexp1.wav", VOL_BASE, ATTN_NORM);
529 else if (w_random<0.7)
530 sound(self, CH_SHOTS, "weapons/hagexp2.wav", VOL_BASE, ATTN_NORM);
532 sound(self, CH_SHOTS, "weapons/hagexp3.wav", VOL_BASE, ATTN_NORM);
539 precache_sound("weapons/hagexp1.wav");
540 precache_sound("weapons/hagexp2.wav");
541 precache_sound("weapons/hagexp3.wav");