Merge branch 'master' into Mario/notifications
[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) && (self.cnt > 0))
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.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.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                         Send_Notification(NOTIF_ONE, self, MSG_MULTI, WEAPON_MINELAYER_LIMIT, WEP_CVAR(minelayer, limit));
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 = (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         if(mine.cnt > 0) { mine.cnt += time; }
365
366         CSQCProjectile(mine, TRUE, PROJECTILE_MINE, TRUE);
367
368         // muzzle flash for 1st person view
369         flash = spawn();
370         setmodel(flash, "models/flash.md3"); // precision set below
371         SUB_SetFade(flash, time, 0.1);
372         flash.effects = EF_ADDITIVE | EF_FULLBRIGHT | EF_LOWPRECISION;
373         W_AttachToShotorg(flash, '5 0 0');
374
375         // common properties
376
377         other = mine; MUTATOR_CALLHOOK(EditProjectile);
378         
379         self.minelayer_mines = W_MineLayer_Count(self);
380 }
381
382 float W_MineLayer_PlacedMines(float detonate)
383 {
384         entity mine;
385         float minfound = 0;
386
387         for(mine = world; (mine = find(mine, classname, "mine")); ) if(mine.realowner == self)
388         {
389                 if(detonate)
390                 {
391                         if(!mine.minelayer_detonate)
392                         {
393                                 mine.minelayer_detonate = TRUE;
394                                 minfound = 1;
395                         }
396                 }
397                 else
398                         minfound = 1;
399         }
400         return minfound;
401 }
402
403 float W_MineLayer(float req)
404 {
405         entity mine;
406         float ammo_amount;
407         switch(req)
408         {
409                 case WR_AIM:
410                 {
411                         // aim and decide to fire if appropriate
412                         if(self.minelayer_mines >= WEP_CVAR(minelayer, limit))
413                                 self.BUTTON_ATCK = FALSE;
414                         else
415                                 self.BUTTON_ATCK = bot_aim(WEP_CVAR(minelayer, speed), 0, WEP_CVAR(minelayer, lifetime), FALSE);
416                         if(skill >= 2) // skill 0 and 1 bots won't detonate mines!
417                         {
418                                 // decide whether to detonate mines
419                                 entity targetlist, targ;
420                                 float edgedamage, coredamage, edgeradius, recipricoledgeradius, d;
421                                 float selfdamage, teamdamage, enemydamage;
422                                 edgedamage = WEP_CVAR(minelayer, edgedamage);
423                                 coredamage = WEP_CVAR(minelayer, damage);
424                                 edgeradius = WEP_CVAR(minelayer, radius);
425                                 recipricoledgeradius = 1 / edgeradius;
426                                 selfdamage = 0;
427                                 teamdamage = 0;
428                                 enemydamage = 0;
429                                 targetlist = findchainfloat(bot_attack, TRUE);
430                                 mine = find(world, classname, "mine");
431                                 while(mine)
432                                 {
433                                         if(mine.realowner != self)
434                                         {
435                                                 mine = find(mine, classname, "mine");
436                                                 continue;
437                                         }
438                                         targ = targetlist;
439                                         while(targ)
440                                         {
441                                                 d = vlen(targ.origin + (targ.mins + targ.maxs) * 0.5 - mine.origin);
442                                                 d = bound(0, edgedamage + (coredamage - edgedamage) * sqrt(1 - d * recipricoledgeradius), 10000);
443                                                 // count potential damage according to type of target
444                                                 if(targ == self)
445                                                         selfdamage = selfdamage + d;
446                                                 else if(targ.team == self.team && teamplay)
447                                                         teamdamage = teamdamage + d;
448                                                 else if(bot_shouldattack(targ))
449                                                         enemydamage = enemydamage + d;
450                                                 targ = targ.chain;
451                                         }
452                                         mine = find(mine, classname, "mine");
453                                 }
454                                 float desirabledamage;
455                                 desirabledamage = enemydamage;
456                                 if(time > self.invincible_finished && time > self.spawnshieldtime)
457                                         desirabledamage = desirabledamage - selfdamage * autocvar_g_balance_selfdamagepercent;
458                                 if(teamplay && self.team)
459                                         desirabledamage = desirabledamage - teamdamage;
460
461                                 mine = find(world, classname, "mine");
462                                 while(mine)
463                                 {
464                                         if(mine.realowner != self)
465                                         {
466                                                 mine = find(mine, classname, "mine");
467                                                 continue;
468                                         }
469                                         makevectors(mine.v_angle);
470                                         targ = targetlist;
471                                         if(skill > 9) // normal players only do this for the target they are tracking
472                                         {
473                                                 targ = targetlist;
474                                                 while(targ)
475                                                 {
476                                                         if(
477                                                                 (v_forward * normalize(mine.origin - targ.origin)< 0.1)
478                                                                 && desirabledamage > 0.1*coredamage
479                                                         )self.BUTTON_ATCK2 = TRUE;
480                                                         targ = targ.chain;
481                                                 }
482                                         }else{
483                                                 float distance; distance= bound(300,vlen(self.origin-self.enemy.origin),30000);
484                                                 //As the distance gets larger, a correct detonation gets near imposible
485                                                 //Bots are assumed to use the mine spawnfunc_light to see if the mine gets near a player
486                                                 if(v_forward * normalize(mine.origin - self.enemy.origin)< 0.1)
487                                                         if(IS_PLAYER(self.enemy))
488                                                                 if(desirabledamage >= 0.1*coredamage)
489                                                                         if(random()/distance*300 > frametime*bound(0,(10-skill)*0.2,1))
490                                                                                 self.BUTTON_ATCK2 = TRUE;
491                                         //      dprint(ftos(random()/distance*300),">");dprint(ftos(frametime*bound(0,(10-skill)*0.2,1)),"\n");
492                                         }
493
494                                         mine = find(mine, classname, "mine");
495                                 }
496                                 // if we would be doing at X percent of the core damage, detonate it
497                                 // but don't fire a new shot at the same time!
498                                 if(desirabledamage >= 0.75 * coredamage) //this should do group damage in rare fortunate events
499                                         self.BUTTON_ATCK2 = TRUE;
500                                 if((skill > 6.5) && (selfdamage > self.health))
501                                         self.BUTTON_ATCK2 = FALSE;
502                                 //if(self.BUTTON_ATCK2 == TRUE)
503                                 //      dprint(ftos(desirabledamage),"\n");
504                                 if(self.BUTTON_ATCK2 == TRUE) self.BUTTON_ATCK = FALSE;
505                         }
506                         
507                         return TRUE;
508                 }
509                 case WR_THINK:
510                 {
511                         if(autocvar_g_balance_minelayer_reload_ammo && self.clip_load < WEP_CVAR(minelayer, ammo)) // forced reload
512                         {
513                                 // not if we're holding the minelayer without enough ammo, but can detonate existing mines
514                                 if(!(W_MineLayer_PlacedMines(FALSE) && self.WEP_AMMO(MINE_LAYER) < WEP_CVAR(minelayer, ammo)))
515                                         WEP_ACTION(self.weapon, WR_RELOAD);
516                         }
517                         else if(self.BUTTON_ATCK)
518                         {
519                                 if(weapon_prepareattack(0, WEP_CVAR(minelayer, refire)))
520                                 {
521                                         W_MineLayer_Attack();
522                                         weapon_thinkf(WFRAME_FIRE1, WEP_CVAR(minelayer, animtime), w_ready);
523                                 }
524                         }
525
526                         if(self.BUTTON_ATCK2)
527                         {
528                                 if(W_MineLayer_PlacedMines(TRUE))
529                                         sound(self, CH_WEAPON_B, "weapons/mine_det.wav", VOL_BASE, ATTN_NORM);
530                         }
531                         
532                         return TRUE;
533                 }
534                 case WR_INIT:
535                 {
536                         precache_model("models/flash.md3");
537                         precache_model("models/mine.md3");
538                         precache_model("models/weapons/g_minelayer.md3");
539                         precache_model("models/weapons/v_minelayer.md3");
540                         precache_model("models/weapons/h_minelayer.iqm");
541                         precache_sound("weapons/mine_det.wav");
542                         precache_sound("weapons/mine_fire.wav");
543                         precache_sound("weapons/mine_stick.wav");
544                         precache_sound("weapons/mine_trigger.wav");
545                         MINELAYER_SETTINGS(WEP_SKIP_CVAR, WEP_SET_PROP)
546                         return TRUE;
547                 }
548                 case WR_CHECKAMMO1:
549                 {
550                         // don't switch while placing a mine
551                         if(ATTACK_FINISHED(self) <= time || self.weapon != WEP_MINE_LAYER)
552                         {
553                                 ammo_amount = self.WEP_AMMO(MINE_LAYER) >= WEP_CVAR(minelayer, ammo);
554                                 ammo_amount += self.(weapon_load[WEP_MINE_LAYER]) >= WEP_CVAR(minelayer, ammo);
555                                 return ammo_amount;
556                         }
557                         return TRUE;
558                 }
559                 case WR_CHECKAMMO2:
560                 {
561                         if(W_MineLayer_PlacedMines(FALSE))
562                                 return TRUE;
563                         else
564                                 return FALSE;
565                 }
566                 case WR_CONFIG:
567                 {
568                         MINELAYER_SETTINGS(WEP_CONFIG_WRITE_CVARS, WEP_CONFIG_WRITE_PROPS)
569                         return TRUE;
570                 }
571                 case WR_RESETPLAYER:
572                 {
573                         self.minelayer_mines = 0;
574                         return TRUE;
575                 }
576                 case WR_RELOAD:
577                 {
578                         W_Reload(WEP_CVAR(minelayer, ammo), "weapons/reload.wav");
579                         return TRUE;
580                 }
581                 case WR_SUICIDEMESSAGE:
582                 {
583                         return WEAPON_MINELAYER_SUICIDE;
584                 }
585                 case WR_KILLMESSAGE:
586                 {
587                         return WEAPON_MINELAYER_MURDER;
588                 }
589         }
590         return FALSE;
591 }
592 #endif
593 #ifdef CSQC
594 float W_MineLayer(float req)
595 {
596         switch(req)
597         {
598                 case WR_IMPACTEFFECT:
599                 {
600                         vector org2;
601                         org2 = w_org + w_backoff * 12;
602                         pointparticles(particleeffectnum("rocket_explode"), org2, '0 0 0', 1);
603                         if(!w_issilent)
604                                 sound(self, CH_SHOTS, "weapons/mine_exp.wav", VOL_BASE, ATTN_NORM);
605                         
606                         return TRUE;
607                 }
608                 case WR_INIT:
609                 {
610                         precache_sound("weapons/mine_exp.wav");
611                         return TRUE;
612                 }
613                 case WR_ZOOMRETICLE:
614                 {
615                         // no weapon specific image for this weapon
616                         return FALSE;
617                 }
618         }
619         return FALSE;
620 }
621 #endif
622 #endif