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