From b9d0314a6a137e37914d674717c8a67e09124546 Mon Sep 17 00:00:00 2001 From: Petr Bartos Date: Sun, 9 Apr 2023 19:38:32 +0200 Subject: [PATCH] Make getting into AT-ST easier --- .../Android/jni/OpenJK/code/game/g_utils.cpp | 24 +++++++++++++------ .../jni/OpenJK/codeJK2/game/g_utils.cpp | 24 +++++++++++++------ 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/Projects/Android/jni/OpenJK/code/game/g_utils.cpp b/Projects/Android/jni/OpenJK/code/game/g_utils.cpp index 81621d8..e9f5fad 100644 --- a/Projects/Android/jni/OpenJK/code/game/g_utils.cpp +++ b/Projects/Android/jni/OpenJK/code/game/g_utils.cpp @@ -1669,6 +1669,14 @@ qboolean CanUseInfrontOf(gentity_t *ent) return qfalse; } + // Check if player is standing on drivable AT-ST + if (ent->client->ps.groundEntityNum < ENTITYNUM_WORLD) { + target = &g_entities[ent->client->ps.groundEntityNum]; + if (target && target->e_UseFunc == useF_misc_atst_use) { + return qtrue; + } + } + bool thirdPersonActive = gi.cvar("cg_thirdPerson", "0", CVAR_TEMP)->integer; if (thirdPersonActive) { VectorCopy(ent->currentOrigin, src); @@ -1712,13 +1720,6 @@ qboolean CanUseInfrontOf(gentity_t *ent) return qfalse; } } - else if ( target->e_UseFunc == useF_misc_atst_use ) - {//drivable AT-ST from JK2 - if ( ent->client->ps.groundEntityNum != target->s.number ) - {//must be standing on it to use it - return qfalse; - } - } else if ( target->NPC!=NULL && target->health<=0 ) { return qfalse; @@ -1771,6 +1772,15 @@ void TryUse_Internal( bool offHand, gentity_t *ent, vec3_t src, vec3_t vf ) trace_t trace; vec3_t dest; + // Drivable AT-ST can be used if player stands on it + if (ent->client->ps.groundEntityNum < ENTITYNUM_WORLD) { + target = &g_entities[ent->client->ps.groundEntityNum]; + if (target && target->e_UseFunc == useF_misc_atst_use) { + GEntity_UseFunc( target, ent, ent ); + return; + } + } + //extend to find end of use trace bool thirdPersonActive = gi.cvar("cg_thirdPerson", "0", CVAR_TEMP)->integer; bool useGestureEnabled = gi.cvar("vr_gesture_triggered_use", "1", CVAR_ARCHIVE)->integer; // defined in VrCvars.h diff --git a/Projects/Android/jni/OpenJK/codeJK2/game/g_utils.cpp b/Projects/Android/jni/OpenJK/codeJK2/game/g_utils.cpp index 6a04a26..cbe34dd 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/game/g_utils.cpp +++ b/Projects/Android/jni/OpenJK/codeJK2/game/g_utils.cpp @@ -1442,6 +1442,14 @@ qboolean CanUseInfrontOf(gentity_t *ent) return qfalse; } + // Check if player is standing on drivable AT-ST + if (ent->client->ps.groundEntityNum < ENTITYNUM_WORLD) { + target = &g_entities[ent->client->ps.groundEntityNum]; + if (target && target->e_UseFunc == useF_misc_atst_use) { + return qtrue; + } + } + bool thirdPersonActive = gi.cvar("cg_thirdPerson", "0", CVAR_TEMP)->integer; if (thirdPersonActive) { VectorCopy(ent->currentOrigin, src); @@ -1485,13 +1493,6 @@ qboolean CanUseInfrontOf(gentity_t *ent) return qfalse; } } - else if ( target->e_UseFunc == useF_misc_atst_use ) - {//drivable AT-ST from JK2 - if ( ent->client->ps.groundEntityNum != target->s.number ) - {//must be standing on it to use it - return qfalse; - } - } else if ( target->NPC!=NULL && target->health<=0 ) { return qfalse; @@ -1536,6 +1537,15 @@ void TryUse_Internal( bool offHand, gentity_t *ent, vec3_t src, vec3_t vf ) { trace_t trace; vec3_t dest; + // Drivable AT-ST can be used if player stands on it + if (ent->client->ps.groundEntityNum < ENTITYNUM_WORLD) { + target = &g_entities[ent->client->ps.groundEntityNum]; + if (target && target->e_UseFunc == useF_misc_atst_use) { + GEntity_UseFunc( target, ent, ent ); + return; + } + } + //extend to find end of use trace bool thirdPersonActive = gi.cvar("cg_thirdPerson", "0", CVAR_TEMP)->integer; bool useGestureEnabled = gi.cvar("vr_gesture_triggered_use", "1", CVAR_ARCHIVE)->integer; // defined in VrCvars.h