From f811435225e85771e1f4a1dcde2b39a44c7d884c Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 24 Nov 2015 00:54:45 +1000 Subject: [PATCH] Decouple doublejump --- qcsrc/common/mutators/all.inc | 1 + .../mutators/mutator/dodging/dodging.qc | 4 - .../mutators/mutator/doublejump/doublejump.qc | 90 +++++++++++++++++++ .../mutators/mutator/doublejump/module.inc | 3 + qcsrc/common/physics.qc | 24 ----- qcsrc/common/physics.qh | 6 -- qcsrc/server/autocvars.qh | 1 - 7 files changed, 94 insertions(+), 35 deletions(-) create mode 100644 qcsrc/common/mutators/mutator/doublejump/doublejump.qc create mode 100644 qcsrc/common/mutators/mutator/doublejump/module.inc diff --git a/qcsrc/common/mutators/all.inc b/qcsrc/common/mutators/all.inc index b7d5b4495..e99092c66 100644 --- a/qcsrc/common/mutators/all.inc +++ b/qcsrc/common/mutators/all.inc @@ -15,6 +15,7 @@ #include "mutator/cloaked/module.inc" #include "mutator/damagetext/module.inc" #include "mutator/dodging/module.inc" +#include "mutator/doublejump/module.inc" #include "mutator/hook/module.inc" #include "mutator/instagib/module.inc" #include "mutator/invincibleproj/module.inc" diff --git a/qcsrc/common/mutators/mutator/dodging/dodging.qc b/qcsrc/common/mutators/mutator/dodging/dodging.qc index b2140bbfc..327f78b1d 100644 --- a/qcsrc/common/mutators/mutator/dodging/dodging.qc +++ b/qcsrc/common/mutators/mutator/dodging/dodging.qc @@ -285,10 +285,6 @@ void PM_dodging(entity this) this.velocity += PHYS_DODGING_UP_SPEED * v_up; - #ifdef CSQC - LOG_INFO("YES?!\n"); - #endif - #ifdef SVQC if (autocvar_sv_dodging_sound) PlayerSound(playersound_jump, CH_PLAYER, VOICETYPE_PLAYERSOUND); diff --git a/qcsrc/common/mutators/mutator/doublejump/doublejump.qc b/qcsrc/common/mutators/mutator/doublejump/doublejump.qc new file mode 100644 index 000000000..a2bd9ca0c --- /dev/null +++ b/qcsrc/common/mutators/mutator/doublejump/doublejump.qc @@ -0,0 +1,90 @@ +#ifdef IMPLEMENTATION +#ifdef SVQC + #include "../../../../server/antilag.qh" +#endif +#include "../../../physics.qh" + + +#if defined(SVQC) +void doublejump_AddStats(); + +REGISTER_MUTATOR(doublejump, true) +{ + MUTATOR_ONADD + { + doublejump_AddStats(); + } + return false; +} +#elif defined(CSQC) +REGISTER_MUTATOR(doublejump, true); +#endif + + +#ifdef CSQC + +#define PHYS_DOUBLEJUMP getstati(STAT_DOUBLEJUMP) + +#elif defined(SVQC) + +bool autocvar_sv_doublejump; + +#define PHYS_DOUBLEJUMP autocvar_sv_doublejump + +.int stat_doublejump; + +void doublejump_UpdateStats(entity this) +{ + this.stat_doublejump = PHYS_DOUBLEJUMP; +} + +void doublejump_AddStats() +{ + addstat(STAT_DOUBLEJUMP, AS_INT, stat_doublejump); +} + +#endif + + +MUTATOR_HOOKFUNCTION(doublejump, PlayerJump) +{ + if (PHYS_DOUBLEJUMP) + { + tracebox(self.origin + '0 0 0.01', self.mins, self.maxs, self.origin - '0 0 0.01', MOVE_NORMAL, self); + if (trace_fraction < 1 && trace_plane_normal_z > 0.7) + { + player_multijump = true; + + // we MUST clip velocity here! + float f = self.velocity * trace_plane_normal; + if (f < 0) + self.velocity -= f * trace_plane_normal; + } + } + return false; +} + +MUTATOR_HOOKFUNCTION(doublejump, PlayerPhysics) +{ +#ifdef SVQC + doublejump_UpdateStats(self); +#endif + return false; +} + +#ifdef SVQC + +MUTATOR_HOOKFUNCTION(doublejump, BuildMutatorsString) +{ + ret_string = strcat(ret_string, ":doublejump"); + return false; +} + +MUTATOR_HOOKFUNCTION(doublejump, BuildMutatorsPrettyString) +{ + ret_string = strcat(ret_string, ", Double jump"); + return false; +} + +#endif +#endif diff --git a/qcsrc/common/mutators/mutator/doublejump/module.inc b/qcsrc/common/mutators/mutator/doublejump/module.inc new file mode 100644 index 000000000..f4c695be0 --- /dev/null +++ b/qcsrc/common/mutators/mutator/doublejump/module.inc @@ -0,0 +1,3 @@ +#ifndef MENUQC +#include "doublejump.qc" +#endif diff --git a/qcsrc/common/physics.qc b/qcsrc/common/physics.qc index 6c81fe273..928440d9c 100644 --- a/qcsrc/common/physics.qc +++ b/qcsrc/common/physics.qc @@ -73,9 +73,6 @@ void Physics_AddStats() addstat(STAT_MOVEVARS_CL_TRACK_CANJUMP, AS_INT, cvar_cl_movement_track_canjump); addstat(STAT_MOVEVARS_TRACK_CANJUMP, AS_INT, stat_sv_track_canjump); - // double jump - addstat(STAT_DOUBLEJUMP, AS_INT, stat_doublejump); - // jump speed caps addstat(STAT_MOVEVARS_JUMPSPEEDCAP_DISABLE_ONRAMPS, AS_INT, stat_jumpspeedcap_disable_onramps); @@ -129,8 +126,6 @@ void Physics_UpdateStats(float maxspd_mod) self.stat_sv_maxspeed = Physics_ClientOption(self, "maxspeed") * maxspd_mod; // also slow walking self.stat_movement_highspeed = PHYS_HIGHSPEED; // TODO: remove this! - self.stat_doublejump = PHYS_DOUBLEJUMP; - self.stat_jetpack_antigravity = PHYS_JETPACK_ANTIGRAVITY; self.stat_jetpack_accel_up = PHYS_JETPACK_ACCEL_UP; self.stat_jetpack_accel_side = PHYS_JETPACK_ACCEL_SIDE; @@ -542,10 +537,6 @@ bool PlayerJump () bool doublejump = false; float mjumpheight = PHYS_JUMPVELOCITY; -#ifdef CSQC - player_multijump = doublejump; - player_jumpheight = mjumpheight; -#endif if (MUTATOR_CALLHOOK(PlayerJump, doublejump, mjumpheight)) return true; @@ -553,21 +544,6 @@ bool PlayerJump () doublejump = player_multijump; mjumpheight = player_jumpheight; - if (PHYS_DOUBLEJUMP) - { - tracebox(self.origin + '0 0 0.01', self.mins, self.maxs, self.origin - '0 0 0.01', MOVE_NORMAL, self); - if (trace_fraction < 1 && trace_plane_normal_z > 0.7) - { - doublejump = true; - - // we MUST clip velocity here! - float f; - f = self.velocity * trace_plane_normal; - if (f < 0) - self.velocity -= f * trace_plane_normal; - } - } - if (self.waterlevel >= WATERLEVEL_SWIMMING) { self.velocity_z = PHYS_MAXSPEED(self) * 0.7; diff --git a/qcsrc/common/physics.qh b/qcsrc/common/physics.qh index 7b46b0379..9d5d4f76c 100644 --- a/qcsrc/common/physics.qh +++ b/qcsrc/common/physics.qh @@ -99,8 +99,6 @@ bool IsFlying(entity a); #define PHYS_FROZEN(s) getstati(STAT_FROZEN) - #define PHYS_DOUBLEJUMP getstati(STAT_DOUBLEJUMP) - #define PHYS_JUMPSPEEDCAP_MIN cvar_string("cl_jumpspeedcap_min") #define PHYS_JUMPSPEEDCAP_MAX cvar_string("cl_jumpspeedcap_max") #define PHYS_JUMPSPEEDCAP_DISABLE_ONRAMPS getstati(STAT_MOVEVARS_JUMPSPEEDCAP_DISABLE_ONRAMPS) @@ -172,8 +170,6 @@ bool IsFlying(entity a); .float stat_sv_friction_on_land; .float stat_sv_friction_slick; - .float stat_doublejump; - .string stat_jumpspeedcap_min; .string stat_jumpspeedcap_max; .float stat_jumpspeedcap_disable_onramps; @@ -270,8 +266,6 @@ bool IsFlying(entity a); #define PHYS_FROZEN(s) s.frozen - #define PHYS_DOUBLEJUMP autocvar_sv_doublejump - #define PHYS_JUMPSPEEDCAP_MIN autocvar_sv_jumpspeedcap_min #define PHYS_JUMPSPEEDCAP_MAX autocvar_sv_jumpspeedcap_max #define PHYS_JUMPSPEEDCAP_DISABLE_ONRAMPS autocvar_sv_jumpspeedcap_max_disable_on_ramps diff --git a/qcsrc/server/autocvars.qh b/qcsrc/server/autocvars.qh index fff61774b..ae36e0cb8 100644 --- a/qcsrc/server/autocvars.qh +++ b/qcsrc/server/autocvars.qh @@ -346,7 +346,6 @@ string autocvar_sv_defaultplayermodel_red; string autocvar_sv_defaultplayermodel_yellow; int autocvar_sv_defaultplayerskin; bool autocvar_sv_dodging_frozen; -bool autocvar_sv_doublejump; bool autocvar_sv_eventlog; bool autocvar_sv_eventlog_console; bool autocvar_sv_eventlog_files; -- 2.39.2