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