newmine.event_damage = this.event_damage;
newmine.spawnshieldtime = this.spawnshieldtime;
newmine.damagedbycontents = true;
+ IL_PUSH(g_damagedbycontents, newmine);
set_movetype(newmine, MOVETYPE_NONE); // lock the mine in place
newmine.projectiledeathtype = this.projectiledeathtype;
W_MineLayer_Explode(this, NULL);
}
-int W_MineLayer_Count(entity e)
+int W_MineLayer_Count(entity e, .entity weaponentity)
{
int minecount = 0;
- IL_EACH(g_mines, it.realowner == e,
+ IL_EACH(g_mines, it.realowner == e && it.weaponentity_fld == weaponentity,
{
minecount += 1;
});
return;
}
- if(toucher && IS_PLAYER(toucher) && !IS_DEAD(toucher))
+ if((toucher && IS_PLAYER(toucher) && !IS_DEAD(toucher)) || toucher.owner == this.owner)
{
- // hit a player
+ // hit a player or other mine
// don't stick
}
else
mine.health = WEP_CVAR(minelayer, health);
mine.event_damage = W_MineLayer_Damage;
mine.damagedbycontents = true;
+ IL_PUSH(g_damagedbycontents, mine);
set_movetype(mine, MOVETYPE_TOSS);
PROJECTILE_MAKETRIGGER(mine);
MUTATOR_CALLHOOK(EditProjectile, actor, mine);
- actor.(weaponentity).minelayer_mines = W_MineLayer_Count(actor);
+ actor.(weaponentity).minelayer_mines = W_MineLayer_Count(actor, weaponentity);
}
-bool W_MineLayer_PlacedMines(entity this, bool detonate)
+bool W_MineLayer_PlacedMines(entity this, .entity weaponentity, bool detonate)
{
bool minfound = false;
- IL_EACH(g_mines, it.realowner == this,
+ IL_EACH(g_mines, it.realowner == this && it.weaponentity_fld == weaponentity,
{
if(detonate)
{
return minfound;
}
-METHOD(MineLayer, wr_aim, void(entity thiswep, entity actor))
+METHOD(MineLayer, wr_aim, void(entity thiswep, entity actor, .entity weaponentity))
{
// aim and decide to fire if appropriate
- .entity weaponentity = weaponentities[0]; // TODO: unhardcode
if(actor.(weaponentity).minelayer_mines >= WEP_CVAR(minelayer, limit))
PHYS_INPUT_BUTTON_ATCK(actor) = false;
else
- PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, WEP_CVAR(minelayer, speed), 0, WEP_CVAR(minelayer, lifetime), false);
+ PHYS_INPUT_BUTTON_ATCK(actor) = bot_aim(actor, weaponentity, WEP_CVAR(minelayer, speed), 0, WEP_CVAR(minelayer, lifetime), false);
if(skill >= 2) // skill 0 and 1 bots won't detonate mines!
{
// decide whether to detonate mines
if(autocvar_g_balance_minelayer_reload_ammo && actor.(weaponentity).clip_load < WEP_CVAR(minelayer, ammo)) // forced reload
{
// not if we're holding the minelayer without enough ammo, but can detonate existing mines
- if(!(W_MineLayer_PlacedMines(actor, false) && actor.(thiswep.ammo_field) < WEP_CVAR(minelayer, ammo))) {
+ if(!(W_MineLayer_PlacedMines(actor, weaponentity, false) && actor.(thiswep.ammo_field) < WEP_CVAR(minelayer, ammo))) {
thiswep.wr_reload(thiswep, actor, weaponentity);
}
}
if(fire & 2)
{
- if(W_MineLayer_PlacedMines(actor, true))
+ if(W_MineLayer_PlacedMines(actor, weaponentity, true))
sound(actor, CH_WEAPON_B, SND_MINE_DET, VOL_BASE, ATTN_NORM);
}
}
}
METHOD(MineLayer, wr_checkammo2, bool(entity thiswep, entity actor, .entity weaponentity))
{
- if(W_MineLayer_PlacedMines(actor, false))
+ if(W_MineLayer_PlacedMines(actor, weaponentity, false))
return true;
else
return false;