]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/weapons/weapon/devastator.qc
Update default video settings
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / weapon / devastator.qc
1 #include "devastator.qh"
2
3 #ifdef SVQC
4
5 .entity lastrocket;
6
7 void W_Devastator_Unregister(entity this)
8 {
9         for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
10         {
11                 .entity weaponentity = weaponentities[slot];
12                 if(this.realowner.(weaponentity).lastrocket == this)
13                         this.realowner.(weaponentity).lastrocket = NULL;
14         }
15 }
16
17 void W_Devastator_Explode(entity this, entity directhitentity)
18 {
19         W_Devastator_Unregister(this);
20
21         if(directhitentity.takedamage == DAMAGE_AIM)
22                 if(IS_PLAYER(directhitentity))
23                         if(DIFF_TEAM(this.realowner, directhitentity))
24                                 if(!IS_DEAD(directhitentity))
25                                         if(IsFlying(directhitentity))
26                                                 Send_Notification(NOTIF_ONE, this.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_AIRSHOT);
27
28         this.event_damage = func_null;
29         this.takedamage = DAMAGE_NO;
30
31         RadiusDamage(
32                 this,
33                 this.realowner,
34                 WEP_CVAR(devastator, damage),
35                 WEP_CVAR(devastator, edgedamage),
36                 WEP_CVAR(devastator, radius),
37                 NULL,
38                 NULL,
39                 WEP_CVAR(devastator, force),
40                 this.projectiledeathtype,
41                 this.weaponentity_fld,
42                 directhitentity
43         );
44
45         Weapon thiswep = WEP_DEVASTATOR;
46         .entity weaponentity = this.weaponentity_fld;
47         if(this.realowner.(weaponentity).m_weapon == thiswep)
48         {
49                 if(GetResource(this.realowner, thiswep.ammo_type) < WEP_CVAR(devastator, ammo))
50                 if(!(this.realowner.items & IT_UNLIMITED_AMMO))
51                 {
52                         this.realowner.cnt = thiswep.m_id;
53                         ATTACK_FINISHED(this.realowner, weaponentity) = time;
54                         this.realowner.(weaponentity).m_switchweapon = w_getbestweapon(this.realowner, weaponentity);
55                 }
56         }
57         delete(this);
58 }
59
60 void W_Devastator_Explode_think(entity this)
61 {
62         W_Devastator_Explode(this, NULL);
63 }
64
65 void W_Devastator_DoRemoteExplode(entity this, .entity weaponentity)
66 {
67         W_Devastator_Unregister(this);
68
69         this.event_damage = func_null;
70         this.takedamage = DAMAGE_NO;
71
72         bool handled_as_rocketjump = false;
73         entity head = NULL;
74         bool allow_rocketjump = WEP_CVAR(devastator, remote_jump);
75         MUTATOR_CALLHOOK(AllowRocketJumping, allow_rocketjump);
76         allow_rocketjump = M_ARGV(0, bool);
77
78         if(allow_rocketjump && WEP_CVAR(devastator, remote_jump_radius))
79         {
80                 head = WarpZone_FindRadius(
81                         this.origin,
82                         WEP_CVAR(devastator, remote_jump_radius),
83                         false
84                 );
85
86                 while(head)
87                 {
88                         if(head.takedamage && (head == this.realowner))
89                         {
90                                 if(vdist(this.origin - head.WarpZone_findradius_nearest, <=, WEP_CVAR(devastator, remote_jump_radius)))
91                                 {
92                                         // we handled this as a rocketjump :)
93                                         handled_as_rocketjump = true;
94
95                                         // modify velocity
96                                         if(WEP_CVAR(devastator, remote_jump_velocity_z_add))
97                                         {
98                                                 head.velocity_x *= 0.9;
99                                                 head.velocity_y *= 0.9;
100                                                 head.velocity_z = bound(
101                                                         WEP_CVAR(devastator, remote_jump_velocity_z_min),
102                                                         head.velocity.z + WEP_CVAR(devastator, remote_jump_velocity_z_add),
103                                                         WEP_CVAR(devastator, remote_jump_velocity_z_max)
104                                                 );
105                                         }
106
107                                         // now do the damage
108                                         RadiusDamage(
109                                                 this,
110                                                 head,
111                                                 WEP_CVAR(devastator, remote_jump_damage),
112                                                 WEP_CVAR(devastator, remote_jump_damage),
113                                                 WEP_CVAR(devastator, remote_jump_radius),
114                                                 NULL,
115                                                 head,
116                                                 (WEP_CVAR(devastator, remote_jump_force) ? WEP_CVAR(devastator, remote_jump_force) : 0),
117                                                 this.projectiledeathtype | HITTYPE_BOUNCE,
118                                                 this.weaponentity_fld,
119                                                 NULL
120                                         );
121                                         break;
122                                 }
123                         }
124                         head = head.chain;
125                 }
126         }
127
128         RadiusDamage(
129                 this,
130                 this.realowner,
131                 WEP_CVAR(devastator, remote_damage),
132                 WEP_CVAR(devastator, remote_edgedamage),
133                 WEP_CVAR(devastator, remote_radius),
134                 (handled_as_rocketjump ? head : NULL),
135                 NULL,
136                 WEP_CVAR(devastator, remote_force),
137                 this.projectiledeathtype | HITTYPE_BOUNCE,
138                 this.weaponentity_fld,
139                 NULL
140         );
141
142         Weapon thiswep = WEP_DEVASTATOR;
143         if(this.realowner.(weaponentity).m_weapon == thiswep)
144         {
145                 if(GetResource(this.realowner, thiswep.ammo_type) < WEP_CVAR(devastator, ammo))
146                 if(!(this.realowner.items & IT_UNLIMITED_AMMO))
147                 {
148                         this.realowner.cnt = thiswep.m_id;
149                         ATTACK_FINISHED(this.realowner, weaponentity) = time;
150                         this.realowner.(weaponentity).m_switchweapon = w_getbestweapon(this.realowner, weaponentity);
151                 }
152         }
153         delete(this);
154 }
155
156 void W_Devastator_RemoteExplode(entity this, .entity weaponentity)
157 {
158         if(!IS_DEAD(this.realowner))
159         if(this.realowner.(weaponentity).lastrocket)
160         {
161                 if((this.spawnshieldtime >= 0)
162                         ? (time >= this.spawnshieldtime) // timer
163                         : (vdist(NearestPointOnBox(this.realowner, this.origin) - this.origin, >, WEP_CVAR(devastator, remote_radius))) // safety device
164                 )
165                 {
166                         W_Devastator_DoRemoteExplode(this, weaponentity);
167                 }
168         }
169 }
170
171 vector W_Devastator_SteerTo(vector thisdir, vector goaldir, float maxturn_cos)
172 {
173         if(thisdir * goaldir > maxturn_cos)
174                 return goaldir;
175         if(thisdir * goaldir < -0.9998) // less than 1 degree and opposite
176                 return thisdir; // refuse to guide (better than letting a numerical error happen)
177         float f, m2;
178         vector v;
179         // solve:
180         //   g = normalize(thisdir + goaldir * X)
181         //   thisdir * g = maxturn
182         //
183         //   gg = thisdir + goaldir * X
184         //   (thisdir * gg)^2 = maxturn^2 * (gg * gg)
185         //
186         //   (1 + (thisdir * goaldir) * X)^2 = maxturn^2 * (1 + X*X + 2 * X * thisdir * goaldir)
187         f = thisdir * goaldir;
188         //   (1 + f * X)^2 = maxturn^2 * (1 + X*X + 2 * X * f)
189         //   0 = (m^2 - f^2) * x^2 + (2 * f * (m^2 - 1)) * x + (m^2 - 1)
190         m2 = maxturn_cos * maxturn_cos;
191         v = solve_quadratic(m2 - f * f, 2 * f * (m2 - 1), m2 - 1);
192         return normalize(thisdir + goaldir * v.y); // the larger solution!
193 }
194 // assume thisdir == -goaldir:
195 //   f == -1
196 //   v = solve_qadratic(m2 - 1, -2 * (m2 - 1), m2 - 1)
197 //   (m2 - 1) x^2 - 2 * (m2 - 1) * x + (m2 - 1) = 0
198 //   x^2 - 2 * x + 1 = 0
199 //   (x - 1)^2 = 0
200 //   x = 1
201 //   normalize(thisdir + goaldir)
202 //   normalize(0)
203
204 void W_Devastator_Think(entity this)
205 {
206         vector desireddir, olddir, newdir, desiredorigin, goal;
207         float velspeed, f;
208         this.nextthink = time;
209         if(time > this.cnt)
210         {
211                 this.projectiledeathtype |= HITTYPE_BOUNCE;
212                 W_Devastator_Explode(this, NULL);
213                 return;
214         }
215
216         // accelerate
217         makevectors(this.angles.x * '-1 0 0' + this.angles.y * '0 1 0');
218         velspeed = WEP_CVAR(devastator, speed) * W_WeaponSpeedFactor(this.realowner) - (this.velocity * v_forward);
219         if(velspeed > 0)
220                 this.velocity = this.velocity + v_forward * min(WEP_CVAR(devastator, speedaccel) * W_WeaponSpeedFactor(this.realowner) * frametime, velspeed);
221
222         // laser guided, or remote detonation
223         .entity weaponentity = this.weaponentity_fld;
224         if(this.realowner.(weaponentity).m_weapon == WEP_DEVASTATOR)
225         {
226                 if(this == this.realowner.(weaponentity).lastrocket)
227                 if(!this.realowner.(weaponentity).rl_release)
228                 if(!PHYS_INPUT_BUTTON_ATCK2(this))
229                 if(WEP_CVAR(devastator, guiderate))
230                 if(time > this.pushltime)
231                 if(!IS_DEAD(this.realowner))
232                 {
233                         f = WEP_CVAR(devastator, guideratedelay);
234                         if(f)
235                                 f = bound(0, (time - this.pushltime) / f, 1);
236                         else
237                                 f = 1;
238
239                         vector md = this.realowner.(weaponentity).movedir;
240                         vector dv = v_right * -md.y + v_up * md.z;
241
242                         if(!W_DualWielding(this.realowner))
243                                 dv = '0 0 0'; // don't override!
244
245                         velspeed = vlen(this.velocity);
246
247                         makevectors(this.realowner.v_angle);
248                         desireddir = WarpZone_RefSys_TransformVelocity(this.realowner, this, v_forward);
249                         desiredorigin = WarpZone_RefSys_TransformOrigin(this.realowner, this, this.realowner.origin + this.realowner.view_ofs + dv);
250                         olddir = normalize(this.velocity);
251
252                         // now it gets tricky... we want to move like some curve to approximate the target direction
253                         // but we are limiting the rate at which we can turn!
254                         goal = desiredorigin + ((this.origin - desiredorigin) * desireddir + WEP_CVAR(devastator, guidegoal)) * desireddir;
255                         newdir = W_Devastator_SteerTo(olddir, normalize(goal - this.origin), cos(WEP_CVAR(devastator, guiderate) * f * frametime * DEG2RAD));
256
257                         this.velocity = newdir * velspeed;
258                         this.angles = vectoangles(this.velocity);
259
260                         if(!this.count)
261                         {
262                                 Send_Effect(EFFECT_ROCKET_GUIDE, this.origin, this.velocity, 1);
263                                 // TODO add a better sound here
264                                 sound(this.realowner, CH_WEAPON_B, SND_ROCKET_MODE, VOL_BASE, ATTN_NORM);
265                                 this.count = 1;
266                         }
267                 }
268
269                 if(this.rl_detonate_later)
270                         W_Devastator_RemoteExplode(this, weaponentity);
271         }
272
273         if(this.csqcprojectile_clientanimate == 0)
274                 UpdateCSQCProjectile(this);
275 }
276
277 void W_Devastator_Touch(entity this, entity toucher)
278 {
279         if(WarpZone_Projectile_Touch(this, toucher))
280         {
281                 if(wasfreed(this))
282                         W_Devastator_Unregister(this);
283                 return;
284         }
285         W_Devastator_Unregister(this);
286         W_Devastator_Explode(this, toucher);
287 }
288
289 void W_Devastator_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
290 {
291         if(GetResource(this, RES_HEALTH) <= 0)
292                 return;
293
294         if(!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, -1)) // no exceptions
295                 return; // g_projectiles_damage says to halt
296
297         TakeResource(this, RES_HEALTH, damage);
298         this.angles = vectoangles(this.velocity);
299
300         if(GetResource(this, RES_HEALTH) <= 0)
301                 W_PrepareExplosionByDamage(this, attacker, W_Devastator_Explode_think);
302 }
303
304 void W_Devastator_Attack(Weapon thiswep, entity actor, .entity weaponentity, int fire)
305 {
306         W_DecreaseAmmo(thiswep, actor, WEP_CVAR(devastator, ammo), weaponentity);
307
308         W_SetupShot_ProjectileSize(actor, weaponentity, '-3 -3 -3', '3 3 3', false, 5, SND_ROCKET_FIRE, CH_WEAPON_A, WEP_CVAR(devastator, damage), thiswep.m_id);
309         W_MuzzleFlash(thiswep, actor, weaponentity, w_shotorg, w_shotdir);
310
311         entity missile = WarpZone_RefSys_SpawnSameRefSys(actor);
312         missile.weaponentity_fld = weaponentity;
313         missile.owner = missile.realowner = actor;
314         actor.(weaponentity).lastrocket = missile;
315         if(WEP_CVAR(devastator, detonatedelay) >= 0)
316                 missile.spawnshieldtime = time + WEP_CVAR(devastator, detonatedelay);
317         else
318                 missile.spawnshieldtime = -1; // NOTE: proximity based when rocket jumping
319         missile.pushltime = time + WEP_CVAR(devastator, guidedelay);
320         missile.classname = "rocket";
321         missile.bot_dodge = true;
322         missile.bot_dodgerating = WEP_CVAR(devastator, damage) * 2; // * 2 because it can be detonated inflight which makes it even more dangerous
323
324         missile.takedamage = DAMAGE_YES;
325         missile.damageforcescale = WEP_CVAR(devastator, damageforcescale);
326         SetResourceExplicit(missile, RES_HEALTH, WEP_CVAR(devastator, health));
327         missile.event_damage = W_Devastator_Damage;
328         missile.damagedbycontents = true;
329         IL_PUSH(g_damagedbycontents, missile);
330
331         set_movetype(missile, MOVETYPE_FLY);
332         PROJECTILE_MAKETRIGGER(missile);
333         missile.projectiledeathtype = thiswep.m_id;
334         setsize(missile, '-3 -3 -3', '3 3 3'); // give it some size so it can be shot
335
336         setorigin(missile, w_shotorg - v_forward * 3); // move it back so it hits the wall at the right point
337         W_SetupProjVelocity_Basic(missile, WEP_CVAR(devastator, speedstart), 0);
338         missile.angles = vectoangles(missile.velocity);
339
340         settouch(missile, W_Devastator_Touch);
341         setthink(missile, W_Devastator_Think);
342         missile.nextthink = time;
343         missile.cnt = time + WEP_CVAR(devastator, lifetime);
344         missile.rl_detonate_later = (fire & 2); // allow instant detonation
345         missile.flags = FL_PROJECTILE;
346         IL_PUSH(g_projectiles, missile);
347         IL_PUSH(g_bot_dodge, missile);
348         missile.missile_flags = MIF_SPLASH;
349
350         CSQCProjectile(missile, WEP_CVAR(devastator, guiderate) == 0 && WEP_CVAR(devastator, speedaccel) == 0, PROJECTILE_ROCKET, false); // because of fly sound
351
352         // common properties
353         MUTATOR_CALLHOOK(EditProjectile, actor, missile);
354
355         if (time >= missile.nextthink)
356         {
357                 getthink(missile)(missile);
358         }
359 }
360
361 METHOD(Devastator, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
362 {
363     if (!WEP_CVAR(devastator, guidestop) && !actor.(weaponentity).rl_release)
364     {
365         int fired_rockets = 0;
366         IL_EACH(g_projectiles, it.realowner == actor && it.classname == "rocket",
367         {
368             fired_rockets++;
369         });
370         // release PHYS_INPUT_BUTTON_ATCK after all fired rocket exploded otherwise bot can't fire again
371         if (!fired_rockets)
372             return;
373     }
374
375     // aim and decide to fire if appropriate
376     float spd = WEP_CVAR(devastator, speed);
377     // simulate rocket guide by calculating rocket trajectory with higher speed
378     // 20 times faster at 90 degrees guide rate
379     if (WEP_CVAR(devastator, guiderate) > 0)
380         spd *= sqrt(WEP_CVAR(devastator, guiderate)) * (20 / 9.489); // 9.489 ~= sqrt(90)
381     // no need to fire with high accuracy on large distances if rockets can be guided
382     bool shot_accurate = (WEP_CVAR(devastator, guiderate) < 50);
383     PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, spd, 0, WEP_CVAR(devastator, lifetime), false, shot_accurate);
384     float pred_time = bound(0.02, 0.02 + (8 - skill) * 0.01, 0.1);
385     if(skill >= 2) // skill 0 and 1 bots won't detonate rockets!
386     {
387         // decide whether to detonate rockets
388         float selfdamage = 0, teamdamage = 0, enemydamage = 0;
389         float pred_selfdamage = 0, pred_teamdamage = 0, pred_enemydamage = 0;
390         float edgedamage = WEP_CVAR(devastator, edgedamage);
391         float coredamage = WEP_CVAR(devastator, damage);
392         float edgeradius = WEP_CVAR(devastator, radius);
393         IL_EACH(g_projectiles, it.realowner == actor && it.classname == "rocket",
394         {
395             entity rocket = it;
396             IL_EACH(g_bot_targets, it.bot_attack,
397             {
398                 // code to calculate damage is similar to the one used in RadiusDamageForSource with some simplifications
399                 vector target_pos = it.origin + (it.maxs - it.mins) * 0.5;
400
401                 float dist = vlen(target_pos - rocket.origin);
402                 float dmg = 0;
403                 if (dist <= edgeradius)
404                 {
405                     float f = (edgeradius > 0) ? max(0, 1 - (dist / edgeradius)) : 1;
406                     dmg = coredamage * f + edgedamage * (1 - f);
407                 }
408
409                 float pred_dist = vlen(target_pos + it.velocity * pred_time - (rocket.origin + rocket.velocity * pred_time));
410                 float pred_dmg = 0;
411                 if (pred_dist <= edgeradius)
412                 {
413                     float f = (edgeradius > 0) ? max(0, 1 - (pred_dist / edgeradius)) : 1;
414                     pred_dmg = coredamage * f + edgedamage * (1 - f);
415                 }
416
417                 // count potential damage according to type of target
418                 if(it == actor)
419                 {
420                     if(StatusEffects_active(STATUSEFFECT_Strength, it))
421                         dmg *= autocvar_g_balance_powerup_strength_damage;
422                     if(StatusEffects_active(STATUSEFFECT_Shield, it))
423                         dmg *= autocvar_g_balance_powerup_invincible_takedamage;
424                     // self damage reduction factor will be applied later to the total damage
425                     selfdamage += dmg;
426                     pred_selfdamage += pred_dmg;
427                 }
428                 else if(SAME_TEAM(it, actor))
429                 {
430                     if(StatusEffects_active(STATUSEFFECT_Shield, it))
431                         dmg *= autocvar_g_balance_powerup_invincible_takedamage;
432                     // bot strength factor will be applied later to the total damage
433                     teamdamage += dmg;
434                     pred_teamdamage += pred_dmg;
435                 }
436                 else if(bot_shouldattack(actor, it))
437                 {
438                     if(StatusEffects_active(STATUSEFFECT_Shield, it))
439                         dmg *= autocvar_g_balance_powerup_invincible_takedamage;
440                     // bot strength factor will be applied later to the total damage
441                     enemydamage += dmg;
442                     pred_enemydamage += pred_dmg;
443                 }
444             });
445         });
446
447         selfdamage *= autocvar_g_balance_selfdamagepercent;
448         pred_selfdamage *= autocvar_g_balance_selfdamagepercent;
449         if(StatusEffects_active(STATUSEFFECT_Strength, actor))
450         {
451             // FIXME bots don't know whether team damage is enabled or not
452             teamdamage *= autocvar_g_balance_powerup_strength_damage;
453             pred_teamdamage *= autocvar_g_balance_powerup_strength_damage;
454             enemydamage *= autocvar_g_balance_powerup_strength_damage;
455             pred_enemydamage *= autocvar_g_balance_powerup_strength_damage;
456         }
457
458         float good_damage = enemydamage;
459         float pred_good_damage = pred_enemydamage;
460         float bad_damage = selfdamage + teamdamage;
461         float pred_bad_damage = pred_selfdamage + pred_teamdamage;
462
463         // detonate if predicted good damage is lower (current good damage is maximum)
464         // or if predicted bad damage is too much
465         if(good_damage > coredamage * 0.1 && good_damage > bad_damage * 1.5
466             && (pred_good_damage < good_damage + 2 || pred_good_damage < pred_bad_damage * 1.5))
467         {
468             PHYS_INPUT_BUTTON_ATCK2(actor) = true;
469         }
470         if(skill >= 7 && selfdamage > GetResource(actor, RES_HEALTH))
471             PHYS_INPUT_BUTTON_ATCK2(actor) = false;
472
473         // don't fire a new shot at the same time!
474         if(PHYS_INPUT_BUTTON_ATCK2(actor)) PHYS_INPUT_BUTTON_ATCK(actor) = false;
475     }
476 }
477
478 METHOD(Devastator, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
479 {
480     if(WEP_CVAR(devastator, reload_ammo) && actor.(weaponentity).clip_load < WEP_CVAR(devastator, ammo)) { // forced reload
481         thiswep.wr_reload(thiswep, actor, weaponentity);
482     } else {
483         if(fire & 1)
484         {
485             if(actor.(weaponentity).rl_release || WEP_CVAR(devastator, guidestop))
486             if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(devastator, refire)))
487             {
488                 W_Devastator_Attack(thiswep, actor, weaponentity, fire);
489                 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(devastator, animtime), w_ready);
490                 actor.(weaponentity).rl_release = 0;
491             }
492         }
493         else
494             actor.(weaponentity).rl_release = 1;
495
496         if(fire & 2)
497         if(actor.(weaponentity).m_switchweapon == thiswep)
498         {
499             bool rockfound = false;
500             IL_EACH(g_projectiles, it.realowner == actor && it.classname == "rocket",
501             {
502                 if(!it.rl_detonate_later)
503                 {
504                     it.rl_detonate_later = true;
505                     rockfound = true;
506                 }
507             });
508             if(rockfound)
509                 sound(actor, CH_WEAPON_B, SND_ROCKET_DET, VOL_BASE, ATTN_NORM);
510         }
511     }
512 }
513 METHOD(Devastator, wr_setup, void(entity thiswep, entity actor, .entity weaponentity))
514 {
515     actor.(weaponentity).rl_release = 1;
516 }
517 METHOD(Devastator, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
518 {
519     #if 0
520     // don't switch while guiding a missile
521     if(ATTACK_FINISHED(actor, weaponentity) <= time || PS(actor).m_weapon != WEP_DEVASTATOR)
522     {
523         ammo_amount = false;
524         if(WEP_CVAR(devastator, reload_ammo))
525         {
526             if(GetResource(actor, thiswep.ammo_type) < WEP_CVAR(devastator, ammo) && actor.(weaponentity).(weapon_load[WEP_DEVASTATOR.m_id]) < WEP_CVAR(devastator, ammo))
527                 ammo_amount = true;
528         }
529         else if(GetResource(actor, thiswep.ammo_type) < WEP_CVAR(devastator, ammo))
530             ammo_amount = true;
531         return !ammo_amount;
532     }
533     #endif
534     #if 0
535     if(actor.rl_release == 0)
536     {
537         LOG_INFOF("W_Devastator(WR_CHECKAMMO1): %d, %.2f, %d: TRUE", actor.rl_release, GetResource(actor, thiswep.ammo_type), WEP_CVAR(devastator, ammo));
538         return true;
539     }
540     else
541     {
542         ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR(devastator, ammo);
543         ammo_amount += actor.(weaponentity).(weapon_load[WEP_DEVASTATOR.m_id]) >= WEP_CVAR(devastator, ammo);
544         LOG_INFOF("W_Devastator(WR_CHECKAMMO1): %d, %.2f, %d: %s", actor.rl_release, GetResource(actor, thiswep.ammo_type), WEP_CVAR(devastator, ammo), (ammo_amount ? "TRUE" : "FALSE"));
545         return ammo_amount;
546     }
547     #else
548     float ammo_amount = GetResource(actor, thiswep.ammo_type) >= WEP_CVAR(devastator, ammo);
549     ammo_amount += actor.(weaponentity).(weapon_load[thiswep.m_id]) >= WEP_CVAR(devastator, ammo);
550     return ammo_amount;
551     #endif
552 }
553 METHOD(Devastator, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
554 {
555     return false;
556 }
557 METHOD(Devastator, wr_resetplayer, void(entity thiswep, entity actor))
558 {
559     for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
560     {
561         .entity weaponentity = weaponentities[slot];
562         actor.(weaponentity).lastrocket = NULL; // stop rocket guiding, no revenge from the grave!
563         actor.(weaponentity).rl_release = 0;
564     }
565 }
566 METHOD(Devastator, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
567 {
568     W_Reload(actor, weaponentity, WEP_CVAR(devastator, ammo), SND_RELOAD);
569 }
570 METHOD(Devastator, wr_suicidemessage, Notification(entity thiswep))
571 {
572     return WEAPON_DEVASTATOR_SUICIDE;
573 }
574 METHOD(Devastator, wr_killmessage, Notification(entity thiswep))
575 {
576     if((w_deathtype & HITTYPE_BOUNCE) || (w_deathtype & HITTYPE_SPLASH))
577         return WEAPON_DEVASTATOR_MURDER_SPLASH;
578     else
579         return WEAPON_DEVASTATOR_MURDER_DIRECT;
580 }
581
582 #endif
583 #ifdef CSQC
584
585 METHOD(Devastator, wr_impacteffect, void(entity thiswep, entity actor))
586 {
587     vector org2 = w_org + w_backoff * 2;
588     pointparticles(EFFECT_ROCKET_EXPLODE, org2, '0 0 0', 1);
589     if(!w_issilent)
590         sound(actor, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTN_NORM);
591 }
592
593 #endif