From e0734881271f41a4d7ded04b160a9059d7476f33 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 14 Mar 2017 07:31:45 +1000 Subject: [PATCH] Fix buff prediction and use PHYS_HIGHSPEED for the speed modifiers --- .../common/mutators/mutator/buffs/sv_buffs.qc | 28 +++++-------------- qcsrc/common/stats.qh | 2 +- qcsrc/ecs/systems/sv_physics.qc | 2 ++ qcsrc/server/client.qc | 2 ++ qcsrc/server/mutators/events.qh | 6 ++++ 5 files changed, 18 insertions(+), 22 deletions(-) diff --git a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc index f6fedde84..70217365d 100644 --- a/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc +++ b/qcsrc/common/mutators/mutator/buffs/sv_buffs.qc @@ -566,39 +566,25 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerSpawn) player.buff_disability_effect_time = 0; } -.float stat_sv_maxspeed; -.float stat_sv_airspeedlimit_nonqw; -.float stat_sv_jumpvelocity; - -MUTATOR_HOOKFUNCTION(buffs, PlayerPhysics) +MUTATOR_HOOKFUNCTION(buffs, PlayerPhysics_UpdateStats) { entity player = M_ARGV(0, entity); + // these automatically reset, no need to worry if(player.buffs & BUFF_SPEED.m_itemid) - { - player.stat_sv_maxspeed *= autocvar_g_buffs_speed_speed; - player.stat_sv_airspeedlimit_nonqw *= autocvar_g_buffs_speed_speed; - } + STAT(MOVEVARS_HIGHSPEED, player) *= autocvar_g_buffs_speed_speed; if(time < player.buff_disability_time) - { - player.stat_sv_maxspeed *= autocvar_g_buffs_disability_speed; - player.stat_sv_airspeedlimit_nonqw *= autocvar_g_buffs_disability_speed; - } - - if(player.buffs & BUFF_JUMP.m_itemid) - { - // automatically reset, no need to worry - player.stat_sv_jumpvelocity = autocvar_g_buffs_jump_height; - } + STAT(MOVEVARS_HIGHSPEED, player) *= autocvar_g_buffs_disability_speed; } -MUTATOR_HOOKFUNCTION(buffs, PlayerJump) +MUTATOR_HOOKFUNCTION(buffs, PlayerPhysics) { entity player = M_ARGV(0, entity); + // these automatically reset, no need to worry if(player.buffs & BUFF_JUMP.m_itemid) - M_ARGV(1, float) = autocvar_g_buffs_jump_height; + STAT(MOVEVARS_JUMPVELOCITY, player) = autocvar_g_buffs_jump_height; } MUTATOR_HOOKFUNCTION(buffs, MonsterMove) diff --git a/qcsrc/common/stats.qh b/qcsrc/common/stats.qh index 44efee885..cde626a2a 100644 --- a/qcsrc/common/stats.qh +++ b/qcsrc/common/stats.qh @@ -244,7 +244,7 @@ REGISTER_STAT(JETPACK_MAXSPEED_SIDE, float, autocvar_g_jetpack_maxspeed_side) REGISTER_STAT(JETPACK_MAXSPEED_UP, float, autocvar_g_jetpack_maxspeed_up) REGISTER_STAT(JETPACK_REVERSE_THRUST, float, autocvar_g_jetpack_reverse_thrust) -REGISTER_STAT(MOVEVARS_HIGHSPEED, float, autocvar_g_movement_highspeed) +REGISTER_STAT(MOVEVARS_HIGHSPEED, float) #ifdef SVQC AUTOCVAR(g_walljump, bool, false, "Enable wall jumping mutator"); diff --git a/qcsrc/ecs/systems/sv_physics.qc b/qcsrc/ecs/systems/sv_physics.qc index a68d51b8e..9e46dcfc5 100644 --- a/qcsrc/ecs/systems/sv_physics.qc +++ b/qcsrc/ecs/systems/sv_physics.qc @@ -3,6 +3,8 @@ void sys_phys_fix(entity this, float dt) { WarpZone_PlayerPhysics_FixVAngle(this); + STAT(MOVEVARS_HIGHSPEED, this) = autocvar_g_movement_highspeed; + MUTATOR_CALLHOOK(PlayerPhysics_UpdateStats, this); // do it BEFORE the function so we can modify highspeed! Physics_UpdateStats(this, PHYS_HIGHSPEED(this)); } diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index ddbf0fd1c..9d5be4c80 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -1231,6 +1231,8 @@ void ClientConnect(entity this) sv_notice_join(this); // update physics stats (players can spawn before physics runs) + STAT(MOVEVARS_HIGHSPEED, this) = autocvar_g_movement_highspeed; + MUTATOR_CALLHOOK(PlayerPhysics_UpdateStats, this); // do it BEFORE the function so we can modify highspeed! Physics_UpdateStats(this, PHYS_HIGHSPEED(this)); IL_EACH(g_initforplayer, it.init_for_player, { diff --git a/qcsrc/server/mutators/events.qh b/qcsrc/server/mutators/events.qh index b6d31c11a..a347aef39 100644 --- a/qcsrc/server/mutators/events.qh +++ b/qcsrc/server/mutators/events.qh @@ -952,3 +952,9 @@ MUTATOR_HOOKABLE(HideTeamNagger, EV_HideTeamNagger); /** respawn time */ i(float, MUTATOR_ARGV_1_float) \ /**/ MUTATOR_HOOKABLE(Item_ScheduleRespawn, EV_Item_ScheduleRespawn); + +/** called before physics stats are set on a player, allows limited early customization */ +#define EV_PlayerPhysics_UpdateStats(i, o) \ + /** player */ i(entity, MUTATOR_ARGV_0_entity) \ + /**/ +MUTATOR_HOOKABLE(PlayerPhysics_UpdateStats, EV_PlayerPhysics_UpdateStats); -- 2.39.2