]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/weapons/w_hagar.qc
Merge remote-tracking branch 'origin/master' into samual/weapons
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / w_hagar.qc
1 #ifdef REGISTER_WEAPON
2 REGISTER_WEAPON(
3 /* WEP_##id */ HAGAR,
4 /* function */ w_hagar,
5 /* ammotype */ IT_ROCKETS,
6 /* impulse  */ 8,
7 /* flags    */ WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH,
8 /* rating   */ BOT_PICKUP_RATING_MID,
9 /* model    */ "hagar",
10 /* netname  */ "hagar",
11 /* fullname */ _("Hagar")
12 );
13
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, refire) \
21         WEP_ADD_CVAR(weapon, MO_BOTH, speed) \
22         WEP_ADD_CVAR(weapon, MO_BOTH, damageforcescale) \
23         WEP_ADD_CVAR(weapon, MO_BOTH, health) \
24         WEP_ADD_CVAR(weapon, MO_PRI,  lifetime) \
25         WEP_ADD_CVAR(weapon, MO_NONE, secondary) \
26         WEP_ADD_CVAR(weapon, MO_SEC,  spread) \
27         WEP_ADD_CVAR(weapon, MO_SEC,  load) \
28         WEP_ADD_CVAR(weapon, MO_SEC,  load_max) \
29         WEP_ADD_CVAR(weapon, MO_SEC,  load_abort) \
30         WEP_ADD_CVAR(weapon, MO_SEC,  load_animtime) \
31         WEP_ADD_CVAR(weapon, MO_SEC,  load_hold) \
32         WEP_ADD_CVAR(weapon, MO_SEC,  load_speed) \
33         WEP_ADD_CVAR(weapon, MO_SEC,  load_releasedeath) \
34         WEP_ADD_CVAR(weapon, MO_SEC,  load_spread) \
35         WEP_ADD_CVAR(weapon, MO_SEC,  load_spread_bias) \
36         WEP_ADD_CVAR(weapon, MO_SEC,  load_linkexplode) \
37         WEP_ADD_CVAR(weapon, MO_SEC,  lifetime_min) \
38         WEP_ADD_CVAR(weapon, MO_SEC,  lifetime_rand) \
39         WEP_ADD_PROP(weapon, reloading_ammo, reload_ammo) \
40         WEP_ADD_PROP(weapon, reloading_time, reload_time) \
41         WEP_ADD_PROP(weapon, switchdelay_raise, switchdelay_raise) \
42         WEP_ADD_PROP(weapon, switchdelay_drop, switchdelay_drop)
43
44 #ifdef SVQC
45 HAGAR_SETTINGS(hagar)
46 #endif
47 #else
48 #ifdef SVQC
49 void spawnfunc_weapon_hagar() { weapon_defaultspawnfunc(WEP_HAGAR); }
50
51 // NO bounce protection, as bounces are limited!
52
53 void W_Hagar_Explode (void)
54 {
55         self.event_damage = func_null;
56         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);
57
58         remove (self);
59 }
60
61 void W_Hagar_Explode2 (void)
62 {
63         self.event_damage = func_null;
64         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);
65
66         remove (self);
67 }
68
69 void W_Hagar_Damage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
70 {
71         if (self.health <= 0)
72                 return;
73                 
74         float is_linkexplode = ( ((inflictor.owner != world) ? (inflictor.owner == self.owner) : TRUE)
75                 && (inflictor.projectiledeathtype & HITTYPE_SECONDARY) 
76                 && (self.projectiledeathtype & HITTYPE_SECONDARY));
77         
78         if(is_linkexplode)
79                 is_linkexplode = (is_linkexplode && WEP_CVAR_SEC(hagar, load_linkexplode));
80         else
81                 is_linkexplode = -1; // not secondary load, so continue as normal without exception.
82
83         if (!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, is_linkexplode))
84                 return; // g_projectiles_damage says to halt
85
86         self.health = self.health - damage;
87         self.angles = vectoangles(self.velocity);
88         
89         if (self.health <= 0)
90                 W_PrepareExplosionByDamage(attacker, self.think);
91 }
92
93 void W_Hagar_Touch (void)
94 {
95         PROJECTILE_TOUCH;
96         self.use ();
97 }
98
99 void W_Hagar_Touch2 (void)
100 {
101         PROJECTILE_TOUCH;
102
103         if(self.cnt > 0 || other.takedamage == DAMAGE_AIM) {
104                 self.use();
105         } else {
106                 self.cnt++;
107                 pointparticles(particleeffectnum("hagar_bounce"), self.origin, self.velocity, 1);
108                 self.angles = vectoangles (self.velocity);
109                 self.owner = world;
110                 self.projectiledeathtype |= HITTYPE_BOUNCE;
111         }
112 }
113
114 void W_Hagar_Attack (void)
115 {
116         entity missile;
117
118         W_DecreaseAmmo(ammo_rockets, WEP_CVAR_PRI(hagar, ammo), autocvar_g_balance_hagar_reload_ammo);
119
120         W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CH_WEAPON_A, WEP_CVAR_PRI(hagar, damage));
121
122         pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
123
124         missile = spawn ();
125         missile.owner = missile.realowner = self;
126         missile.classname = "missile";
127         missile.bot_dodge = TRUE;
128         missile.bot_dodgerating = WEP_CVAR_PRI(hagar, damage);
129         
130         missile.takedamage = DAMAGE_YES;
131         missile.health = WEP_CVAR_PRI(hagar, health);
132         missile.damageforcescale = WEP_CVAR_PRI(hagar, damageforcescale);
133         missile.event_damage = W_Hagar_Damage;
134         missile.damagedbycontents = TRUE;
135         
136         missile.touch = W_Hagar_Touch;
137         missile.use = W_Hagar_Explode;
138         missile.think = adaptor_think2use_hittype_splash;
139         missile.nextthink = time + WEP_CVAR_PRI(hagar, lifetime);
140         PROJECTILE_MAKETRIGGER(missile);
141         missile.projectiledeathtype = WEP_HAGAR;
142         setorigin (missile, w_shotorg);
143         setsize(missile, '0 0 0', '0 0 0');
144
145         missile.movetype = MOVETYPE_FLY;
146         W_SETUPPROJECTILEVELOCITY(missile, g_balance_hagar_primary);
147
148         missile.angles = vectoangles (missile.velocity);
149         missile.flags = FL_PROJECTILE;
150         missile.missile_flags = MIF_SPLASH; 
151
152         CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR, TRUE);
153
154         other = missile; MUTATOR_CALLHOOK(EditProjectile);
155 }
156
157 void W_Hagar_Attack2 (void)
158 {
159         entity missile;
160
161         W_DecreaseAmmo(ammo_rockets, WEP_CVAR_SEC(hagar, ammo), autocvar_g_balance_hagar_reload_ammo);
162
163         W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CH_WEAPON_A, WEP_CVAR_SEC(hagar, damage));
164
165         pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
166
167         missile = spawn ();
168         missile.owner = missile.realowner = self;
169         missile.classname = "missile";
170         missile.bot_dodge = TRUE;
171         missile.bot_dodgerating = WEP_CVAR_SEC(hagar, damage);
172         
173         missile.takedamage = DAMAGE_YES;
174         missile.health = WEP_CVAR_SEC(hagar, health);
175         missile.damageforcescale = WEP_CVAR_SEC(hagar, damageforcescale);
176         missile.event_damage = W_Hagar_Damage;
177         missile.damagedbycontents = TRUE;
178
179         missile.touch = W_Hagar_Touch2;
180         missile.cnt = 0;
181         missile.use = W_Hagar_Explode2;
182         missile.think = adaptor_think2use_hittype_splash;
183         missile.nextthink = time + WEP_CVAR_SEC(hagar, lifetime_min) + random() * WEP_CVAR_SEC(hagar, lifetime_rand);
184         PROJECTILE_MAKETRIGGER(missile);
185         missile.projectiledeathtype = WEP_HAGAR | HITTYPE_SECONDARY;
186         setorigin (missile, w_shotorg);
187         setsize(missile, '0 0 0', '0 0 0');
188
189         missile.movetype = MOVETYPE_BOUNCEMISSILE;
190         W_SETUPPROJECTILEVELOCITY(missile, g_balance_hagar_secondary);
191
192         missile.angles = vectoangles (missile.velocity);
193         missile.flags = FL_PROJECTILE;
194         missile.missile_flags = MIF_SPLASH; 
195
196         CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR_BOUNCING, TRUE);
197
198         other = missile; MUTATOR_CALLHOOK(EditProjectile);
199 }
200
201 .float hagar_loadstep, hagar_loadblock, hagar_loadbeep, hagar_warning;
202 void W_Hagar_Attack2_Load_Release (void)
203 {
204         // time to release the rockets we've loaded
205
206         entity missile;
207         float counter, shots, spread_pershot;
208         vector s;
209         vector forward, right, up;
210
211         if(!self.hagar_load)
212                 return;
213
214         weapon_prepareattack_do(1, WEP_CVAR_SEC(hagar, refire));
215
216         W_SetupShot (self, FALSE, 2, "weapons/hagar_fire.wav", CH_WEAPON_A, WEP_CVAR_SEC(hagar, damage));
217         pointparticles(particleeffectnum("hagar_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
218
219         forward = v_forward;
220         right = v_right;
221         up = v_up;
222
223         shots = self.hagar_load;
224         missile = world;
225         for(counter = 0; counter < shots; ++counter)
226         {
227                 missile = spawn ();
228                 missile.owner = missile.realowner = self;
229                 missile.classname = "missile";
230                 missile.bot_dodge = TRUE;
231                 missile.bot_dodgerating = WEP_CVAR_SEC(hagar, damage);
232                 
233                 missile.takedamage = DAMAGE_YES;
234                 missile.health = WEP_CVAR_SEC(hagar, health);
235                 missile.damageforcescale = WEP_CVAR_SEC(hagar, damageforcescale);
236                 missile.event_damage = W_Hagar_Damage;
237                 missile.damagedbycontents = TRUE;
238
239                 missile.touch = W_Hagar_Touch; // not bouncy
240                 missile.use = W_Hagar_Explode2;
241                 missile.think = adaptor_think2use_hittype_splash;
242                 missile.nextthink = time + WEP_CVAR_SEC(hagar, lifetime_min) + random() * WEP_CVAR_SEC(hagar, lifetime_rand);
243                 PROJECTILE_MAKETRIGGER(missile);
244                 missile.projectiledeathtype = WEP_HAGAR | HITTYPE_SECONDARY;
245                 setorigin (missile, w_shotorg);
246                 setsize(missile, '0 0 0', '0 0 0');
247                 missile.movetype = MOVETYPE_FLY;
248                 missile.missile_flags = MIF_SPLASH; 
249                 
250                 // per-shot spread calculation: the more shots there are, the less spread is applied (based on the bias cvar)
251                 spread_pershot = ((shots - 1) / (WEP_CVAR_SEC(hagar, load_max) - 1)); 
252                 spread_pershot = (1 - (spread_pershot * WEP_CVAR_SEC(hagar, load_spread_bias)));
253                 spread_pershot = (WEP_CVAR_SEC(hagar, spread) * spread_pershot * g_weaponspreadfactor);
254                 
255                 // pattern spread calculation
256                 s = '0 0 0';
257                 if (counter == 0)
258                         s = '0 0 0';
259                 else
260                 {
261                         makevectors('0 360 0' * (0.75 + (counter - 0.5) / (shots - 1)));
262                         s_y = v_forward_x;
263                         s_z = v_forward_y;
264                 }
265                 s = s * WEP_CVAR_SEC(hagar, load_spread) * g_weaponspreadfactor;
266                 
267                 W_SetupProjectileVelocityEx(missile, w_shotdir + right * s_y + up * s_z, v_up, WEP_CVAR_SEC(hagar, speed), 0, 0, spread_pershot, FALSE);
268
269                 missile.angles = vectoangles (missile.velocity);
270                 missile.flags = FL_PROJECTILE;
271
272                 CSQCProjectile(missile, TRUE, PROJECTILE_HAGAR, TRUE);
273
274                 other = missile; MUTATOR_CALLHOOK(EditProjectile);
275         }
276
277         weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(hagar, load_animtime), w_ready);
278         self.hagar_loadstep = time + WEP_CVAR_SEC(hagar, refire) * W_WeaponRateFactor();
279         self.hagar_load = 0;
280 }
281
282 void W_Hagar_Attack2_Load (void)
283 {
284         // loadable hagar secondary attack, must always run each frame
285         
286         if(time < game_starttime)
287                 return;
288
289         float loaded, enough_ammo;
290         loaded = self.hagar_load >= WEP_CVAR_SEC(hagar, load_max);
291
292         // this is different than WR_CHECKAMMO when it comes to reloading
293         if(autocvar_g_balance_hagar_reload_ammo)
294                 enough_ammo = self.(weapon_load[WEP_HAGAR]) >= WEP_CVAR_SEC(hagar, ammo);
295         else
296                 enough_ammo = self.ammo_rockets >= WEP_CVAR_SEC(hagar, ammo);
297
298         if(self.BUTTON_ATCK2)
299         {
300                 if(self.BUTTON_ATCK && WEP_CVAR_SEC(hagar, load_abort))
301                 {
302                         if(self.hagar_load)
303                         {
304                                 // if we pressed primary fire while loading, unload all rockets and abort
305                                 self.weaponentity.state = WS_READY;
306                                 W_DecreaseAmmo(ammo_rockets, WEP_CVAR_SEC(hagar, ammo) * self.hagar_load * -1, autocvar_g_balance_hagar_reload_ammo); // give back ammo
307                                 self.hagar_load = 0;
308                                 sound(self, CH_WEAPON_A, "weapons/hagar_beep.wav", VOL_BASE, ATTN_NORM);
309
310                                 // pause until we can load rockets again, once we re-press the alt fire button
311                                 self.hagar_loadstep = time + WEP_CVAR_SEC(hagar, load_speed) * W_WeaponRateFactor();
312
313                                 // require letting go of the alt fire button before we can load again
314                                 self.hagar_loadblock = TRUE;
315                         }
316                 }
317                 else
318                 {
319                         // check if we can attempt to load another rocket
320                         if(!loaded && enough_ammo)
321                         {
322                                 if(!self.hagar_loadblock && self.hagar_loadstep < time)
323                                 {
324                                         W_DecreaseAmmo(ammo_rockets, WEP_CVAR_SEC(hagar, ammo), autocvar_g_balance_hagar_reload_ammo);
325                                         self.weaponentity.state = WS_INUSE;
326                                         self.hagar_load += 1;
327                                         sound(self, CH_WEAPON_B, "weapons/hagar_load.wav", VOL_BASE * 0.8, ATTN_NORM); // sound is too loud according to most
328
329                                         if (self.hagar_load >= WEP_CVAR_SEC(hagar, load_max))
330                                                 self.hagar_loadstep = time + WEP_CVAR_SEC(hagar, load_hold) * W_WeaponRateFactor();
331                                         else
332                                                 self.hagar_loadstep = time + WEP_CVAR_SEC(hagar, load_speed) * W_WeaponRateFactor();
333                                 }
334                         }
335                         else if(!self.hagar_loadbeep && self.hagar_load) // prevents the beep from playing each frame
336                         {
337                                 // if this is the last rocket we can load, play a beep sound to notify the player
338                                 sound(self, CH_WEAPON_A, "weapons/hagar_beep.wav", VOL_BASE, ATTN_NORM);
339                                 self.hagar_loadbeep = TRUE;
340                         }
341                 }
342         }
343         else if(self.hagar_loadblock)
344         {
345                 // the alt fire button has been released, so re-enable loading if blocked
346                 self.hagar_loadblock = FALSE;
347         }
348
349         if(self.hagar_load)
350         {
351                 // play warning sound if we're about to release
352                 if((loaded || !enough_ammo) && self.hagar_loadstep - 0.5 < time && WEP_CVAR_SEC(hagar, load_hold) >= 0)
353                 {
354                         if(!self.hagar_warning && self.hagar_load) // prevents the beep from playing each frame
355                         {
356                                 // we're about to automatically release after holding time, play a beep sound to notify the player
357                                 sound(self, CH_WEAPON_A, "weapons/hagar_beep.wav", VOL_BASE, ATTN_NORM);
358                                 self.hagar_warning = TRUE;
359                         }
360                 }
361                 
362                 // release if player let go of button or if they've held it in too long
363                 if(!self.BUTTON_ATCK2 || ((loaded || !enough_ammo) && self.hagar_loadstep < time && WEP_CVAR_SEC(hagar, load_hold) >= 0))
364                 {
365                         self.weaponentity.state = WS_READY;
366                         W_Hagar_Attack2_Load_Release();
367                 }
368         }
369         else
370         {
371                 self.hagar_loadbeep = FALSE;
372                 self.hagar_warning = FALSE;
373         }
374
375         // we aren't checking ammo during an attack, so we must do it here
376         if not(WEP_ACTION(self.weapon, WR_CHECKAMMO1) + WEP_ACTION(self.weapon, WR_CHECKAMMO2))
377         {
378                 // note: this doesn't force the switch
379                 W_SwitchToOtherWeapon(self);
380                 return;
381         }
382 }
383
384 float w_hagar(float req)
385 {
386         float ammo_amount;
387         switch(req)
388         {
389                 case WR_AIM:
390                 {
391                         if (random()>0.15)
392                                 self.BUTTON_ATCK = bot_aim(WEP_CVAR_PRI(hagar, speed), 0, WEP_CVAR_PRI(hagar, lifetime), FALSE);
393                         else // not using secondary_speed since these are only 15% and should cause some ricochets without re-aiming
394                                 self.BUTTON_ATCK2 = bot_aim(WEP_CVAR_PRI(hagar, speed), 0, WEP_CVAR_PRI(hagar, lifetime), FALSE);
395                                 
396                         return TRUE;
397                 }
398                 case WR_THINK:
399                 {
400                         float loadable_secondary;
401                         loadable_secondary = (WEP_CVAR_SEC(hagar, load) && WEP_CVAR(hagar, secondary));
402
403                         if (loadable_secondary)
404                                 W_Hagar_Attack2_Load(); // must always run each frame
405                         if(autocvar_g_balance_hagar_reload_ammo && self.clip_load < min(WEP_CVAR_PRI(hagar, ammo), WEP_CVAR_SEC(hagar, ammo))) // forced reload
406                                 WEP_ACTION(self.weapon, WR_RELOAD);
407                         else if (self.BUTTON_ATCK && !self.hagar_load && !self.hagar_loadblock) // not while secondary is loaded or awaiting reset
408                         {
409                                 if (weapon_prepareattack(0, WEP_CVAR_PRI(hagar, refire)))
410                                 {
411                                         W_Hagar_Attack();
412                                         weapon_thinkf(WFRAME_FIRE1, WEP_CVAR_PRI(hagar, refire), w_ready);
413                                 }
414                         }
415                         else if (self.BUTTON_ATCK2 && !loadable_secondary && WEP_CVAR(hagar, secondary))
416                         {
417                                 if (weapon_prepareattack(1, WEP_CVAR_SEC(hagar, refire)))
418                                 {
419                                         W_Hagar_Attack2();
420                                         weapon_thinkf(WFRAME_FIRE2, WEP_CVAR_SEC(hagar, refire), w_ready);
421                                 }
422                         }
423                         
424                         return TRUE;
425                 }
426                 case WR_GONETHINK:
427                 {
428                         // we lost the weapon and want to prepare switching away
429                         if(self.hagar_load)
430                         {
431                                 self.weaponentity.state = WS_READY;
432                                 W_Hagar_Attack2_Load_Release();
433                         }
434                         
435                         return TRUE;
436                 }
437                 case WR_INIT:
438                 {
439                         precache_model ("models/weapons/g_hagar.md3");
440                         precache_model ("models/weapons/v_hagar.md3");
441                         precache_model ("models/weapons/h_hagar.iqm");
442                         precache_sound ("weapons/hagar_fire.wav");
443                         precache_sound ("weapons/hagar_load.wav");
444                         precache_sound ("weapons/hagar_beep.wav");
445                         WEP_SET_PROPS(HAGAR_SETTINGS(hagar), WEP_HAGAR)
446                         return TRUE;
447                 }
448                 case WR_SETUP:
449                 {
450                         self.current_ammo = ammo_rockets;
451                         self.hagar_loadblock = FALSE;
452
453                         if(self.hagar_load)
454                         {
455                                 W_DecreaseAmmo(ammo_rockets, WEP_CVAR_SEC(hagar, ammo) * self.hagar_load * -1, autocvar_g_balance_hagar_reload_ammo); // give back ammo if necessary
456                                 self.hagar_load = 0;
457                         }
458                         
459                         return TRUE;
460                 }
461                 case WR_CHECKAMMO1:
462                 {
463                         ammo_amount = self.ammo_rockets >= WEP_CVAR_PRI(hagar, ammo);
464                         ammo_amount += self.(weapon_load[WEP_HAGAR]) >= WEP_CVAR_PRI(hagar, ammo);
465                         return ammo_amount;
466                 }
467                 case WR_CHECKAMMO2:
468                 {
469                         ammo_amount = self.ammo_rockets >= WEP_CVAR_SEC(hagar, ammo);
470                         ammo_amount += self.(weapon_load[WEP_HAGAR]) >= WEP_CVAR_SEC(hagar, ammo);
471                         return ammo_amount;
472                 }
473                 case WR_CONFIG:
474                 {
475                         WEP_CONFIG_SETTINGS(HAGAR_SETTINGS(hagar))
476                         return TRUE;
477                 }
478                 case WR_RESETPLAYER:
479                 {
480                         self.hagar_load = 0;
481                         return TRUE;
482                 }
483                 case WR_PLAYERDEATH:
484                 {
485                         // if we have any rockets loaded when we die, release them
486                         if(self.hagar_load && WEP_CVAR_SEC(hagar, load_releasedeath))
487                                 W_Hagar_Attack2_Load_Release();
488                                 
489                         return TRUE;
490                 }
491                 case WR_RELOAD:
492                 {
493                         if not(self.hagar_load) // require releasing loaded rockets first
494                                 W_Reload(min(WEP_CVAR_PRI(hagar, ammo), WEP_CVAR_SEC(hagar, ammo)), "weapons/reload.wav");
495                                 
496                         return TRUE;
497                 }
498                 case WR_SUICIDEMESSAGE:
499                 {
500                         return WEAPON_HAGAR_SUICIDE;
501                 }
502                 case WR_KILLMESSAGE:
503                 {
504                         if(w_deathtype & HITTYPE_SECONDARY)
505                                 return WEAPON_HAGAR_MURDER_BURST;
506                         else
507                                 return WEAPON_HAGAR_MURDER_SPRAY;
508                 }
509         }
510         return TRUE;
511 }
512 #endif
513 #ifdef CSQC
514 float w_hagar(float req)
515 {
516         switch(req)
517         {
518                 case WR_IMPACTEFFECT:
519                 {
520                         vector org2;
521                         org2 = w_org + w_backoff * 6;
522                         pointparticles(particleeffectnum("hagar_explode"), org2, '0 0 0', 1);
523                         if(!w_issilent)
524                         {
525                                 if (w_random<0.15)
526                                         sound(self, CH_SHOTS, "weapons/hagexp1.wav", VOL_BASE, ATTN_NORM);
527                                 else if (w_random<0.7)
528                                         sound(self, CH_SHOTS, "weapons/hagexp2.wav", VOL_BASE, ATTN_NORM);
529                                 else
530                                         sound(self, CH_SHOTS, "weapons/hagexp3.wav", VOL_BASE, ATTN_NORM);
531                         }
532                         
533                         return TRUE;
534                 }
535                 case WR_INIT:
536                 {
537                         precache_sound("weapons/hagexp1.wav");
538                         precache_sound("weapons/hagexp2.wav");
539                         precache_sound("weapons/hagexp3.wav");
540                         return TRUE;
541                 }
542         }
543         return TRUE;
544 }
545 #endif
546 #endif