From aad362a8f350ab4f81604a171173b6c77d8435e1 Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 29 Aug 2015 16:11:06 +1000 Subject: [PATCH] Add a clientside hook for PlayerJump --- qcsrc/client/mutators/events.qh | 11 +++++++++++ qcsrc/common/physics.qc | 13 +++++++------ qcsrc/common/physics.qh | 4 ++-- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/qcsrc/client/mutators/events.qh b/qcsrc/client/mutators/events.qh index 9516fd25e..d6ac0c881 100644 --- a/qcsrc/client/mutators/events.qh +++ b/qcsrc/client/mutators/events.qh @@ -112,4 +112,15 @@ MUTATOR_HOOKABLE(ClearModelParams, EV_NO_ARGS); string checkmodel_input, checkmodel_command; MUTATOR_HOOKABLE(GetModelParams, EV_GetModelParams); +/** called when a player presses the jump key */ +#define EV_PlayerJump(i, o) \ + /**/ i(float, player_multijump) \ + /**/ i(float, player_jumpheight) \ + /**/ o(float, player_multijump) \ + /**/ o(float, player_jumpheight) \ + /**/ +float player_multijump; +float player_jumpheight; +MUTATOR_HOOKABLE(PlayerJump, EV_PlayerJump); + #endif diff --git a/qcsrc/common/physics.qc b/qcsrc/common/physics.qc index e5b83443f..34dedf132 100644 --- a/qcsrc/common/physics.qc +++ b/qcsrc/common/physics.qc @@ -552,15 +552,16 @@ bool PlayerJump (void) bool doublejump = false; float mjumpheight = PHYS_JUMPVELOCITY; - -#ifdef SVQC - if (MUTATOR_CALLHOOK(PlayerJump, doublejump, mjumpheight)) -#elif defined(CSQC) +#ifdef CSQC player_multijump = doublejump; player_jumpheight = mjumpheight; - if (PM_multijump_checkjump()) #endif - return true; + + if (MUTATOR_CALLHOOK(PlayerJump, doublejump, mjumpheight) +#ifdef CSQC + || PM_multijump_checkjump() +#endif + ) { return true; } doublejump = player_multijump; mjumpheight = player_jumpheight; diff --git a/qcsrc/common/physics.qh b/qcsrc/common/physics.qh index d4e5fdd38..a249b238d 100644 --- a/qcsrc/common/physics.qh +++ b/qcsrc/common/physics.qh @@ -43,8 +43,8 @@ bool IsFlying(entity a); #define IS_PLAYER(s) (s).isplayermodel #define isPushable(s) (s).isplayermodel - float player_multijump; - float player_jumpheight; + //float player_multijump; + //float player_jumpheight; #define PHYS_INPUT_ANGLES(s) input_angles // TODO -- 2.39.2