#ifdef REGISTER_WEAPON
-REGISTER_WEAPON(MINE_LAYER, w_minelayer, IT_ROCKETS, 4, WEP_FLAG_MUTATORBLOCKED | WEP_FLAG_RELOADABLE | WEP_TYPE_SPLASH, BOT_PICKUP_RATING_HIGH, "minelayer", "minelayer", _("Mine Layer"))
+REGISTER_WEAPON(
+/* WEP_##id */ MINE_LAYER,
+/* function */ w_minelayer,
+/* ammotype */ IT_ROCKETS,
+/* impulse */ 4,
+/* flags */ WEP_FLAG_MUTATORBLOCKED | WEP_FLAG_RELOADABLE | WEP_TYPE_SPLASH,
+/* rating */ BOT_PICKUP_RATING_HIGH,
+/* model */ "minelayer",
+/* shortname */ "minelayer",
+/* fullname */ _("Mine Layer")
+);
#else
#ifdef SVQC
void W_Mine_Think (void);
.float minelayer_detonate, mine_explodeanyway;
.float mine_time;
+.vector mine_orientation;
void spawnfunc_weapon_minelayer (void)
{
void W_Mine_Stick (entity to)
{
- spamsound (self, CH_SHOTS, "weapons/mine_stick.wav", VOL_BASE, ATTN_NORM);
+ spamsound (self, CH_SHOTS, "weapons/mine_stick.wav", VOL_BASE, ATTEN_NORM);
// in order for mines to face properly when sticking to the ground, they must be a server side entity rather than a csqc projectile
setmodel(newmine, "models/mine.md3");
newmine.angles = vectoangles(-trace_plane_normal); // face against the surface
- newmine.oldvelocity = self.velocity;
+ newmine.mine_orientation = -trace_plane_normal;
newmine.takedamage = self.takedamage;
newmine.damageforcescale = self.damageforcescale;
void W_Mine_Explode ()
{
if(other.takedamage == DAMAGE_AIM)
- if(other.classname == "player")
- if(IsDifferentTeam(self.realowner, other))
+ if(IS_PLAYER(other))
+ if(DIFF_TEAM(self.realowner, other))
if(other.deadflag == DEAD_NO)
if(IsFlying(other))
- AnnounceTo(self.realowner, "airshot");
+ Send_Notification(NOTIF_ONE, self.realowner, MSG_ANNCE, ANNCE_ACHIEVEMENT_AIRSHOT);
self.event_damage = func_null;
self.takedamage = DAMAGE_NO;
self.takedamage = DAMAGE_NO;
if(self.movetype == MOVETYPE_NONE || self.movetype == MOVETYPE_FOLLOW)
- self.velocity = self.oldvelocity;
+ self.velocity = self.mine_orientation; // particle fx and decals need .velocity
RadiusDamage (self, self.realowner, autocvar_g_balance_minelayer_remote_damage, autocvar_g_balance_minelayer_remote_edgedamage, autocvar_g_balance_minelayer_remote_radius, world, autocvar_g_balance_minelayer_remote_force, self.projectiledeathtype | HITTYPE_BOUNCE, world);
head = findradius(self.origin, autocvar_g_balance_minelayer_radius);
while(head)
{
- if(head == self.realowner || !IsDifferentTeam(head, self.realowner))
+ if(head == self.realowner || SAME_TEAM(head, self.realowner))
return;
head = head.chain;
}
entity mine;
for(mine = world; (mine = find(mine, classname, "mine")); ) if(mine.realowner == e)
minecount += 1;
-
+
return minecount;
}
self.movetype = MOVETYPE_NONE;
}
}
-
+
// 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))
{
if(autocvar_g_balance_minelayer_lifetime_countdown > 0)
- spamsound (self, CH_SHOTS, "weapons/mine_trigger.wav", VOL_BASE, ATTN_NORM);
+ spamsound (self, CH_SHOTS, "weapons/mine_trigger.wav", VOL_BASE, ATTEN_NORM);
self.mine_time = time + autocvar_g_balance_minelayer_lifetime_countdown;
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
// TODO: Do this on team change too -- Samual: But isn't a player killed when they switch teams?
- if(self.realowner.classname != "player" || self.realowner.deadflag != DEAD_NO)
+ if(!IS_PLAYER(self.realowner) || self.realowner.deadflag != DEAD_NO)
{
other = world;
self.projectiledeathtype |= HITTYPE_BOUNCE;
head = findradius(self.origin, autocvar_g_balance_minelayer_proximityradius);
while(head)
{
- if(head.classname == "player" && head.deadflag == DEAD_NO)
- if(head != self.realowner && IsDifferentTeam(head, self.realowner)) // don't trigger for team mates
+ if(IS_PLAYER(head) && head.deadflag == DEAD_NO)
+ if(head != self.realowner && DIFF_TEAM(head, self.realowner)) // don't trigger for team mates
if(!self.mine_time)
{
- spamsound (self, CH_SHOTS, "weapons/mine_trigger.wav", VOL_BASE, ATTN_NORM);
+ spamsound (self, CH_SHOTS, "weapons/mine_trigger.wav", VOL_BASE, ATTEN_NORM);
self.mine_time = time + autocvar_g_balance_minelayer_time;
}
head = head.chain;
if(self.movetype == MOVETYPE_NONE || self.movetype == MOVETYPE_FOLLOW)
return; // we're already a stuck mine, why do we get called? TODO does this even happen?
- PROJECTILE_TOUCH;
+ if(WarpZone_Projectile_Touch())
+ {
+ if(wasfreed(self))
+ self.realowner.minelayer_mines -= 1;
+ return;
+ }
- if(other && other.classname == "player" && other.deadflag == DEAD_NO)
+ if(other && IS_PLAYER(other) && other.deadflag == DEAD_NO)
{
// hit a player
// don't stick
{
if (self.health <= 0)
return;
-
+
float is_from_enemy = (inflictor.realowner != self.realowner);
-
+
if (!W_CheckProjectileDamage(inflictor.realowner, self.realowner, deathtype, (is_from_enemy ? 1 : -1)))
return; // g_projectiles_damage says to halt
-
+
self.health = self.health - damage;
self.angles = vectoangles(self.velocity);
-
+
if (self.health <= 0)
W_PrepareExplosionByDamage(attacker, W_Mine_Explode);
}
// scan how many mines we placed, and return if we reached our limit
if(autocvar_g_balance_minelayer_limit)
{
-
- if(W_Mine_Count(self) >= autocvar_g_balance_minelayer_limit)
+ if(self.minelayer_mines >= autocvar_g_balance_minelayer_limit)
{
// the refire delay keeps this message from being spammed
sprint(self, strcat("minelayer: You cannot place more than ^2", ftos(autocvar_g_balance_minelayer_limit), " ^7mines at a time\n") );
// common properties
other = mine; MUTATOR_CALLHOOK(EditProjectile);
-
+
self.minelayer_mines = W_Mine_Count(self);
}
if (req == WR_AIM)
{
// aim and decide to fire if appropriate
- self.BUTTON_ATCK = bot_aim(autocvar_g_balance_minelayer_speed, 0, autocvar_g_balance_minelayer_lifetime, FALSE);
+ if(self.minelayer_mines >= autocvar_g_balance_minelayer_limit)
+ self.BUTTON_ATCK = FALSE;
+ else
+ self.BUTTON_ATCK = bot_aim(autocvar_g_balance_minelayer_speed, 0, autocvar_g_balance_minelayer_lifetime, FALSE);
if(skill >= 2) // skill 0 and 1 bots won't detonate mines!
{
// decide whether to detonate mines
//As the distance gets larger, a correct detonation gets near imposible
//Bots are assumed to use the mine spawnfunc_light to see if the mine gets near a player
if(v_forward * normalize(mine.origin - self.enemy.origin)< 0.1)
- if(self.enemy.classname == "player")
+ if(IS_PLAYER(self.enemy))
if(desirabledamage >= 0.1*coredamage)
if(random()/distance*300 > frametime*bound(0,(10-skill)*0.2,1))
self.BUTTON_ATCK2 = TRUE;
if(autocvar_g_balance_minelayer_reload_ammo && self.clip_load < autocvar_g_balance_minelayer_ammo) // forced 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)
+ if (!(W_PlacedMines(FALSE) && self.ammo_rockets < autocvar_g_balance_minelayer_ammo))
weapon_action(self.weapon, WR_RELOAD);
}
else if (self.BUTTON_ATCK)
if (self.BUTTON_ATCK2)
{
if(W_PlacedMines(TRUE))
- sound (self, CH_WEAPON_B, "weapons/mine_det.wav", VOL_BASE, ATTN_NORM);
+ sound (self, CH_WEAPON_B, "weapons/mine_det.wav", VOL_BASE, ATTEN_NORM);
}
}
else if (req == WR_PRECACHE)
else
return FALSE;
}
+ else if (req == WR_RESETPLAYER)
+ {
+ self.minelayer_mines = 0;
+ }
else if (req == WR_RELOAD)
{
W_Reload(autocvar_g_balance_minelayer_ammo, autocvar_g_balance_minelayer_reload_ammo, autocvar_g_balance_minelayer_reload_time, "weapons/reload.wav");
org2 = w_org + w_backoff * 12;
pointparticles(particleeffectnum("rocket_explode"), org2, '0 0 0', 1);
if(!w_issilent)
- sound(self, CH_SHOTS, "weapons/mine_exp.wav", VOL_BASE, ATTN_NORM);
+ sound(self, CH_SHOTS, "weapons/mine_exp.wav", VOL_BASE, ATTEN_NORM);
}
else if(req == WR_PRECACHE)
{