]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/weapons/weapon/devastator.qc
Merge branch 'Mario/cts_respawn_clear' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / weapon / devastator.qc
1 #include "devastator.qh"
2 #ifndef IMPLEMENTATION
3 CLASS(Devastator, Weapon)
4 /* ammotype  */ ATTRIB(Devastator, ammo_field, .int, ammo_rockets);
5 /* impulse   */ ATTRIB(Devastator, impulse, int, 9);
6 /* flags     */ ATTRIB(Devastator, spawnflags, int, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_FLAG_CANCLIMB | WEP_TYPE_SPLASH);
7 /* rating    */ ATTRIB(Devastator, bot_pickupbasevalue, float, 8000);
8 /* color     */ ATTRIB(Devastator, wpcolor, vector, '1 1 0');
9 /* modelname */ ATTRIB(Devastator, mdl, string, "rl");
10 #ifdef GAMEQC
11 /* model     */ ATTRIB(Devastator, m_model, Model, MDL_DEVASTATOR_ITEM);
12 #endif
13 /* crosshair */ ATTRIB(Devastator, w_crosshair, string, "gfx/crosshairrocketlauncher");
14 /* crosshair */ ATTRIB(Devastator, w_crosshair_size, float, 0.7);
15 /* wepimg    */ ATTRIB(Devastator, model2, string, "weaponrocketlauncher");
16 /* refname   */ ATTRIB(Devastator, netname, string, "devastator");
17 /* wepname   */ ATTRIB(Devastator, m_name, string, _("Devastator"));
18
19 #define X(BEGIN, P, END, class, prefix) \
20         BEGIN(class) \
21                 P(class, prefix, ammo, float, NONE) \
22         P(class, prefix, animtime, float, NONE) \
23         P(class, prefix, damageforcescale, float, NONE) \
24         P(class, prefix, damage, float, NONE) \
25         P(class, prefix, detonatedelay, float, NONE) \
26         P(class, prefix, edgedamage, float, NONE) \
27         P(class, prefix, force, float, NONE) \
28         P(class, prefix, guidedelay, float, NONE) \
29         P(class, prefix, guidegoal, float, NONE) \
30         P(class, prefix, guideratedelay, float, NONE) \
31         P(class, prefix, guiderate, float, NONE) \
32         P(class, prefix, guidestop, float, NONE) \
33         P(class, prefix, health, float, NONE) \
34         P(class, prefix, lifetime, float, NONE) \
35         P(class, prefix, radius, float, NONE) \
36         P(class, prefix, refire, float, NONE) \
37                 P(class, prefix, reload_ammo, float, NONE) \
38                 P(class, prefix, reload_time, float, NONE) \
39         P(class, prefix, remote_damage, float, NONE) \
40         P(class, prefix, remote_edgedamage, float, NONE) \
41         P(class, prefix, remote_force, float, NONE) \
42         P(class, prefix, remote_jump_damage, float, NONE) \
43         P(class, prefix, remote_jump_force, float, NONE) \
44         P(class, prefix, remote_jump_radius, float, NONE) \
45         P(class, prefix, remote_jump_velocity_z_add, float, NONE) \
46         P(class, prefix, remote_jump_velocity_z_max, float, NONE) \
47         P(class, prefix, remote_jump_velocity_z_min, float, NONE) \
48         P(class, prefix, remote_radius, float, NONE) \
49         P(class, prefix, speedaccel, float, NONE) \
50         P(class, prefix, speedstart, float, NONE) \
51         P(class, prefix, speed, float, NONE) \
52                 P(class, prefix, switchdelay_drop, float, NONE) \
53                 P(class, prefix, switchdelay_raise, float, NONE) \
54                 P(class, prefix, weaponreplace, string,NONE) \
55                 P(class, prefix, weaponstartoverride, float, NONE) \
56                 P(class, prefix, weaponstart, float, NONE) \
57                 P(class, prefix, weaponthrowable, float, NONE) \
58         END()
59         W_PROPS(X, Devastator, devastator)
60 #undef X
61
62 ENDCLASS(Devastator)
63 REGISTER_WEAPON(DEVASTATOR, devastator, NEW(Devastator));
64
65 #ifdef SVQC
66 .float rl_release;
67 .float rl_detonate_later;
68 #endif
69 #endif
70 #ifdef IMPLEMENTATION
71 #ifdef SVQC
72 spawnfunc(weapon_devastator) { weapon_defaultspawnfunc(this, WEP_DEVASTATOR); }
73 spawnfunc(weapon_rocketlauncher) { spawnfunc_weapon_devastator(this); }
74
75 .entity lastrocket;
76
77 void W_Devastator_Unregister(entity this)
78 {
79         for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
80         {
81                 .entity weaponentity = weaponentities[slot];
82                 if(this.realowner.(weaponentity).lastrocket == this)
83                         this.realowner.(weaponentity).lastrocket = NULL;
84         }
85 }
86
87 void W_Devastator_Explode(entity this, entity directhitentity)
88 {
89         W_Devastator_Unregister(this);
90
91         if(directhitentity.takedamage == DAMAGE_AIM)
92                 if(IS_PLAYER(directhitentity))
93                         if(DIFF_TEAM(this.realowner, directhitentity))
94                                 if(!IS_DEAD(directhitentity))
95                                         if(IsFlying(directhitentity))
96                                                 Send_Notification(NOTIF_ONE, this.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_AIRSHOT);
97
98         this.event_damage = func_null;
99         this.takedamage = DAMAGE_NO;
100
101         RadiusDamage(
102                 this,
103                 this.realowner,
104                 WEP_CVAR(devastator, damage),
105                 WEP_CVAR(devastator, edgedamage),
106                 WEP_CVAR(devastator, radius),
107                 NULL,
108                 NULL,
109                 WEP_CVAR(devastator, force),
110                 this.projectiledeathtype,
111                 directhitentity
112         );
113
114         Weapon thiswep = WEP_DEVASTATOR;
115         .entity weaponentity = this.weaponentity_fld;
116         if(this.realowner.(weaponentity).m_weapon == thiswep)
117         {
118                 if(this.realowner.(thiswep.ammo_field) < WEP_CVAR(devastator, ammo))
119                 if(!(this.realowner.items & IT_UNLIMITED_WEAPON_AMMO))
120                 {
121                         this.realowner.cnt = WEP_DEVASTATOR.m_id;
122                         int slot = weaponslot(weaponentity);
123                         ATTACK_FINISHED(this.realowner, slot) = time;
124                         this.realowner.(weaponentity).m_switchweapon = w_getbestweapon(this.realowner, weaponentity);
125                 }
126         }
127         delete(this);
128 }
129
130 void W_Devastator_Explode_think(entity this)
131 {
132         W_Devastator_Explode(this, NULL);
133 }
134
135 void W_Devastator_DoRemoteExplode(entity this, .entity weaponentity)
136 {
137         W_Devastator_Unregister(this);
138
139         this.event_damage = func_null;
140         this.takedamage = DAMAGE_NO;
141
142         bool handled_as_rocketjump = false;
143         entity head = NULL;
144
145         if(WEP_CVAR(devastator, remote_jump_radius))
146         {
147                 head = WarpZone_FindRadius(
148                         this.origin,
149                         WEP_CVAR(devastator, remote_jump_radius),
150                         false
151                 );
152
153                 while(head)
154                 {
155                         if(head.takedamage && (head == this.realowner))
156                         {
157                                 if(vdist(this.origin - head.WarpZone_findradius_nearest, <=, WEP_CVAR(devastator, remote_jump_radius)))
158                                 {
159                                         // we handled this as a rocketjump :)
160                                         handled_as_rocketjump = true;
161
162                                         // modify velocity
163                                         if(WEP_CVAR(devastator, remote_jump_velocity_z_add))
164                                         {
165                                                 head.velocity_x *= 0.9;
166                                                 head.velocity_y *= 0.9;
167                                                 head.velocity_z = bound(
168                                                         WEP_CVAR(devastator, remote_jump_velocity_z_min),
169                                                         head.velocity.z + WEP_CVAR(devastator, remote_jump_velocity_z_add),
170                                                         WEP_CVAR(devastator, remote_jump_velocity_z_max)
171                                                 );
172                                         }
173
174                                         // now do the damage
175                                         RadiusDamage(
176                                                 this,
177                                                 head,
178                                                 WEP_CVAR(devastator, remote_jump_damage),
179                                                 WEP_CVAR(devastator, remote_jump_damage),
180                                                 WEP_CVAR(devastator, remote_jump_radius),
181                                                 NULL,
182                                                 head,
183                                                 (WEP_CVAR(devastator, remote_jump_force) ? WEP_CVAR(devastator, remote_jump_force) : 0),
184                                                 this.projectiledeathtype | HITTYPE_BOUNCE,
185                                                 NULL
186                                         );
187                                         break;
188                                 }
189                         }
190                         head = head.chain;
191                 }
192         }
193
194         RadiusDamage(
195                 this,
196                 this.realowner,
197                 WEP_CVAR(devastator, remote_damage),
198                 WEP_CVAR(devastator, remote_edgedamage),
199                 WEP_CVAR(devastator, remote_radius),
200                 (handled_as_rocketjump ? head : NULL),
201                 NULL,
202                 WEP_CVAR(devastator, remote_force),
203                 this.projectiledeathtype | HITTYPE_BOUNCE,
204                 NULL
205         );
206
207         Weapon thiswep = WEP_DEVASTATOR;
208         if(this.realowner.(weaponentity).m_weapon == thiswep)
209         {
210                 if(this.realowner.(thiswep.ammo_field) < WEP_CVAR(devastator, ammo))
211                 if(!(this.realowner.items & IT_UNLIMITED_WEAPON_AMMO))
212                 {
213                         this.realowner.cnt = WEP_DEVASTATOR.m_id;
214                         int slot = weaponslot(weaponentity);
215                         ATTACK_FINISHED(this.realowner, slot) = time;
216                         this.realowner.(weaponentity).m_switchweapon = w_getbestweapon(this.realowner, weaponentity);
217                 }
218         }
219         delete(this);
220 }
221
222 void W_Devastator_RemoteExplode(entity this, .entity weaponentity)
223 {
224         if(!IS_DEAD(this.realowner))
225         if(this.realowner.(weaponentity).lastrocket)
226         {
227                 if((this.spawnshieldtime >= 0)
228                         ? (time >= this.spawnshieldtime) // timer
229                         : (vdist(NearestPointOnBox(this.realowner, this.origin) - this.origin, >, WEP_CVAR(devastator, remote_radius))) // safety device
230                 )
231                 {
232                         W_Devastator_DoRemoteExplode(this, weaponentity);
233                 }
234         }
235 }
236
237 vector W_Devastator_SteerTo(vector thisdir, vector goaldir, float maxturn_cos)
238 {
239         if(thisdir * goaldir > maxturn_cos)
240                 return goaldir;
241         if(thisdir * goaldir < -0.9998) // less than 1 degree and opposite
242                 return thisdir; // refuse to guide (better than letting a numerical error happen)
243         float f, m2;
244         vector v;
245         // solve:
246         //   g = normalize(thisdir + goaldir * X)
247         //   thisdir * g = maxturn
248         //
249         //   gg = thisdir + goaldir * X
250         //   (thisdir * gg)^2 = maxturn^2 * (gg * gg)
251         //
252         //   (1 + (thisdir * goaldir) * X)^2 = maxturn^2 * (1 + X*X + 2 * X * thisdir * goaldir)
253         f = thisdir * goaldir;
254         //   (1 + f * X)^2 = maxturn^2 * (1 + X*X + 2 * X * f)
255         //   0 = (m^2 - f^2) * x^2 + (2 * f * (m^2 - 1)) * x + (m^2 - 1)
256         m2 = maxturn_cos * maxturn_cos;
257         v = solve_quadratic(m2 - f * f, 2 * f * (m2 - 1), m2 - 1);
258         return normalize(thisdir + goaldir * v.y); // the larger solution!
259 }
260 // assume thisdir == -goaldir:
261 //   f == -1
262 //   v = solve_qadratic(m2 - 1, -2 * (m2 - 1), m2 - 1)
263 //   (m2 - 1) x^2 - 2 * (m2 - 1) * x + (m2 - 1) = 0
264 //   x^2 - 2 * x + 1 = 0
265 //   (x - 1)^2 = 0
266 //   x = 1
267 //   normalize(thisdir + goaldir)
268 //   normalize(0)
269
270 void W_Devastator_Think(entity this)
271 {
272         vector desireddir, olddir, newdir, desiredorigin, goal;
273         float velspeed, f;
274         this.nextthink = time;
275         if(time > this.cnt)
276         {
277                 this.projectiledeathtype |= HITTYPE_BOUNCE;
278                 W_Devastator_Explode(this, NULL);
279                 return;
280         }
281
282         // accelerate
283         makevectors(this.angles.x * '-1 0 0' + this.angles.y * '0 1 0');
284         velspeed = WEP_CVAR(devastator, speed) * W_WeaponSpeedFactor(this.realowner) - (this.velocity * v_forward);
285         if(velspeed > 0)
286                 this.velocity = this.velocity + v_forward * min(WEP_CVAR(devastator, speedaccel) * W_WeaponSpeedFactor(this.realowner) * frametime, velspeed);
287
288         // laser guided, or remote detonation
289         .entity weaponentity = this.weaponentity_fld;
290         if(this.realowner.(weaponentity).m_weapon == WEP_DEVASTATOR)
291         {
292                 if(this == this.realowner.(weaponentity).lastrocket)
293                 if(!this.realowner.(weaponentity).rl_release)
294                 if(!PHYS_INPUT_BUTTON_ATCK2(this))
295                 if(WEP_CVAR(devastator, guiderate))
296                 if(time > this.pushltime)
297                 if(!IS_DEAD(this.realowner))
298                 {
299                         f = WEP_CVAR(devastator, guideratedelay);
300                         if(f)
301                                 f = bound(0, (time - this.pushltime) / f, 1);
302                         else
303                                 f = 1;
304
305                         velspeed = vlen(this.velocity);
306
307                         makevectors(this.realowner.v_angle);
308                         desireddir = WarpZone_RefSys_TransformVelocity(this.realowner, this, v_forward);
309                         desiredorigin = WarpZone_RefSys_TransformOrigin(this.realowner, this, this.realowner.origin + this.realowner.view_ofs);
310                         olddir = normalize(this.velocity);
311
312                         // now it gets tricky... we want to move like some curve to approximate the target direction
313                         // but we are limiting the rate at which we can turn!
314                         goal = desiredorigin + ((this.origin - desiredorigin) * desireddir + WEP_CVAR(devastator, guidegoal)) * desireddir;
315                         newdir = W_Devastator_SteerTo(olddir, normalize(goal - this.origin), cos(WEP_CVAR(devastator, guiderate) * f * frametime * DEG2RAD));
316
317                         this.velocity = newdir * velspeed;
318                         this.angles = vectoangles(this.velocity);
319
320                         if(!this.count)
321                         {
322                                 Send_Effect(EFFECT_ROCKET_GUIDE, this.origin, this.velocity, 1);
323                                 // TODO add a better sound here
324                                 sound(this.realowner, CH_WEAPON_B, SND_ROCKET_MODE, VOL_BASE, ATTN_NORM);
325                                 this.count = 1;
326                         }
327                 }
328
329                 if(this.rl_detonate_later)
330                         W_Devastator_RemoteExplode(this, weaponentity);
331         }
332
333         if(this.csqcprojectile_clientanimate == 0)
334                 UpdateCSQCProjectile(this);
335 }
336
337 void W_Devastator_Touch(entity this, entity toucher)
338 {
339         if(WarpZone_Projectile_Touch(this, toucher))
340         {
341                 if(wasfreed(this))
342                         W_Devastator_Unregister(this);
343                 return;
344         }
345         W_Devastator_Unregister(this);
346         W_Devastator_Explode(this, toucher);
347 }
348
349 void W_Devastator_Damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
350 {
351         if(this.health <= 0)
352                 return;
353
354         if(!W_CheckProjectileDamage(inflictor.realowner, this.realowner, deathtype, -1)) // no exceptions
355                 return; // g_projectiles_damage says to halt
356
357         this.health = this.health - damage;
358         this.angles = vectoangles(this.velocity);
359
360         if(this.health <= 0)
361                 W_PrepareExplosionByDamage(this, attacker, W_Devastator_Explode_think);
362 }
363
364 void W_Devastator_Attack(Weapon thiswep, entity actor, .entity weaponentity)
365 {
366         W_DecreaseAmmo(thiswep, actor, WEP_CVAR(devastator, ammo), weaponentity);
367
368         W_SetupShot_ProjectileSize(actor, weaponentity, '-3 -3 -3', '3 3 3', false, 5, SND_ROCKET_FIRE, CH_WEAPON_A, WEP_CVAR(devastator, damage));
369         Send_Effect(EFFECT_ROCKET_MUZZLEFLASH, w_shotorg, w_shotdir * 1000, 1);
370
371         entity missile = WarpZone_RefSys_SpawnSameRefSys(actor);
372         missile.weaponentity_fld = weaponentity;
373         missile.owner = missile.realowner = actor;
374         actor.(weaponentity).lastrocket = missile;
375         if(WEP_CVAR(devastator, detonatedelay) >= 0)
376                 missile.spawnshieldtime = time + WEP_CVAR(devastator, detonatedelay);
377         else
378                 missile.spawnshieldtime = -1;
379         missile.pushltime = time + WEP_CVAR(devastator, guidedelay);
380         missile.classname = "rocket";
381         missile.bot_dodge = true;
382         missile.bot_dodgerating = WEP_CVAR(devastator, damage) * 2; // * 2 because it can be detonated inflight which makes it even more dangerous
383
384         missile.takedamage = DAMAGE_YES;
385         missile.damageforcescale = WEP_CVAR(devastator, damageforcescale);
386         missile.health = WEP_CVAR(devastator, health);
387         missile.event_damage = W_Devastator_Damage;
388         missile.damagedbycontents = true;
389         IL_PUSH(g_damagedbycontents, missile);
390
391         set_movetype(missile, MOVETYPE_FLY);
392         PROJECTILE_MAKETRIGGER(missile);
393         missile.projectiledeathtype = WEP_DEVASTATOR.m_id;
394         setsize(missile, '-3 -3 -3', '3 3 3'); // give it some size so it can be shot
395
396         setorigin(missile, w_shotorg - v_forward * 3); // move it back so it hits the wall at the right point
397         W_SetupProjVelocity_Basic(missile, WEP_CVAR(devastator, speedstart), 0);
398         missile.angles = vectoangles(missile.velocity);
399
400         settouch(missile, W_Devastator_Touch);
401         setthink(missile, W_Devastator_Think);
402         missile.nextthink = time;
403         missile.cnt = time + WEP_CVAR(devastator, lifetime);
404         missile.flags = FL_PROJECTILE;
405         IL_PUSH(g_projectiles, missile);
406         IL_PUSH(g_bot_dodge, missile);
407         missile.missile_flags = MIF_SPLASH;
408
409         CSQCProjectile(missile, WEP_CVAR(devastator, guiderate) == 0 && WEP_CVAR(devastator, speedaccel) == 0, PROJECTILE_ROCKET, false); // because of fly sound
410
411         // muzzle flash for 1st person view
412         entity flash = spawn();
413         setmodel(flash, MDL_DEVASTATOR_MUZZLEFLASH); // precision set below
414         SUB_SetFade(flash, time, 0.1);
415         flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
416         W_AttachToShotorg(actor, weaponentity, flash, '5 0 0');
417
418         // common properties
419         MUTATOR_CALLHOOK(EditProjectile, actor, missile);
420 }
421
422 METHOD(Devastator, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
423 {
424     // aim and decide to fire if appropriate
425     PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, WEP_CVAR(devastator, speed), 0, WEP_CVAR(devastator, lifetime), false);
426     if(skill >= 2) // skill 0 and 1 bots won't detonate rockets!
427     {
428         // decide whether to detonate rockets
429         float edgedamage, coredamage, edgeradius, recipricoledgeradius;
430         float selfdamage, teamdamage, enemydamage;
431         edgedamage = WEP_CVAR(devastator, edgedamage);
432         coredamage = WEP_CVAR(devastator, damage);
433         edgeradius = WEP_CVAR(devastator, radius);
434         recipricoledgeradius = 1 / edgeradius;
435         selfdamage = 0;
436         teamdamage = 0;
437         enemydamage = 0;
438         IL_EACH(g_projectiles, it.realowner == actor && it.classname == "rocket",
439         {
440             entity rocket = it;
441             IL_EACH(g_bot_targets, it.bot_attack,
442             {
443                 float d = vlen(it.origin + (it.mins + it.maxs) * 0.5 - rocket.origin);
444                 d = bound(0, edgedamage + (coredamage - edgedamage) * sqrt(1 - d * recipricoledgeradius), 10000);
445                 // count potential damage according to type of target
446                 if(it == actor)
447                         selfdamage = selfdamage + d;
448                 else if(SAME_TEAM(it, actor))
449                         teamdamage = teamdamage + d;
450                 else if(bot_shouldattack(actor, it))
451                         enemydamage = enemydamage + d;
452             });
453         });
454         float desirabledamage;
455         desirabledamage = enemydamage;
456         if(time > actor.invincible_finished && time > actor.spawnshieldtime)
457             desirabledamage = desirabledamage - selfdamage * autocvar_g_balance_selfdamagepercent;
458         if(teamplay && actor.team)
459             desirabledamage = desirabledamage - teamdamage;
460
461         makevectors(actor.v_angle);
462         IL_EACH(g_projectiles, it.realowner == actor && it.classname == "rocket",
463         {
464             if(skill > 9) // normal players only do this for the target they are tracking
465             {
466                     entity rocket = it;
467                     IL_EACH(g_bot_targets, it.bot_attack,
468                     {
469                         if((v_forward * normalize(rocket.origin - it.origin) < 0.1)
470                             && desirabledamage > 0.1 * coredamage
471                             ) PHYS_INPUT_BUTTON_ATCK2(actor) = true;
472                     });
473                 }
474                 else
475                 {
476                 //As the distance gets larger, a correct detonation gets near imposible
477                 //Bots are assumed to use the rocket spawnfunc_light to see if the rocket gets near a player
478                 if((v_forward * normalize(it.origin - actor.enemy.origin) < 0.1)
479                         && IS_PLAYER(actor.enemy)
480                         && (desirabledamage >= 0.1 * coredamage)
481                         )
482                 {
483                         float distance = bound(300, vlen(actor.origin - actor.enemy.origin), 30000);
484                         if(random() / distance * 300 > frametime * bound(0, (10 - skill) * 0.2, 1))
485                                 PHYS_INPUT_BUTTON_ATCK2(actor) = true;
486                 }
487                 }
488         });
489         // if we would be doing at X percent of the core damage, detonate it
490         // but don't fire a new shot at the same time!
491         if(desirabledamage >= 0.75 * coredamage) //this should do group damage in rare fortunate events
492             PHYS_INPUT_BUTTON_ATCK2(actor) = true;
493         if((skill > 6.5) && (selfdamage > actor.health))
494             PHYS_INPUT_BUTTON_ATCK2(actor) = false;
495         //if(PHYS_INPUT_BUTTON_ATCK2(actor) == true)
496         //      dprint(ftos(desirabledamage),"\n");
497         if(PHYS_INPUT_BUTTON_ATCK2(actor)) PHYS_INPUT_BUTTON_ATCK(actor) = false;
498     }
499 }
500
501 METHOD(Devastator, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire))
502 {
503     if(WEP_CVAR(devastator, reload_ammo) && actor.(weaponentity).clip_load < WEP_CVAR(devastator, ammo)) { // forced reload
504         thiswep.wr_reload(thiswep, actor, weaponentity);
505     } else {
506         if(fire & 1)
507         {
508             if(actor.(weaponentity).rl_release || WEP_CVAR(devastator, guidestop))
509             if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(devastator, refire)))
510             {
511                 W_Devastator_Attack(thiswep, actor, weaponentity);
512                 weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(devastator, animtime), w_ready);
513                 actor.(weaponentity).rl_release = 0;
514             }
515         }
516         else
517             actor.(weaponentity).rl_release = 1;
518
519         if(fire & 2)
520         if(actor.(weaponentity).m_switchweapon == WEP_DEVASTATOR)
521         {
522             bool rockfound = false;
523             IL_EACH(g_projectiles, it.realowner == actor && it.classname == "rocket",
524             {
525                 if(!it.rl_detonate_later)
526                 {
527                     it.rl_detonate_later = true;
528                     rockfound = true;
529                 }
530             });
531             if(rockfound)
532                 sound(actor, CH_WEAPON_B, SND_ROCKET_DET, VOL_BASE, ATTN_NORM);
533         }
534     }
535 }
536 METHOD(Devastator, wr_setup, void(entity thiswep, entity actor, .entity weaponentity))
537 {
538     actor.(weaponentity).rl_release = 1;
539 }
540 METHOD(Devastator, wr_checkammo1, bool(entity thiswep, entity actor, .entity weaponentity))
541 {
542     #if 0
543     // don't switch while guiding a missile
544     if(ATTACK_FINISHED(actor, slot) <= time || PS(actor).m_weapon != WEP_DEVASTATOR)
545     {
546         ammo_amount = false;
547         if(WEP_CVAR(devastator, reload_ammo))
548         {
549             if(actor.(thiswep.ammo_field) < WEP_CVAR(devastator, ammo) && actor.(weaponentity).(weapon_load[WEP_DEVASTATOR.m_id]) < WEP_CVAR(devastator, ammo))
550                 ammo_amount = true;
551         }
552         else if(actor.(thiswep.ammo_field) < WEP_CVAR(devastator, ammo))
553             ammo_amount = true;
554         return !ammo_amount;
555     }
556     #endif
557     #if 0
558     if(actor.rl_release == 0)
559     {
560         LOG_INFOF("W_Devastator(WR_CHECKAMMO1): %d, %.2f, %d: TRUE\n", actor.rl_release, actor.(thiswep.ammo_field), WEP_CVAR(devastator, ammo));
561         return true;
562     }
563     else
564     {
565         ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(devastator, ammo);
566         ammo_amount += actor.(weaponentity).(weapon_load[WEP_DEVASTATOR.m_id]) >= WEP_CVAR(devastator, ammo);
567         LOG_INFOF("W_Devastator(WR_CHECKAMMO1): %d, %.2f, %d: %s\n", actor.rl_release, actor.(thiswep.ammo_field), WEP_CVAR(devastator, ammo), (ammo_amount ? "TRUE" : "FALSE"));
568         return ammo_amount;
569     }
570     #else
571     float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(devastator, ammo);
572     ammo_amount += actor.(weaponentity).(weapon_load[WEP_DEVASTATOR.m_id]) >= WEP_CVAR(devastator, ammo);
573     return ammo_amount;
574     #endif
575 }
576 METHOD(Devastator, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
577 {
578     return false;
579 }
580 METHOD(Devastator, wr_resetplayer, void(entity thiswep, entity actor))
581 {
582     for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
583     {
584         .entity weaponentity = weaponentities[slot];
585         actor.(weaponentity).lastrocket = NULL; // stop rocket guiding, no revenge from the grave!
586         actor.(weaponentity).rl_release = 0;
587     }
588 }
589 METHOD(Devastator, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
590 {
591     W_Reload(actor, weaponentity, WEP_CVAR(devastator, ammo), SND_RELOAD);
592 }
593 METHOD(Devastator, wr_suicidemessage, Notification(entity thiswep))
594 {
595     return WEAPON_DEVASTATOR_SUICIDE;
596 }
597 METHOD(Devastator, wr_killmessage, Notification(entity thiswep))
598 {
599     if((w_deathtype & HITTYPE_BOUNCE) || (w_deathtype & HITTYPE_SPLASH))
600         return WEAPON_DEVASTATOR_MURDER_SPLASH;
601     else
602         return WEAPON_DEVASTATOR_MURDER_DIRECT;
603 }
604
605 #endif
606 #ifdef CSQC
607
608 METHOD(Devastator, wr_impacteffect, void(entity thiswep, entity actor))
609 {
610     vector org2;
611     org2 = w_org + w_backoff * 12;
612     pointparticles(EFFECT_ROCKET_EXPLODE, org2, '0 0 0', 1);
613     if(!w_issilent)
614         sound(actor, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTN_NORM);
615 }
616
617 #endif
618 #endif