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