From 537313c9e52ce93b28ad6580b76e92d99f0a9d93 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 22 May 2016 11:36:00 +1000 Subject: [PATCH] Clean out self from wr_checkammo1 & wr_checkammo2 --- .../gamemodes/gamemode/nexball/nexball.qc | 4 +- qcsrc/common/monsters/monster/wyvern.qc | 2 +- qcsrc/common/mutators/mutator/overkill/hmg.qc | 16 +++-- qcsrc/common/mutators/mutator/overkill/rpc.qc | 9 ++- qcsrc/common/vehicles/vehicle/racer.qc | 2 +- qcsrc/common/vehicles/vehicle/racer_weapon.qc | 7 +-- qcsrc/common/vehicles/vehicle/raptor.qc | 3 +- .../common/vehicles/vehicle/raptor_weapons.qc | 7 +-- qcsrc/common/weapons/weapon.qh | 4 +- qcsrc/common/weapons/weapon/arc.qc | 16 +++-- qcsrc/common/weapons/weapon/blaster.qc | 4 +- qcsrc/common/weapons/weapon/crylink.qc | 20 +++---- qcsrc/common/weapons/weapon/devastator.qc | 25 ++++---- qcsrc/common/weapons/weapon/electro.qc | 18 +++--- qcsrc/common/weapons/weapon/fireball.qc | 4 +- qcsrc/common/weapons/weapon/hagar.qc | 18 +++--- qcsrc/common/weapons/weapon/hlac.qc | 16 +++-- qcsrc/common/weapons/weapon/hook.qc | 12 ++-- qcsrc/common/weapons/weapon/machinegun.qc | 28 ++++----- qcsrc/common/weapons/weapon/minelayer.qc | 27 ++++----- qcsrc/common/weapons/weapon/mortar.qc | 14 ++--- qcsrc/common/weapons/weapon/porto.qc | 4 +- qcsrc/common/weapons/weapon/rifle.qc | 14 ++--- qcsrc/common/weapons/weapon/seeker.qc | 49 +++++++-------- qcsrc/common/weapons/weapon/shockwave.qc | 4 +- qcsrc/common/weapons/weapon/shotgun.qc | 22 ++++--- qcsrc/common/weapons/weapon/tuba.qc | 4 +- qcsrc/common/weapons/weapon/vaporizer.qc | 14 ++--- qcsrc/common/weapons/weapon/vortex.qc | 14 ++--- qcsrc/lib/warpzone/common.qc | 6 +- qcsrc/lib/warpzone/common.qh | 4 +- qcsrc/lib/warpzone/server.qc | 21 ++++--- qcsrc/lib/warpzone/util_server.qh | 2 +- qcsrc/server/bot/havocbot/havocbot.qc | 2 +- qcsrc/server/command/sv_cmd.qc | 8 ++- qcsrc/server/command/vote.qc | 17 +++--- qcsrc/server/g_damage.qc | 54 ++++++++--------- qcsrc/server/g_world.qc | 7 +-- qcsrc/server/mutators/mutator/gamemode_ca.qc | 1 - qcsrc/server/mutators/mutator/gamemode_ctf.qc | 12 +--- .../mutators/mutator/gamemode_domination.qc | 60 +++++++++---------- .../mutators/mutator/gamemode_freezetag.qc | 3 +- qcsrc/server/weapons/selection.qc | 2 +- qcsrc/server/weapons/weaponsystem.qc | 10 ++-- 44 files changed, 270 insertions(+), 320 deletions(-) diff --git a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc index 184055d55b..2acc4faf6d 100644 --- a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc +++ b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc @@ -895,13 +895,13 @@ METHOD(BallStealer, wr_setup, void(BallStealer this)) //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; diff --git a/qcsrc/common/monsters/monster/wyvern.qc b/qcsrc/common/monsters/monster/wyvern.qc index 3757f7941f..c52ce3f999 100644 --- a/qcsrc/common/monsters/monster/wyvern.qc +++ b/qcsrc/common/monsters/monster/wyvern.qc @@ -80,7 +80,7 @@ METHOD(WyvernAttack, wr_think, void(WyvernAttack thiswep, entity actor, .entity } } -METHOD(WyvernAttack, wr_checkammo1, bool(WyvernAttack this)) { +METHOD(WyvernAttack, wr_checkammo1, bool(WyvernAttack this, entity actor)) { TC(WyvernAttack, this); return true; } diff --git a/qcsrc/common/mutators/mutator/overkill/hmg.qc b/qcsrc/common/mutators/mutator/overkill/hmg.qc index ec8061c3d2..ee4c85635e 100644 --- a/qcsrc/common/mutators/mutator/overkill/hmg.qc +++ b/qcsrc/common/mutators/mutator/overkill/hmg.qc @@ -64,7 +64,7 @@ void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity weapone 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)); @@ -124,24 +124,22 @@ METHOD(HeavyMachineGun, wr_think, void(entity thiswep, entity actor, .entity wea } } -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; } diff --git a/qcsrc/common/mutators/mutator/overkill/rpc.qc b/qcsrc/common/mutators/mutator/overkill/rpc.qc index 2d9d423cf5..f16b7024df 100644 --- a/qcsrc/common/mutators/mutator/overkill/rpc.qc +++ b/qcsrc/common/mutators/mutator/overkill/rpc.qc @@ -178,15 +178,14 @@ METHOD(RocketPropelledChainsaw, wr_think, void(entity thiswep, entity actor, .en } } -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; } diff --git a/qcsrc/common/vehicles/vehicle/racer.qc b/qcsrc/common/vehicles/vehicle/racer.qc index ded599b7d2..7b433a84e9 100644 --- a/qcsrc/common/vehicles/vehicle/racer.qc +++ b/qcsrc/common/vehicles/vehicle/racer.qc @@ -321,7 +321,7 @@ bool racer_frame(entity this) 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") diff --git a/qcsrc/common/vehicles/vehicle/racer_weapon.qc b/qcsrc/common/vehicles/vehicle/racer_weapon.qc index 36655fd1de..33d11c1c64 100644 --- a/qcsrc/common/vehicles/vehicle/racer_weapon.qc +++ b/qcsrc/common/vehicles/vehicle/racer_weapon.qc @@ -34,11 +34,10 @@ METHOD(RacerAttack, wr_think, void(entity thiswep, entity actor, .entity weapone } } -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; } diff --git a/qcsrc/common/vehicles/vehicle/raptor.qc b/qcsrc/common/vehicles/vehicle/raptor.qc index 8b2f9e01b8..d91754024d 100644 --- a/qcsrc/common/vehicles/vehicle/raptor.qc +++ b/qcsrc/common/vehicles/vehicle/raptor.qc @@ -385,13 +385,12 @@ bool raptor_frame(entity this) 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); diff --git a/qcsrc/common/vehicles/vehicle/raptor_weapons.qc b/qcsrc/common/vehicles/vehicle/raptor_weapons.qc index c51fa154f7..eedb0644bd 100644 --- a/qcsrc/common/vehicles/vehicle/raptor_weapons.qc +++ b/qcsrc/common/vehicles/vehicle/raptor_weapons.qc @@ -30,10 +30,9 @@ METHOD(RaptorCannon, wr_think, void(entity thiswep, entity actor, .entity weapon 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; } diff --git a/qcsrc/common/weapons/weapon.qh b/qcsrc/common/weapons/weapon.qh index ef115b220d..c76a88399d 100644 --- a/qcsrc/common/weapons/weapon.qh +++ b/qcsrc/common/weapons/weapon.qh @@ -89,9 +89,9 @@ CLASS(Weapon, Object) /** (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 */ diff --git a/qcsrc/common/weapons/weapon/arc.qc b/qcsrc/common/weapons/weapon/arc.qc index 19cf8a591c..0881da4963 100644 --- a/qcsrc/common/weapons/weapon/arc.qc +++ b/qcsrc/common/weapons/weapon/arc.qc @@ -374,7 +374,7 @@ void W_Arc_Beam_Think() 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 @@ -831,23 +831,21 @@ METHOD(Arc, wr_init, void(entity thiswep)) 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)) { diff --git a/qcsrc/common/weapons/weapon/blaster.qc b/qcsrc/common/weapons/weapon/blaster.qc index f9f3008ff8..6bb741b0db 100644 --- a/qcsrc/common/weapons/weapon/blaster.qc +++ b/qcsrc/common/weapons/weapon/blaster.qc @@ -229,12 +229,12 @@ METHOD(Blaster, wr_setup, void(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 } diff --git a/qcsrc/common/weapons/weapon/crylink.qc b/qcsrc/common/weapons/weapon/crylink.qc index 9e2bb47416..b422992643 100644 --- a/qcsrc/common/weapons/weapon/crylink.qc +++ b/qcsrc/common/weapons/weapon/crylink.qc @@ -621,7 +621,7 @@ METHOD(Crylink, wr_think, void(entity thiswep, entity actor, .entity weaponentit 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! @@ -631,26 +631,24 @@ METHOD(Crylink, wr_think, void(entity thiswep, entity actor, .entity weaponentit } } } -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)) diff --git a/qcsrc/common/weapons/weapon/devastator.qc b/qcsrc/common/weapons/weapon/devastator.qc index 1cde73d446..4e7b5cf100 100644 --- a/qcsrc/common/weapons/weapon/devastator.qc +++ b/qcsrc/common/weapons/weapon/devastator.qc @@ -561,44 +561,43 @@ METHOD(Devastator, wr_setup, void(entity thiswep)) 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; } diff --git a/qcsrc/common/weapons/weapon/electro.qc b/qcsrc/common/weapons/weapon/electro.qc index 315ea5a5a4..b977ddb910 100644 --- a/qcsrc/common/weapons/weapon/electro.qc +++ b/qcsrc/common/weapons/weapon/electro.qc @@ -496,26 +496,24 @@ METHOD(Electro, wr_think, void(entity thiswep, entity actor, .entity weaponentit } } } -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; } diff --git a/qcsrc/common/weapons/weapon/fireball.qc b/qcsrc/common/weapons/weapon/fireball.qc index 4bbcdb68e5..245a05ff3c 100644 --- a/qcsrc/common/weapons/weapon/fireball.qc +++ b/qcsrc/common/weapons/weapon/fireball.qc @@ -403,11 +403,11 @@ METHOD(Fireball, wr_setup, void(entity thiswep)) 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 } diff --git a/qcsrc/common/weapons/weapon/hagar.qc b/qcsrc/common/weapons/weapon/hagar.qc index 4b0367fb5e..54539f7272 100644 --- a/qcsrc/common/weapons/weapon/hagar.qc +++ b/qcsrc/common/weapons/weapon/hagar.qc @@ -397,7 +397,7 @@ void W_Hagar_Attack2_Load(Weapon thiswep, .entity weaponentity) 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 @@ -415,7 +415,7 @@ void W_Hagar_Attack_Auto(Weapon thiswep, entity actor, .entity weaponentity, int 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)); @@ -491,18 +491,16 @@ METHOD(Hagar, wr_setup, void(entity thiswep)) 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)) diff --git a/qcsrc/common/weapons/weapon/hlac.qc b/qcsrc/common/weapons/weapon/hlac.qc index 4be78821cd..932f3d17da 100644 --- a/qcsrc/common/weapons/weapon/hlac.qc +++ b/qcsrc/common/weapons/weapon/hlac.qc @@ -171,7 +171,7 @@ void W_HLAC_Attack_Frame(Weapon thiswep, entity actor, .entity weaponentity, int 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)); @@ -235,18 +235,16 @@ METHOD(HLAC, wr_think, void(entity thiswep, entity actor, .entity weaponentity, } } } -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)) diff --git a/qcsrc/common/weapons/weapon/hook.qc b/qcsrc/common/weapons/weapon/hook.qc index 9b923bd466..468c64b9a6 100644 --- a/qcsrc/common/weapons/weapon/hook.qc +++ b/qcsrc/common/weapons/weapon/hook.qc @@ -283,19 +283,19 @@ METHOD(Hook, wr_setup, void(entity thiswep)) 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)) { diff --git a/qcsrc/common/weapons/weapon/machinegun.qc b/qcsrc/common/weapons/weapon/machinegun.qc index 4a49933b16..8b16c273b9 100644 --- a/qcsrc/common/weapons/weapon/machinegun.qc +++ b/qcsrc/common/weapons/weapon/machinegun.qc @@ -148,7 +148,7 @@ void W_MachineGun_Attack_Frame(Weapon thiswep, entity actor, .entity weaponentit } 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)); @@ -174,7 +174,7 @@ void W_MachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity weaponentity 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)); @@ -267,7 +267,7 @@ METHOD(MachineGun, wr_think, void(entity thiswep, entity actor, .entity weaponen 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)); @@ -301,39 +301,37 @@ METHOD(MachineGun, wr_think, void(entity thiswep, entity actor, .entity weaponen } } } -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; } diff --git a/qcsrc/common/weapons/weapon/minelayer.qc b/qcsrc/common/weapons/weapon/minelayer.qc index 96d7555cda..9670dbda89 100644 --- a/qcsrc/common/weapons/weapon/minelayer.qc +++ b/qcsrc/common/weapons/weapon/minelayer.qc @@ -127,7 +127,7 @@ void W_MineLayer_Explode() { 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 @@ -154,7 +154,7 @@ void W_MineLayer_DoRemoteExplode() { 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 @@ -383,12 +383,12 @@ void W_MineLayer_Attack(Weapon thiswep) 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) { @@ -508,7 +508,7 @@ METHOD(MineLayer, wr_think, void(entity thiswep, entity actor, .entity weaponent 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); } } @@ -523,26 +523,25 @@ METHOD(MineLayer, wr_think, void(entity thiswep, entity actor, .entity weaponent 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; diff --git a/qcsrc/common/weapons/weapon/mortar.qc b/qcsrc/common/weapons/weapon/mortar.qc index 5fbacc7ba4..1e1c924e6d 100644 --- a/qcsrc/common/weapons/weapon/mortar.qc +++ b/qcsrc/common/weapons/weapon/mortar.qc @@ -381,18 +381,16 @@ METHOD(Mortar, wr_think, void(entity thiswep, entity actor, .entity weaponentity } } } -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)) diff --git a/qcsrc/common/weapons/weapon/porto.qc b/qcsrc/common/weapons/weapon/porto.qc index b9488889dd..00aa0153cb 100644 --- a/qcsrc/common/weapons/weapon/porto.qc +++ b/qcsrc/common/weapons/weapon/porto.qc @@ -357,12 +357,12 @@ METHOD(PortoLaunch, wr_think, void(entity thiswep, entity actor, .entity weapone } } } -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; diff --git a/qcsrc/common/weapons/weapon/rifle.qc b/qcsrc/common/weapons/weapon/rifle.qc index 6067705798..e11bdd85b7 100644 --- a/qcsrc/common/weapons/weapon/rifle.qc +++ b/qcsrc/common/weapons/weapon/rifle.qc @@ -197,18 +197,16 @@ METHOD(Rifle, wr_think, void(entity thiswep, entity actor, .entity weaponentity, } } } -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)) diff --git a/qcsrc/common/weapons/weapon/seeker.qc b/qcsrc/common/weapons/weapon/seeker.qc index 6dffec39d3..ce0aacd2d5 100644 --- a/qcsrc/common/weapons/weapon/seeker.qc +++ b/qcsrc/common/weapons/weapon/seeker.qc @@ -423,42 +423,41 @@ void W_Seeker_Vollycontroller_Think() // TODO: Merge this with W_Seeker_Attack {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() @@ -658,35 +657,33 @@ METHOD(Seeker, wr_think, void(entity thiswep, entity actor, .entity weaponentity } } } -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; } diff --git a/qcsrc/common/weapons/weapon/shockwave.qc b/qcsrc/common/weapons/weapon/shockwave.qc index 444f96894f..64264de593 100644 --- a/qcsrc/common/weapons/weapon/shockwave.qc +++ b/qcsrc/common/weapons/weapon/shockwave.qc @@ -704,11 +704,11 @@ METHOD(Shockwave, wr_think, void(entity thiswep, entity actor, .entity weaponent } } } -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; diff --git a/qcsrc/common/weapons/weapon/shotgun.qc b/qcsrc/common/weapons/weapon/shotgun.qc index 1a23189402..568b1fe6ba 100644 --- a/qcsrc/common/weapons/weapon/shotgun.qc +++ b/qcsrc/common/weapons/weapon/shotgun.qc @@ -198,7 +198,7 @@ void W_Shotgun_Attack2(Weapon thiswep, entity actor, .entity weaponentity, int f // 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)); @@ -212,7 +212,7 @@ void W_Shotgun_Attack3_Frame2(Weapon thiswep, entity actor, .entity weaponentity } 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)); @@ -285,26 +285,24 @@ METHOD(Shotgun, wr_setup, void(entity thiswep)) 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 diff --git a/qcsrc/common/weapons/weapon/tuba.qc b/qcsrc/common/weapons/weapon/tuba.qc index 4cb5ded982..abd3870841 100644 --- a/qcsrc/common/weapons/weapon/tuba.qc +++ b/qcsrc/common/weapons/weapon/tuba.qc @@ -461,8 +461,8 @@ METHOD(Tuba, wr_reload, void(Tuba this, entity actor, .entity weaponentity)) #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)) { diff --git a/qcsrc/common/weapons/weapon/vaporizer.qc b/qcsrc/common/weapons/weapon/vaporizer.qc index 08f6638991..cd05a8682b 100644 --- a/qcsrc/common/weapons/weapon/vaporizer.qc +++ b/qcsrc/common/weapons/weapon/vaporizer.qc @@ -432,21 +432,19 @@ METHOD(Vaporizer, wr_setup, void(entity thiswep)) 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)) diff --git a/qcsrc/common/weapons/weapon/vortex.qc b/qcsrc/common/weapons/weapon/vortex.qc index 210bb14aa7..d0d0025ec2 100644 --- a/qcsrc/common/weapons/weapon/vortex.qc +++ b/qcsrc/common/weapons/weapon/vortex.qc @@ -326,21 +326,19 @@ METHOD(Vortex, wr_setup, 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 diff --git a/qcsrc/lib/warpzone/common.qc b/qcsrc/lib/warpzone/common.qc index 130e1b2d14..832e32e01d 100644 --- a/qcsrc/lib/warpzone/common.qc +++ b/qcsrc/lib/warpzone/common.qc @@ -786,9 +786,9 @@ entity WarpZone_RefSys_SpawnSameRefSys(entity me) 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); } diff --git a/qcsrc/lib/warpzone/common.qh b/qcsrc/lib/warpzone/common.qh index c827900958..2cfa7ef9bc 100644 --- a/qcsrc/lib/warpzone/common.qh +++ b/qcsrc/lib/warpzone/common.qh @@ -107,10 +107,10 @@ entity WarpZone_RefSys_SpawnSameRefSys(entity me); // spawn().R = me.R 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 diff --git a/qcsrc/lib/warpzone/server.qc b/qcsrc/lib/warpzone/server.qc index 6a748eed41..8bd5d692ff 100644 --- a/qcsrc/lib/warpzone/server.qc +++ b/qcsrc/lib/warpzone/server.qc @@ -206,7 +206,7 @@ void WarpZone_Touch () #endif return; - if(WarpZoneLib_ExactTrigger_Touch()) + if(WarpZoneLib_ExactTrigger_Touch(self, other)) return; #ifdef SVQC @@ -866,24 +866,23 @@ void WarpZone_StartFrame() // 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; } diff --git a/qcsrc/lib/warpzone/util_server.qh b/qcsrc/lib/warpzone/util_server.qh index 5c94d4319f..39d1d24699 100644 --- a/qcsrc/lib/warpzone/util_server.qh +++ b/qcsrc/lib/warpzone/util_server.qh @@ -2,7 +2,7 @@ #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 diff --git a/qcsrc/server/bot/havocbot/havocbot.qc b/qcsrc/server/bot/havocbot/havocbot.qc index cff3fe2145..3163c21f5c 100644 --- a/qcsrc/server/bot/havocbot/havocbot.qc +++ b/qcsrc/server/bot/havocbot/havocbot.qc @@ -993,7 +993,7 @@ float havocbot_chooseweapon_checkreload(entity this, int new_weapon) { 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) diff --git a/qcsrc/server/command/sv_cmd.qc b/qcsrc/server/command/sv_cmd.qc index 63733e1c65..e601bfc6ca 100644 --- a/qcsrc/server/command/sv_cmd.qc +++ b/qcsrc/server/command/sv_cmd.qc @@ -1384,9 +1384,13 @@ void GameCommand_shuffleteams(float request) { 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; diff --git a/qcsrc/server/command/vote.qc b/qcsrc/server/command/vote.qc index 252ab2f852..e19ef52e87 100644 --- a/qcsrc/server/command/vote.qc +++ b/qcsrc/server/command/vote.qc @@ -363,7 +363,6 @@ void reset_map(bool dorespawn) 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 @@ -373,20 +372,18 @@ void reset_map(bool dorespawn) 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); } } } diff --git a/qcsrc/server/g_damage.qc b/qcsrc/server/g_damage.qc index b30f2353ba..0c76214c87 100644 --- a/qcsrc/server/g_damage.qc +++ b/qcsrc/server/g_damage.qc @@ -577,7 +577,7 @@ void Unfreeze (entity targ) } void Damage (entity targ, entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force) -{SELFPARAM(); +{ float mirrordamage; float mirrorforce; float complainteamdamage = 0; @@ -588,11 +588,10 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, int d 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) @@ -603,19 +602,17 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, int d // 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 @@ -838,18 +835,18 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, int d } // 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; @@ -857,18 +854,17 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, int d } 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) diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc index b9d8035d5f..583391d22f 100644 --- a/qcsrc/server/g_world.qc +++ b/qcsrc/server/g_world.qc @@ -2049,13 +2049,12 @@ float RedirectionThink() 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; )); diff --git a/qcsrc/server/mutators/mutator/gamemode_ca.qc b/qcsrc/server/mutators/mutator/gamemode_ca.qc index 072fe90dde..8835d11a9c 100644 --- a/qcsrc/server/mutators/mutator/gamemode_ca.qc +++ b/qcsrc/server/mutators/mutator/gamemode_ca.qc @@ -242,7 +242,6 @@ MUTATOR_HOOKFUNCTION(ca, PutClientInServer) MUTATOR_HOOKFUNCTION(ca, reset_map_players) { - SELFPARAM(); FOREACH_CLIENT(true, { it.killcount = 0; if (!it.caplayer && IS_BOT_CLIENT(it)) diff --git a/qcsrc/server/mutators/mutator/gamemode_ctf.qc b/qcsrc/server/mutators/mutator/gamemode_ctf.qc index 33fb745a58..cbefd4c73f 100644 --- a/qcsrc/server/mutators/mutator/gamemode_ctf.qc +++ b/qcsrc/server/mutators/mutator/gamemode_ctf.qc @@ -943,10 +943,8 @@ void ctf_FlagThink() 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) { @@ -1188,9 +1186,6 @@ void ctf_DelayedFlagSetup(entity this) // called after a flag is placed on a map 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; @@ -1290,8 +1285,7 @@ void ctf_FlagSetup(int teamnumber, entity flag) // called when spawning a flag e 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; } diff --git a/qcsrc/server/mutators/mutator/gamemode_domination.qc b/qcsrc/server/mutators/mutator/gamemode_domination.qc index 08b00716b3..8db6de10c2 100644 --- a/qcsrc/server/mutators/mutator/gamemode_domination.qc +++ b/qcsrc/server/mutators/mutator/gamemode_domination.qc @@ -496,15 +496,14 @@ MUTATOR_HOOKFUNCTION(dom, GetTeamCount) } 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; } @@ -630,41 +629,38 @@ void ScoreRules_dom(float teams) // 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 diff --git a/qcsrc/server/mutators/mutator/gamemode_freezetag.qc b/qcsrc/server/mutators/mutator/gamemode_freezetag.qc index f57661fba9..9900497282 100644 --- a/qcsrc/server/mutators/mutator/gamemode_freezetag.qc +++ b/qcsrc/server/mutators/mutator/gamemode_freezetag.qc @@ -456,8 +456,7 @@ MUTATOR_HOOKFUNCTION(ft, reset_map_players) 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(); diff --git a/qcsrc/server/weapons/selection.qc b/qcsrc/server/weapons/selection.qc index 18dc4001a9..70284a8f4b 100644 --- a/qcsrc/server/weapons/selection.qc +++ b/qcsrc/server/weapons/selection.qc @@ -71,7 +71,7 @@ bool client_hasweapon(entity this, Weapon wpn, float andammo, bool complain) } 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) diff --git a/qcsrc/server/weapons/weaponsystem.qc b/qcsrc/server/weapons/weaponsystem.qc index 94805a59b3..db5f9fe901 100644 --- a/qcsrc/server/weapons/weaponsystem.qc +++ b/qcsrc/server/weapons/weaponsystem.qc @@ -213,8 +213,8 @@ bool weapon_prepareattack_checkammo(Weapon thiswep, entity actor, bool secondary 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) @@ -232,8 +232,8 @@ bool weapon_prepareattack_checkammo(Weapon thiswep, entity actor, bool secondary // 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) @@ -731,7 +731,7 @@ void W_Reload(entity actor, float sent_ammo_min, Sound sent_sound) } // 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); -- 2.39.2