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