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