Merge branch 'master' into samual/weapons
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / weapons / w_minelayer.qc
1 #ifdef REGISTER_WEAPON
2 REGISTER_WEAPON(
3 /* WEP_##id  */ MINE_LAYER,
4 /* function  */ W_MineLayer,
5 /* ammotype  */ ammo_rockets,
6 /* impulse   */ 4,
7 /* flags     */ WEP_FLAG_MUTATORBLOCKED | WEP_FLAG_RELOADABLE | WEP_TYPE_SPLASH,
8 /* rating    */ BOT_PICKUP_RATING_HIGH,
9 /* color     */ '0.75 1 0',
10 /* modelname */ "minelayer",
11 /* simplemdl */ "foobar",
12 /* crosshair */ "gfx/crosshairminelayer 0.9",
13 /* wepimg    */ "weaponminelayer",
14 /* refname   */ "minelayer",
15 /* wepname   */ _("Mine Layer")
16 );
17
18 #define MINELAYER_SETTINGS(w_cvar,w_prop) MINELAYER_SETTINGS_LIST(w_cvar, w_prop, MINE_LAYER, minelayer)
19 #define MINELAYER_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, health) \
28         w_cvar(id, sn, NONE, lifetime) \
29         w_cvar(id, sn, NONE, lifetime_countdown) \
30         w_cvar(id, sn, NONE, limit) \
31         w_cvar(id, sn, NONE, protection) \
32         w_cvar(id, sn, NONE, proximityradius) \
33         w_cvar(id, sn, NONE, radius) \
34         w_cvar(id, sn, NONE, refire) \
35         w_cvar(id, sn, NONE, remote_damage) \
36         w_cvar(id, sn, NONE, remote_edgedamage) \
37         w_cvar(id, sn, NONE, remote_force) \
38         w_cvar(id, sn, NONE, remote_radius) \
39         w_cvar(id, sn, NONE, speed) \
40         w_cvar(id, sn, NONE, time) \
41         w_prop(id, sn, float,  reloading_ammo, reload_ammo) \
42         w_prop(id, sn, float,  reloading_time, reload_time) \
43         w_prop(id, sn, float,  switchdelay_raise, switchdelay_raise) \
44         w_prop(id, sn, float,  switchdelay_drop, switchdelay_drop) \
45         w_prop(id, sn, string, weaponreplace, weaponreplace) \
46         w_prop(id, sn, float,  weaponstart, weaponstart) \
47         w_prop(id, sn, float,  weaponstartoverride, weaponstartoverride) \
48         w_prop(id, sn, float,  weaponthrowable, weaponthrowable)
49
50 #ifdef SVQC
51 MINELAYER_SETTINGS(WEP_ADD_CVAR, WEP_ADD_PROP)
52 void W_MineLayer_Think(void);
53 .float minelayer_detonate, mine_explodeanyway;
54 .float mine_time;
55 .vector mine_orientation;
56 #endif
57 #else
58 #ifdef SVQC
59 void spawnfunc_weapon_minelayer(void) { weapon_defaultspawnfunc(WEP_MINE_LAYER); }
60
61 void W_MineLayer_Stick(entity to)
62 {
63         spamsound(self, CH_SHOTS, "weapons/mine_stick.wav", VOL_BASE, ATTN_NORM);
64
65         // in order for mines to face properly when sticking to the ground, they must be a server side entity rather than a csqc projectile
66
67         entity newmine;
68         newmine = spawn();
69         newmine.classname = self.classname;
70
71         newmine.bot_dodge = self.bot_dodge;
72         newmine.bot_dodgerating = self.bot_dodgerating;
73
74         newmine.owner = self.owner;
75         newmine.realowner = self.realowner;
76         setsize(newmine, '-4 -4 -4', '4 4 4');
77         setorigin(newmine, self.origin);
78         setmodel(newmine, "models/mine.md3");
79         newmine.angles = vectoangles(-trace_plane_normal); // face against the surface
80
81         newmine.mine_orientation = -trace_plane_normal;
82
83         newmine.takedamage = self.takedamage;
84         newmine.damageforcescale = self.damageforcescale;
85         newmine.health = self.health;
86         newmine.event_damage = self.event_damage;
87         newmine.spawnshieldtime = self.spawnshieldtime;
88         newmine.damagedbycontents = TRUE;
89
90         newmine.movetype = MOVETYPE_NONE; // lock the mine in place
91         newmine.projectiledeathtype = self.projectiledeathtype;
92
93         newmine.mine_time = self.mine_time;
94
95         newmine.touch = func_null;
96         newmine.think = W_MineLayer_Think;
97         newmine.nextthink = time;
98         newmine.cnt = self.cnt;
99         newmine.flags = self.flags;
100
101         remove(self);
102         self = newmine;
103
104         if(to)
105                 SetMovetypeFollow(self, to);
106 }
107
108 void W_MineLayer_Explode(void)
109 {
110         if(other.takedamage == DAMAGE_AIM)
111                 if(IS_PLAYER(other))
112                         if(DIFF_TEAM(self.realowner, other))
113                                 if(other.deadflag == DEAD_NO)
114                                         if(IsFlying(other))
115                                                 Send_Notification(NOTIF_ONE, self.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_AIRSHOT);
116
117         self.event_damage = func_null;
118         self.takedamage = DAMAGE_NO;
119
120         RadiusDamage(self, self.realowner, WEP_CVAR(minelayer, damage), WEP_CVAR(minelayer, edgedamage), WEP_CVAR(minelayer, radius), world, world, WEP_CVAR(minelayer, force), self.projectiledeathtype, other);
121
122         if(self.realowner.weapon == WEP_MINE_LAYER)
123         {
124                 entity oldself;
125                 oldself = self;
126                 self = self.realowner;
127                 if(!WEP_ACTION(WEP_MINE_LAYER, WR_CHECKAMMO1))
128                 {
129                         self.cnt = WEP_MINE_LAYER;
130                         ATTACK_FINISHED(self) = time;
131                         self.switchweapon = w_getbestweapon(self);
132                 }
133                 self = oldself;
134         }
135         self.realowner.minelayer_mines -= 1;
136         remove(self);
137 }
138
139 void W_MineLayer_DoRemoteExplode(void)
140 {
141         self.event_damage = func_null;
142         self.takedamage = DAMAGE_NO;
143
144         if(self.movetype == MOVETYPE_NONE || self.movetype == MOVETYPE_FOLLOW)
145                 self.velocity = self.mine_orientation; // particle fx and decals need .velocity
146
147         RadiusDamage(self, self.realowner, WEP_CVAR(minelayer, remote_damage), WEP_CVAR(minelayer, remote_edgedamage), WEP_CVAR(minelayer, remote_radius), world, world, WEP_CVAR(minelayer, remote_force), self.projectiledeathtype | HITTYPE_BOUNCE, world);
148
149         if(self.realowner.weapon == WEP_MINE_LAYER)
150         {
151                 entity oldself;
152                 oldself = self;
153                 self = self.realowner;
154                 if(!WEP_ACTION(WEP_MINE_LAYER, WR_CHECKAMMO1))
155                 {
156                         self.cnt = WEP_MINE_LAYER;
157                         ATTACK_FINISHED(self) = time;
158                         self.switchweapon = w_getbestweapon(self);
159                 }
160                 self = oldself;
161         }
162         self.realowner.minelayer_mines -= 1;
163         remove(self);
164 }
165
166 void W_MineLayer_RemoteExplode(void)
167 {
168         if(self.realowner.deadflag == DEAD_NO)
169                 if((self.spawnshieldtime >= 0)
170                         ? (time >= self.spawnshieldtime) // timer
171                         : (vlen(NearestPointOnBox(self.realowner, self.origin) - self.origin) > WEP_CVAR(minelayer, remote_radius)) // safety device
172                 )
173                 {
174                         W_MineLayer_DoRemoteExplode();
175                 }
176 }
177
178 void W_MineLayer_ProximityExplode(void)
179 {
180         // make sure no friend is in the mine's radius. If there is any, explosion is delayed until he's at a safe distance
181         if(WEP_CVAR(minelayer, protection) && self.mine_explodeanyway == 0)
182         {
183                 entity head;
184                 head = findradius(self.origin, WEP_CVAR(minelayer, radius));
185                 while(head)
186                 {
187                         if(head == self.realowner || SAME_TEAM(head, self.realowner))
188                                 return;
189                         head = head.chain;
190                 }
191         }
192
193         self.mine_time = 0;
194         W_MineLayer_Explode();
195 }
196
197 float W_MineLayer_Count(entity e)
198 {
199         float minecount = 0;
200         entity mine;
201         for(mine = world; (mine = find(mine, classname, "mine")); ) if(mine.realowner == e)
202                 minecount += 1;
203
204         return minecount;
205 }
206
207 void W_MineLayer_Think(void)
208 {
209         entity head;
210
211         self.nextthink = time;
212
213         if(self.movetype == MOVETYPE_FOLLOW)
214         {
215                 if(LostMovetypeFollow(self))
216                 {
217                         UnsetMovetypeFollow(self);
218                         self.movetype = MOVETYPE_NONE;
219                 }
220         }
221         
222         // our lifetime has expired, it's time to die - mine_time just allows us to play a sound for this
223         // TODO: replace this mine_trigger.wav sound with a real countdown
224         if((time > self.cnt) && (!self.mine_time))
225         {
226                 if(WEP_CVAR(minelayer, lifetime_countdown) > 0)
227                         spamsound(self, CH_SHOTS, "weapons/mine_trigger.wav", VOL_BASE, ATTN_NORM);
228                 self.mine_time = time + WEP_CVAR(minelayer, lifetime_countdown);
229                 self.mine_explodeanyway = 1; // make the mine super aggressive -- Samual: Rather, make it not care if a team mate is near.
230         }
231
232         // a player's mines shall explode if he disconnects or dies
233         // TODO: Do this on team change too -- Samual: But isn't a player killed when they switch teams?
234         if(!IS_PLAYER(self.realowner) || self.realowner.deadflag != DEAD_NO || self.realowner.freezetag_frozen)
235         {
236                 other = world;
237                 self.projectiledeathtype |= HITTYPE_BOUNCE;
238                 W_MineLayer_Explode();
239                 return;
240         }
241
242         // set the mine for detonation when a foe gets close enough
243         head = findradius(self.origin, WEP_CVAR(minelayer, proximityradius));
244         while(head)
245         {
246                 if(IS_PLAYER(head) && head.deadflag == DEAD_NO && !head.freezetag_frozen)
247                 if(head != self.realowner && DIFF_TEAM(head, self.realowner)) // don't trigger for team mates
248                 if(!self.mine_time)
249                 {
250                         spamsound(self, CH_SHOTS, "weapons/mine_trigger.wav", VOL_BASE, ATTN_NORM);
251                         self.mine_time = time + WEP_CVAR(minelayer, time);
252                 }
253                 head = head.chain;
254         }
255
256         // explode if it's time to
257         if(self.mine_time && time >= self.mine_time)
258         {
259                 W_MineLayer_ProximityExplode();
260                 return;
261         }
262
263         // remote detonation
264         if(self.realowner.weapon == WEP_MINE_LAYER)
265         if(self.realowner.deadflag == DEAD_NO)
266         if(self.minelayer_detonate)
267                 W_MineLayer_RemoteExplode();
268 }
269
270 void W_MineLayer_Touch(void)
271 {
272         if(self.movetype == MOVETYPE_NONE || self.movetype == MOVETYPE_FOLLOW)
273                 return; // we're already a stuck mine, why do we get called? TODO does this even happen?
274
275         if(WarpZone_Projectile_Touch())
276         {
277                 if(wasfreed(self))
278                         self.realowner.minelayer_mines -= 1;
279                 return;
280         }
281
282         if(other && IS_PLAYER(other) && other.deadflag == DEAD_NO)
283         {
284                 // hit a player
285                 // don't stick
286         }
287         else
288         {
289                 W_MineLayer_Stick(other);
290         }
291 }
292
293 void W_MineLayer_Damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
294 {
295         if(self.health <= 0)
296                 return;
297                 
298         float is_from_enemy = (inflictor.realowner != self.realowner);
299                 
300         if(!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, (is_from_enemy ? 1 : -1)))
301                 return; // g_projectiles_damage says to halt
302                 
303         self.health = self.health - damage;
304         self.angles = vectoangles(self.velocity);
305         
306         if(self.health <= 0)
307                 W_PrepareExplosionByDamage(attacker, W_MineLayer_Explode);
308 }
309
310 void W_MineLayer_Attack(void)
311 {
312         entity mine;
313         entity flash;
314
315         // scan how many mines we placed, and return if we reached our limit
316         if(WEP_CVAR(minelayer, limit))
317         {
318                 if(self.minelayer_mines >= WEP_CVAR(minelayer, limit))
319                 {
320                         // the refire delay keeps this message from being spammed
321                         sprint(self, strcat("minelayer: You cannot place more than ^2", ftos(WEP_CVAR(minelayer, limit)), " ^7mines at a time\n") );
322                         play2(self, "weapons/unavailable.wav");
323                         return;
324                 }
325         }
326
327         W_DecreaseAmmo(WEP_CVAR(minelayer, ammo));
328
329         W_SetupShot_ProjectileSize(self, '-4 -4 -4', '4 4 4', FALSE, 5, "weapons/mine_fire.wav", CH_WEAPON_A, WEP_CVAR(minelayer, damage));
330         pointparticles(particleeffectnum("rocketlauncher_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
331
332         mine = WarpZone_RefSys_SpawnSameRefSys(self);
333         mine.owner = mine.realowner = self;
334         if(WEP_CVAR(minelayer, detonatedelay) >= 0)
335                 mine.spawnshieldtime = time + WEP_CVAR(minelayer, detonatedelay);
336         else
337                 mine.spawnshieldtime = -1;
338         mine.classname = "mine";
339         mine.bot_dodge = TRUE;
340         mine.bot_dodgerating = WEP_CVAR(minelayer, damage) * 2; // * 2 because it can detonate inflight which makes it even more dangerous
341
342         mine.takedamage = DAMAGE_YES;
343         mine.damageforcescale = WEP_CVAR(minelayer, damageforcescale);
344         mine.health = WEP_CVAR(minelayer, health);
345         mine.event_damage = W_MineLayer_Damage;
346         mine.damagedbycontents = TRUE;
347
348         mine.movetype = MOVETYPE_TOSS;
349         PROJECTILE_MAKETRIGGER(mine);
350         mine.projectiledeathtype = WEP_MINE_LAYER;
351         setsize(mine, '-4 -4 -4', '4 4 4'); // give it some size so it can be shot
352
353         setorigin(mine, w_shotorg - v_forward * 4); // move it back so it hits the wall at the right point
354         W_SetupProjVelocity_Basic(mine, WEP_CVAR(minelayer, speed), 0);
355         mine.angles = vectoangles(mine.velocity);
356
357         mine.touch = W_MineLayer_Touch;
358         mine.think = W_MineLayer_Think;
359         mine.nextthink = time;
360         mine.cnt = time + (WEP_CVAR(minelayer, lifetime) - WEP_CVAR(minelayer, lifetime_countdown));
361         mine.flags = FL_PROJECTILE;
362         mine.missile_flags = MIF_SPLASH | MIF_ARC | MIF_PROXY;
363
364         CSQCProjectile(mine, TRUE, PROJECTILE_MINE, TRUE);
365
366         // muzzle flash for 1st person view
367         flash = spawn();
368         setmodel(flash, "models/flash.md3"); // precision set below
369         SUB_SetFade(flash, time, 0.1);
370         flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
371         W_AttachToShotorg(flash, '5 0 0');
372
373         // common properties
374
375         other = mine; MUTATOR_CALLHOOK(EditProjectile);
376         
377         self.minelayer_mines = W_MineLayer_Count(self);
378 }
379
380 float W_MineLayer_PlacedMines(float detonate)
381 {
382         entity mine;
383         float minfound = 0;
384
385         for(mine = world; (mine = find(mine, classname, "mine")); ) if(mine.realowner == self)
386         {
387                 if(detonate)
388                 {
389                         if(!mine.minelayer_detonate)
390                         {
391                                 mine.minelayer_detonate = TRUE;
392                                 minfound = 1;
393                         }
394                 }
395                 else
396                         minfound = 1;
397         }
398         return minfound;
399 }
400
401 float W_MineLayer(float req)
402 {
403         entity mine;
404         float ammo_amount;
405         switch(req)
406         {
407                 case WR_AIM:
408                 {
409                         // aim and decide to fire if appropriate
410                         if(self.minelayer_mines >= WEP_CVAR(minelayer, limit))
411                                 self.BUTTON_ATCK = FALSE;
412                         else
413                                 self.BUTTON_ATCK = bot_aim(WEP_CVAR(minelayer, speed), 0, WEP_CVAR(minelayer, lifetime), FALSE);
414                         if(skill >= 2) // skill 0 and 1 bots won't detonate mines!
415                         {
416                                 // decide whether to detonate mines
417                                 entity targetlist, targ;
418                                 float edgedamage, coredamage, edgeradius, recipricoledgeradius, d;
419                                 float selfdamage, teamdamage, enemydamage;
420                                 edgedamage = WEP_CVAR(minelayer, edgedamage);
421                                 coredamage = WEP_CVAR(minelayer, damage);
422                                 edgeradius = WEP_CVAR(minelayer, radius);
423                                 recipricoledgeradius = 1 / edgeradius;
424                                 selfdamage = 0;
425                                 teamdamage = 0;
426                                 enemydamage = 0;
427                                 targetlist = findchainfloat(bot_attack, TRUE);
428                                 mine = find(world, classname, "mine");
429                                 while(mine)
430                                 {
431                                         if(mine.realowner != self)
432                                         {
433                                                 mine = find(mine, classname, "mine");
434                                                 continue;
435                                         }
436                                         targ = targetlist;
437                                         while(targ)
438                                         {
439                                                 d = vlen(targ.origin + (targ.mins + targ.maxs) * 0.5 - mine.origin);
440                                                 d = bound(0, edgedamage + (coredamage - edgedamage) * sqrt(1 - d * recipricoledgeradius), 10000);
441                                                 // count potential damage according to type of target
442                                                 if(targ == self)
443                                                         selfdamage = selfdamage + d;
444                                                 else if(targ.team == self.team && teamplay)
445                                                         teamdamage = teamdamage + d;
446                                                 else if(bot_shouldattack(targ))
447                                                         enemydamage = enemydamage + d;
448                                                 targ = targ.chain;
449                                         }
450                                         mine = find(mine, classname, "mine");
451                                 }
452                                 float desirabledamage;
453                                 desirabledamage = enemydamage;
454                                 if(time > self.invincible_finished && time > self.spawnshieldtime)
455                                         desirabledamage = desirabledamage - selfdamage * autocvar_g_balance_selfdamagepercent;
456                                 if(teamplay && self.team)
457                                         desirabledamage = desirabledamage - teamdamage;
458
459                                 mine = find(world, classname, "mine");
460                                 while(mine)
461                                 {
462                                         if(mine.realowner != self)
463                                         {
464                                                 mine = find(mine, classname, "mine");
465                                                 continue;
466                                         }
467                                         makevectors(mine.v_angle);
468                                         targ = targetlist;
469                                         if(skill > 9) // normal players only do this for the target they are tracking
470                                         {
471                                                 targ = targetlist;
472                                                 while(targ)
473                                                 {
474                                                         if(
475                                                                 (v_forward * normalize(mine.origin - targ.origin)< 0.1)
476                                                                 && desirabledamage > 0.1*coredamage
477                                                         )self.BUTTON_ATCK2 = TRUE;
478                                                         targ = targ.chain;
479                                                 }
480                                         }else{
481                                                 float distance; distance= bound(300,vlen(self.origin-self.enemy.origin),30000);
482                                                 //As the distance gets larger, a correct detonation gets near imposible
483                                                 //Bots are assumed to use the mine spawnfunc_light to see if the mine gets near a player
484                                                 if(v_forward * normalize(mine.origin - self.enemy.origin)< 0.1)
485                                                         if(IS_PLAYER(self.enemy))
486                                                                 if(desirabledamage >= 0.1*coredamage)
487                                                                         if(random()/distance*300 > frametime*bound(0,(10-skill)*0.2,1))
488                                                                                 self.BUTTON_ATCK2 = TRUE;
489                                         //      dprint(ftos(random()/distance*300),">");dprint(ftos(frametime*bound(0,(10-skill)*0.2,1)),"\n");
490                                         }
491
492                                         mine = find(mine, classname, "mine");
493                                 }
494                                 // if we would be doing at X percent of the core damage, detonate it
495                                 // but don't fire a new shot at the same time!
496                                 if(desirabledamage >= 0.75 * coredamage) //this should do group damage in rare fortunate events
497                                         self.BUTTON_ATCK2 = TRUE;
498                                 if((skill > 6.5) && (selfdamage > self.health))
499                                         self.BUTTON_ATCK2 = FALSE;
500                                 //if(self.BUTTON_ATCK2 == TRUE)
501                                 //      dprint(ftos(desirabledamage),"\n");
502                                 if(self.BUTTON_ATCK2 == TRUE) self.BUTTON_ATCK = FALSE;
503                         }
504                         
505                         return TRUE;
506                 }
507                 case WR_THINK:
508                 {
509                         if(autocvar_g_balance_minelayer_reload_ammo && self.clip_load < WEP_CVAR(minelayer, ammo)) // forced reload
510                         {
511                                 // not if we're holding the minelayer without enough ammo, but can detonate existing mines
512                                 if(!(W_MineLayer_PlacedMines(FALSE) && self.WEP_AMMO(MINE_LAYER) < WEP_CVAR(minelayer, ammo)))
513                                         WEP_ACTION(self.weapon, WR_RELOAD);
514                         }
515                         else if(self.BUTTON_ATCK)
516                         {
517                                 if(weapon_prepareattack(0, WEP_CVAR(minelayer, refire)))
518                                 {
519                                         W_MineLayer_Attack();
520                                         weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(minelayer, animtime), w_ready);
521                                 }
522                         }
523
524                         if(self.BUTTON_ATCK2)
525                         {
526                                 if(W_MineLayer_PlacedMines(TRUE))
527                                         sound(self, CH_WEAPON_B, "weapons/mine_det.wav", VOL_BASE, ATTN_NORM);
528                         }
529                         
530                         return TRUE;
531                 }
532                 case WR_INIT:
533                 {
534                         precache_model("models/flash.md3");
535                         precache_model("models/mine.md3");
536                         precache_model("models/weapons/g_minelayer.md3");
537                         precache_model("models/weapons/v_minelayer.md3");
538                         precache_model("models/weapons/h_minelayer.iqm");
539                         precache_sound("weapons/mine_det.wav");
540                         precache_sound("weapons/mine_fire.wav");
541                         precache_sound("weapons/mine_stick.wav");
542                         precache_sound("weapons/mine_trigger.wav");
543                         MINELAYER_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP)
544                         return TRUE;
545                 }
546                 case WR_CHECKAMMO1:
547                 {
548                         // don't switch while placing a mine
549                         if(ATTACK_FINISHED(self) <= time || self.weapon != WEP_MINE_LAYER)
550                         {
551                                 ammo_amount = self.WEP_AMMO(MINE_LAYER) >= WEP_CVAR(minelayer, ammo);
552                                 ammo_amount += self.(weapon_load[WEP_MINE_LAYER]) >= WEP_CVAR(minelayer, ammo);
553                                 return ammo_amount;
554                         }
555                         return TRUE;
556                 }
557                 case WR_CHECKAMMO2:
558                 {
559                         if(W_MineLayer_PlacedMines(FALSE))
560                                 return TRUE;
561                         else
562                                 return FALSE;
563                 }
564                 case WR_CONFIG:
565                 {
566                         MINELAYER_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS)
567                         return TRUE;
568                 }
569                 case WR_RESETPLAYER:
570                 {
571                         self.minelayer_mines = 0;
572                         return TRUE;
573                 }
574                 case WR_RELOAD:
575                 {
576                         W_Reload(WEP_CVAR(minelayer, ammo), "weapons/reload.wav");
577                         return TRUE;
578                 }
579                 case WR_SUICIDEMESSAGE:
580                 {
581                         return WEAPON_MINELAYER_SUICIDE;
582                 }
583                 case WR_KILLMESSAGE:
584                 {
585                         return WEAPON_MINELAYER_MURDER;
586                 }
587         }
588         return FALSE;
589 }
590 #endif
591 #ifdef CSQC
592 float W_MineLayer(float req)
593 {
594         switch(req)
595         {
596                 case WR_IMPACTEFFECT:
597                 {
598                         vector org2;
599                         org2 = w_org + w_backoff * 12;
600                         pointparticles(particleeffectnum("rocket_explode"), org2, '0 0 0', 1);
601                         if(!w_issilent)
602                                 sound(self, CH_SHOTS, "weapons/mine_exp.wav", VOL_BASE, ATTN_NORM);
603                         
604                         return TRUE;
605                 }
606                 case WR_INIT:
607                 {
608                         precache_sound("weapons/mine_exp.wav");
609                         return TRUE;
610                 }
611                 case WR_ZOOMRETICLE:
612                 {
613                         // no weapon specific image for this weapon
614                         return FALSE;
615                 }
616         }
617         return FALSE;
618 }
619 #endif
620 #endif