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