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