REGISTER_WEAPON(MINE_LAYER, minelayer, NEW(MineLayer));
#ifdef SVQC
-void W_MineLayer_Think();
+void W_MineLayer_Think(entity this);
.float minelayer_detonate, mine_explodeanyway;
.float mine_time;
.vector mine_orientation;
#ifdef SVQC
spawnfunc(weapon_minelayer) { weapon_defaultspawnfunc(this, WEP_MINE_LAYER); }
-void W_MineLayer_Stick(entity to)
-{SELFPARAM();
+void W_MineLayer_Stick(entity this, entity to)
+{
spamsound(self, CH_SHOTS, SND(MINE_STICK), VOL_BASE, ATTN_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
newmine.mine_time = self.mine_time;
- newmine.touch = func_null;
- newmine.think = W_MineLayer_Think;
+ settouch(newmine, func_null);
+ setthink(newmine, W_MineLayer_Think);
newmine.nextthink = time;
newmine.cnt = self.cnt;
newmine.flags = self.flags;
remove(self);
- setself(newmine);
if(to)
- SetMovetypeFollow(self, to);
+ SetMovetypeFollow(newmine, to);
}
-void W_MineLayer_Explode()
-{SELFPARAM();
+void W_MineLayer_Explode(entity this)
+{
if(other.takedamage == DAMAGE_AIM)
if(IS_PLAYER(other))
if(DIFF_TEAM(self.realowner, other))
if(PS(self.realowner).m_weapon == WEP_MINE_LAYER)
{
- setself(self.realowner);
+ entity own = this.realowner;
Weapon w = WEP_MINE_LAYER;
- if(!w.wr_checkammo1(w))
+ if(!w.wr_checkammo1(w, own))
{
- self.cnt = WEP_MINE_LAYER.m_id;
+ own.cnt = WEP_MINE_LAYER.m_id;
int slot = 0; // TODO: unhardcode
- ATTACK_FINISHED(self, slot) = time;
- PS(self).m_switchweapon = w_getbestweapon(self);
+ ATTACK_FINISHED(own, slot) = time;
+ PS(own).m_switchweapon = w_getbestweapon(own);
}
- setself(this);
}
self.realowner.minelayer_mines -= 1;
remove(self);
}
-void W_MineLayer_DoRemoteExplode()
-{SELFPARAM();
+void W_MineLayer_DoRemoteExplode(entity this)
+{
self.event_damage = func_null;
self.takedamage = DAMAGE_NO;
if(PS(self.realowner).m_weapon == WEP_MINE_LAYER)
{
- setself(self.realowner);
+ entity own = this.realowner;
Weapon w = WEP_MINE_LAYER;
- if(!w.wr_checkammo1(w))
+ if(!w.wr_checkammo1(w, own))
{
- self.cnt = WEP_MINE_LAYER.m_id;
+ own.cnt = WEP_MINE_LAYER.m_id;
int slot = 0; // TODO: unhardcode
- ATTACK_FINISHED(self, slot) = time;
- PS(self).m_switchweapon = w_getbestweapon(self);
+ ATTACK_FINISHED(own, slot) = time;
+ PS(own).m_switchweapon = w_getbestweapon(own);
}
- setself(this);
}
- self.realowner.minelayer_mines -= 1;
+ this.realowner.minelayer_mines -= 1;
remove(self);
}
-void W_MineLayer_RemoteExplode()
-{SELFPARAM();
+void W_MineLayer_RemoteExplode(entity this)
+{
if(!IS_DEAD(self.realowner))
if((self.spawnshieldtime >= 0)
? (time >= self.spawnshieldtime) // timer
: (vdist(NearestPointOnBox(self.realowner, self.origin) - self.origin, >, WEP_CVAR(minelayer, remote_radius))) // safety device
)
{
- W_MineLayer_DoRemoteExplode();
+ W_MineLayer_DoRemoteExplode(self);
}
}
-void W_MineLayer_ProximityExplode()
-{SELFPARAM();
+void W_MineLayer_ProximityExplode(entity this)
+{
// 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(WEP_CVAR(minelayer, protection) && self.mine_explodeanyway == 0)
{
}
self.mine_time = 0;
- W_MineLayer_Explode();
+ W_MineLayer_Explode(self);
}
int W_MineLayer_Count(entity e)
return minecount;
}
-void W_MineLayer_Think()
-{SELFPARAM();
+void W_MineLayer_Think(entity this)
+{
entity head;
self.nextthink = time;
{
other = world;
self.projectiledeathtype |= HITTYPE_BOUNCE;
- W_MineLayer_Explode();
+ W_MineLayer_Explode(self);
return;
}
// explode if it's time to
if(self.mine_time && time >= self.mine_time)
{
- W_MineLayer_ProximityExplode();
+ W_MineLayer_ProximityExplode(self);
return;
}
if(PS(self.realowner).m_weapon == WEP_MINE_LAYER)
if(!IS_DEAD(self.realowner))
if(self.minelayer_detonate)
- W_MineLayer_RemoteExplode();
+ W_MineLayer_RemoteExplode(self);
}
-void W_MineLayer_Touch()
-{SELFPARAM();
+void W_MineLayer_Touch(entity this)
+{
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?
}
else
{
- W_MineLayer_Stick(other);
+ W_MineLayer_Stick(self, other);
}
}
this.angles = vectoangles(this.velocity);
if(this.health <= 0)
- WITHSELF(this, W_PrepareExplosionByDamage(attacker, W_MineLayer_Explode));
+ W_PrepareExplosionByDamage(this, attacker, W_MineLayer_Explode);
}
-void W_MineLayer_Attack(Weapon thiswep)
-{SELFPARAM();
+void W_MineLayer_Attack(Weapon thiswep, entity actor)
+{entity this = actor;
entity mine;
entity flash;
W_SetupProjVelocity_Basic(mine, WEP_CVAR(minelayer, speed), 0);
mine.angles = vectoangles(mine.velocity);
- mine.touch = W_MineLayer_Touch;
- mine.think = W_MineLayer_Think;
+ settouch(mine, W_MineLayer_Touch);
+ setthink(mine, W_MineLayer_Think);
mine.nextthink = time;
mine.cnt = (WEP_CVAR(minelayer, lifetime) - WEP_CVAR(minelayer, lifetime_countdown));
mine.flags = FL_PROJECTILE;
self.minelayer_mines = W_MineLayer_Count(self);
}
-float W_MineLayer_PlacedMines(float detonate)
-{SELFPARAM();
+float W_MineLayer_PlacedMines(entity this, float detonate)
+{
entity mine;
float minfound = 0;
- for(mine = world; (mine = find(mine, classname, "mine")); ) if(mine.realowner == self)
+ for(mine = world; (mine = find(mine, classname, "mine")); ) if(mine.realowner == this)
{
if(detonate)
{
return minfound;
}
-METHOD(MineLayer, wr_aim, void(entity thiswep))
+METHOD(MineLayer, wr_aim, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
// aim and decide to fire if appropriate
if(self.minelayer_mines >= WEP_CVAR(minelayer, limit))
PHYS_INPUT_BUTTON_ATCK(self) = false;
if(autocvar_g_balance_minelayer_reload_ammo && actor.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(false) && actor.(thiswep.ammo_field) < WEP_CVAR(minelayer, ammo))) {
+ if(!(W_MineLayer_PlacedMines(actor, false) && actor.(thiswep.ammo_field) < WEP_CVAR(minelayer, ammo))) {
thiswep.wr_reload(thiswep, actor, weaponentity);
}
}
{
if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(minelayer, refire)))
{
- W_MineLayer_Attack(thiswep);
+ W_MineLayer_Attack(thiswep, actor);
weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(minelayer, animtime), w_ready);
}
}
if(fire & 2)
{
- if(W_MineLayer_PlacedMines(true))
+ if(W_MineLayer_PlacedMines(actor, true))
sound(actor, CH_WEAPON_B, SND_MINE_DET, VOL_BASE, ATTN_NORM);
}
}
-METHOD(MineLayer, wr_checkammo1, bool(entity thiswep))
+METHOD(MineLayer, wr_checkammo1, bool(entity thiswep, entity actor))
{
- SELFPARAM();
- int slot = 0; // TODO: unhardcode
- // don't switch while placing a mine
- if(ATTACK_FINISHED(self, slot) <= time || PS(self).m_weapon != WEP_MINE_LAYER)
- {
- float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(minelayer, ammo);
- ammo_amount += self.(weapon_load[WEP_MINE_LAYER.m_id]) >= WEP_CVAR(minelayer, ammo);
+ //int slot = 0; // TODO: unhardcode
+ // actually do // don't switch while placing a mine
+ //if(ATTACK_FINISHED(actor, slot) <= time || PS(actor).m_weapon != WEP_MINE_LAYER)
+ //{
+ float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(minelayer, ammo);
+ ammo_amount += actor.(weapon_load[WEP_MINE_LAYER.m_id]) >= WEP_CVAR(minelayer, ammo);
return ammo_amount;
- }
- return true;
+ //}
+ //return true;
}
-METHOD(MineLayer, wr_checkammo2, bool(entity thiswep))
+METHOD(MineLayer, wr_checkammo2, bool(entity thiswep, entity actor))
{
- if(W_MineLayer_PlacedMines(false))
+ if(W_MineLayer_PlacedMines(actor, false))
return true;
else
return false;
}
-METHOD(MineLayer, wr_resetplayers, void(entity thiswep))
+METHOD(MineLayer, wr_resetplayer, void(entity thiswep, entity actor))
{
- SELFPARAM();
- self.minelayer_mines = 0;
+ actor.minelayer_mines = 0;
}
METHOD(MineLayer, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
{
- SELFPARAM();
- W_Reload(self, WEP_CVAR(minelayer, ammo), SND_RELOAD);
+ W_Reload(actor, WEP_CVAR(minelayer, ammo), SND_RELOAD);
}
METHOD(MineLayer, wr_suicidemessage, Notification(entity thiswep))
{
#endif
#ifdef CSQC
-METHOD(MineLayer, wr_impacteffect, void(entity thiswep))
+METHOD(MineLayer, wr_impacteffect, void(entity thiswep, entity actor))
{
- SELFPARAM();
+ entity this = actor;
vector org2;
org2 = w_org + w_backoff * 12;
pointparticles(EFFECT_ROCKET_EXPLODE, org2, '0 0 0', 1);