2 REGISTER_WEAPON(HAGAR, w_hagar, IT_ROCKETS, 8, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH, BOT_PICKUP_RATING_MID, "hagar", "hagar", _("Hagar"))
5 // NO bounce protection, as bounces are limited!
7 void W_Hagar_Explode (void)
9 self.event_damage = SUB_Null;
10 RadiusDamage (self, self.realowner, autocvar_g_balance_hagar_primary_damage, autocvar_g_balance_hagar_primary_edgedamage, autocvar_g_balance_hagar_primary_radius, world, autocvar_g_balance_hagar_primary_force, self.projectiledeathtype, other);
15 void W_Hagar_Explode2 (void)
17 self.event_damage = SUB_Null;
18 RadiusDamage (self, self.realowner, autocvar_g_balance_hagar_secondary_damage, autocvar_g_balance_hagar_secondary_edgedamage, autocvar_g_balance_hagar_secondary_radius, world, autocvar_g_balance_hagar_secondary_force, self.projectiledeathtype, other);
23 void W_Hagar_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
28 float is_linkexplode = ((inflictor.owner == self.owner)
29 && (inflictor.projectiledeathtype & HITTYPE_SECONDARY)
30 && (self.projectiledeathtype & HITTYPE_SECONDARY));
33 float is_linkexplode = ( ( ((inflictor.realowner == self.realowner)
34 && (inflictor.projectiledeathtype & HITTYPE_SECONDARY))
35 || (deathtype == DEATH_SLIME || deathtype == DEATH_LAVA) )
36 && (self.projectiledeathtype & HITTYPE_SECONDARY) );
40 is_linkexplode = (is_linkexplode && autocvar_g_balance_hagar_secondary_load_linkexplode);
42 is_linkexplode = -1; // not secondary load, so continue as normal without exception.
44 print(strcat("is_linkexplode: ", ftos(is_linkexplode), ", inflict_owner_classname: ", inflictor.owner.classname, ", self_owner_classname: ", self.owner.classname, ". \n"));
46 if (!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, is_linkexplode))
47 return; // g_projectiles_damage says to halt
49 self.health = self.health - damage;
50 self.angles = vectoangles(self.velocity);
53 W_PrepareExplosionByDamage(attacker, self.think);
56 void W_Hagar_Touch (void)
62 void W_Hagar_Touch2 (void)
66 if(self.cnt > 0 || other.takedamage == DAMAGE_AIM) {
70 pointparticles(particleeffectnum("hagar_bounce"), self.origin, self.velocity, 1);
71 self.angles = vectoangles (self.velocity);
73 self.projectiledeathtype |= HITTYPE_BOUNCE;
77 void W_Hagar_Attack (void)
81 W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_hagar_primary_ammo, autocvar_g_balance_hagar_reload_ammo);
83 W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CH_WEAPON_A, autocvar_g_balance_hagar_primary_damage);
85 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
88 missile.owner = missile.realowner = self;
89 missile.classname = "missile";
90 missile.bot_dodge = TRUE;
91 missile.bot_dodgerating = autocvar_g_balance_hagar_primary_damage;
93 missile.takedamage = DAMAGE_YES;
94 missile.health = autocvar_g_balance_hagar_primary_health;
95 missile.damageforcescale = autocvar_g_balance_hagar_primary_damageforcescale;
96 missile.event_damage = W_Hagar_Damage;
97 missile.damagedbycontents = TRUE;
99 missile.touch = W_Hagar_Touch;
100 missile.use = W_Hagar_Explode;
101 missile.think = adaptor_think2use_hittype_splash;
102 missile.nextthink = time + autocvar_g_balance_hagar_primary_lifetime;
103 PROJECTILE_MAKETRIGGER(missile);
104 missile.projectiledeathtype = WEP_HAGAR;
105 setorigin (missile, w_shotorg);
106 setsize(missile, '0 0 0', '0 0 0');
108 missile.movetype = MOVETYPE_FLY;
109 W_SETUPPROJECTILEVELOCITY(missile, g_balance_hagar_primary);
111 missile.angles = vectoangles (missile.velocity);
112 missile.flags = FL_PROJECTILE;
114 CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR, TRUE);
116 other = missile; MUTATOR_CALLHOOK(EditProjectile);
119 void W_Hagar_Attack2 (void)
123 W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_hagar_secondary_ammo, autocvar_g_balance_hagar_reload_ammo);
125 W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CH_WEAPON_A, autocvar_g_balance_hagar_secondary_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 = autocvar_g_balance_hagar_secondary_damage;
135 missile.takedamage = DAMAGE_YES;
136 missile.health = autocvar_g_balance_hagar_secondary_health;
137 missile.damageforcescale = autocvar_g_balance_hagar_secondary_damageforcescale;
138 missile.event_damage = W_Hagar_Damage;
139 missile.damagedbycontents = TRUE;
141 missile.touch = W_Hagar_Touch2;
143 missile.use = W_Hagar_Explode2;
144 missile.think = adaptor_think2use_hittype_splash;
145 missile.nextthink = time + autocvar_g_balance_hagar_secondary_lifetime_min + random() * autocvar_g_balance_hagar_secondary_lifetime_rand;
146 PROJECTILE_MAKETRIGGER(missile);
147 missile.projectiledeathtype = WEP_HAGAR | HITTYPE_SECONDARY;
148 setorigin (missile, w_shotorg);
149 setsize(missile, '0 0 0', '0 0 0');
151 missile.movetype = MOVETYPE_BOUNCEMISSILE;
152 W_SETUPPROJECTILEVELOCITY(missile, g_balance_hagar_secondary);
154 missile.angles = vectoangles (missile.velocity);
155 missile.flags = FL_PROJECTILE;
157 CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR_BOUNCING, TRUE);
159 other = missile; MUTATOR_CALLHOOK(EditProjectile);
162 .float hagar_loadstep, hagar_loadblock, hagar_loadbeep, hagar_warning;
163 void W_Hagar_Attack2_Load_Release (void)
165 // time to release the rockets we've loaded
168 float counter, shots, spread_pershot;
170 vector forward, right, up;
175 weapon_prepareattack_do(1, autocvar_g_balance_hagar_secondary_refire);
177 W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CH_WEAPON_A, autocvar_g_balance_hagar_secondary_damage);
178 pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
184 shots = self.hagar_load;
186 while (counter < shots)
189 missile.owner = missile.realowner = self;
190 missile.classname = "missile";
191 missile.bot_dodge = TRUE;
192 missile.bot_dodgerating = autocvar_g_balance_hagar_secondary_damage;
194 missile.takedamage = DAMAGE_YES;
195 missile.health = autocvar_g_balance_hagar_secondary_health;
196 missile.damageforcescale = autocvar_g_balance_hagar_secondary_damageforcescale;
197 missile.event_damage = W_Hagar_Damage;
198 missile.damagedbycontents = TRUE;
200 missile.touch = W_Hagar_Touch; // not bouncy
201 missile.use = W_Hagar_Explode2;
202 missile.think = adaptor_think2use_hittype_splash;
203 missile.nextthink = time + autocvar_g_balance_hagar_secondary_lifetime_min + random() * autocvar_g_balance_hagar_secondary_lifetime_rand;
204 PROJECTILE_MAKETRIGGER(missile);
205 missile.projectiledeathtype = WEP_HAGAR | HITTYPE_SECONDARY;
206 setorigin (missile, w_shotorg);
207 setsize(missile, '0 0 0', '0 0 0');
208 missile.movetype = MOVETYPE_FLY;
210 // per-shot spread calculation: the more shots there are, the less spread is applied (based on the bias cvar)
211 spread_pershot = ((shots - 1) / (autocvar_g_balance_hagar_secondary_load_max - 1));
212 spread_pershot = (1 - (spread_pershot * autocvar_g_balance_hagar_secondary_load_spread_bias));
213 spread_pershot = (autocvar_g_balance_hagar_secondary_spread * spread_pershot * g_weaponspreadfactor);
215 // pattern spread calculation
221 makevectors('0 360 0' * (0.75 + (counter - 0.5) / (shots - 1)));
225 s = s * autocvar_g_balance_hagar_secondary_load_spread * g_weaponspreadfactor;
227 W_SetupProjectileVelocityEx(missile, w_shotdir + right * s_y + up * s_z, v_up, autocvar_g_balance_hagar_secondary_speed, 0, 0, spread_pershot, FALSE);
229 missile.angles = vectoangles (missile.velocity);
230 missile.flags = FL_PROJECTILE;
232 CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR, TRUE);
234 other = missile; MUTATOR_CALLHOOK(EditProjectile);
236 counter = counter + 1;
239 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_hagar_secondary_load_animtime, w_ready);
240 self.hagar_loadstep = time + autocvar_g_balance_hagar_secondary_refire * W_WeaponRateFactor();
244 void W_Hagar_Attack2_Load (void)
246 // loadable hagar secondary attack, must always run each frame
248 float loaded, enough_ammo;
249 loaded = self.hagar_load >= autocvar_g_balance_hagar_secondary_load_max;
251 // this is different than WR_CHECKAMMO when it comes to reloading
252 if(autocvar_g_balance_hagar_reload_ammo)
253 enough_ammo = self.(weapon_load[WEP_HAGAR]) >= autocvar_g_balance_hagar_secondary_ammo;
255 enough_ammo = self.ammo_rockets >= autocvar_g_balance_hagar_secondary_ammo;
257 if(self.BUTTON_ATCK2)
259 if(self.BUTTON_ATCK && autocvar_g_balance_hagar_secondary_load_abort)
263 // if we pressed primary fire while loading, unload all rockets and abort
264 self.weaponentity.state = WS_READY;
265 W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_hagar_secondary_ammo * self.hagar_load * -1, autocvar_g_balance_hagar_reload_ammo); // give back ammo
267 sound(self, CH_WEAPON_A, "weapons/hagar_beep.wav", VOL_BASE, ATTN_NORM);
269 // pause until we can load rockets again, once we re-press the alt fire button
270 self.hagar_loadstep = time + autocvar_g_balance_hagar_secondary_load_speed * W_WeaponRateFactor();
272 // require letting go of the alt fire button before we can load again
273 self.hagar_loadblock = TRUE;
278 // check if we can attempt to load another rocket
279 if(!loaded && enough_ammo)
281 if(!self.hagar_loadblock && self.hagar_loadstep < time)
283 W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_hagar_secondary_ammo, autocvar_g_balance_hagar_reload_ammo);
284 self.weaponentity.state = WS_INUSE;
285 self.hagar_load += 1;
286 sound(self, CH_WEAPON_B, "weapons/hagar_load.wav", VOL_BASE * 0.8, ATTN_NORM); // sound is too loud according to most
288 if (self.hagar_load >= autocvar_g_balance_hagar_secondary_load_max)
289 self.hagar_loadstep = time + autocvar_g_balance_hagar_secondary_load_hold * W_WeaponRateFactor();
291 self.hagar_loadstep = time + autocvar_g_balance_hagar_secondary_load_speed * W_WeaponRateFactor();
294 else if(!self.hagar_loadbeep && self.hagar_load) // prevents the beep from playing each frame
296 // if this is the last rocket we can load, play a beep sound to notify the player
297 sound(self, CH_WEAPON_A, "weapons/hagar_beep.wav", VOL_BASE, ATTN_NORM);
298 self.hagar_loadbeep = TRUE;
302 else if(self.hagar_loadblock)
304 // the alt fire button has been released, so re-enable loading if blocked
305 self.hagar_loadblock = FALSE;
310 // play warning sound if we're about to release
311 if((loaded || !enough_ammo) && self.hagar_loadstep - 0.5 < time && autocvar_g_balance_hagar_secondary_load_hold >= 0)
313 if(!self.hagar_warning && self.hagar_load) // prevents the beep from playing each frame
315 // we're about to automatically release after holding time, play a beep sound to notify the player
316 sound(self, CH_WEAPON_A, "weapons/hagar_beep.wav", VOL_BASE, ATTN_NORM);
317 self.hagar_warning = TRUE;
321 // release if player let go of button or if they've held it in too long
322 if(!self.BUTTON_ATCK2 || ((loaded || !enough_ammo) && self.hagar_loadstep < time && autocvar_g_balance_hagar_secondary_load_hold >= 0))
324 self.weaponentity.state = WS_READY;
325 W_Hagar_Attack2_Load_Release();
330 self.hagar_loadbeep = FALSE;
331 self.hagar_warning = FALSE;
334 // we aren't checking ammo during an attack, so we must do it here
335 if not(weapon_action(self.weapon, WR_CHECKAMMO1) + weapon_action(self.weapon, WR_CHECKAMMO2))
337 // note: this doesn't force the switch
338 W_SwitchToOtherWeapon(self);
343 void spawnfunc_weapon_hagar (void)
345 weapon_defaultspawnfunc(WEP_HAGAR);
348 float w_hagar(float req)
353 self.BUTTON_ATCK = bot_aim(autocvar_g_balance_hagar_primary_speed, 0, autocvar_g_balance_hagar_primary_lifetime, FALSE);
356 // not using secondary_speed since these are only 15% and should cause some ricochets without re-aiming
357 self.BUTTON_ATCK2 = bot_aim(autocvar_g_balance_hagar_primary_speed, 0, autocvar_g_balance_hagar_primary_lifetime, FALSE);
359 else if (req == WR_THINK)
361 float loadable_secondary;
362 loadable_secondary = autocvar_g_balance_hagar_secondary_load && autocvar_g_balance_hagar_secondary;
364 if (loadable_secondary)
365 W_Hagar_Attack2_Load(); // must always run each frame
366 if(autocvar_g_balance_hagar_reload_ammo && self.clip_load < min(autocvar_g_balance_hagar_primary_ammo, autocvar_g_balance_hagar_secondary_ammo)) // forced reload
367 weapon_action(self.weapon, WR_RELOAD);
368 else if (self.BUTTON_ATCK && !self.hagar_load && !self.hagar_loadblock) // not while secondary is loaded or awaiting reset
370 if (weapon_prepareattack(0, autocvar_g_balance_hagar_primary_refire))
373 weapon_thinkf(WFRAME_FIRE1, autocvar_g_balance_hagar_primary_refire, w_ready);
376 else if (self.BUTTON_ATCK2 && !loadable_secondary && autocvar_g_balance_hagar_secondary)
378 if (weapon_prepareattack(1, autocvar_g_balance_hagar_secondary_refire))
381 weapon_thinkf(WFRAME_FIRE2, autocvar_g_balance_hagar_secondary_refire, w_ready);
385 else if (req == WR_GONETHINK)
387 // we lost the weapon and want to prepare switching away
390 self.weaponentity.state = WS_READY;
391 W_Hagar_Attack2_Load_Release();
394 else if (req == WR_PRECACHE)
396 precache_model ("models/weapons/g_hagar.md3");
397 precache_model ("models/weapons/v_hagar.md3");
398 precache_model ("models/weapons/h_hagar.iqm");
399 precache_sound ("weapons/hagar_fire.wav");
400 precache_sound ("weapons/hagar_load.wav");
401 precache_sound ("weapons/hagar_beep.wav");
402 //precache_sound ("weapons/reload.wav"); // until weapons have individual reload sounds, precache the reload sound somewhere else
404 else if (req == WR_SETUP)
406 weapon_setup(WEP_HAGAR);
407 self.current_ammo = ammo_rockets;
408 self.hagar_loadblock = FALSE;
412 W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_hagar_secondary_ammo * self.hagar_load * -1, autocvar_g_balance_hagar_reload_ammo); // give back ammo if necessary
416 else if (req == WR_CHECKAMMO1)
418 ammo_amount = self.ammo_rockets >= autocvar_g_balance_hagar_primary_ammo;
419 ammo_amount += self.(weapon_load[WEP_HAGAR]) >= autocvar_g_balance_hagar_primary_ammo;
422 else if (req == WR_CHECKAMMO2)
424 ammo_amount = self.ammo_rockets >= autocvar_g_balance_hagar_secondary_ammo;
425 ammo_amount += self.(weapon_load[WEP_HAGAR]) >= autocvar_g_balance_hagar_secondary_ammo;
428 else if (req == WR_RESETPLAYER)
432 else if (req == WR_PLAYERDEATH)
434 // if we have any rockets loaded when we die, release them
435 if(self.hagar_load && autocvar_g_balance_hagar_secondary_load_releasedeath)
436 W_Hagar_Attack2_Load_Release();
438 else if (req == WR_RELOAD)
440 if not(self.hagar_load) // require releasing loaded rockets first
441 W_Reload(min(autocvar_g_balance_hagar_primary_ammo, autocvar_g_balance_hagar_secondary_ammo), autocvar_g_balance_hagar_reload_ammo, autocvar_g_balance_hagar_reload_time, "weapons/reload.wav");
447 float w_hagar(float req)
449 if(req == WR_IMPACTEFFECT)
452 org2 = w_org + w_backoff * 6;
453 pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
457 sound(self, CH_SHOTS, "weapons/hagexp1.wav", VOL_BASE, ATTN_NORM);
458 else if (w_random<0.7)
459 sound(self, CH_SHOTS, "weapons/hagexp2.wav", VOL_BASE, ATTN_NORM);
461 sound(self, CH_SHOTS, "weapons/hagexp3.wav", VOL_BASE, ATTN_NORM);
464 else if(req == WR_PRECACHE)
466 precache_sound("weapons/hagexp1.wav");
467 precache_sound("weapons/hagexp2.wav");
468 precache_sound("weapons/hagexp3.wav");
470 else if (req == WR_SUICIDEMESSAGE)
471 w_deathtypestring = _("%s played with tiny hagar rockets");
472 else if (req == WR_KILLMESSAGE)
474 if(w_deathtype & HITTYPE_BOUNCE) // must be secondary; unchecked: SPLASH
475 w_deathtypestring = _("%s was pummeled with a burst of hagar rockets by %s");
476 else // unchecked: SPLASH, SECONDARY
477 w_deathtypestring = _("%s was pummeled with hagar rockets by %s");