From: Mario Date: Mon, 30 Mar 2020 15:13:31 +0000 (+1000) Subject: Add an option for servers to enable opt-in mode for dodging using the cl_dodging... X-Git-Tag: xonotic-v0.8.5~1140 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=26776f5e8860f6630a64e2eae8c52eac54041821;p=xonotic%2Fxonotic-data.pk3dir.git Add an option for servers to enable opt-in mode for dodging using the cl_dodging setting (off by default), allows servers to provide dodging optionally without forcing it on everyone --- diff --git a/mutators.cfg b/mutators.cfg index f3ed5e076..fd69befbb 100644 --- a/mutators.cfg +++ b/mutators.cfg @@ -9,6 +9,7 @@ set g_dodging 0 "set to 1 to enable dodging (quick acceleration in a given direction)" seta cl_dodging_timeout 0.2 "determines how long apart (in seconds) two taps on the same direction key are considered a dodge. use 0 to disable" +seta cl_dodging 0 "enable dodging, requires sv_dodging_clientselect to be enabled on the server" set sv_dodging_air_dodging 0 set sv_dodging_wall_dodging 0 "allow dodging off walls" @@ -27,6 +28,7 @@ set sv_dodging_frozen 0 "allow dodging while frozen" set sv_dodging_frozen_doubletap 0 set sv_dodging_maxspeed 350 "maximum speed a player can be moving at to use the standard dodging from an (almost) standstill" set sv_dodging_air_maxspeed 450 "maximum speed a player can be moving at before they dodge again when air dodging is enabled" +set sv_dodging_clientselect 0 "allow clients to opt-in to dodging movement with the cl_dodging cvar, dodging will be off for clients by default with this enabled" // =========== diff --git a/qcsrc/common/mutators/mutator/dodging/cl_dodging.qh b/qcsrc/common/mutators/mutator/dodging/cl_dodging.qh index 84f77314e..696a2d9e5 100644 --- a/qcsrc/common/mutators/mutator/dodging/cl_dodging.qh +++ b/qcsrc/common/mutators/mutator/dodging/cl_dodging.qh @@ -2,3 +2,6 @@ float cvar_cl_dodging_timeout; REPLICATE(cvar_cl_dodging_timeout, float, "cl_dodging_timeout"); + +float cvar_cl_dodging; +REPLICATE(cvar_cl_dodging, float, "cl_dodging"); diff --git a/qcsrc/common/mutators/mutator/dodging/sv_dodging.qc b/qcsrc/common/mutators/mutator/dodging/sv_dodging.qc index 66d18ac67..3651e9aa0 100644 --- a/qcsrc/common/mutators/mutator/dodging/sv_dodging.qc +++ b/qcsrc/common/mutators/mutator/dodging/sv_dodging.qc @@ -18,6 +18,7 @@ #define PHYS_DODGING_AIR autocvar_sv_dodging_air_dodging #define PHYS_DODGING_MAXSPEED autocvar_sv_dodging_maxspeed #define PHYS_DODGING_AIR_MAXSPEED autocvar_sv_dodging_air_maxspeed +#define PHYS_DODGING_CLIENTSELECT autocvar_sv_dodging_clientselect // we ran out of stats slots! TODO: re-enable this when prediction is available for dodging #if 0 @@ -37,18 +38,24 @@ #define PHYS_DODGING_AIR STAT(DODGING_AIR, this) #define PHYS_DODGING_MAXSPEED STAT(DODGING_MAXSPEED, this) #define PHYS_DODGING_AIR_MAXSPEED STAT(DODGING_AIR_MAXSPEED, this) +#define PHYS_DODGING_CLIENTSELECT STAT(DODGING_CLIENTSELECT, this) #endif #ifdef CSQC float cvar_cl_dodging_timeout; + bool cvar_cl_dodging; + bool autocvar_cl_dodging; #define PHYS_DODGING_FRAMETIME (1 / (frametime <= 0 ? 60 : frametime)) #define PHYS_DODGING_TIMEOUT(s) STAT(DODGING_TIMEOUT) #define PHYS_DODGING_PRESSED_KEYS(s) (s).pressedkeys + #define PHYS_DODGING_ENABLED(s) autocvar_cl_dodging #elif defined(SVQC) .float cvar_cl_dodging_timeout; + .bool cvar_cl_dodging; #define PHYS_DODGING_FRAMETIME sys_frametime #define PHYS_DODGING_TIMEOUT(s) CS(s).cvar_cl_dodging_timeout #define PHYS_DODGING_PRESSED_KEYS(s) CS(s).pressedkeys + #define PHYS_DODGING_ENABLED(s) CS(s).cvar_cl_dodging #endif #ifdef SVQC @@ -214,7 +221,7 @@ void PM_dodging(entity this) if (!this.dodging_action) return; // when swimming or dead, no dodging allowed.. - if (this.waterlevel >= WATERLEVEL_SWIMMING || IS_DEAD(this)) + if (this.waterlevel >= WATERLEVEL_SWIMMING || IS_DEAD(this) || (PHYS_DODGING_CLIENTSELECT && !PHYS_DODGING_ENABLED(this))) { this.dodging_action = 0; this.dodging_direction.x = 0; @@ -299,6 +306,7 @@ MUTATOR_HOOKFUNCTION(dodging, PlayerPhysics) #ifdef SVQC REPLICATE(cvar_cl_dodging_timeout, float, "cl_dodging_timeout"); +REPLICATE(cvar_cl_dodging, bool, "cl_dodging"); MUTATOR_HOOKFUNCTION(dodging, GetPressedKeys) { diff --git a/qcsrc/common/stats.qh b/qcsrc/common/stats.qh index 612e5b6cd..a13d5fcf6 100644 --- a/qcsrc/common/stats.qh +++ b/qcsrc/common/stats.qh @@ -243,6 +243,7 @@ bool autocvar_sv_dodging_wall_dodging; bool autocvar_sv_dodging_air_dodging; float autocvar_sv_dodging_maxspeed; float autocvar_sv_dodging_air_maxspeed; +bool autocvar_sv_dodging_clientselect; #endif #if 0 @@ -262,6 +263,7 @@ REGISTER_STAT(DODGING_WALL, bool, autocvar_sv_dodging_wall_dodging) REGISTER_STAT(DODGING_AIR, bool, autocvar_sv_dodging_air_dodging) REGISTER_STAT(DODGING_MAXSPEED, float, autocvar_sv_dodging_maxspeed) REGISTER_STAT(DODGING_AIR_MAXSPEED, float, autocvar_sv_dodging_air_maxspeed) +REGISTER_STAT(DODGING_CLIENTSELECT, bool, autocvar_sv_dodging_clientselect) #endif /** cvar loopback */ REGISTER_STAT(DODGING_FROZEN, int, autocvar_sv_dodging_frozen) diff --git a/qcsrc/server/client.qh b/qcsrc/server/client.qh index b20a8af93..887a026aa 100644 --- a/qcsrc/server/client.qh +++ b/qcsrc/server/client.qh @@ -141,6 +141,7 @@ CLASS(Client, Object) ATTRIB(Client, autoswitch, bool, this.autoswitch); ATTRIB(Client, cvar_cl_casings, bool, this.cvar_cl_casings); ATTRIB(Client, cvar_cl_dodging_timeout, float, this.cvar_cl_dodging_timeout); + ATTRIB(Client, cvar_cl_dodging, float, this.cvar_cl_dodging); ATTRIB(Client, cvar_cl_multijump, bool, this.cvar_cl_multijump); ATTRIB(Client, cvar_cl_accuracy_data_share, bool, this.cvar_cl_accuracy_data_share); ATTRIB(Client, cvar_cl_accuracy_data_receive, bool, this.cvar_cl_accuracy_data_receive);