From 0c6d44f6559bc5c4f89b80663811516ec5a027ef Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 9 Dec 2023 10:36:59 +0000 Subject: [PATCH] Allow player to recall saber to their hand with a gesture when it is dropped --- .../jni/OpenJK/code/cgame/cg_players.cpp | 33 +++++++++++++++++-- .../jni/OpenJK/codeJK2/cgame/cg_players.cpp | 33 +++++++++++++++++-- 2 files changed, 62 insertions(+), 4 deletions(-) diff --git a/Projects/Android/jni/OpenJK/code/cgame/cg_players.cpp b/Projects/Android/jni/OpenJK/code/cgame/cg_players.cpp index 26f6bd6..02968f2 100644 --- a/Projects/Android/jni/OpenJK/code/cgame/cg_players.cpp +++ b/Projects/Android/jni/OpenJK/code/cgame/cg_players.cpp @@ -7010,8 +7010,37 @@ void CG_Player( centity_t *cent ) { vr->velocitytriggered = (!cg.renderingThirdPerson && (cg.snap->ps.weapon == WP_SABER || cg.snap->ps.weapon == WP_MELEE || cg.snap->ps.weapon == WP_STUN_BATON)); cvar_t *vr_motion_enable_saber = gi.cvar("vr_motion_enable_saber", "0", CVAR_ARCHIVE); - vr->velocitytriggeractive = (cg.snap->ps.weapon == WP_SABER && (g_entities[0].client->ps.SaberActive() || vr_motion_enable_saber->integer)) || - cg.snap->ps.weapon == WP_MELEE || cg.snap->ps.weapon == WP_STUN_BATON; + + switch (cg.snap->ps.weapon) + { + case WP_SABER: + { + gentity_t *saberent = &g_entities[cent->gent->client->ps.saberEntityNum]; + + if (g_entities[0].client->ps.SaberActive() || vr_motion_enable_saber->integer) + { + vr->velocitytriggeractive = true; + } + //Should we allow player to pull saber back with motion? + else if (cent->gent->client->ps.saberInFlight && + saberent->s.pos.trType != TR_LINEAR) + { + vr->velocitytriggeractive = true; + } + else + { + vr->velocitytriggeractive = false; + } + break; + } + case WP_MELEE: + case WP_STUN_BATON: + vr->velocitytriggeractive = true; + break; + default: + vr->velocitytriggeractive = false; + break; + } } G_RagDoll(cent->gent, cent->lerpAngles); diff --git a/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_players.cpp b/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_players.cpp index 73541ba..5b8c560 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_players.cpp +++ b/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_players.cpp @@ -4914,8 +4914,37 @@ void CG_Player(centity_t *cent ) { vr->velocitytriggered = (!cg.renderingThirdPerson && (cg.snap->ps.weapon == WP_SABER || cg.snap->ps.weapon == WP_MELEE || cg.snap->ps.weapon == WP_STUN_BATON)); cvar_t *vr_motion_enable_saber = gi.cvar("vr_motion_enable_saber", "0", CVAR_ARCHIVE); - vr->velocitytriggeractive = ((cg.snap->ps.weapon == WP_SABER && (cent->gent->client->ps.saberActive || vr_motion_enable_saber->integer)) || - cg.snap->ps.weapon == WP_MELEE || cg.snap->ps.weapon == WP_STUN_BATON); + + switch (cg.snap->ps.weapon) + { + case WP_SABER: + { + gentity_t *saberent = &g_entities[cent->gent->client->ps.saberEntityNum]; + + if (cent->gent->client->ps.saberActive || vr_motion_enable_saber->integer) + { + vr->velocitytriggeractive = true; + } + //Should we allow player to pull saber back with motion? + else if (cent->gent->client->ps.saberInFlight && + saberent->s.pos.trType != TR_LINEAR) + { + vr->velocitytriggeractive = true; + } + else + { + vr->velocitytriggeractive = false; + } + break; + } + case WP_MELEE: + case WP_STUN_BATON: + vr->velocitytriggeractive = true; + break; + default: + vr->velocitytriggeractive = false; + break; + } } //Get the player's light level for stealth calculations