#ifdef REGISTER_WEAPON
-REGISTER_WEAPON(MINE_LAYER, w_minelayer, IT_ROCKETS, 4, WEP_FLAG_NORMAL | WEP_FLAG_RELOADABLE | WEP_TYPE_SPLASH, BOT_PICKUP_RATING_HIGH, "minelayer", "minelayer", _("Mine Layer"))
+REGISTER_WEAPON(MINE_LAYER, w_minelayer, IT_ROCKETS, 4, WEP_FLAG_RELOADABLE | WEP_TYPE_SPLASH, BOT_PICKUP_RATING_HIGH, "minelayer", "minelayer", _("Mine Layer"))
#else
#ifdef SVQC
void W_Mine_Think (void);
-.float minelayer_detonate, minelayer_mines;
+.float minelayer_detonate, mine_explodeanyway;
.float mine_time;
-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);
if (self.owner.weapon == WEP_MINE_LAYER)
{
- if(self.owner.ammo_rockets < autocvar_g_balance_minelayer_ammo)
+ entity oldself;
+ oldself = self;
+ self = self.owner;
+ if (!weapon_action(WEP_MINE_LAYER, WR_CHECKAMMO1))
{
- self.owner.cnt = WEP_MINE_LAYER;
- ATTACK_FINISHED(self.owner) = time;
- self.owner.switchweapon = w_getbestweapon(self.owner);
+ self.cnt = WEP_MINE_LAYER;
+ ATTACK_FINISHED(self) = time;
+ self.switchweapon = w_getbestweapon(self);
}
+ self = oldself;
}
+ self.owner.minelayer_mines -= 1;
remove (self);
}
if (self.owner.weapon == WEP_MINE_LAYER)
{
- if(self.owner.ammo_rockets < autocvar_g_balance_minelayer_ammo)
+ entity oldself;
+ oldself = self;
+ self = self.owner;
+ if (!weapon_action(WEP_MINE_LAYER, WR_CHECKAMMO1))
{
- self.owner.cnt = WEP_MINE_LAYER;
- ATTACK_FINISHED(self.owner) = time;
- self.owner.switchweapon = w_getbestweapon(self.owner);
+ self.cnt = WEP_MINE_LAYER;
+ ATTACK_FINISHED(self) = time;
+ self.switchweapon = w_getbestweapon(self);
}
+ self = oldself;
}
+ self.owner.minelayer_mines -= 1;
remove (self);
}
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 && self.minelayer_mines == 0)
+ if(autocvar_g_balance_minelayer_protection && self.mine_explodeanyway == 0)
{
entity head;
head = findradius(self.origin, autocvar_g_balance_minelayer_radius);
W_Mine_Explode();
}
+float W_Mine_Count(entity e)
+{
+ float minecount;
+ entity mine;
+ for(mine = world; (mine = find(mine, classname, "mine")); ) if(mine.owner == e)
+ minecount += 1;
+
+ return minecount;
+}
+
void W_Mine_Think (void)
{
entity head;
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
+ self.mine_explodeanyway = 1; // make the mine super aggressive -- Samual: Rather, make it not care if a team mate is near.
}
// a player's mines shall explode if he disconnects or dies
// scan how many mines we placed, and return if we reached our limit
if(autocvar_g_balance_minelayer_limit)
{
- self.minelayer_mines = 0;
- for(mine = world; (mine = find(mine, classname, "mine")); ) if(mine.owner == self)
- self.minelayer_mines += 1;
-
- if(self.minelayer_mines >= autocvar_g_balance_minelayer_limit)
+
+ if(W_Mine_Count(self) >= autocvar_g_balance_minelayer_limit)
{
// the refire delay keeps this message from being spammed
sprint(self, strcat("You cannot place more than ^2", ftos(autocvar_g_balance_minelayer_limit), " ^7mines at a time\n") );
}
}
- // 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);
// common properties
other = mine; MUTATOR_CALLHOOK(EditProjectile);
+
+ self.minelayer_mines = W_Mine_Count(self);
}
void spawnfunc_weapon_minelayer (void); // defined in t_items.qc
-float w_minelayer(float req)
+float W_PlacedMines(float detonate)
{
entity mine;
float minfound;
+
+ for(mine = world; (mine = find(mine, classname, "mine")); ) if(mine.owner == self)
+ {
+ if(detonate)
+ {
+ if(!mine.minelayer_detonate)
+ {
+ mine.minelayer_detonate = TRUE;
+ minfound = 1;
+ }
+ }
+ else
+ minfound = 1;
+ }
+ return minfound;
+}
+
+float w_minelayer(float req)
+{
+ entity mine;
float ammo_amount;
if (req == WR_AIM)
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();
+ {
+ // not if we're holding the minelayer without enough ammo, but can detonate existing mines
+ if not (W_PlacedMines(FALSE) && self.ammo_rockets < autocvar_g_balance_minelayer_ammo)
+ weapon_action(self.weapon, WR_RELOAD);
+ }
else if (self.BUTTON_ATCK)
{
if(weapon_prepareattack(0, autocvar_g_balance_minelayer_refire))
}
}
- else if (self.BUTTON_ATCK2)
+ if (self.BUTTON_ATCK2)
{
- minfound = 0;
- for(mine = world; (mine = find(mine, classname, "mine")); ) if(mine.owner == self)
- {
- if(!mine.minelayer_detonate)
- {
- mine.minelayer_detonate = TRUE;
- minfound = 1;
- }
- }
- if(minfound)
+ if(W_PlacedMines(TRUE))
sound (self, CHAN_WEAPON2, "weapons/mine_det.wav", VOL_BASE, ATTN_NORM);
}
}
precache_sound ("weapons/mine_fire.wav");
precache_sound ("weapons/mine_stick.wav");
precache_sound ("weapons/mine_trigger.wav");
- precache_sound ("weapons/reload.wav");
+ //precache_sound ("weapons/reload.wav"); // until weapons have individual reload sounds, precache the reload sound somewhere else
}
else if (req == WR_SETUP)
{
weapon_setup(WEP_MINE_LAYER);
+ self.current_ammo = ammo_rockets;
}
else if (req == WR_CHECKAMMO1)
{
// don't switch while placing a mine
if (ATTACK_FINISHED(self) <= time || self.weapon != WEP_MINE_LAYER)
{
- if(autocvar_g_balance_minelayer_reload_ammo)
- {
- if(self.ammo_rockets < autocvar_g_balance_minelayer_ammo && self.weapon_load[WEP_MINE_LAYER] < autocvar_g_balance_minelayer_ammo)
- ammo_amount = TRUE;
- }
- else if(self.ammo_rockets < autocvar_g_balance_minelayer_ammo)
- ammo_amount = TRUE;
- return !ammo_amount;
+ ammo_amount = self.ammo_rockets >= autocvar_g_balance_minelayer_ammo;
+ ammo_amount += self.weapon_load[WEP_MINE_LAYER] >= autocvar_g_balance_minelayer_ammo;
+ return ammo_amount;
}
}
else if (req == WR_CHECKAMMO2)
{
- return FALSE;
+ if (W_PlacedMines(FALSE))
+ return TRUE;
+ else
+ return FALSE;
}
else if (req == WR_RELOAD)
{
- W_MineLayer_Reload();
+ W_Reload(autocvar_g_balance_minelayer_ammo, autocvar_g_balance_minelayer_reload_ammo, autocvar_g_balance_minelayer_reload_time, "weapons/reload.wav");
}
return TRUE;
};