//weapon_setup(WEP_PORTO.m_id);
}
-METHOD(BallStealer, wr_checkammo1, bool(BallStealer this))
+METHOD(BallStealer, wr_checkammo1, bool(BallStealer this, entity actor))
{
TC(BallStealer, this);
return true;
}
-METHOD(BallStealer, wr_checkammo2, bool(BallStealer this))
+METHOD(BallStealer, wr_checkammo2, bool(BallStealer this, entity actor))
{
TC(BallStealer, this);
return true;
}
}
-METHOD(WyvernAttack, wr_checkammo1, bool(WyvernAttack this)) {
+METHOD(WyvernAttack, wr_checkammo1, bool(WyvernAttack this, entity actor)) {
TC(WyvernAttack, this);
return true;
}
return;
}
- if(!thiswep.wr_checkammo1(thiswep))
+ if(!thiswep.wr_checkammo1(thiswep, actor))
if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
}
}
-METHOD(HeavyMachineGun, wr_checkammo1, bool(entity thiswep))
+METHOD(HeavyMachineGun, wr_checkammo1, bool(entity thiswep, entity actor))
{
- SELFPARAM();
- float ammo_amount = self.ammo_nails >= WEP_CVAR(hmg, ammo);
+ float ammo_amount = actor.ammo_nails >= WEP_CVAR(hmg, ammo);
if(autocvar_g_balance_hmg_reload_ammo)
- ammo_amount += self.(weapon_load[WEP_HMG.m_id]) >= WEP_CVAR(hmg, ammo);
+ ammo_amount += actor.(weapon_load[WEP_HMG.m_id]) >= WEP_CVAR(hmg, ammo);
return ammo_amount;
}
-METHOD(HeavyMachineGun, wr_checkammo2, bool(entity thiswep))
+METHOD(HeavyMachineGun, wr_checkammo2, bool(entity thiswep, entity actor))
{
- SELFPARAM();
- float ammo_amount = self.ammo_nails >= WEP_CVAR(hmg, ammo);
+ float ammo_amount = actor.ammo_nails >= WEP_CVAR(hmg, ammo);
if(autocvar_g_balance_hmg_reload_ammo)
- ammo_amount += self.(weapon_load[WEP_HMG.m_id]) >= WEP_CVAR(hmg, ammo);
+ ammo_amount += actor.(weapon_load[WEP_HMG.m_id]) >= WEP_CVAR(hmg, ammo);
return ammo_amount;
}
}
}
-METHOD(RocketPropelledChainsaw, wr_checkammo1, bool(entity thiswep))
+METHOD(RocketPropelledChainsaw, wr_checkammo1, bool(entity thiswep, entity actor))
{
- SELFPARAM();
- float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(rpc, ammo);
- ammo_amount += self.(weapon_load[WEP_RPC.m_id]) >= WEP_CVAR(rpc, ammo);
+ float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(rpc, ammo);
+ ammo_amount += actor.(weapon_load[WEP_RPC.m_id]) >= WEP_CVAR(rpc, ammo);
return ammo_amount;
}
-METHOD(RocketPropelledChainsaw, wr_checkammo2, bool(entity thiswep))
+METHOD(RocketPropelledChainsaw, wr_checkammo2, bool(entity thiswep, entity actor))
{
return false;
}
Weapon wep1 = WEP_RACER;
if (!forbidWeaponUse(this))
if (PHYS_INPUT_BUTTON_ATCK(this))
- if (wep1.wr_checkammo1(wep1))
+ if (wep1.wr_checkammo1(wep1, vehic))
{
string tagname = (vehic.cnt)
? (vehic.cnt = 0, "tag_fire1")
}
}
-METHOD(RacerAttack, wr_checkammo1, bool(RacerAttack thiswep))
+METHOD(RacerAttack, wr_checkammo1, bool(RacerAttack thiswep, entity actor))
{
- SELFPARAM();
- bool isPlayer = IS_PLAYER(self);
- entity player = isPlayer ? self : self.owner;
+ bool isPlayer = IS_PLAYER(actor);
+ entity player = isPlayer ? actor : actor.owner;
entity veh = player.vehicle;
return isPlayer || veh.vehicle_energy >= autocvar_g_vehicle_racer_cannon_cost;
}
UpdateAuxiliaryXhair(this, trace_endpos, '0 1 0', 0);
*/
- // TODO: fix wr_checkammo and its use of self!
setself(vehic);
Weapon wep1 = WEP_RAPTOR;
if(!forbidWeaponUse(this))
if(PHYS_INPUT_BUTTON_ATCK(this))
- if (wep1.wr_checkammo1(wep1))
+ if (wep1.wr_checkammo1(wep1, vehic))
{
.entity weaponentity = weaponentities[0];
wep1.wr_think(wep1, vehic, weaponentity, 1);
weapon_thinkf(player, weaponentity, WFRAME_FIRE1, 0, w_ready);
}
}
-METHOD(RaptorCannon, wr_checkammo1, bool(RacerAttack thiswep)) {
- SELFPARAM();
- bool isPlayer = IS_PLAYER(self);
- entity player = isPlayer ? self : self.owner;
+METHOD(RaptorCannon, wr_checkammo1, bool(RacerAttack thiswep, entity actor)) {
+ bool isPlayer = IS_PLAYER(actor);
+ entity player = isPlayer ? actor : actor.owner;
entity veh = player.vehicle;
return isPlayer || veh.vehicle_energy >= autocvar_g_vehicle_raptor_cannon_cost;
}
/** (SERVER) logic to run every frame */
METHOD(Weapon, wr_think, void(Weapon this, entity actor, .entity weaponentity, int fire)) {}
/** (SERVER) checks ammo for weapon primary */
- METHOD(Weapon, wr_checkammo1, bool(Weapon this)) {return false;}
+ METHOD(Weapon, wr_checkammo1, bool(Weapon this, entity actor)) {return false;}
/** (SERVER) checks ammo for weapon second */
- METHOD(Weapon, wr_checkammo2, bool(Weapon this)) {return false;}
+ METHOD(Weapon, wr_checkammo2, bool(Weapon this, entity actor)) {return false;}
/** (SERVER) runs bot aiming code for this weapon */
METHOD(Weapon, wr_aim, void(Weapon this)) {}
/** (BOTH) precaches models/sounds used by this weapon, also sets up weapon properties */
if(self == self.owner.arc_beam) { self.owner.arc_beam = world; }
setself(self.owner);
Weapon w = WEP_ARC;
- if(!w.wr_checkammo1(w) && !w.wr_checkammo2(w))
+ if(!w.wr_checkammo1(w, self) && !w.wr_checkammo2(w, self))
if(!(self.items & IT_UNLIMITED_WEAPON_AMMO))
{
// note: this doesn't force the switch
arc_shotorigin[3] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ARC.m_id), false, false, 4);
}
}
-METHOD(Arc, wr_checkammo1, bool(entity thiswep))
+METHOD(Arc, wr_checkammo1, bool(entity thiswep, entity actor))
{
- SELFPARAM();
- return ((!WEP_CVAR(arc, beam_ammo)) || (self.(thiswep.ammo_field) > 0));
+ return ((!WEP_CVAR(arc, beam_ammo)) || (actor.(thiswep.ammo_field) > 0));
}
-METHOD(Arc, wr_checkammo2, bool(entity thiswep))
+METHOD(Arc, wr_checkammo2, bool(entity thiswep, entity actor))
{
- SELFPARAM();
if(WEP_CVAR(arc, bolt))
{
- float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(arc, bolt_ammo);
- ammo_amount += self.(weapon_load[WEP_ARC.m_id]) >= WEP_CVAR(arc, bolt_ammo);
+ float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(arc, bolt_ammo);
+ ammo_amount += actor.(weapon_load[WEP_ARC.m_id]) >= WEP_CVAR(arc, bolt_ammo);
return ammo_amount;
}
else
return WEP_CVAR(arc, overheat_max) > 0 &&
- ((!WEP_CVAR(arc, burst_ammo)) || (self.(thiswep.ammo_field) > 0));
+ ((!WEP_CVAR(arc, burst_ammo)) || (actor.(thiswep.ammo_field) > 0));
}
METHOD(Arc, wr_killmessage, Notification(entity thiswep))
{
self.ammo_field = ammo_none;
}
-METHOD(Blaster, wr_checkammo1, bool(entity thiswep))
+METHOD(Blaster, wr_checkammo1, bool(entity thiswep, entity actor))
{
return true; // infinite ammo
}
-METHOD(Blaster, wr_checkammo2, bool(entity thiswep))
+METHOD(Blaster, wr_checkammo2, bool(entity thiswep, entity actor))
{
return true; // blaster has infinite ammo
}
setorigin(linkjoineffect, pos);
}
actor.crylink_waitrelease = 0;
- if(!thiswep.wr_checkammo1(thiswep) && !thiswep.wr_checkammo2(thiswep))
+ if(!thiswep.wr_checkammo1(thiswep, actor) && !thiswep.wr_checkammo2(thiswep, actor))
if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
// ran out of ammo!
}
}
}
-METHOD(Crylink, wr_checkammo1, bool(entity thiswep))
+METHOD(Crylink, wr_checkammo1, bool(entity thiswep, entity actor))
{
- SELFPARAM();
// don't "run out of ammo" and switch weapons while waiting for release
- if(self.crylink_lastgroup && self.crylink_waitrelease)
+ if(actor.crylink_lastgroup && actor.crylink_waitrelease)
return true;
- float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_PRI(crylink, ammo);
- ammo_amount += self.(weapon_load[WEP_CRYLINK.m_id]) >= WEP_CVAR_PRI(crylink, ammo);
+ float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(crylink, ammo);
+ ammo_amount += actor.(weapon_load[WEP_CRYLINK.m_id]) >= WEP_CVAR_PRI(crylink, ammo);
return ammo_amount;
}
-METHOD(Crylink, wr_checkammo2, bool(entity thiswep))
+METHOD(Crylink, wr_checkammo2, bool(entity thiswep, entity actor))
{
- SELFPARAM();
// don't "run out of ammo" and switch weapons while waiting for release
- if(self.crylink_lastgroup && self.crylink_waitrelease)
+ if(actor.crylink_lastgroup && actor.crylink_waitrelease)
return true;
- float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_SEC(crylink, ammo);
- ammo_amount += self.(weapon_load[WEP_CRYLINK.m_id]) >= WEP_CVAR_SEC(crylink, ammo);
+ float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(crylink, ammo);
+ ammo_amount += actor.(weapon_load[WEP_CRYLINK.m_id]) >= WEP_CVAR_SEC(crylink, ammo);
return ammo_amount;
}
METHOD(Crylink, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
SELFPARAM();
self.rl_release = 1;
}
-METHOD(Devastator, wr_checkammo1, bool(entity thiswep))
+METHOD(Devastator, wr_checkammo1, bool(entity thiswep, entity actor))
{
- SELFPARAM();
#if 0
// don't switch while guiding a missile
- if(ATTACK_FINISHED(self, slot) <= time || PS(self).m_weapon != WEP_DEVASTATOR)
+ if(ATTACK_FINISHED(actor, slot) <= time || PS(actor).m_weapon != WEP_DEVASTATOR)
{
ammo_amount = false;
if(WEP_CVAR(devastator, reload_ammo))
{
- if(self.(thiswep.ammo_field) < WEP_CVAR(devastator, ammo) && self.(weapon_load[WEP_DEVASTATOR.m_id]) < WEP_CVAR(devastator, ammo))
+ if(actor.(thiswep.ammo_field) < WEP_CVAR(devastator, ammo) && actor.(weapon_load[WEP_DEVASTATOR.m_id]) < WEP_CVAR(devastator, ammo))
ammo_amount = true;
}
- else if(self.(thiswep.ammo_field) < WEP_CVAR(devastator, ammo))
+ else if(actor.(thiswep.ammo_field) < WEP_CVAR(devastator, ammo))
ammo_amount = true;
return !ammo_amount;
}
#endif
#if 0
- if(self.rl_release == 0)
+ if(actor.rl_release == 0)
{
- LOG_INFOF("W_Devastator(WR_CHECKAMMO1): %d, %.2f, %d: TRUE\n", self.rl_release, self.(thiswep.ammo_field), WEP_CVAR(devastator, ammo));
+ LOG_INFOF("W_Devastator(WR_CHECKAMMO1): %d, %.2f, %d: TRUE\n", actor.rl_release, actor.(thiswep.ammo_field), WEP_CVAR(devastator, ammo));
return true;
}
else
{
- ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(devastator, ammo);
- ammo_amount += self.(weapon_load[WEP_DEVASTATOR.m_id]) >= WEP_CVAR(devastator, ammo);
- LOG_INFOF("W_Devastator(WR_CHECKAMMO1): %d, %.2f, %d: %s\n", self.rl_release, self.(thiswep.ammo_field), WEP_CVAR(devastator, ammo), (ammo_amount ? "TRUE" : "FALSE"));
+ ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(devastator, ammo);
+ ammo_amount += actor.(weapon_load[WEP_DEVASTATOR.m_id]) >= WEP_CVAR(devastator, ammo);
+ LOG_INFOF("W_Devastator(WR_CHECKAMMO1): %d, %.2f, %d: %s\n", actor.rl_release, actor.(thiswep.ammo_field), WEP_CVAR(devastator, ammo), (ammo_amount ? "TRUE" : "FALSE"));
return ammo_amount;
}
#else
- float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(devastator, ammo);
- ammo_amount += self.(weapon_load[WEP_DEVASTATOR.m_id]) >= WEP_CVAR(devastator, ammo);
+ float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(devastator, ammo);
+ ammo_amount += actor.(weapon_load[WEP_DEVASTATOR.m_id]) >= WEP_CVAR(devastator, ammo);
return ammo_amount;
#endif
}
-METHOD(Devastator, wr_checkammo2, bool(entity thiswep))
+METHOD(Devastator, wr_checkammo2, bool(entity thiswep, entity actor))
{
return false;
}
}
}
}
-METHOD(Electro, wr_checkammo1, bool(entity thiswep))
+METHOD(Electro, wr_checkammo1, bool(entity thiswep, entity actor))
{
- SELFPARAM();
- float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_PRI(electro, ammo);
- ammo_amount += self.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_PRI(electro, ammo);
+ float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(electro, ammo);
+ ammo_amount += actor.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_PRI(electro, ammo);
return ammo_amount;
}
-METHOD(Electro, wr_checkammo2, bool(entity thiswep))
+METHOD(Electro, wr_checkammo2, bool(entity thiswep, entity actor))
{
- SELFPARAM();
float ammo_amount;
if(WEP_CVAR(electro, combo_safeammocheck)) // true if you can fire at least one secondary blob AND one primary shot after it, otherwise false.
{
- ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
- ammo_amount += self.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
+ ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
+ ammo_amount += actor.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_SEC(electro, ammo) + WEP_CVAR_PRI(electro, ammo);
}
else
{
- ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_SEC(electro, ammo);
- ammo_amount += self.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_SEC(electro, ammo);
+ ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(electro, ammo);
+ ammo_amount += actor.(weapon_load[WEP_ELECTRO.m_id]) >= WEP_CVAR_SEC(electro, ammo);
}
return ammo_amount;
}
SELFPARAM();
self.ammo_field = ammo_none;
}
-METHOD(Fireball, wr_checkammo1, bool(entity thiswep))
+METHOD(Fireball, wr_checkammo1, bool(entity thiswep, entity actor))
{
return true; // infinite ammo
}
-METHOD(Fireball, wr_checkammo2, bool(entity thiswep))
+METHOD(Fireball, wr_checkammo2, bool(entity thiswep, entity actor))
{
return true; // fireball has infinite ammo
}
self.hagar_warning = false;
// we aren't checking ammo during an attack, so we must do it here
- if(!(thiswep.wr_checkammo1(thiswep) + thiswep.wr_checkammo2(thiswep)))
+ if(!(thiswep.wr_checkammo1(thiswep, self) + thiswep.wr_checkammo2(thiswep, self)))
if(!(self.items & IT_UNLIMITED_WEAPON_AMMO))
{
// note: this doesn't force the switch
return;
}
- if(!thiswep.wr_checkammo1(thiswep))
+ if(!thiswep.wr_checkammo1(thiswep, actor))
if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
self.hagar_load = 0;
}
}
-METHOD(Hagar, wr_checkammo1, bool(entity thiswep))
+METHOD(Hagar, wr_checkammo1, bool(entity thiswep, entity actor))
{
- SELFPARAM();
- float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_PRI(hagar, ammo);
- ammo_amount += self.(weapon_load[WEP_HAGAR.m_id]) >= WEP_CVAR_PRI(hagar, ammo);
+ float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(hagar, ammo);
+ ammo_amount += actor.(weapon_load[WEP_HAGAR.m_id]) >= WEP_CVAR_PRI(hagar, ammo);
return ammo_amount;
}
-METHOD(Hagar, wr_checkammo2, bool(entity thiswep))
+METHOD(Hagar, wr_checkammo2, bool(entity thiswep, entity actor))
{
- SELFPARAM();
- float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_SEC(hagar, ammo);
- ammo_amount += self.(weapon_load[WEP_HAGAR.m_id]) >= WEP_CVAR_SEC(hagar, ammo);
+ float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(hagar, ammo);
+ ammo_amount += actor.(weapon_load[WEP_HAGAR.m_id]) >= WEP_CVAR_SEC(hagar, ammo);
return ammo_amount;
}
METHOD(Hagar, wr_resetplayer, void(entity thiswep))
if(PHYS_INPUT_BUTTON_ATCK(actor))
{
- if(!thiswep.wr_checkammo1(thiswep))
+ if(!thiswep.wr_checkammo1(thiswep, actor))
if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
}
}
}
-METHOD(HLAC, wr_checkammo1, bool(entity thiswep))
+METHOD(HLAC, wr_checkammo1, bool(entity thiswep, entity actor))
{
- SELFPARAM();
- float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_PRI(hlac, ammo);
- ammo_amount += self.(weapon_load[WEP_HLAC.m_id]) >= WEP_CVAR_PRI(hlac, ammo);
+ float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(hlac, ammo);
+ ammo_amount += actor.(weapon_load[WEP_HLAC.m_id]) >= WEP_CVAR_PRI(hlac, ammo);
return ammo_amount;
}
-METHOD(HLAC, wr_checkammo2, bool(entity thiswep))
+METHOD(HLAC, wr_checkammo2, bool(entity thiswep, entity actor))
{
- SELFPARAM();
- float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_SEC(hlac, ammo);
- ammo_amount += self.(weapon_load[WEP_HLAC.m_id]) >= WEP_CVAR_SEC(hlac, ammo);
+ float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(hlac, ammo);
+ ammo_amount += actor.(weapon_load[WEP_HLAC.m_id]) >= WEP_CVAR_SEC(hlac, ammo);
return ammo_amount;
}
METHOD(HLAC, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
SELFPARAM();
self.hook_state &= ~HOOK_WAITING_FOR_RELEASE;
}
-METHOD(Hook, wr_checkammo1, bool(Hook thiswep))
+METHOD(Hook, wr_checkammo1, bool(Hook thiswep, entity actor))
{
SELFPARAM();
if (!thiswep.ammo_factor) return true;
- if(self.hook)
- return self.ammo_fuel > 0;
+ if(actor.hook)
+ return actor.ammo_fuel > 0;
else
- return self.ammo_fuel >= WEP_CVAR_PRI(hook, ammo);
+ return actor.ammo_fuel >= WEP_CVAR_PRI(hook, ammo);
}
-METHOD(Hook, wr_checkammo2, bool(Hook thiswep))
+METHOD(Hook, wr_checkammo2, bool(Hook thiswep, entity actor))
{
// infinite ammo for now
- return true; // self.ammo_cells >= WEP_CVAR_SEC(hook, ammo); // WEAPONTODO: see above
+ return true; // actor.ammo_cells >= WEP_CVAR_SEC(hook, ammo); // WEAPONTODO: see above
}
METHOD(Hook, wr_resetplayer, void(entity thiswep))
{
}
if(PHYS_INPUT_BUTTON_ATCK(actor))
{
- if(!thiswep.wr_checkammo2(thiswep))
+ if(!thiswep.wr_checkammo2(thiswep, actor))
if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
return;
}
- if(!thiswep.wr_checkammo1(thiswep))
+ if(!thiswep.wr_checkammo1(thiswep, actor))
if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
if(fire & 2)
if(weapon_prepareattack(thiswep, actor, weaponentity, true, 0))
{
- if(!thiswep.wr_checkammo2(thiswep))
+ if(!thiswep.wr_checkammo2(thiswep, actor))
if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
}
}
}
-METHOD(MachineGun, wr_checkammo1, bool(entity thiswep))
+METHOD(MachineGun, wr_checkammo1, bool(entity thiswep, entity actor))
{
- SELFPARAM();
float ammo_amount;
if(WEP_CVAR(machinegun, mode) == 1)
- ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(machinegun, sustained_ammo);
+ ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(machinegun, sustained_ammo);
else
- ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(machinegun, first_ammo);
+ ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(machinegun, first_ammo);
if(WEP_CVAR(machinegun, reload_ammo))
{
if(WEP_CVAR(machinegun, mode) == 1)
- ammo_amount += self.(weapon_load[WEP_MACHINEGUN.m_id]) >= WEP_CVAR(machinegun, sustained_ammo);
+ ammo_amount += actor.(weapon_load[WEP_MACHINEGUN.m_id]) >= WEP_CVAR(machinegun, sustained_ammo);
else
- ammo_amount += self.(weapon_load[WEP_MACHINEGUN.m_id]) >= WEP_CVAR(machinegun, first_ammo);
+ ammo_amount += actor.(weapon_load[WEP_MACHINEGUN.m_id]) >= WEP_CVAR(machinegun, first_ammo);
}
return ammo_amount;
}
-METHOD(MachineGun, wr_checkammo2, bool(entity thiswep))
+METHOD(MachineGun, wr_checkammo2, bool(entity thiswep, entity actor))
{
- SELFPARAM();
float ammo_amount;
if(WEP_CVAR(machinegun, mode) == 1)
- ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(machinegun, burst_ammo);
+ ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(machinegun, burst_ammo);
else
- ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(machinegun, first_ammo);
+ ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(machinegun, first_ammo);
if(WEP_CVAR(machinegun, reload_ammo))
{
if(WEP_CVAR(machinegun, mode) == 1)
- ammo_amount += self.(weapon_load[WEP_MACHINEGUN.m_id]) >= WEP_CVAR(machinegun, burst_ammo);
+ ammo_amount += actor.(weapon_load[WEP_MACHINEGUN.m_id]) >= WEP_CVAR(machinegun, burst_ammo);
else
- ammo_amount += self.(weapon_load[WEP_MACHINEGUN.m_id]) >= WEP_CVAR(machinegun, first_ammo);
+ ammo_amount += actor.(weapon_load[WEP_MACHINEGUN.m_id]) >= WEP_CVAR(machinegun, first_ammo);
}
return ammo_amount;
}
{
setself(self.realowner);
Weapon w = WEP_MINE_LAYER;
- if(!w.wr_checkammo1(w))
+ if(!w.wr_checkammo1(w, self))
{
self.cnt = WEP_MINE_LAYER.m_id;
int slot = 0; // TODO: unhardcode
{
setself(self.realowner);
Weapon w = WEP_MINE_LAYER;
- if(!w.wr_checkammo1(w))
+ if(!w.wr_checkammo1(w, self))
{
self.cnt = WEP_MINE_LAYER.m_id;
int slot = 0; // TODO: unhardcode
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)
{
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(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
// actually do // don't switch while placing a mine
- //if(ATTACK_FINISHED(self, slot) <= time || PS(self).m_weapon != WEP_MINE_LAYER)
+ //if(ATTACK_FINISHED(actor, slot) <= time || PS(actor).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);
+ 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;
}
-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(Mortar, wr_checkammo1, bool(entity thiswep))
+METHOD(Mortar, wr_checkammo1, bool(entity thiswep, entity actor))
{
- SELFPARAM();
- float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_PRI(mortar, ammo);
- ammo_amount += self.(weapon_load[WEP_MORTAR.m_id]) >= WEP_CVAR_PRI(mortar, ammo);
+ float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(mortar, ammo);
+ ammo_amount += actor.(weapon_load[WEP_MORTAR.m_id]) >= WEP_CVAR_PRI(mortar, ammo);
return ammo_amount;
}
-METHOD(Mortar, wr_checkammo2, bool(entity thiswep))
+METHOD(Mortar, wr_checkammo2, bool(entity thiswep, entity actor))
{
- SELFPARAM();
- float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_SEC(mortar, ammo);
- ammo_amount += self.(weapon_load[WEP_MORTAR.m_id]) >= WEP_CVAR_SEC(mortar, ammo);
+ float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(mortar, ammo);
+ ammo_amount += actor.(weapon_load[WEP_MORTAR.m_id]) >= WEP_CVAR_SEC(mortar, ammo);
return ammo_amount;
}
METHOD(Mortar, wr_reload, void(entity thiswep, entity actor, .entity weaponentity))
}
}
}
-METHOD(PortoLaunch, wr_checkammo1, bool(entity this))
+METHOD(PortoLaunch, wr_checkammo1, bool(entity thiswep, entity this))
{
// always allow infinite ammo
return true;
}
-METHOD(PortoLaunch, wr_checkammo2, bool(entity this))
+METHOD(PortoLaunch, wr_checkammo2, bool(entity thiswep, entity this))
{
// always allow infinite ammo
return true;
}
}
}
-METHOD(Rifle, wr_checkammo1, bool(entity thiswep))
+METHOD(Rifle, wr_checkammo1, bool(entity thiswep, entity actor))
{
- SELFPARAM();
- float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_PRI(rifle, ammo);
- ammo_amount += self.(weapon_load[WEP_RIFLE.m_id]) >= WEP_CVAR_PRI(rifle, ammo);
+ float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(rifle, ammo);
+ ammo_amount += actor.(weapon_load[WEP_RIFLE.m_id]) >= WEP_CVAR_PRI(rifle, ammo);
return ammo_amount;
}
-METHOD(Rifle, wr_checkammo2, bool(entity thiswep))
+METHOD(Rifle, wr_checkammo2, bool(entity thiswep, entity actor))
{
- SELFPARAM();
- float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_SEC(rifle, ammo);
- ammo_amount += self.(weapon_load[WEP_RIFLE.m_id]) >= WEP_CVAR_SEC(rifle, ammo);
+ float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(rifle, ammo);
+ ammo_amount += actor.(weapon_load[WEP_RIFLE.m_id]) >= WEP_CVAR_SEC(rifle, ammo);
return ammo_amount;
}
METHOD(Rifle, wr_resetplayer, void(entity thiswep))
{SELFPARAM();
float c;
entity oldenemy;
- self.cnt = self.cnt - 1;
+ this.cnt = this.cnt - 1;
Weapon thiswep = WEP_SEEKER;
- if((!(self.realowner.items & IT_UNLIMITED_AMMO) && self.realowner.(thiswep.ammo_field) < WEP_CVAR(seeker, missile_ammo)) || (self.cnt <= -1) || (IS_DEAD(self.realowner)) || (PS(self.realowner).m_switchweapon != WEP_SEEKER))
+ if((!(this.realowner.items & IT_UNLIMITED_AMMO) && this.realowner.(thiswep.ammo_field) < WEP_CVAR(seeker, missile_ammo)) || (this.cnt <= -1) || (IS_DEAD(this.realowner)) || (PS(this.realowner).m_switchweapon != WEP_SEEKER))
{
- remove(self);
+ remove(this);
return;
}
- self.nextthink = time + WEP_CVAR(seeker, missile_delay) * W_WeaponRateFactor();
+ this.nextthink = time + WEP_CVAR(seeker, missile_delay) * W_WeaponRateFactor();
- setself(self.realowner);
+ entity own = this.realowner;
- oldenemy = self.enemy;
- self.enemy = this.enemy;
+ oldenemy = own.enemy;
+ own.enemy = this.enemy;
- c = self.cnt % 4;
+ c = own.cnt % 4;
switch(c)
{
case 0:
- W_Seeker_Fire_Missile(WEP_SEEKER, '-1.25 -3.75 0', self.enemy);
+ WITHSELF(own, W_Seeker_Fire_Missile(WEP_SEEKER, '-1.25 -3.75 0', own.enemy));
break;
case 1:
- W_Seeker_Fire_Missile(WEP_SEEKER, '+1.25 -3.75 0', self.enemy);
+ WITHSELF(own, W_Seeker_Fire_Missile(WEP_SEEKER, '+1.25 -3.75 0', own.enemy));
break;
case 2:
- W_Seeker_Fire_Missile(WEP_SEEKER, '-1.25 +3.75 0', self.enemy);
+ WITHSELF(own, W_Seeker_Fire_Missile(WEP_SEEKER, '-1.25 +3.75 0', own.enemy));
break;
case 3:
default:
- W_Seeker_Fire_Missile(WEP_SEEKER, '+1.25 +3.75 0', self.enemy);
+ WITHSELF(own, W_Seeker_Fire_Missile(WEP_SEEKER, '+1.25 +3.75 0', own.enemy));
break;
}
- self.enemy = oldenemy;
- setself(this);
+ own.enemy = oldenemy;
}
void W_Seeker_Tracker_Think()
}
}
}
-METHOD(Seeker, wr_checkammo1, bool(entity thiswep))
+METHOD(Seeker, wr_checkammo1, bool(entity thiswep, entity actor))
{
- SELFPARAM();
float ammo_amount;
if(WEP_CVAR(seeker, type) == 1)
{
- ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(seeker, missile_ammo);
- ammo_amount += self.(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, missile_ammo);
+ ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(seeker, missile_ammo);
+ ammo_amount += actor.(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, missile_ammo);
}
else
{
- ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(seeker, tag_ammo);
- ammo_amount += self.(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, tag_ammo);
+ ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(seeker, tag_ammo);
+ ammo_amount += actor.(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, tag_ammo);
}
return ammo_amount;
}
-METHOD(Seeker, wr_checkammo2, bool(entity thiswep))
+METHOD(Seeker, wr_checkammo2, bool(entity thiswep, entity actor))
{
- SELFPARAM();
float ammo_amount;
if(WEP_CVAR(seeker, type) == 1)
{
- ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(seeker, tag_ammo);
- ammo_amount += self.(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, tag_ammo);
+ ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(seeker, tag_ammo);
+ ammo_amount += actor.(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, tag_ammo);
}
else
{
- ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR(seeker, flac_ammo);
- ammo_amount += self.(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, flac_ammo);
+ ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR(seeker, flac_ammo);
+ ammo_amount += actor.(weapon_load[WEP_SEEKER.m_id]) >= WEP_CVAR(seeker, flac_ammo);
}
return ammo_amount;
}
}
}
}
-METHOD(Shockwave, wr_checkammo1, bool(entity thiswep))
+METHOD(Shockwave, wr_checkammo1, bool(entity thiswep, entity actor))
{
return true; // infinite ammo
}
-METHOD(Shockwave, wr_checkammo2, bool(entity thiswep))
+METHOD(Shockwave, wr_checkammo2, bool(entity thiswep, entity actor))
{
// shockwave has infinite ammo
return true;
// alternate secondary weapon frames
void W_Shotgun_Attack3_Frame2(Weapon thiswep, entity actor, .entity weaponentity, int fire)
{
- if (!thiswep.wr_checkammo2(thiswep))
+ if (!thiswep.wr_checkammo2(thiswep, actor))
if (!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
}
void W_Shotgun_Attack3_Frame1(Weapon thiswep, entity actor, .entity weaponentity, int fire)
{
- if (!thiswep.wr_checkammo2(thiswep))
+ if (!thiswep.wr_checkammo2(thiswep, actor))
if (!(actor.items & IT_UNLIMITED_WEAPON_AMMO))
{
W_SwitchWeapon_Force(actor, w_getbestweapon(actor));
SELFPARAM();
self.ammo_field = ammo_none;
}
-METHOD(Shotgun, wr_checkammo1, bool(entity thiswep))
+METHOD(Shotgun, wr_checkammo1, bool(entity thiswep, entity actor))
{
- SELFPARAM();
- float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_PRI(shotgun, ammo);
- ammo_amount += self.(weapon_load[WEP_SHOTGUN.m_id]) >= WEP_CVAR_PRI(shotgun, ammo);
+ float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(shotgun, ammo);
+ ammo_amount += actor.(weapon_load[WEP_SHOTGUN.m_id]) >= WEP_CVAR_PRI(shotgun, ammo);
return ammo_amount;
}
-METHOD(Shotgun, wr_checkammo2, bool(entity thiswep))
+METHOD(Shotgun, wr_checkammo2, bool(entity thiswep, entity actor))
{
- SELFPARAM();
- if(IS_BOT_CLIENT(self))
- if(vdist(self.origin - self.enemy.origin, >, WEP_CVAR_SEC(shotgun, melee_range)))
+ if(IS_BOT_CLIENT(actor))
+ if(vdist(actor.origin - actor.enemy.origin, >, WEP_CVAR_SEC(shotgun, melee_range)))
return false; // bots cannot use secondary out of range (fixes constant melee when out of ammo)
switch(WEP_CVAR(shotgun, secondary))
{
case 1: return true; // melee does not use ammo
case 2: // secondary triple shot
{
- float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_PRI(shotgun, ammo);
- ammo_amount += self.(weapon_load[WEP_SHOTGUN.m_id]) >= WEP_CVAR_PRI(shotgun, ammo);
+ float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(shotgun, ammo);
+ ammo_amount += actor.(weapon_load[WEP_SHOTGUN.m_id]) >= WEP_CVAR_PRI(shotgun, ammo);
return ammo_amount;
}
default: return false; // secondary unavailable
#ifdef SVQC
// infinite ammo
-METHOD(Tuba, wr_checkammo1, bool(Tuba this)) { return true; }
-METHOD(Tuba, wr_checkammo2, bool(Tuba this)) { return true; }
+METHOD(Tuba, wr_checkammo1, bool(Tuba this, entity actor)) { return true; }
+METHOD(Tuba, wr_checkammo2, bool(Tuba this, entity actor)) { return true; }
METHOD(Tuba, wr_suicidemessage, Notification(Tuba this))
{
self.ammo_field = (thiswep.ammo_field);
self.vaporizer_lasthit = 0;
}
-METHOD(Vaporizer, wr_checkammo1, bool(entity thiswep))
+METHOD(Vaporizer, wr_checkammo1, bool(entity thiswep, entity actor))
{
- SELFPARAM();
float vaporizer_ammo = ((g_instagib) ? 1 : WEP_CVAR_PRI(vaporizer, ammo));
- float ammo_amount = self.(thiswep.ammo_field) >= vaporizer_ammo;
- ammo_amount += self.(weapon_load[WEP_VAPORIZER.m_id]) >= vaporizer_ammo;
+ float ammo_amount = actor.(thiswep.ammo_field) >= vaporizer_ammo;
+ ammo_amount += actor.(weapon_load[WEP_VAPORIZER.m_id]) >= vaporizer_ammo;
return ammo_amount;
}
-METHOD(Vaporizer, wr_checkammo2, bool(entity thiswep))
+METHOD(Vaporizer, wr_checkammo2, bool(entity thiswep, entity actor))
{
- SELFPARAM();
if(!WEP_CVAR_SEC(vaporizer, ammo))
return true;
- float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_SEC(vaporizer, ammo);
- ammo_amount += self.(weapon_load[WEP_VAPORIZER.m_id]) >= WEP_CVAR_SEC(vaporizer, ammo);
+ float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(vaporizer, ammo);
+ ammo_amount += actor.(weapon_load[WEP_VAPORIZER.m_id]) >= WEP_CVAR_SEC(vaporizer, ammo);
return ammo_amount;
}
METHOD(Vaporizer, wr_resetplayer, void(entity thiswep))
SELFPARAM();
self.vortex_lasthit = 0;
}
-METHOD(Vortex, wr_checkammo1, bool(entity thiswep))
+METHOD(Vortex, wr_checkammo1, bool(entity thiswep, entity actor))
{
- SELFPARAM();
- float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_PRI(vortex, ammo);
- ammo_amount += (autocvar_g_balance_vortex_reload_ammo && self.(weapon_load[WEP_VORTEX.m_id]) >= WEP_CVAR_PRI(vortex, ammo));
+ float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_PRI(vortex, ammo);
+ ammo_amount += (autocvar_g_balance_vortex_reload_ammo && actor.(weapon_load[WEP_VORTEX.m_id]) >= WEP_CVAR_PRI(vortex, ammo));
return ammo_amount;
}
-METHOD(Vortex, wr_checkammo2, bool(entity thiswep))
+METHOD(Vortex, wr_checkammo2, bool(entity thiswep, entity actor))
{
- SELFPARAM();
if(WEP_CVAR(vortex, secondary))
{
// don't allow charging if we don't have enough ammo
- float ammo_amount = self.(thiswep.ammo_field) >= WEP_CVAR_SEC(vortex, ammo);
- ammo_amount += self.(weapon_load[WEP_VORTEX.m_id]) >= WEP_CVAR_SEC(vortex, ammo);
+ float ammo_amount = actor.(thiswep.ammo_field) >= WEP_CVAR_SEC(vortex, ammo);
+ ammo_amount += actor.(weapon_load[WEP_VORTEX.m_id]) >= WEP_CVAR_SEC(vortex, ammo);
return ammo_amount;
}
else
return e;
}
-float WarpZoneLib_ExactTrigger_Touch()
-{SELFPARAM();
- return !WarpZoneLib_BoxTouchesBrush(other.absmin, other.absmax, this, other);
+float WarpZoneLib_ExactTrigger_Touch(entity this, entity toucher)
+{
+ return !WarpZoneLib_BoxTouchesBrush(toucher.absmin, toucher.absmax, this, toucher);
}
float WarpZoneLib_MoveOutOfSolid(entity e);
#define move_out_of_solid(e) WarpZoneLib_MoveOutOfSolid(e)
-float WarpZoneLib_ExactTrigger_Touch();
+float WarpZoneLib_ExactTrigger_Touch(entity this, entity toucher);
void WarpZoneLib_ExactTrigger_Init(entity this);
// WARNING: this kills the trace globals
-#define EXACTTRIGGER_TOUCH if(WarpZoneLib_ExactTrigger_Touch()) return
+#define EXACTTRIGGER_TOUCH if(WarpZoneLib_ExactTrigger_Touch(this, other)) return
#define EXACTTRIGGER_INIT WarpZoneLib_ExactTrigger_Init(this)
#endif
#endif
return;
- if(WarpZoneLib_ExactTrigger_Touch())
+ if(WarpZoneLib_ExactTrigger_Touch(self, other))
return;
#ifdef SVQC
// warpzones
if (warpzone_warpzones_exist) {
- setself(WarpZone_Find(it.origin + it.mins, it.origin + it.maxs));
- if (self)
- if (!WarpZoneLib_ExactTrigger_Touch())
- if (WarpZone_PlaneDist(self, it.origin + it.view_ofs) <= 0)
- WarpZone_Teleport(self, it, -1, 0); // NOT triggering targets by this!
+ entity e = WarpZone_Find(it.origin + it.mins, it.origin + it.maxs);
+ if (e)
+ if (!WarpZoneLib_ExactTrigger_Touch(e, other))
+ if (WarpZone_PlaneDist(e, it.origin + it.view_ofs) <= 0)
+ WarpZone_Teleport(e, it, -1, 0); // NOT triggering targets by this!
}
// teleporters
if(other.teleportable)
{
- setself(Teleport_Find(it.origin + it.mins, it.origin + it.maxs));
- if (self)
- if (!WarpZoneLib_ExactTrigger_Touch())
- Simple_TeleportPlayer(self, other); // NOT triggering targets by this!
+ entity ent = Teleport_Find(it.origin + it.mins, it.origin + it.maxs);
+ if (ent)
+ if (!WarpZoneLib_ExactTrigger_Touch(ent, other))
+ Simple_TeleportPlayer(ent, other); // NOT triggering targets by this!
}
}
});
- setself(this);
other = oldother;
}
#define LIB_WARPZONE_UTIL_SERVER_H
float WarpZoneLib_MoveOutOfSolid(entity e);
-float WarpZoneLib_ExactTrigger_Touch();
+float WarpZoneLib_ExactTrigger_Touch(entity this, entity toucher);
#ifdef SVQC
void WarpZoneLib_ExactTrigger_Init(entity this);
#endif
{
bool other_weapon_available = false;
FOREACH(Weapons, it != WEP_Null, LAMBDA(
- if(it.wr_checkammo1(it) + it.wr_checkammo2(it))
+ if(it.wr_checkammo1(it, this) + it.wr_checkammo2(it, this))
other_weapon_available = true;
));
if(other_weapon_available)
{
if (!(shuffleteams_players[z])) continue; // not a player, move on to next random slot
- if (VerifyClientNumber(shuffleteams_players[z])) setself(edict_num(shuffleteams_players[z]));
+ entity e = NULL;
+ if(VerifyClientNumber(shuffleteams_players[z]))
+ e = edict_num(shuffleteams_players[z]);
- if (self.team != team_color) MoveToTeam(self, team_color, 6);
+ if(!e) continue; // unverified
+
+ if (e.team != team_color) MoveToTeam(e, team_color, 6);
shuffleteams_players[z] = 0;
shuffleteams_teams[i] = shuffleteams_teams[i] + 1;
if (!MUTATOR_CALLHOOK(reset_map_players))
{
FOREACH_CLIENT(true, LAMBDA(
- setself(it);
/*
only reset players if a restart countdown is active
this can either be due to cvar sv_ready_restart_after_countdown having set
if (restart_mapalreadyrestarted || (time < game_starttime))
{
// NEW: changed behaviour so that it prevents that previous spectators/observers suddenly spawn as players
- if (IS_PLAYER(self))
+ if (IS_PLAYER(it))
{
- // PlayerScore_Clear(self);
- self.killcount = 0;
+ // PlayerScore_Clear(it);
+ it.killcount = 0;
// stop the player from moving so that he stands still once he gets respawned
- self.velocity = '0 0 0';
- self.avelocity = '0 0 0';
- self.movement = '0 0 0';
- PutClientInServer();
+ it.velocity = '0 0 0';
+ it.avelocity = '0 0 0';
+ it.movement = '0 0 0';
+ WITHSELF(it, PutClientInServer());
}
}
));
-
- setself(this);
}
}
}
}
void Damage (entity targ, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
-{SELFPARAM();
+{
float mirrordamage;
float mirrorforce;
float complainteamdamage = 0;
if (gameover || targ.killcount == FRAGS_SPECTATOR)
return;
- setself(targ);
- damage_targ = targ;
- damage_inflictor = inflictor;
- damage_attacker = attacker;
- attacker_save = attacker;
+ damage_targ = targ;
+ damage_inflictor = inflictor;
+ damage_attacker = attacker;
+ attacker_save = attacker;
if(IS_PLAYER(targ))
if(targ.hook)
// special rule: gravity bomb does not hit team mates (other than for disconnecting the hook)
if(DEATH_ISWEAPON(deathtype, WEP_HOOK) || DEATH_ISWEAPON(deathtype, WEP_TUBA))
{
- if(IS_PLAYER(targ))
- if(SAME_TEAM(targ, attacker))
- {
- setself(this);
- return;
- }
+ if(IS_PLAYER(targ) && SAME_TEAM(targ, attacker))
+ {
+ return;
+ }
}
if(deathtype == DEATH_KILL.m_id || deathtype == DEATH_TEAMCHANGE.m_id || deathtype == DEATH_AUTOTEAMCHANGE.m_id)
{
// exit the vehicle before killing (fixes a crash)
if(IS_PLAYER(targ) && targ.vehicle)
- vehicles_exit(VHEF_RELEASE);
+ WITHSELF(targ, vehicles_exit(VHEF_RELEASE));
// These are ALWAYS lethal
// No damage modification here
}
// apply push
- if (self.damageforcescale)
+ if (targ.damageforcescale)
if (vlen(force))
- if (!IS_PLAYER(self) || time >= self.spawnshieldtime || self == attacker)
+ if (!IS_PLAYER(targ) || time >= targ.spawnshieldtime || targ == attacker)
{
- vector farce = damage_explosion_calcpush(self.damageforcescale * force, self.velocity, autocvar_g_balance_damagepush_speedfactor);
- if(self.movetype == MOVETYPE_PHYSICS)
+ vector farce = damage_explosion_calcpush(targ.damageforcescale * force, targ.velocity, autocvar_g_balance_damagepush_speedfactor);
+ if(targ.movetype == MOVETYPE_PHYSICS)
{
entity farcent = new(farce);
- farcent.enemy = self;
+ farcent.enemy = targ;
farcent.movedir = farce * 10;
- if(self.mass)
- farcent.movedir = farcent.movedir * self.mass;
+ if(targ.mass)
+ farcent.movedir = farcent.movedir * targ.mass;
farcent.origin = hitloc;
farcent.forcetype = FORCETYPE_FORCEATPOS;
farcent.nextthink = time + 0.1;
}
else
{
- self.velocity = self.velocity + farce;
- self.move_velocity = self.velocity;
+ targ.velocity = targ.velocity + farce;
+ targ.move_velocity = targ.velocity;
}
- UNSET_ONGROUND(self);
- self.move_flags &= ~FL_ONGROUND;
- UpdateCSQCProjectile(self);
+ UNSET_ONGROUND(targ);
+ targ.move_flags &= ~FL_ONGROUND;
+ UpdateCSQCProjectile(targ);
}
// apply damage
- if (damage != 0 || (self.damageforcescale && vlen(force)))
- if (self.event_damage)
- self.event_damage (self, inflictor, attacker, damage, deathtype, hitloc, force);
- setself(this);
+ if (damage != 0 || (targ.damageforcescale && vlen(force)))
+ if (targ.event_damage)
+ targ.event_damage (targ, inflictor, attacker, damage, deathtype, hitloc, force);
// apply mirror damage if any
if(!autocvar_g_mirrordamage_onlyweapons || DEATH_WEAPONOF(deathtype) != WEP_Null)
clients_found = 0;
FOREACH_CLIENT(IS_REAL_CLIENT(it), LAMBDA(
- setself(it);
// TODO add timer
- LOG_INFO("Redirecting: sending connect command to ", self.netname, "\n");
+ LOG_INFO("Redirecting: sending connect command to ", it.netname, "\n");
if(redirection_target == "self")
- stuffcmd(self, "\ndisconnect; defer ", ftos(autocvar_quit_and_redirect_timer), " reconnect\n");
+ stuffcmd(it, "\ndisconnect; defer ", ftos(autocvar_quit_and_redirect_timer), " reconnect\n");
else
- stuffcmd(self, strcat("\ndisconnect; defer ", ftos(autocvar_quit_and_redirect_timer), " \"connect ", redirection_target, "\"\n"));
+ stuffcmd(it, strcat("\ndisconnect; defer ", ftos(autocvar_quit_and_redirect_timer), " \"connect ", redirection_target, "\"\n"));
++clients_found;
));
MUTATOR_HOOKFUNCTION(ca, reset_map_players)
{
- SELFPARAM();
FOREACH_CLIENT(true, {
it.killcount = 0;
if (!it.caplayer && IS_BOT_CLIENT(it))
self.health = 0;
ctf_CheckFlagReturn(self, RETURN_SPEEDRUN);
- setself(self.owner);
- self.impulse = CHIMPULSE_SPEEDRUN.impulse; // move the player back to the waypoint they set
- ImpulseCommands(self);
- setself(this);
+ self.owner.impulse = CHIMPULSE_SPEEDRUN.impulse; // move the player back to the waypoint they set
+ ImpulseCommands(self.owner);
}
if(autocvar_g_ctf_stalemate)
{
void ctf_FlagSetup(int teamnumber, entity flag) // called when spawning a flag entity on the map as a spawnfunc
{
- // declarations
- setself(flag); // for later usage with droptofloor()
-
// main setup
flag.ctf_worldflagnext = ctf_worldflaglist; // link flag into ctf_worldflaglist
ctf_worldflaglist = flag;
else // drop to floor, automatically find a platform and set that as spawn origin
{
flag.noalign = false;
- setself(flag);
- droptofloor();
+ WITHSELF(flag, droptofloor());
flag.movetype = MOVETYPE_TOSS;
}
}
MUTATOR_HOOKFUNCTION(dom, reset_map_players)
-{SELFPARAM();
+{
total_pps = 0, pps_red = 0, pps_blue = 0, pps_yellow = 0, pps_pink = 0;
FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
- setself(it);
- PutClientInServer();
+ WITHSELF(it, PutClientInServer());
if(domination_roundbased)
- self.player_blocked = 1;
- if(IS_REAL_CLIENT(self))
- set_dom_state(self);
+ it.player_blocked = 1;
+ if(IS_REAL_CLIENT(it))
+ set_dom_state(it);
));
return 1;
}
// code from here on is just to support maps that don't have control point and team entities
void dom_spawnteam (string teamname, float teamcolor, string pointmodel, float pointskin, Sound capsound, string capnarration, string capmessage)
-{SELFPARAM();
+{
TC(Sound, capsound);
- setself(spawn());
- self.classname = "dom_team";
- self.netname = strzone(teamname);
- self.cnt = teamcolor;
- self.model = pointmodel;
- self.skin = pointskin;
- self.noise = strzone(Sound_fixpath(capsound));
- self.noise1 = strzone(capnarration);
- self.message = strzone(capmessage);
+ entity e = new_pure(dom_team);
+ e.netname = strzone(teamname);
+ e.cnt = teamcolor;
+ e.model = pointmodel;
+ e.skin = pointskin;
+ e.noise = strzone(Sound_fixpath(capsound));
+ e.noise1 = strzone(capnarration);
+ e.message = strzone(capmessage);
// this code is identical to spawnfunc_dom_team
- _setmodel(self, self.model); // precision not needed
- self.mdl = self.model;
- self.dmg = self.modelindex;
- self.model = "";
- self.modelindex = 0;
+ _setmodel(e, e.model); // precision not needed
+ e.mdl = e.model;
+ e.dmg = e.modelindex;
+ e.model = "";
+ e.modelindex = 0;
// this would have to be changed if used in quakeworld
- self.team = self.cnt + 1;
+ e.team = e.cnt + 1;
- //eprint(self);
- setself(this);
+ //eprint(e);
}
void self_spawnfunc_dom_controlpoint() { SELFPARAM(); spawnfunc_dom_controlpoint(self); }
void dom_spawnpoint(vector org)
-{SELFPARAM();
- setself(spawn());
- self.classname = "dom_controlpoint";
- self.think = self_spawnfunc_dom_controlpoint;
- self.nextthink = time;
- setorigin(self, org);
- spawnfunc_dom_controlpoint(this);
- setself(this);
+{
+ entity e = spawn();
+ e.classname = "dom_controlpoint";
+ e.think = self_spawnfunc_dom_controlpoint;
+ e.nextthink = time;
+ setorigin(e, org);
+ spawnfunc_dom_controlpoint(e);
}
// spawn some default teams if the map is not set up for domination
FOREACH_CLIENT(IS_PLAYER(it), LAMBDA(
it.killcount = 0;
it.freezetag_frozen_timeout = -1;
- setself(it);
- PutClientInServer();
+ WITHSELF(it, PutClientInServer());
it.freezetag_frozen_timeout = 0;
));
freezetag_count_alive_players();
}
else
{
- WITHSELF(this, f = wpn.wr_checkammo1(wpn) + wpn.wr_checkammo2(wpn));
+ f = wpn.wr_checkammo1(wpn, this) + wpn.wr_checkammo2(wpn, this);
// always allow selecting the Mine Layer if we placed mines, so that we can detonate them
if(wpn == WEP_MINE_LAYER)
SELFPARAM();
if ((actor.items & IT_UNLIMITED_WEAPON_AMMO)) return true;
bool ammo = false;
- if (secondary) WITHSELF(actor, ammo = thiswep.wr_checkammo2(thiswep));
- else WITHSELF(actor, ammo = thiswep.wr_checkammo1(thiswep));
+ if (secondary) ammo = thiswep.wr_checkammo2(thiswep, actor);
+ else ammo = thiswep.wr_checkammo1(thiswep, actor);
if (ammo) return true;
// always keep the Mine Layer if we placed mines, so that we can detonate them
if (thiswep == WEP_MINE_LAYER)
// check if the other firing mode has enough ammo
bool ammo_other = false;
- if (secondary) WITHSELF(actor, ammo_other = thiswep.wr_checkammo1(thiswep));
- else WITHSELF(actor, ammo_other = thiswep.wr_checkammo2(thiswep));
+ if (secondary) ammo_other = thiswep.wr_checkammo1(thiswep, actor);
+ else ammo_other = thiswep.wr_checkammo2(thiswep, actor);
if (ammo_other)
{
if (time - actor.prevwarntime > 1)
}
// switch away if the amount of ammo is not enough to keep using this weapon
Weapon w = PS(actor).m_weapon;
- if (!(w.wr_checkammo1(w) + w.wr_checkammo2(w)))
+ if (!(w.wr_checkammo1(w, actor) + w.wr_checkammo2(w, actor)))
{
actor.clip_load = -1; // reload later
W_SwitchToOtherWeapon(actor);