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