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 /* crosshair */ "gfx/crosshairhagar 0.8",
12 /* refname */ "hagar",
13 /* wepname */ _("Hagar")
16 #define HAGAR_SETTINGS(w_cvar,w_prop) HAGAR_SETTINGS_LIST(w_cvar, w_prop, HAGAR, hagar)
17 #define HAGAR_SETTINGS_LIST(w_cvar,w_prop,id,sn) \
18 w_cvar(id, sn, BOTH, ammo) \
19 w_cvar(id, sn, BOTH, damage) \
20 w_cvar(id, sn, BOTH, edgedamage) \
21 w_cvar(id, sn, BOTH, force) \
22 w_cvar(id, sn, BOTH, radius) \
23 w_cvar(id, sn, BOTH, refire) \
24 w_cvar(id, sn, BOTH, speed) \
25 w_cvar(id, sn, BOTH, spread) \
26 w_cvar(id, sn, BOTH, damageforcescale) \
27 w_cvar(id, sn, BOTH, health) \
28 w_cvar(id, sn, PRI, lifetime) \
29 w_cvar(id, sn, SEC, load) \
30 w_cvar(id, sn, SEC, load_max) \
31 w_cvar(id, sn, SEC, load_abort) \
32 w_cvar(id, sn, SEC, load_animtime) \
33 w_cvar(id, sn, SEC, load_hold) \
34 w_cvar(id, sn, SEC, load_speed) \
35 w_cvar(id, sn, SEC, load_releasedeath) \
36 w_cvar(id, sn, SEC, load_spread) \
37 w_cvar(id, sn, SEC, load_spread_bias) \
38 w_cvar(id, sn, SEC, load_linkexplode) \
39 w_cvar(id, sn, SEC, lifetime_min) \
40 w_cvar(id, sn, SEC, lifetime_rand) \
41 w_cvar(id, sn, NONE, secondary) \
42 w_prop(id, sn, float, reloading_ammo, reload_ammo) \
43 w_prop(id, sn, float, reloading_time, reload_time) \
44 w_prop(id, sn, float, switchdelay_raise, switchdelay_raise) \
45 w_prop(id, sn, float, switchdelay_drop, switchdelay_drop) \
46 w_prop(id, sn, string, weaponreplace, weaponreplace) \
47 w_prop(id, sn, float, weaponstart, weaponstart) \
48 w_prop(id, sn, float, weaponstartoverride, weaponstartoverride)
51 HAGAR_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
55 void spawnfunc_weapon_hagar() { weapon_defaultspawnfunc(WEP_HAGAR); }
57 // NO bounce protection, as bounces are limited!
59 void W_Hagar_Explode (void)
61 self.event_damage = func_null;
62 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);
67 void W_Hagar_Explode2 (void)
69 self.event_damage = func_null;
70 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);
75 void W_Hagar_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
80 float is_linkexplode = ( ((inflictor.owner != world) ? (inflictor.owner == self.owner) : TRUE)
81 && (inflictor.projectiledeathtype & HITTYPE_SECONDARY)
82 && (self.projectiledeathtype & HITTYPE_SECONDARY));
85 is_linkexplode = (is_linkexplode && WEP_CVAR_SEC(hagar, load_linkexplode));
87 is_linkexplode = -1; // not secondary load, so continue as normal without exception.
89 if (!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, is_linkexplode))
90 return; // g_projectiles_damage says to halt
92 self.health = self.health - damage;
93 self.angles = vectoangles(self.velocity);
96 W_PrepareExplosionByDamage(attacker, self.think);
99 void W_Hagar_Touch (void)
105 void W_Hagar_Touch2 (void)
109 if(self.cnt > 0 || other.takedamage == DAMAGE_AIM) {
113 pointparticles(particleeffectnum("hagar_bounce"), self.origin, self.velocity, 1);
114 self.angles = vectoangles (self.velocity);
116 self.projectiledeathtype |= HITTYPE_BOUNCE;
120 void W_Hagar_Attack (void)
124 W_DecreaseAmmo(WEP_CVAR_PRI(hagar, ammo));
126 W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CH_WEAPON_A, WEP_CVAR_PRI(hagar, damage));
128 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
131 missile.owner = missile.realowner = self;
132 missile.classname = "missile";
133 missile.bot_dodge = TRUE;
134 missile.bot_dodgerating = WEP_CVAR_PRI(hagar, damage);
136 missile.takedamage = DAMAGE_YES;
137 missile.health = WEP_CVAR_PRI(hagar, health);
138 missile.damageforcescale = WEP_CVAR_PRI(hagar, damageforcescale);
139 missile.event_damage = W_Hagar_Damage;
140 missile.damagedbycontents = TRUE;
142 missile.touch = W_Hagar_Touch;
143 missile.use = W_Hagar_Explode;
144 missile.think = adaptor_think2use_hittype_splash;
145 missile.nextthink = time + WEP_CVAR_PRI(hagar, lifetime);
146 PROJECTILE_MAKETRIGGER(missile);
147 missile.projectiledeathtype = WEP_HAGAR;
148 setorigin (missile, w_shotorg);
149 setsize(missile, '0 0 0', '0 0 0');
151 missile.movetype = MOVETYPE_FLY;
152 W_SetupProjVelocity_PRI(missile, hagar);
154 missile.angles = vectoangles (missile.velocity);
155 missile.flags = FL_PROJECTILE;
156 missile.missile_flags = MIF_SPLASH;
158 CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR, TRUE);
160 other = missile; MUTATOR_CALLHOOK(EditProjectile);
163 void W_Hagar_Attack2 (void)
167 W_DecreaseAmmo(WEP_CVAR_SEC(hagar, ammo));
169 W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CH_WEAPON_A, WEP_CVAR_SEC(hagar, damage));
171 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
174 missile.owner = missile.realowner = self;
175 missile.classname = "missile";
176 missile.bot_dodge = TRUE;
177 missile.bot_dodgerating = WEP_CVAR_SEC(hagar, damage);
179 missile.takedamage = DAMAGE_YES;
180 missile.health = WEP_CVAR_SEC(hagar, health);
181 missile.damageforcescale = WEP_CVAR_SEC(hagar, damageforcescale);
182 missile.event_damage = W_Hagar_Damage;
183 missile.damagedbycontents = TRUE;
185 missile.touch = W_Hagar_Touch2;
187 missile.use = W_Hagar_Explode2;
188 missile.think = adaptor_think2use_hittype_splash;
189 missile.nextthink = time + WEP_CVAR_SEC(hagar, lifetime_min) + random() * WEP_CVAR_SEC(hagar, lifetime_rand);
190 PROJECTILE_MAKETRIGGER(missile);
191 missile.projectiledeathtype = WEP_HAGAR | HITTYPE_SECONDARY;
192 setorigin (missile, w_shotorg);
193 setsize(missile, '0 0 0', '0 0 0');
195 missile.movetype = MOVETYPE_BOUNCEMISSILE;
196 W_SetupProjVelocity_SEC(missile, hagar);
198 missile.angles = vectoangles (missile.velocity);
199 missile.flags = FL_PROJECTILE;
200 missile.missile_flags = MIF_SPLASH;
202 CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR_BOUNCING, TRUE);
204 other = missile; MUTATOR_CALLHOOK(EditProjectile);
207 .float hagar_loadstep, hagar_loadblock, hagar_loadbeep, hagar_warning;
208 void W_Hagar_Attack2_Load_Release (void)
210 // time to release the rockets we've loaded
213 float counter, shots, spread_pershot;
215 vector forward, right, up;
220 weapon_prepareattack_do(1, WEP_CVAR_SEC(hagar, refire));
222 W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CH_WEAPON_A, WEP_CVAR_SEC(hagar, damage));
223 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
229 shots = self.hagar_load;
231 for(counter = 0; counter < shots; ++counter)
234 missile.owner = missile.realowner = self;
235 missile.classname = "missile";
236 missile.bot_dodge = TRUE;
237 missile.bot_dodgerating = WEP_CVAR_SEC(hagar, damage);
239 missile.takedamage = DAMAGE_YES;
240 missile.health = WEP_CVAR_SEC(hagar, health);
241 missile.damageforcescale = WEP_CVAR_SEC(hagar, damageforcescale);
242 missile.event_damage = W_Hagar_Damage;
243 missile.damagedbycontents = TRUE;
245 missile.touch = W_Hagar_Touch; // not bouncy
246 missile.use = W_Hagar_Explode2;
247 missile.think = adaptor_think2use_hittype_splash;
248 missile.nextthink = time + WEP_CVAR_SEC(hagar, lifetime_min) + random() * WEP_CVAR_SEC(hagar, lifetime_rand);
249 PROJECTILE_MAKETRIGGER(missile);
250 missile.projectiledeathtype = WEP_HAGAR | HITTYPE_SECONDARY;
251 setorigin (missile, w_shotorg);
252 setsize(missile, '0 0 0', '0 0 0');
253 missile.movetype = MOVETYPE_FLY;
254 missile.missile_flags = MIF_SPLASH;
256 // per-shot spread calculation: the more shots there are, the less spread is applied (based on the bias cvar)
257 spread_pershot = ((shots - 1) / (WEP_CVAR_SEC(hagar, load_max) - 1));
258 spread_pershot = (1 - (spread_pershot * WEP_CVAR_SEC(hagar, load_spread_bias)));
259 spread_pershot = (WEP_CVAR_SEC(hagar, spread) * spread_pershot * g_weaponspreadfactor);
261 // pattern spread calculation
267 makevectors('0 360 0' * (0.75 + (counter - 0.5) / (shots - 1)));
271 s = s * WEP_CVAR_SEC(hagar, load_spread) * g_weaponspreadfactor;
273 W_SetupProjVelocity_Explicit(missile, w_shotdir + right * s_y + up * s_z, v_up, WEP_CVAR_SEC(hagar, speed), 0, 0, spread_pershot, FALSE);
275 missile.angles = vectoangles (missile.velocity);
276 missile.flags = FL_PROJECTILE;
278 CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR, TRUE);
280 other = missile; MUTATOR_CALLHOOK(EditProjectile);
283 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(hagar, load_animtime), w_ready);
284 self.hagar_loadstep = time + WEP_CVAR_SEC(hagar, refire) * W_WeaponRateFactor();
288 void W_Hagar_Attack2_Load (void)
290 // loadable hagar secondary attack, must always run each frame
292 if(time < game_starttime)
295 float loaded, enough_ammo;
296 loaded = self.hagar_load >= WEP_CVAR_SEC(hagar, load_max);
298 // this is different than WR_CHECKAMMO when it comes to reloading
299 if(autocvar_g_balance_hagar_reload_ammo)
300 enough_ammo = self.(weapon_load[WEP_HAGAR]) >= WEP_CVAR_SEC(hagar, ammo);
302 enough_ammo = self.WEP_AMMO(HAGAR) >= WEP_CVAR_SEC(hagar, ammo);
304 if(self.BUTTON_ATCK2)
306 if(self.BUTTON_ATCK && WEP_CVAR_SEC(hagar, load_abort))
310 // if we pressed primary fire while loading, unload all rockets and abort
311 self.weaponentity.state = WS_READY;
312 W_DecreaseAmmo(WEP_CVAR_SEC(hagar, ammo) * self.hagar_load * -1); // give back ammo
314 sound(self, CH_WEAPON_A, "weapons/hagar_beep.wav", VOL_BASE, ATTN_NORM);
316 // pause until we can load rockets again, once we re-press the alt fire button
317 self.hagar_loadstep = time + WEP_CVAR_SEC(hagar, load_speed) * W_WeaponRateFactor();
319 // require letting go of the alt fire button before we can load again
320 self.hagar_loadblock = TRUE;
325 // check if we can attempt to load another rocket
326 if(!loaded && enough_ammo)
328 if(!self.hagar_loadblock && self.hagar_loadstep < time)
330 W_DecreaseAmmo(WEP_CVAR_SEC(hagar, ammo));
331 self.weaponentity.state = WS_INUSE;
332 self.hagar_load += 1;
333 sound(self, CH_WEAPON_B, "weapons/hagar_load.wav", VOL_BASE * 0.8, ATTN_NORM); // sound is too loud according to most
335 if (self.hagar_load >= WEP_CVAR_SEC(hagar, load_max))
336 self.hagar_loadstep = time + WEP_CVAR_SEC(hagar, load_hold) * W_WeaponRateFactor();
338 self.hagar_loadstep = time + WEP_CVAR_SEC(hagar, load_speed) * W_WeaponRateFactor();
341 else if(!self.hagar_loadbeep && self.hagar_load) // prevents the beep from playing each frame
343 // if this is the last rocket we can load, play a beep sound to notify the player
344 sound(self, CH_WEAPON_A, "weapons/hagar_beep.wav", VOL_BASE, ATTN_NORM);
345 self.hagar_loadbeep = TRUE;
349 else if(self.hagar_loadblock)
351 // the alt fire button has been released, so re-enable loading if blocked
352 self.hagar_loadblock = FALSE;
357 // play warning sound if we're about to release
358 if((loaded || !enough_ammo) && self.hagar_loadstep - 0.5 < time && WEP_CVAR_SEC(hagar, load_hold) >= 0)
360 if(!self.hagar_warning && self.hagar_load) // prevents the beep from playing each frame
362 // we're about to automatically release after holding time, play a beep sound to notify the player
363 sound(self, CH_WEAPON_A, "weapons/hagar_beep.wav", VOL_BASE, ATTN_NORM);
364 self.hagar_warning = TRUE;
368 // release if player let go of button or if they've held it in too long
369 if(!self.BUTTON_ATCK2 || ((loaded || !enough_ammo) && self.hagar_loadstep < time && WEP_CVAR_SEC(hagar, load_hold) >= 0))
371 self.weaponentity.state = WS_READY;
372 W_Hagar_Attack2_Load_Release();
377 self.hagar_loadbeep = FALSE;
378 self.hagar_warning = FALSE;
381 // we aren't checking ammo during an attack, so we must do it here
382 if(!(WEP_ACTION(self.weapon, WR_CHECKAMMO1) + WEP_ACTION(self.weapon, WR_CHECKAMMO2)))
384 // note: this doesn't force the switch
385 W_SwitchToOtherWeapon(self);
390 float W_Hagar(float req)
398 self.BUTTON_ATCK = bot_aim(WEP_CVAR_PRI(hagar, speed), 0, WEP_CVAR_PRI(hagar, lifetime), FALSE);
399 else // not using secondary_speed since these are only 15% and should cause some ricochets without re-aiming
400 self.BUTTON_ATCK2 = bot_aim(WEP_CVAR_PRI(hagar, speed), 0, WEP_CVAR_PRI(hagar, lifetime), FALSE);
406 float loadable_secondary;
407 loadable_secondary = (WEP_CVAR_SEC(hagar, load) && WEP_CVAR(hagar, secondary));
409 if (loadable_secondary)
410 W_Hagar_Attack2_Load(); // must always run each frame
411 if(autocvar_g_balance_hagar_reload_ammo && self.clip_load < min(WEP_CVAR_PRI(hagar, ammo), WEP_CVAR_SEC(hagar, ammo))) // forced reload
412 WEP_ACTION(self.weapon, WR_RELOAD);
413 else if (self.BUTTON_ATCK && !self.hagar_load && !self.hagar_loadblock) // not while secondary is loaded or awaiting reset
415 if (weapon_prepareattack(0, WEP_CVAR_PRI(hagar, refire)))
418 weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(hagar, refire), w_ready);
421 else if (self.BUTTON_ATCK2 && !loadable_secondary && WEP_CVAR(hagar, secondary))
423 if (weapon_prepareattack(1, WEP_CVAR_SEC(hagar, refire)))
426 weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(hagar, refire), w_ready);
434 // we lost the weapon and want to prepare switching away
437 self.weaponentity.state = WS_READY;
438 W_Hagar_Attack2_Load_Release();
445 precache_model ("models/weapons/g_hagar.md3");
446 precache_model ("models/weapons/v_hagar.md3");
447 precache_model ("models/weapons/h_hagar.iqm");
448 precache_sound ("weapons/hagar_fire.wav");
449 precache_sound ("weapons/hagar_load.wav");
450 precache_sound ("weapons/hagar_beep.wav");
451 HAGAR_SETTINGS(WEP_SKIPCVAR, WEP_SET_PROP)
456 self.hagar_loadblock = FALSE;
460 W_DecreaseAmmo(WEP_CVAR_SEC(hagar, ammo) * self.hagar_load * -1); // give back ammo if necessary
468 ammo_amount = self.WEP_AMMO(HAGAR) >= WEP_CVAR_PRI(hagar, ammo);
469 ammo_amount += self.(weapon_load[WEP_HAGAR]) >= WEP_CVAR_PRI(hagar, ammo);
474 ammo_amount = self.WEP_AMMO(HAGAR) >= WEP_CVAR_SEC(hagar, ammo);
475 ammo_amount += self.(weapon_load[WEP_HAGAR]) >= WEP_CVAR_SEC(hagar, ammo);
480 HAGAR_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS)
490 // if we have any rockets loaded when we die, release them
491 if(self.hagar_load && WEP_CVAR_SEC(hagar, load_releasedeath))
492 W_Hagar_Attack2_Load_Release();
498 if(!self.hagar_load) // require releasing loaded rockets first
499 W_Reload(min(WEP_CVAR_PRI(hagar, ammo), WEP_CVAR_SEC(hagar, ammo)), "weapons/reload.wav");
503 case WR_SUICIDEMESSAGE:
505 return WEAPON_HAGAR_SUICIDE;
509 if(w_deathtype & HITTYPE_SECONDARY)
510 return WEAPON_HAGAR_MURDER_BURST;
512 return WEAPON_HAGAR_MURDER_SPRAY;
519 float W_Hagar(float req)
523 case WR_IMPACTEFFECT:
526 org2 = w_org + w_backoff * 6;
527 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
531 sound(self, CH_SHOTS, "weapons/hagexp1.wav", VOL_BASE, ATTN_NORM);
532 else if (w_random<0.7)
533 sound(self, CH_SHOTS, "weapons/hagexp2.wav", VOL_BASE, ATTN_NORM);
535 sound(self, CH_SHOTS, "weapons/hagexp3.wav", VOL_BASE, ATTN_NORM);
542 precache_sound("weapons/hagexp1.wav");
543 precache_sound("weapons/hagexp2.wav");
544 precache_sound("weapons/hagexp3.wav");
549 // no weapon specific image for this weapon