From 50d812441af6f8b57db82d99eb883dd2de8cb705 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 10 Jun 2016 18:54:05 +1000 Subject: [PATCH] Cleanse the physics hooks --- .../gamemodes/gamemode/nexball/nexball.qc | 11 +- qcsrc/common/monsters/monster/spider.qc | 14 +-- qcsrc/common/mutators/events.qh | 27 ++--- .../mutators/mutator/bloodloss/bloodloss.qc | 6 +- qcsrc/common/mutators/mutator/buffs/buffs.qc | 30 ++--- .../mutators/mutator/bugrigs/bugrigs.qc | 18 ++- .../mutators/mutator/dodging/dodging.qc | 8 +- .../mutators/mutator/doublejump/doublejump.qc | 14 +-- .../mutators/mutator/instagib/instagib.qc | 8 +- .../mutators/mutator/multijump/multijump.qc | 103 +++++++++--------- qcsrc/common/physics/player.qc | 16 +-- qcsrc/common/weapons/all.qc | 2 +- qcsrc/server/mutators/mutator/gamemode_cts.qc | 64 +++++------ .../mutators/mutator/gamemode_keepaway.qc | 11 +- .../server/mutators/mutator/gamemode_race.qc | 64 +++++------ 15 files changed, 195 insertions(+), 201 deletions(-) diff --git a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc index 110141476d..e624428ec2 100644 --- a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc +++ b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc @@ -1038,13 +1038,14 @@ MUTATOR_HOOKFUNCTION(nb, PlayerSpawn) .float stat_sv_maxspeed; MUTATOR_HOOKFUNCTION(nb, PlayerPhysics) -{SELFPARAM(); - if(self.ballcarried) +{ + entity player = M_ARGV(0, entity); + + if(player.ballcarried) { - self.stat_sv_airspeedlimit_nonqw *= autocvar_g_nexball_basketball_carrier_highspeed; - self.stat_sv_maxspeed *= autocvar_g_nexball_basketball_carrier_highspeed; + player.stat_sv_airspeedlimit_nonqw *= autocvar_g_nexball_basketball_carrier_highspeed; + player.stat_sv_maxspeed *= autocvar_g_nexball_basketball_carrier_highspeed; } - return false; } MUTATOR_HOOKFUNCTION(nb, ForbidThrowCurrentWeapon) diff --git a/qcsrc/common/monsters/monster/spider.qc b/qcsrc/common/monsters/monster/spider.qc index 6ec111b1f7..ba899548b6 100644 --- a/qcsrc/common/monsters/monster/spider.qc +++ b/qcsrc/common/monsters/monster/spider.qc @@ -56,14 +56,14 @@ REGISTER_MUTATOR(spiderweb, true); MUTATOR_HOOKFUNCTION(spiderweb, PlayerPhysics) { - SELFPARAM(); - if (time >= this.spider_slowness) + entity player = M_ARGV(0, entity); + + if (time >= player.spider_slowness) return false; - PHYS_MAXSPEED(this) *= 0.5; // half speed while slow from spider - PHYS_MAXAIRSPEED(this) *= 0.5; - PHYS_AIRSPEEDLIMIT_NONQW(this) *= 0.5; - PHYS_AIRSTRAFEACCELERATE(this) *= 0.5; - return false; + PHYS_MAXSPEED(player) *= 0.5; // half speed while slow from spider + PHYS_MAXAIRSPEED(player) *= 0.5; + PHYS_AIRSPEEDLIMIT_NONQW(player) *= 0.5; + PHYS_AIRSTRAFEACCELERATE(player) *= 0.5; } MUTATOR_HOOKFUNCTION(spiderweb, MonsterMove) diff --git a/qcsrc/common/mutators/events.qh b/qcsrc/common/mutators/events.qh index 69e077e350..75fc8d31e1 100644 --- a/qcsrc/common/mutators/events.qh +++ b/qcsrc/common/mutators/events.qh @@ -74,38 +74,33 @@ MUTATOR_HOOKABLE(WP_Format, EV_WP_Format); * is run AFTER bot code and idle checking on the server */ #define EV_PlayerPhysics(i, o) \ - /**/ i(entity, __self) \ + /** player */ i(entity, MUTATOR_ARGV_0_entity) \ /**/ MUTATOR_HOOKABLE(PlayerPhysics, EV_PlayerPhysics); /** called when a player presses the jump key */ #define EV_PlayerJump(i, o) \ - /**/ i(entity, __self) \ - /**/ i(float, player_multijump) \ - /**/ i(float, player_jumpheight) \ - /**/ o(float, player_multijump) \ - /**/ o(float, player_jumpheight) \ + /** player */ i(entity, MUTATOR_ARGV_0_entity) \ + /** jump height */ i(float, MUTATOR_ARGV_1_float) \ + /**/ o(float, MUTATOR_ARGV_1_float) \ + /** multijump */ i(bool, MUTATOR_ARGV_2_bool) \ + /**/ o(bool, MUTATOR_ARGV_2_bool) \ /**/ -float player_multijump; -float player_jumpheight; MUTATOR_HOOKABLE(PlayerJump, EV_PlayerJump); /** called during player physics, allows adjusting the movement type used */ #define EV_PM_Physics(i, o) \ - /**/ i(entity, __self) \ - /**/ i(float, pm_maxspeed_mod) \ + /** player */ i(entity, MUTATOR_ARGV_0_entity) \ + /** maxspeed_mod */ i(float, MUTATOR_ARGV_1_float) \ /**/ -float pm_maxspeed_mod; MUTATOR_HOOKABLE(PM_Physics, EV_PM_Physics); /** called when a weapon model is about to be set, allows custom paths etc. */ #define EV_WeaponModel(i, o) \ - /**/ i(string, weapon_model) \ - /**/ i(string, weapon_model_output) \ - /**/ o(string, weapon_model_output) \ + /** model */ i(string, MUTATOR_ARGV_0_string) \ + /** output */ i(string, MUTATOR_ARGV_1_string) \ + /**/ o(string, MUTATOR_ARGV_1_string) \ /**/ -string weapon_model; -string weapon_model_output; MUTATOR_HOOKABLE(WeaponModel, EV_WeaponModel); #endif diff --git a/qcsrc/common/mutators/mutator/bloodloss/bloodloss.qc b/qcsrc/common/mutators/mutator/bloodloss/bloodloss.qc index cdef3d9531..4cbdfcfb7b 100644 --- a/qcsrc/common/mutators/mutator/bloodloss/bloodloss.qc +++ b/qcsrc/common/mutators/mutator/bloodloss/bloodloss.qc @@ -24,8 +24,10 @@ MUTATOR_HOOKFUNCTION(bloodloss, PlayerPreThink) } MUTATOR_HOOKFUNCTION(bloodloss, PlayerJump) -{SELFPARAM(); - if(self.health <= autocvar_g_bloodloss) +{ + entity player = M_ARGV(0, entity); + + if(player.health <= autocvar_g_bloodloss) return true; return false; diff --git a/qcsrc/common/mutators/mutator/buffs/buffs.qc b/qcsrc/common/mutators/mutator/buffs/buffs.qc index 492c657d87..78ced032d8 100644 --- a/qcsrc/common/mutators/mutator/buffs/buffs.qc +++ b/qcsrc/common/mutators/mutator/buffs/buffs.qc @@ -640,34 +640,34 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerSpawn) .float stat_sv_jumpvelocity; MUTATOR_HOOKFUNCTION(buffs, PlayerPhysics) -{SELFPARAM(); - if(self.buffs & BUFF_SPEED.m_itemid) +{ + entity player = M_ARGV(0, entity); + + if(player.buffs & BUFF_SPEED.m_itemid) { - self.stat_sv_maxspeed *= autocvar_g_buffs_speed_speed; - self.stat_sv_airspeedlimit_nonqw *= autocvar_g_buffs_speed_speed; + player.stat_sv_maxspeed *= autocvar_g_buffs_speed_speed; + player.stat_sv_airspeedlimit_nonqw *= autocvar_g_buffs_speed_speed; } - if(time < self.buff_disability_time) + if(time < player.buff_disability_time) { - self.stat_sv_maxspeed *= autocvar_g_buffs_disability_speed; - self.stat_sv_airspeedlimit_nonqw *= autocvar_g_buffs_disability_speed; + player.stat_sv_maxspeed *= autocvar_g_buffs_disability_speed; + player.stat_sv_airspeedlimit_nonqw *= autocvar_g_buffs_disability_speed; } - if(self.buffs & BUFF_JUMP.m_itemid) + if(player.buffs & BUFF_JUMP.m_itemid) { // automatically reset, no need to worry - self.stat_sv_jumpvelocity = autocvar_g_buffs_jump_height; + player.stat_sv_jumpvelocity = autocvar_g_buffs_jump_height; } - - return false; } MUTATOR_HOOKFUNCTION(buffs, PlayerJump) -{SELFPARAM(); - if(self.buffs & BUFF_JUMP.m_itemid) - player_jumpheight = autocvar_g_buffs_jump_height; +{ + entity player = M_ARGV(0, entity); - return false; + if(player.buffs & BUFF_JUMP.m_itemid) + M_ARGV(1, float) = autocvar_g_buffs_jump_height; } MUTATOR_HOOKFUNCTION(buffs, MonsterMove) diff --git a/qcsrc/common/mutators/mutator/bugrigs/bugrigs.qc b/qcsrc/common/mutators/mutator/bugrigs/bugrigs.qc index 7d7ba39397..df25ad4c59 100644 --- a/qcsrc/common/mutators/mutator/bugrigs/bugrigs.qc +++ b/qcsrc/common/mutators/mutator/bugrigs/bugrigs.qc @@ -271,27 +271,25 @@ void RaceCarPhysics(entity this) #endif MUTATOR_HOOKFUNCTION(bugrigs, PM_Physics) { - SELFPARAM(); - if(!PHYS_BUGRIGS(self) || !IS_PLAYER(self)) { return false; } + entity player = M_ARGV(0, entity); + + if(!PHYS_BUGRIGS(player) || !IS_PLAYER(player)) { return false; } #ifdef SVQC - self.angles = self.bugrigs_prevangles; + player.angles = player.bugrigs_prevangles; #endif - RaceCarPhysics(self); + RaceCarPhysics(player); return true; } MUTATOR_HOOKFUNCTION(bugrigs, PlayerPhysics) { + if(!PHYS_BUGRIGS(M_ARGV(0, entity))) { return false; } #ifdef SVQC - SELFPARAM(); + entity player = M_ARGV(0, entity); + player.bugrigs_prevangles = player.angles; #endif - if(!PHYS_BUGRIGS(self)) { return false; } -#ifdef SVQC - self.bugrigs_prevangles = self.angles; -#endif - return false; } #ifdef SVQC diff --git a/qcsrc/common/mutators/mutator/dodging/dodging.qc b/qcsrc/common/mutators/mutator/dodging/dodging.qc index 8e2ece0835..98ebe9c986 100644 --- a/qcsrc/common/mutators/mutator/dodging/dodging.qc +++ b/qcsrc/common/mutators/mutator/dodging/dodging.qc @@ -267,11 +267,11 @@ void PM_dodging_GetPressedKeys(entity this) MUTATOR_HOOKFUNCTION(dodging, PlayerPhysics) { - SELFPARAM(); + entity player = M_ARGV(0, entity); + // print("dodging_PlayerPhysics\n"); - PM_dodging_GetPressedKeys(self); - PM_dodging(self); - return false; + PM_dodging_GetPressedKeys(player); + PM_dodging(player); } #ifdef SVQC diff --git a/qcsrc/common/mutators/mutator/doublejump/doublejump.qc b/qcsrc/common/mutators/mutator/doublejump/doublejump.qc index 144e87ae8e..d490ecaaff 100644 --- a/qcsrc/common/mutators/mutator/doublejump/doublejump.qc +++ b/qcsrc/common/mutators/mutator/doublejump/doublejump.qc @@ -15,21 +15,21 @@ REGISTER_MUTATOR(doublejump, true); MUTATOR_HOOKFUNCTION(doublejump, PlayerJump) { - SELFPARAM(); - if (PHYS_DOUBLEJUMP(self)) + entity player = M_ARGV(0, entity); + + if (PHYS_DOUBLEJUMP(player)) { - tracebox(self.origin + '0 0 0.01', self.mins, self.maxs, self.origin - '0 0 0.01', MOVE_NORMAL, self); + tracebox(player.origin + '0 0 0.01', player.mins, player.maxs, player.origin - '0 0 0.01', MOVE_NORMAL, player); if (trace_fraction < 1 && trace_plane_normal_z > 0.7) { - player_multijump = true; + M_ARGV(2, bool) = true; // we MUST clip velocity here! - float f = self.velocity * trace_plane_normal; + float f = player.velocity * trace_plane_normal; if (f < 0) - self.velocity -= f * trace_plane_normal; + player.velocity -= f * trace_plane_normal; } } - return false; } #endif diff --git a/qcsrc/common/mutators/mutator/instagib/instagib.qc b/qcsrc/common/mutators/mutator/instagib/instagib.qc index 57afc84a19..ef1856d688 100644 --- a/qcsrc/common/mutators/mutator/instagib/instagib.qc +++ b/qcsrc/common/mutators/mutator/instagib/instagib.qc @@ -252,11 +252,11 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerPowerups) .float stat_sv_maxspeed; MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerPhysics) -{SELFPARAM(); - if(self.items & ITEM_Speed.m_itemid) - self.stat_sv_maxspeed = self.stat_sv_maxspeed * autocvar_g_instagib_speed_highspeed; +{ + entity player = M_ARGV(0, entity); - return false; + if(player.items & ITEM_Speed.m_itemid) + player.stat_sv_maxspeed = player.stat_sv_maxspeed * autocvar_g_instagib_speed_highspeed; } MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerDamage_SplitHealthArmor) diff --git a/qcsrc/common/mutators/mutator/multijump/multijump.qc b/qcsrc/common/mutators/mutator/multijump/multijump.qc index 8cd137252e..cafe5255f1 100644 --- a/qcsrc/common/mutators/mutator/multijump/multijump.qc +++ b/qcsrc/common/mutators/mutator/multijump/multijump.qc @@ -11,12 +11,12 @@ REGISTER_MUTATOR(multijump, cvar("g_multijump")); REGISTER_MUTATOR(multijump, true); #endif -#define PHYS_MULTIJUMP STAT(MULTIJUMP, self) -#define PHYS_MULTIJUMP_SPEED STAT(MULTIJUMP_SPEED, self) -#define PHYS_MULTIJUMP_ADD STAT(MULTIJUMP_ADD, self) -#define PHYS_MULTIJUMP_MAXSPEED STAT(MULTIJUMP_MAXSPEED, self) -#define PHYS_MULTIJUMP_DODGING STAT(MULTIJUMP_DODGING, self) -#define PHYS_MULTIJUMP_COUNT(s) STAT(MULTIJUMP_COUNT, s) +#define PHYS_MULTIJUMP(s) STAT(MULTIJUMP, s) +#define PHYS_MULTIJUMP_SPEED(s) STAT(MULTIJUMP_SPEED, s) +#define PHYS_MULTIJUMP_ADD(s) STAT(MULTIJUMP_ADD, s) +#define PHYS_MULTIJUMP_MAXSPEED(s) STAT(MULTIJUMP_MAXSPEED, s) +#define PHYS_MULTIJUMP_DODGING(s) STAT(MULTIJUMP_DODGING, s) +#define PHYS_MULTIJUMP_COUNT(s) STAT(MULTIJUMP_COUNT, s) .bool multijump_ready; @@ -30,90 +30,85 @@ bool autocvar_cl_multijump = true; #define PHYS_MULTIJUMP_CLIENT(s) (s).cvar_cl_multijump #endif -bool PM_multijump_checkjump(entity this) +MUTATOR_HOOKFUNCTION(multijump, PlayerPhysics) { - if(!PHYS_MULTIJUMP) { return false; } + entity player = M_ARGV(0, entity); + +#ifdef CSQC + player.multijump_count = PHYS_MULTIJUMP_COUNT(player); +#endif + if(!PHYS_MULTIJUMP(player)) { return; } + + if(IS_ONGROUND(player)) + player.multijump_count = 0; +} - int client_multijump = PHYS_MULTIJUMP_CLIENT(this); +MUTATOR_HOOKFUNCTION(multijump, PlayerJump) +{ + entity player = M_ARGV(0, entity); + + if(!PHYS_MULTIJUMP(player)) { return false; } + + int client_multijump = PHYS_MULTIJUMP_CLIENT(player); if(client_multijump > 1) return false; // nope - if (!IS_JUMP_HELD(this) && !IS_ONGROUND(this) && client_multijump) // jump button pressed this frame and we are in midair - this.multijump_ready = true; // this is necessary to check that we released the jump button and pressed it again + if (!IS_JUMP_HELD(player) && !IS_ONGROUND(player) && client_multijump) // jump button pressed this frame and we are in midair + player.multijump_ready = true; // this is necessary to check that we released the jump button and pressed it again else - this.multijump_ready = false; + player.multijump_ready = false; - int phys_multijump = PHYS_MULTIJUMP; + int phys_multijump = PHYS_MULTIJUMP(player); - if(!player_multijump && this.multijump_ready && (PHYS_MULTIJUMP_COUNT(this) < phys_multijump || phys_multijump == -1) && this.velocity_z > PHYS_MULTIJUMP_SPEED && (!PHYS_MULTIJUMP_MAXSPEED || vlen(this.velocity) <= PHYS_MULTIJUMP_MAXSPEED)) + if(!M_ARGV(2, bool) && player.multijump_ready && (PHYS_MULTIJUMP_COUNT(player) < phys_multijump || phys_multijump == -1) && player.velocity_z > PHYS_MULTIJUMP_SPEED(player) && + (!PHYS_MULTIJUMP_MAXSPEED(player) || vdist(player.velocity, <=, PHYS_MULTIJUMP_MAXSPEED(player)))) { - if (PHYS_MULTIJUMP) + if (PHYS_MULTIJUMP(player)) { - if (!PHYS_MULTIJUMP_ADD) // in this case we make the z velocity == jumpvelocity + if (!PHYS_MULTIJUMP_ADD(player)) // in this case we make the z velocity == jumpvelocity { - if (this.velocity_z < PHYS_JUMPVELOCITY(this)) + if (player.velocity_z < PHYS_JUMPVELOCITY(player)) { - player_multijump = true; - this.velocity_z = 0; + M_ARGV(2, bool) = true; + player.velocity_z = 0; } } else - player_multijump = true; + M_ARGV(2, bool) = true; - if(player_multijump) + if(M_ARGV(2, bool)) { - if(PHYS_MULTIJUMP_DODGING) - if(this.movement_x != 0 || this.movement_y != 0) // don't remove all speed if player isnt pressing any movement keys + if(PHYS_MULTIJUMP_DODGING(player)) + if(player.movement_x != 0 || player.movement_y != 0) // don't remove all speed if player isnt pressing any movement keys { float curspeed; vector wishvel, wishdir; /*#ifdef SVQC curspeed = max( - vlen(vec2(this.velocity)), // current xy speed - vlen(vec2(antilag_takebackavgvelocity(this, max(this.lastteleporttime + sys_frametime, time - 0.25), time))) // average xy topspeed over the last 0.25 secs + vlen(vec2(player.velocity)), // current xy speed + vlen(vec2(antilag_takebackavgvelocity(player, max(player.lastteleporttime + sys_frametime, time - 0.25), time))) // average xy topspeed over the last 0.25 secs ); #elif defined(CSQC)*/ - curspeed = vlen(vec2(this.velocity)); + curspeed = vlen(vec2(player.velocity)); //#endif - makevectors(this.v_angle_y * '0 1 0'); - wishvel = v_forward * this.movement_x + v_right * this.movement_y; + makevectors(player.v_angle_y * '0 1 0'); + wishvel = v_forward * player.movement_x + v_right * player.movement_y; wishdir = normalize(wishvel); - this.velocity_x = wishdir_x * curspeed; // allow "dodging" at a multijump - this.velocity_y = wishdir_y * curspeed; + player.velocity_x = wishdir_x * curspeed; // allow "dodging" at a multijump + player.velocity_y = wishdir_y * curspeed; // keep velocity_z unchanged! } - if (PHYS_MULTIJUMP > 0) + if (PHYS_MULTIJUMP(player) > 0) { - this.multijump_count += 1; + player.multijump_count += 1; } } } - this.multijump_ready = false; // require releasing and pressing the jump button again for the next jump + player.multijump_ready = false; // require releasing and pressing the jump button again for the next jump } - - return false; -} - -MUTATOR_HOOKFUNCTION(multijump, PlayerPhysics) -{ - SELFPARAM(); -#ifdef CSQC - this.multijump_count = PHYS_MULTIJUMP_COUNT(this); -#endif - if(!PHYS_MULTIJUMP) { return; } - - if(IS_ONGROUND(this)) - this.multijump_count = 0; - return false; -} - -MUTATOR_HOOKFUNCTION(multijump, PlayerJump) -{ - SELFPARAM(); - return PM_multijump_checkjump(this); } #ifdef SVQC diff --git a/qcsrc/common/physics/player.qc b/qcsrc/common/physics/player.qc index e59dc306e3..285b2cb7f9 100644 --- a/qcsrc/common/physics/player.qc +++ b/qcsrc/common/physics/player.qc @@ -452,11 +452,11 @@ bool PlayerJump(entity this) bool doublejump = false; float mjumpheight = PHYS_JUMPVELOCITY(this); - if (MUTATOR_CALLHOOK(PlayerJump, this, doublejump, mjumpheight)) + if (MUTATOR_CALLHOOK(PlayerJump, this, mjumpheight, doublejump)) return true; - doublejump = player_multijump; - mjumpheight = player_jumpheight; + mjumpheight = M_ARGV(1, float); + doublejump = M_ARGV(2, bool); if (this.waterlevel >= WATERLEVEL_SWIMMING) { @@ -587,16 +587,18 @@ void CheckWaterJump(entity this) void CheckPlayerJump(entity this) { #ifdef SVQC - float was_flying = ITEMS_STAT(this) & IT_USING_JETPACK; + bool was_flying = boolean(ITEMS_STAT(this) & IT_USING_JETPACK); #endif if (JETPACK_JUMP(this) < 2) ITEMS_STAT(this) &= ~IT_USING_JETPACK; if(PHYS_INPUT_BUTTON_JUMP(this) || PHYS_INPUT_BUTTON_JETPACK(this)) { - float air_jump = !PlayerJump(this) || player_multijump; // PlayerJump() has important side effects - float activate = JETPACK_JUMP(this) && air_jump && PHYS_INPUT_BUTTON_JUMP(this) || PHYS_INPUT_BUTTON_JETPACK(this); - float has_fuel = !PHYS_JETPACK_FUEL(this) || PHYS_AMMO_FUEL(this) || (ITEMS_STAT(this) & IT_UNLIMITED_WEAPON_AMMO); + bool playerjump = PlayerJump(this); // required + + bool air_jump = !playerjump || M_ARGV(2, bool); + bool activate = JETPACK_JUMP(this) && air_jump && PHYS_INPUT_BUTTON_JUMP(this) || PHYS_INPUT_BUTTON_JETPACK(this); + bool has_fuel = !PHYS_JETPACK_FUEL(this) || PHYS_AMMO_FUEL(this) || (ITEMS_STAT(this) & IT_UNLIMITED_WEAPON_AMMO); if (!(ITEMS_STAT(this) & ITEM_Jetpack.m_itemid)) { } else if (this.jetpack_stopped) { } diff --git a/qcsrc/common/weapons/all.qc b/qcsrc/common/weapons/all.qc index 1e1ce3eede..65168e13a3 100644 --- a/qcsrc/common/weapons/all.qc +++ b/qcsrc/common/weapons/all.qc @@ -272,7 +272,7 @@ string W_Model(string w_mdl) { string output = strcat("models/weapons/", w_mdl); MUTATOR_CALLHOOK(WeaponModel, w_mdl, output); - return weapon_model_output; + return M_ARGV(1, string); } #ifndef MENUQC diff --git a/qcsrc/server/mutators/mutator/gamemode_cts.qc b/qcsrc/server/mutators/mutator/gamemode_cts.qc index 9079a2f600..5f2a7eeedc 100644 --- a/qcsrc/server/mutators/mutator/gamemode_cts.qc +++ b/qcsrc/server/mutators/mutator/gamemode_cts.qc @@ -109,24 +109,26 @@ void CTS_ClientKill(entity e) // silent version of ClientKill, used when player } MUTATOR_HOOKFUNCTION(cts, PlayerPhysics) -{SELFPARAM(); - self.race_movetime_frac += PHYS_INPUT_TIMELENGTH; - float f = floor(self.race_movetime_frac); - self.race_movetime_frac -= f; - self.race_movetime_count += f; - self.race_movetime = self.race_movetime_frac + self.race_movetime_count; +{ + entity player = M_ARGV(0, entity); + + player.race_movetime_frac += PHYS_INPUT_TIMELENGTH; + float f = floor(player.race_movetime_frac); + player.race_movetime_frac -= f; + player.race_movetime_count += f; + player.race_movetime = player.race_movetime_frac + player.race_movetime_count; #ifdef SVQC - if(IS_PLAYER(self)) + if(IS_PLAYER(player)) { - if (self.race_penalty) - if (time > self.race_penalty) - self.race_penalty = 0; - if(self.race_penalty) + if (player.race_penalty) + if (time > player.race_penalty) + player.race_penalty = 0; + if(player.race_penalty) { - self.velocity = '0 0 0'; - self.movetype = MOVETYPE_NONE; - self.disableclientprediction = 2; + player.velocity = '0 0 0'; + player.movetype = MOVETYPE_NONE; + player.disableclientprediction = 2; } } #endif @@ -139,8 +141,8 @@ MUTATOR_HOOKFUNCTION(cts, PlayerPhysics) // ensure nothing EVIL is being done (i.e. div0_evade) // this hinders joystick users though // but it still gives SOME analog control - wishvel.x = fabs(self.movement.x); - wishvel.y = fabs(self.movement.y); + wishvel.x = fabs(player.movement.x); + wishvel.y = fabs(player.movement.y); if(wishvel.x != 0 && wishvel.y != 0 && wishvel.x != wishvel.y) { wishvel.z = 0; @@ -148,36 +150,34 @@ MUTATOR_HOOKFUNCTION(cts, PlayerPhysics) if(wishvel.x >= 2 * wishvel.y) { // pure X motion - if(self.movement.x > 0) - self.movement_x = wishspeed; + if(player.movement.x > 0) + player.movement_x = wishspeed; else - self.movement_x = -wishspeed; - self.movement_y = 0; + player.movement_x = -wishspeed; + player.movement_y = 0; } else if(wishvel.y >= 2 * wishvel.x) { // pure Y motion - self.movement_x = 0; - if(self.movement.y > 0) - self.movement_y = wishspeed; + player.movement_x = 0; + if(player.movement.y > 0) + player.movement_y = wishspeed; else - self.movement_y = -wishspeed; + player.movement_y = -wishspeed; } else { // diagonal - if(self.movement.x > 0) - self.movement_x = M_SQRT1_2 * wishspeed; + if(player.movement.x > 0) + player.movement_x = M_SQRT1_2 * wishspeed; else - self.movement_x = -M_SQRT1_2 * wishspeed; - if(self.movement.y > 0) - self.movement_y = M_SQRT1_2 * wishspeed; + player.movement_x = -M_SQRT1_2 * wishspeed; + if(player.movement.y > 0) + player.movement_y = M_SQRT1_2 * wishspeed; else - self.movement_y = -M_SQRT1_2 * wishspeed; + player.movement_y = -M_SQRT1_2 * wishspeed; } } - - return false; } MUTATOR_HOOKFUNCTION(cts, reset_map_global) diff --git a/qcsrc/server/mutators/mutator/gamemode_keepaway.qc b/qcsrc/server/mutators/mutator/gamemode_keepaway.qc index f93ddfefc3..7af44fcc15 100644 --- a/qcsrc/server/mutators/mutator/gamemode_keepaway.qc +++ b/qcsrc/server/mutators/mutator/gamemode_keepaway.qc @@ -439,13 +439,14 @@ MUTATOR_HOOKFUNCTION(ka, PlayerPowerups) .float stat_sv_maxspeed; MUTATOR_HOOKFUNCTION(ka, PlayerPhysics) -{SELFPARAM(); - if(self.ballcarried) +{ + entity player = M_ARGV(0, entity); + + if(player.ballcarried) { - self.stat_sv_airspeedlimit_nonqw *= autocvar_g_keepaway_ballcarrier_highspeed; - self.stat_sv_maxspeed *= autocvar_g_keepaway_ballcarrier_highspeed; + player.stat_sv_airspeedlimit_nonqw *= autocvar_g_keepaway_ballcarrier_highspeed; + player.stat_sv_maxspeed *= autocvar_g_keepaway_ballcarrier_highspeed; } - return false; } MUTATOR_HOOKFUNCTION(ka, BotShouldAttack) diff --git a/qcsrc/server/mutators/mutator/gamemode_race.qc b/qcsrc/server/mutators/mutator/gamemode_race.qc index 8d5cbe9da9..2b68bf6d38 100644 --- a/qcsrc/server/mutators/mutator/gamemode_race.qc +++ b/qcsrc/server/mutators/mutator/gamemode_race.qc @@ -141,24 +141,26 @@ float WinningCondition_QualifyingThenRace(float limit) } MUTATOR_HOOKFUNCTION(rc, PlayerPhysics) -{SELFPARAM(); - self.race_movetime_frac += PHYS_INPUT_TIMELENGTH; - float f = floor(self.race_movetime_frac); - self.race_movetime_frac -= f; - self.race_movetime_count += f; - self.race_movetime = self.race_movetime_frac + self.race_movetime_count; +{ + entity player = M_ARGV(0, entity); + + player.race_movetime_frac += PHYS_INPUT_TIMELENGTH; + float f = floor(player.race_movetime_frac); + player.race_movetime_frac -= f; + player.race_movetime_count += f; + player.race_movetime = player.race_movetime_frac + player.race_movetime_count; #ifdef SVQC - if(IS_PLAYER(self)) + if(IS_PLAYER(player)) { - if (self.race_penalty) - if (time > self.race_penalty) - self.race_penalty = 0; - if(self.race_penalty) + if (player.race_penalty) + if (time > player.race_penalty) + player.race_penalty = 0; + if(player.race_penalty) { - self.velocity = '0 0 0'; - self.movetype = MOVETYPE_NONE; - self.disableclientprediction = 2; + player.velocity = '0 0 0'; + player.movetype = MOVETYPE_NONE; + player.disableclientprediction = 2; } } #endif @@ -171,8 +173,8 @@ MUTATOR_HOOKFUNCTION(rc, PlayerPhysics) // ensure nothing EVIL is being done (i.e. div0_evade) // this hinders joystick users though // but it still gives SOME analog control - wishvel.x = fabs(self.movement.x); - wishvel.y = fabs(self.movement.y); + wishvel.x = fabs(player.movement.x); + wishvel.y = fabs(player.movement.y); if(wishvel.x != 0 && wishvel.y != 0 && wishvel.x != wishvel.y) { wishvel.z = 0; @@ -180,36 +182,34 @@ MUTATOR_HOOKFUNCTION(rc, PlayerPhysics) if(wishvel.x >= 2 * wishvel.y) { // pure X motion - if(self.movement.x > 0) - self.movement_x = wishspeed; + if(player.movement.x > 0) + player.movement_x = wishspeed; else - self.movement_x = -wishspeed; - self.movement_y = 0; + player.movement_x = -wishspeed; + player.movement_y = 0; } else if(wishvel.y >= 2 * wishvel.x) { // pure Y motion - self.movement_x = 0; - if(self.movement.y > 0) - self.movement_y = wishspeed; + player.movement_x = 0; + if(player.movement.y > 0) + player.movement_y = wishspeed; else - self.movement_y = -wishspeed; + player.movement_y = -wishspeed; } else { // diagonal - if(self.movement.x > 0) - self.movement_x = M_SQRT1_2 * wishspeed; + if(player.movement.x > 0) + player.movement_x = M_SQRT1_2 * wishspeed; else - self.movement_x = -M_SQRT1_2 * wishspeed; - if(self.movement.y > 0) - self.movement_y = M_SQRT1_2 * wishspeed; + player.movement_x = -M_SQRT1_2 * wishspeed; + if(player.movement.y > 0) + player.movement_y = M_SQRT1_2 * wishspeed; else - self.movement_y = -M_SQRT1_2 * wishspeed; + player.movement_y = -M_SQRT1_2 * wishspeed; } } - - return false; } MUTATOR_HOOKFUNCTION(rc, reset_map_global) -- 2.39.2