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