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 /* shortname */ "hagar",
11 /* fullname */ _("Hagar")
14 #define HAGAR_SETTINGS(weapon) \
15 WEP_ADD_CVAR(weapon, MO_BOTH, ammo) \
16 WEP_ADD_CVAR(weapon, MO_BOTH, damage) \
17 WEP_ADD_CVAR(weapon, MO_BOTH, edgedamage) \
18 WEP_ADD_CVAR(weapon, MO_BOTH, force) \
19 WEP_ADD_CVAR(weapon, MO_BOTH, radius) \
20 WEP_ADD_CVAR(weapon, MO_BOTH, ammo) \
21 WEP_ADD_CVAR(weapon, MO_BOTH, refire) \
22 WEP_ADD_CVAR(weapon, MO_BOTH, speed) \
23 WEP_ADD_CVAR(weapon, MO_BOTH, damageforcescale) \
24 WEP_ADD_CVAR(weapon, MO_BOTH, health) \
25 WEP_ADD_CVAR(weapon, MO_PRI, lifetime) \
26 WEP_ADD_CVAR(weapon, MO_NONE, secondary) \
27 WEP_ADD_CVAR(weapon, MO_SEC, spread) \
28 WEP_ADD_CVAR(weapon, MO_SEC, load) \
29 WEP_ADD_CVAR(weapon, MO_SEC, load_max) \
30 WEP_ADD_CVAR(weapon, MO_SEC, load_abort) \
31 WEP_ADD_CVAR(weapon, MO_SEC, load_animtime) \
32 WEP_ADD_CVAR(weapon, MO_SEC, load_hold) \
33 WEP_ADD_CVAR(weapon, MO_SEC, load_speed) \
34 WEP_ADD_CVAR(weapon, MO_SEC, load_releasedeath) \
35 WEP_ADD_CVAR(weapon, MO_SEC, load_spread) \
36 WEP_ADD_CVAR(weapon, MO_SEC, load_spread_bias) \
37 WEP_ADD_CVAR(weapon, MO_SEC, load_linkexplode) \
38 WEP_ADD_CVAR(weapon, MO_SEC, lifetime_min) \
39 WEP_ADD_CVAR(weapon, MO_SEC, lifetime_rand) \
40 WEP_ADD_PROP(weapon, reloading_ammo, reload_ammo) \
41 WEP_ADD_PROP(weapon, reloading_time, reload_time) \
42 WEP_ADD_PROP(weapon, switchdelay_raise, switchdelay_raise) \
43 WEP_ADD_PROP(weapon, switchdelay_drop, switchdelay_drop)
47 void spawnfunc_weapon_hagar() { weapon_defaultspawnfunc(WEP_HAGAR); }
52 // NO bounce protection, as bounces are limited!
54 void W_Hagar_Explode (void)
56 self.event_damage = func_null;
57 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);
62 void W_Hagar_Explode2 (void)
64 self.event_damage = func_null;
65 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);
70 void W_Hagar_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
75 float is_linkexplode = ( ((inflictor.owner != world) ? (inflictor.owner == self.owner) : TRUE)
76 && (inflictor.projectiledeathtype & HITTYPE_SECONDARY)
77 && (self.projectiledeathtype & HITTYPE_SECONDARY));
80 is_linkexplode = (is_linkexplode && WEP_CVAR_SEC(hagar, load_linkexplode));
82 is_linkexplode = -1; // not secondary load, so continue as normal without exception.
84 if (!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, is_linkexplode))
85 return; // g_projectiles_damage says to halt
87 self.health = self.health - damage;
88 self.angles = vectoangles(self.velocity);
91 W_PrepareExplosionByDamage(attacker, self.think);
94 void W_Hagar_Touch (void)
100 void W_Hagar_Touch2 (void)
104 if(self.cnt > 0 || other.takedamage == DAMAGE_AIM) {
108 pointparticles(particleeffectnum("hagar_bounce"), self.origin, self.velocity, 1);
109 self.angles = vectoangles (self.velocity);
111 self.projectiledeathtype |= HITTYPE_BOUNCE;
115 void W_Hagar_Attack (void)
119 W_DecreaseAmmo(ammo_rockets, WEP_CVAR_PRI(hagar, ammo), autocvar_g_balance_hagar_reload_ammo);
121 W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CH_WEAPON_A, WEP_CVAR_PRI(hagar, damage));
123 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
126 missile.owner = missile.realowner = self;
127 missile.classname = "missile";
128 missile.bot_dodge = TRUE;
129 missile.bot_dodgerating = WEP_CVAR_PRI(hagar, damage);
131 missile.takedamage = DAMAGE_YES;
132 missile.health = WEP_CVAR_PRI(hagar, health);
133 missile.damageforcescale = WEP_CVAR_PRI(hagar, damageforcescale);
134 missile.event_damage = W_Hagar_Damage;
135 missile.damagedbycontents = TRUE;
137 missile.touch = W_Hagar_Touch;
138 missile.use = W_Hagar_Explode;
139 missile.think = adaptor_think2use_hittype_splash;
140 missile.nextthink = time + WEP_CVAR_PRI(hagar, lifetime);
141 PROJECTILE_MAKETRIGGER(missile);
142 missile.projectiledeathtype = WEP_HAGAR;
143 setorigin (missile, w_shotorg);
144 setsize(missile, '0 0 0', '0 0 0');
146 missile.movetype = MOVETYPE_FLY;
147 W_SETUPPROJECTILEVELOCITY(missile, g_balance_hagar_primary);
149 missile.angles = vectoangles (missile.velocity);
150 missile.flags = FL_PROJECTILE;
151 missile.missile_flags = MIF_SPLASH;
153 CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR, TRUE);
155 other = missile; MUTATOR_CALLHOOK(EditProjectile);
158 void W_Hagar_Attack2 (void)
162 W_DecreaseAmmo(ammo_rockets, WEP_CVAR_SEC(hagar, ammo), autocvar_g_balance_hagar_reload_ammo);
164 W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CH_WEAPON_A, WEP_CVAR_SEC(hagar, damage));
166 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
169 missile.owner = missile.realowner = self;
170 missile.classname = "missile";
171 missile.bot_dodge = TRUE;
172 missile.bot_dodgerating = WEP_CVAR_SEC(hagar, damage);
174 missile.takedamage = DAMAGE_YES;
175 missile.health = WEP_CVAR_SEC(hagar, health);
176 missile.damageforcescale = WEP_CVAR_SEC(hagar, damageforcescale);
177 missile.event_damage = W_Hagar_Damage;
178 missile.damagedbycontents = TRUE;
180 missile.touch = W_Hagar_Touch2;
182 missile.use = W_Hagar_Explode2;
183 missile.think = adaptor_think2use_hittype_splash;
184 missile.nextthink = time + WEP_CVAR_SEC(hagar, lifetime_min) + random() * WEP_CVAR_SEC(hagar, lifetime_rand);
185 PROJECTILE_MAKETRIGGER(missile);
186 missile.projectiledeathtype = WEP_HAGAR | HITTYPE_SECONDARY;
187 setorigin (missile, w_shotorg);
188 setsize(missile, '0 0 0', '0 0 0');
190 missile.movetype = MOVETYPE_BOUNCEMISSILE;
191 W_SETUPPROJECTILEVELOCITY(missile, g_balance_hagar_secondary);
193 missile.angles = vectoangles (missile.velocity);
194 missile.flags = FL_PROJECTILE;
195 missile.missile_flags = MIF_SPLASH;
197 CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR_BOUNCING, TRUE);
199 other = missile; MUTATOR_CALLHOOK(EditProjectile);
202 .float hagar_loadstep, hagar_loadblock, hagar_loadbeep, hagar_warning;
203 void W_Hagar_Attack2_Load_Release (void)
205 // time to release the rockets we've loaded
208 float counter, shots, spread_pershot;
210 vector forward, right, up;
215 weapon_prepareattack_do(1, WEP_CVAR_SEC(hagar, refire));
217 W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CH_WEAPON_A, WEP_CVAR_SEC(hagar, damage));
218 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
224 shots = self.hagar_load;
226 for(counter = 0; counter < shots; ++counter)
229 missile.owner = missile.realowner = self;
230 missile.classname = "missile";
231 missile.bot_dodge = TRUE;
232 missile.bot_dodgerating = WEP_CVAR_SEC(hagar, damage);
234 missile.takedamage = DAMAGE_YES;
235 missile.health = WEP_CVAR_SEC(hagar, health);
236 missile.damageforcescale = WEP_CVAR_SEC(hagar, damageforcescale);
237 missile.event_damage = W_Hagar_Damage;
238 missile.damagedbycontents = TRUE;
240 missile.touch = W_Hagar_Touch; // not bouncy
241 missile.use = W_Hagar_Explode2;
242 missile.think = adaptor_think2use_hittype_splash;
243 missile.nextthink = time + WEP_CVAR_SEC(hagar, lifetime_min) + random() * WEP_CVAR_SEC(hagar, lifetime_rand);
244 PROJECTILE_MAKETRIGGER(missile);
245 missile.projectiledeathtype = WEP_HAGAR | HITTYPE_SECONDARY;
246 setorigin (missile, w_shotorg);
247 setsize(missile, '0 0 0', '0 0 0');
248 missile.movetype = MOVETYPE_FLY;
249 missile.missile_flags = MIF_SPLASH;
251 // per-shot spread calculation: the more shots there are, the less spread is applied (based on the bias cvar)
252 spread_pershot = ((shots - 1) / (WEP_CVAR_SEC(hagar, load_max) - 1));
253 spread_pershot = (1 - (spread_pershot * WEP_CVAR_SEC(hagar, load_spread_bias)));
254 spread_pershot = (WEP_CVAR_SEC(hagar, spread) * spread_pershot * g_weaponspreadfactor);
256 // pattern spread calculation
262 makevectors('0 360 0' * (0.75 + (counter - 0.5) / (shots - 1)));
266 s = s * WEP_CVAR_SEC(hagar, load_spread) * g_weaponspreadfactor;
268 W_SetupProjectileVelocityEx(missile, w_shotdir + right * s_y + up * s_z, v_up, WEP_CVAR_SEC(hagar, speed), 0, 0, spread_pershot, FALSE);
270 missile.angles = vectoangles (missile.velocity);
271 missile.flags = FL_PROJECTILE;
273 CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR, TRUE);
275 other = missile; MUTATOR_CALLHOOK(EditProjectile);
278 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(hagar, load_animtime), w_ready);
279 self.hagar_loadstep = time + WEP_CVAR_SEC(hagar, refire) * W_WeaponRateFactor();
283 void W_Hagar_Attack2_Load (void)
285 // loadable hagar secondary attack, must always run each frame
287 if(time < game_starttime)
290 float loaded, enough_ammo;
291 loaded = self.hagar_load >= WEP_CVAR_SEC(hagar, load_max);
293 // this is different than WR_CHECKAMMO when it comes to reloading
294 if(autocvar_g_balance_hagar_reload_ammo)
295 enough_ammo = self.(weapon_load[WEP_HAGAR]) >= WEP_CVAR_SEC(hagar, ammo);
297 enough_ammo = self.ammo_rockets >= WEP_CVAR_SEC(hagar, ammo);
299 if(self.BUTTON_ATCK2)
301 if(self.BUTTON_ATCK && WEP_CVAR_SEC(hagar, load_abort))
305 // if we pressed primary fire while loading, unload all rockets and abort
306 self.weaponentity.state = WS_READY;
307 W_DecreaseAmmo(ammo_rockets, WEP_CVAR_SEC(hagar, ammo) * self.hagar_load * -1, autocvar_g_balance_hagar_reload_ammo); // give back ammo
309 sound(self, CH_WEAPON_A, "weapons/hagar_beep.wav", VOL_BASE, ATTN_NORM);
311 // pause until we can load rockets again, once we re-press the alt fire button
312 self.hagar_loadstep = time + WEP_CVAR_SEC(hagar, load_speed) * W_WeaponRateFactor();
314 // require letting go of the alt fire button before we can load again
315 self.hagar_loadblock = TRUE;
320 // check if we can attempt to load another rocket
321 if(!loaded && enough_ammo)
323 if(!self.hagar_loadblock && self.hagar_loadstep < time)
325 W_DecreaseAmmo(ammo_rockets, WEP_CVAR_SEC(hagar, ammo), autocvar_g_balance_hagar_reload_ammo);
326 self.weaponentity.state = WS_INUSE;
327 self.hagar_load += 1;
328 sound(self, CH_WEAPON_B, "weapons/hagar_load.wav", VOL_BASE * 0.8, ATTN_NORM); // sound is too loud according to most
330 if (self.hagar_load >= WEP_CVAR_SEC(hagar, load_max))
331 self.hagar_loadstep = time + WEP_CVAR_SEC(hagar, load_hold) * W_WeaponRateFactor();
333 self.hagar_loadstep = time + WEP_CVAR_SEC(hagar, load_speed) * W_WeaponRateFactor();
336 else if(!self.hagar_loadbeep && self.hagar_load) // prevents the beep from playing each frame
338 // if this is the last rocket we can load, play a beep sound to notify the player
339 sound(self, CH_WEAPON_A, "weapons/hagar_beep.wav", VOL_BASE, ATTN_NORM);
340 self.hagar_loadbeep = TRUE;
344 else if(self.hagar_loadblock)
346 // the alt fire button has been released, so re-enable loading if blocked
347 self.hagar_loadblock = FALSE;
352 // play warning sound if we're about to release
353 if((loaded || !enough_ammo) && self.hagar_loadstep - 0.5 < time && WEP_CVAR_SEC(hagar, load_hold) >= 0)
355 if(!self.hagar_warning && self.hagar_load) // prevents the beep from playing each frame
357 // we're about to automatically release after holding time, play a beep sound to notify the player
358 sound(self, CH_WEAPON_A, "weapons/hagar_beep.wav", VOL_BASE, ATTN_NORM);
359 self.hagar_warning = TRUE;
363 // release if player let go of button or if they've held it in too long
364 if(!self.BUTTON_ATCK2 || ((loaded || !enough_ammo) && self.hagar_loadstep < time && WEP_CVAR_SEC(hagar, load_hold) >= 0))
366 self.weaponentity.state = WS_READY;
367 W_Hagar_Attack2_Load_Release();
372 self.hagar_loadbeep = FALSE;
373 self.hagar_warning = FALSE;
376 // we aren't checking ammo during an attack, so we must do it here
377 if not(WEP_ACTION(self.weapon, WR_CHECKAMMO1) + WEP_ACTION(self.weapon, WR_CHECKAMMO2))
379 // note: this doesn't force the switch
380 W_SwitchToOtherWeapon(self);
385 float w_hagar(float req)
393 self.BUTTON_ATCK = bot_aim(WEP_CVAR_PRI(hagar, speed), 0, WEP_CVAR_PRI(hagar, lifetime), FALSE);
394 else // not using secondary_speed since these are only 15% and should cause some ricochets without re-aiming
395 self.BUTTON_ATCK2 = bot_aim(WEP_CVAR_PRI(hagar, speed), 0, WEP_CVAR_PRI(hagar, lifetime), FALSE);
401 float loadable_secondary;
402 loadable_secondary = (WEP_CVAR_SEC(hagar, load) && WEP_CVAR(hagar, secondary));
404 if (loadable_secondary)
405 W_Hagar_Attack2_Load(); // must always run each frame
406 if(autocvar_g_balance_hagar_reload_ammo && self.clip_load < min(WEP_CVAR_PRI(hagar, ammo), WEP_CVAR_SEC(hagar, ammo))) // forced reload
407 WEP_ACTION(self.weapon, WR_RELOAD);
408 else if (self.BUTTON_ATCK && !self.hagar_load && !self.hagar_loadblock) // not while secondary is loaded or awaiting reset
410 if (weapon_prepareattack(0, WEP_CVAR_PRI(hagar, refire)))
413 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(hagar, refire), w_ready);
416 else if (self.BUTTON_ATCK2 && !loadable_secondary && WEP_CVAR(hagar, secondary))
418 if (weapon_prepareattack(1, WEP_CVAR_SEC(hagar, refire)))
421 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(hagar, refire), w_ready);
429 // we lost the weapon and want to prepare switching away
432 self.weaponentity.state = WS_READY;
433 W_Hagar_Attack2_Load_Release();
440 precache_model ("models/weapons/g_hagar.md3");
441 precache_model ("models/weapons/v_hagar.md3");
442 precache_model ("models/weapons/h_hagar.iqm");
443 precache_sound ("weapons/hagar_fire.wav");
444 precache_sound ("weapons/hagar_load.wav");
445 precache_sound ("weapons/hagar_beep.wav");
446 #define WEP_ADD_CVAR(weapon,mode,name) /*nothing*/
447 #define WEP_ADD_PROP(weapon,prop,name) WEP_SET_PROP(WEP_HAGAR,weapon,prop,name)
448 HAGAR_SETTINGS(hagar)
455 weapon_setup(WEP_HAGAR);
456 self.current_ammo = ammo_rockets;
457 self.hagar_loadblock = FALSE;
461 W_DecreaseAmmo(ammo_rockets, WEP_CVAR_SEC(hagar, ammo) * self.hagar_load * -1, autocvar_g_balance_hagar_reload_ammo); // give back ammo if necessary
469 ammo_amount = self.ammo_rockets >= WEP_CVAR_PRI(hagar, ammo);
470 ammo_amount += self.(weapon_load[WEP_HAGAR]) >= WEP_CVAR_PRI(hagar, ammo);
475 ammo_amount = self.ammo_rockets >= WEP_CVAR_SEC(hagar, ammo);
476 ammo_amount += self.(weapon_load[WEP_HAGAR]) >= WEP_CVAR_SEC(hagar, ammo);
486 // if we have any rockets loaded when we die, release them
487 if(self.hagar_load && WEP_CVAR_SEC(hagar, load_releasedeath))
488 W_Hagar_Attack2_Load_Release();
494 if not(self.hagar_load) // require releasing loaded rockets first
495 W_Reload(min(WEP_CVAR_PRI(hagar, ammo), WEP_CVAR_SEC(hagar, ammo)), autocvar_g_balance_hagar_reload_ammo, autocvar_g_balance_hagar_reload_time, "weapons/reload.wav");
499 case WR_SUICIDEMESSAGE:
501 return WEAPON_HAGAR_SUICIDE;
505 if(w_deathtype & HITTYPE_SECONDARY)
506 return WEAPON_HAGAR_MURDER_BURST;
508 return WEAPON_HAGAR_MURDER_SPRAY;
515 float w_hagar(float req)
519 case WR_IMPACTEFFECT:
522 org2 = w_org + w_backoff * 6;
523 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
527 sound(self, CH_SHOTS, "weapons/hagexp1.wav", VOL_BASE, ATTN_NORM);
528 else if (w_random<0.7)
529 sound(self, CH_SHOTS, "weapons/hagexp2.wav", VOL_BASE, ATTN_NORM);
531 sound(self, CH_SHOTS, "weapons/hagexp3.wav", VOL_BASE, ATTN_NORM);
538 precache_sound("weapons/hagexp1.wav");
539 precache_sound("weapons/hagexp2.wav");
540 precache_sound("weapons/hagexp3.wav");