.float minelayer_detonate, minelayer_mines;
.float mine_time;
-void W_MineLayer_SetAmmoCounter()
-{
- // set clip_load to the weapon we have switched to, if the gun uses reloading
- if(!autocvar_g_balance_minelayer_reload_ammo)
- self.clip_load = 0; // also keeps crosshair ammo from displaying
- else
- {
- self.clip_load = self.weapon_load[WEP_MINE_LAYER];
- self.clip_size = autocvar_g_balance_minelayer_reload_ammo; // for the crosshair ammo display
- }
-}
-
-void W_MineLayer_Reload()
-{
- self.reload_ammo_player = ammo_rockets;
- self.reload_ammo_min = autocvar_g_balance_minelayer_ammo;
- self.reload_ammo_amount = autocvar_g_balance_minelayer_reload_ammo;
- self.reload_time = autocvar_g_balance_minelayer_reload_time;
- self.reload_sound = "weapons/reload.wav";
-
- W_Reload();
-}
-
void spawnfunc_weapon_minelayer (void)
{
weapon_defaultspawnfunc(WEP_MINE_LAYER);
void W_Mine_ProximityExplode ()
{
// make sure no friend is in the mine's radius. If there is any, explosion is delayed until he's at a safe distance
- if(autocvar_g_balance_minelayer_protection)
+ if(autocvar_g_balance_minelayer_protection && self.minelayer_mines == 0)
{
entity head;
head = findradius(self.origin, autocvar_g_balance_minelayer_radius);
entity head;
self.nextthink = time;
- if (time > self.cnt)
+
+ // our lifetime has expired, it's time to die - mine_time just allows us to play a sound for this
+ // TODO: replace this mine_trigger.wav sound with a real countdown
+ if ((time > self.cnt) && (!self.mine_time))
{
- other = world;
- self.projectiledeathtype |= HITTYPE_BOUNCE;
- W_Mine_Explode();
- return;
+ if(autocvar_g_balance_minelayer_lifetime_countdown > 0)
+ spamsound (self, CHAN_PROJECTILE, "weapons/mine_trigger.wav", VOL_BASE, ATTN_NORM);
+ self.mine_time = time + autocvar_g_balance_minelayer_lifetime_countdown;
+ self.minelayer_mines = 1; // make the mine super aggressive
}
// a player's mines shall explode if he disconnects or dies
- // TODO: Do this on team change too
+ // TODO: Do this on team change too -- Samual: But isn't a player killed when they switch teams?
if(self.owner.classname != "player" || self.owner.deadflag != DEAD_NO)
{
other = world;
// explode if it's time to
if(self.mine_time && time >= self.mine_time)
+ {
W_Mine_ProximityExplode();
+ return;
+ }
// remote detonation
if (self.owner.weapon == WEP_MINE_LAYER)
}
}
- // if this weapon is reloadable, decrease its load. Else decrease the player's ammo
- if not(self.items & IT_UNLIMITED_WEAPON_AMMO)
- {
- if(autocvar_g_balance_minelayer_reload_ammo)
- {
- self.clip_load -= autocvar_g_balance_minelayer_ammo;
- self.weapon_load[WEP_MINE_LAYER] = self.clip_load;
- }
- else
- self.ammo_rockets -= autocvar_g_balance_minelayer_ammo;
- }
+ W_DecreaseAmmo(ammo_rockets, autocvar_g_balance_minelayer_ammo, autocvar_g_balance_minelayer_reload_ammo);
W_SetupShot_ProjectileSize (self, '-4 -4 -4', '4 4 4', FALSE, 5, "weapons/mine_fire.wav", CHAN_WEAPON, autocvar_g_balance_minelayer_damage);
pointparticles(particleeffectnum("rocketlauncher_muzzleflash"), w_shotorg, w_shotdir * 1000, 1);
mine.touch = W_Mine_Touch;
mine.think = W_Mine_Think;
mine.nextthink = time;
- mine.cnt = time + autocvar_g_balance_minelayer_lifetime;
+ mine.cnt = time + (autocvar_g_balance_minelayer_lifetime - autocvar_g_balance_minelayer_lifetime_countdown);
mine.flags = FL_PROJECTILE;
CSQCProjectile(mine, TRUE, PROJECTILE_MINE, TRUE);
else if (req == WR_THINK)
{
if(autocvar_g_balance_minelayer_reload_ammo && self.clip_load < autocvar_g_balance_minelayer_ammo) // forced reload
- W_MineLayer_Reload();
+ weapon_action(self.weapon, WR_RELOAD);
else if (self.BUTTON_ATCK)
{
if(weapon_prepareattack(0, autocvar_g_balance_minelayer_refire))
else if (req == WR_SETUP)
{
weapon_setup(WEP_MINE_LAYER);
- W_MineLayer_SetAmmoCounter();
}
else if (req == WR_CHECKAMMO1)
{
}
else if (req == WR_RELOAD)
{
- W_MineLayer_Reload();
+ W_Reload(ammo_rockets, autocvar_g_balance_minelayer_ammo, autocvar_g_balance_minelayer_reload_ammo, autocvar_g_balance_minelayer_reload_time, "weapons/reload.wav");
}
return TRUE;
};