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