From 1939a26542ad6182abb91881c7dd86eb4d5d5a07 Mon Sep 17 00:00:00 2001 From: Grant Bagwell Date: Tue, 4 Apr 2023 23:37:41 +0200 Subject: [PATCH] TBDC Laser Saber deflections Guns balancing. --- .../Android/jni/JKXR/JKXR_SurfaceView.cpp | 2 +- Projects/Android/jni/JKXR/VrClientInfo.h | 1 + Projects/Android/jni/JKXR/VrInputDefault.cpp | 80 +++++++++++++++---- Projects/Android/jni/JKXR/VrTBDC.h | 24 +++++- .../jni/OpenJK/code/cgame/cg_players.cpp | 2 +- .../jni/OpenJK/codeJK2/cgame/cg_players.cpp | 11 ++- .../jni/OpenJK/codeJK2/game/g_combat.cpp | 4 +- 7 files changed, 98 insertions(+), 26 deletions(-) diff --git a/Projects/Android/jni/JKXR/JKXR_SurfaceView.cpp b/Projects/Android/jni/JKXR/JKXR_SurfaceView.cpp index 6fe3c32..4141f71 100644 --- a/Projects/Android/jni/JKXR/JKXR_SurfaceView.cpp +++ b/Projects/Android/jni/JKXR/JKXR_SurfaceView.cpp @@ -306,7 +306,7 @@ void VR_Init() vr_crouch_toggle = Cvar_Get ("vr_crouch_toggle", "0", CVAR_ARCHIVE); vr_irl_crouch_enabled = Cvar_Get ("vr_irl_crouch_enabled", "0", CVAR_ARCHIVE); vr_irl_crouch_to_stand_ratio = Cvar_Get ("vr_irl_crouch_to_stand_ratio", "0.65", CVAR_ARCHIVE); - vr_saber_block_debounce_time = Cvar_Get ("vr_saber_block_debounce_time", "200", CVAR_ARCHIVE); + vr_saber_block_debounce_time = Cvar_Get ("vr_saber_block_debounce_time", "1000", CVAR_ARCHIVE); vr_haptic_intensity = Cvar_Get ("vr_haptic_intensity", "1.0", CVAR_ARCHIVE); vr_comfort_vignette = Cvar_Get ("vr_comfort_vignette", "0.0", CVAR_ARCHIVE); vr_saber_3rdperson_mode = Cvar_Get ("vr_saber_3rdperson_mode", "1", CVAR_ARCHIVE); diff --git a/Projects/Android/jni/JKXR/VrClientInfo.h b/Projects/Android/jni/JKXR/VrClientInfo.h index b1c0401..0ba090a 100644 --- a/Projects/Android/jni/JKXR/VrClientInfo.h +++ b/Projects/Android/jni/JKXR/VrClientInfo.h @@ -43,6 +43,7 @@ typedef struct { int cgzoommode; int cgzoomdir; int saberBlockDebounce; // Amount of time after player is blocked that the saber position is fixed + short saberBounceMove; int forceid; diff --git a/Projects/Android/jni/JKXR/VrInputDefault.cpp b/Projects/Android/jni/JKXR/VrInputDefault.cpp index cf4434a..3f38667 100644 --- a/Projects/Android/jni/JKXR/VrInputDefault.cpp +++ b/Projects/Android/jni/JKXR/VrInputDefault.cpp @@ -17,6 +17,7 @@ Authors : Simon Brown #include #include #include "android/sys_local.h" +#include "VrTBDC.h" #ifdef JK2_MODE #include "../OpenJK/codeJK2/game/weapons.h" @@ -121,12 +122,63 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew, QuatToYawPitchRoll(pWeapon->Pose.orientation, rotation, vr.weaponangles[ANGLES_DEFAULT]); QuatToYawPitchRoll(pOff->Pose.orientation, rotation, vr.offhandangles[ANGLES_DEFAULT]); - //if we are in saber block debounce, don't update the saber angles - if (vr.saberBlockDebounce < cl.serverTime) { - rotation[PITCH] = 45; - QuatToYawPitchRoll(pWeapon->Pose.orientation, rotation, vr.weaponangles[ANGLES_SABER]); - QuatToYawPitchRoll(pOff->Pose.orientation, rotation, vr.offhandangles[ANGLES_SABER]); + rotation[PITCH] = 45; + //If we are in a saberBlockDebounce thing then add on an angle + //Lerped upon how far from the start of the saber move + if (vr.saberBlockDebounce > cl.serverTime) { + float lerp = 0.0f; + //Where are we in the lerp + // 0 = vr.saberBlockDebounce - TBDC_SABER_BOUNCETIME + // 1 = vr.saberBlockDebounce - TBDC_SABER_BOUNCETIME / 2 + // 0 (again) = vr.saberBlockDebounce + if(cl.serverTime < vr.saberBlockDebounce - TBDC_SABER_BOUNCETIME / 2) + { + //Somewhere between 0 and 1 + lerp = float(cl.serverTime - (vr.saberBlockDebounce - TBDC_SABER_BOUNCETIME)) / float((vr.saberBlockDebounce - TBDC_SABER_BOUNCETIME / 2) - (vr.saberBlockDebounce - TBDC_SABER_BOUNCETIME)); + } + else + { + //Somewhere between 1 and 0 + lerp = 1 - float(cl.serverTime - (vr.saberBlockDebounce - TBDC_SABER_BOUNCETIME / 2)) / float(vr.saberBlockDebounce - (vr.saberBlockDebounce - TBDC_SABER_BOUNCETIME / 2)); + } + switch(vr.saberBounceMove) { + case VRLS_B1_BR: + rotation[PITCH] += lerp * TBDC_SABER_BOUNCEANGLE; + rotation[YAW] -= lerp * TBDC_SABER_BOUNCEANGLE; + break; + case VRLS_B1__R: + rotation[YAW] -= lerp * TBDC_SABER_BOUNCEANGLE; + break; + case VRLS_B1_TR: + rotation[PITCH] -= lerp * TBDC_SABER_BOUNCEANGLE; + rotation[YAW] -= lerp * TBDC_SABER_BOUNCEANGLE; + break; + case VRLS_B1_T_: + rotation[PITCH] -= lerp * TBDC_SABER_BOUNCEANGLE; + break; + case VRLS_B1_TL: + rotation[PITCH] -= lerp * TBDC_SABER_BOUNCEANGLE; + rotation[YAW] += lerp * TBDC_SABER_BOUNCEANGLE; + break; + case VRLS_B1__L: + rotation[YAW] += lerp * TBDC_SABER_BOUNCEANGLE; + break; + case VRLS_B1_BL: + rotation[PITCH] += lerp * TBDC_SABER_BOUNCEANGLE; + rotation[YAW] += lerp * TBDC_SABER_BOUNCEANGLE; + break; + } } + /*else if(cl.serverTime > vr.saberBlockDebounce + 3000) + { + if(vr.saberBounceMove < 82) + { + vr.saberBounceMove = 82; + } + vr.saberBlockDebounce = cl.serverTime + TBDC_SABER_BOUNCETIME; + }*/ + QuatToYawPitchRoll(pWeapon->Pose.orientation, rotation, vr.weaponangles[ANGLES_SABER]); + QuatToYawPitchRoll(pOff->Pose.orientation, rotation, vr.offhandangles[ANGLES_SABER]); rotation[PITCH] = vr_weapon_pitchadjust->value; QuatToYawPitchRoll(pWeapon->Pose.orientation, rotation, vr.weaponangles[ANGLES_ADJUSTED]); @@ -380,16 +432,16 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew, VectorCopy(vr.weaponoffset, vr.weaponoffset_history[0]); vr.weaponoffset_history_timestamp[0] = vr.weaponoffset_timestamp; - if (vr.saberBlockDebounce < cl.serverTime) { - VectorSet(vr.weaponposition, pWeapon->Pose.position.x, - pWeapon->Pose.position.y, pWeapon->Pose.position.z); + //if (vr.saberBlockDebounce < cl.serverTime) { + VectorSet(vr.weaponposition, pWeapon->Pose.position.x, + pWeapon->Pose.position.y, pWeapon->Pose.position.z); - ///Weapon location relative to view - VectorSet(vr.weaponoffset, pWeapon->Pose.position.x, - pWeapon->Pose.position.y, pWeapon->Pose.position.z); - VectorSubtract(vr.weaponoffset, vr.hmdposition, vr.weaponoffset); - vr.weaponoffset_timestamp = Sys_Milliseconds(); - } + ///Weapon location relative to view + VectorSet(vr.weaponoffset, pWeapon->Pose.position.x, + pWeapon->Pose.position.y, pWeapon->Pose.position.z); + VectorSubtract(vr.weaponoffset, vr.hmdposition, vr.weaponoffset); + vr.weaponoffset_timestamp = Sys_Milliseconds(); + //} vec3_t velocity; VectorSet(velocity, pWeapon->Velocity.linearVelocity.x, diff --git a/Projects/Android/jni/JKXR/VrTBDC.h b/Projects/Android/jni/JKXR/VrTBDC.h index 404da5a..38ec6e6 100644 --- a/Projects/Android/jni/JKXR/VrTBDC.h +++ b/Projects/Android/jni/JKXR/VrTBDC.h @@ -6,17 +6,33 @@ #define JKXR_VRTBDC_H //VELOCITIES -#define TBDC_BRYAR_PISTOL_VEL 3600 -#define TBDC_BLASTER_VELOCITY 4600 +#define TBDC_BRYAR_PISTOL_VEL 3300 +#define TBDC_BLASTER_VELOCITY 4200 #define TBDC_BOWCASTER_VELOCITY 3000 -#define TBDC_REPEATER_VELOCITY 3200 +#define TBDC_REPEATER_VELOCITY 3000 #define TBDC_REPEATER_ALT_VELOCITY 1600 #define TBDC_DEMP2_VELOCITY 2500 -#define TBDC_ROCKET_VELOCITY 2800 +#define TBDC_ROCKET_VELOCITY 2400 //FIRERATES #define TBDC_BRYAR_PISTOL_FIRERATE 250 #define TBDC_BLASTER_FIRERATE 200 +//SABERS +#define TBDC_SABER_BOUNCETIME 200 +#define TBDC_SABER_BOUNCEANGLE 90 + +typedef enum { + // Invalid, or saber not armed + VRLS_NONE = 0, + //Bounces + VRLS_B1_BR = 82, + VRLS_B1__R, + VRLS_B1_TR, + VRLS_B1_T_, + VRLS_B1_TL, + VRLS_B1__L, + VRLS_B1_BL +} vrBounce; #endif //JKXR_VRTBDC_H diff --git a/Projects/Android/jni/OpenJK/code/cgame/cg_players.cpp b/Projects/Android/jni/OpenJK/code/cgame/cg_players.cpp index 475fe6a..713f995 100644 --- a/Projects/Android/jni/OpenJK/code/cgame/cg_players.cpp +++ b/Projects/Android/jni/OpenJK/code/cgame/cg_players.cpp @@ -6792,7 +6792,7 @@ Ghoul2 Insert End vr->saberBlockDebounce < cg.time && bladeNum == 0) // Only need to do this for the first blade { - cvar_t *vr_saber_block_debounce_time = gi.cvar("vr_saber_block_debounce_time", "200", CVAR_ARCHIVE); // defined in VrCvars.h + cvar_t *vr_saber_block_debounce_time = gi.cvar("vr_saber_block_debounce_time", "1000", CVAR_ARCHIVE); // defined in VrCvars.h vr->saberBlockDebounce = cg.time + vr_saber_block_debounce_time->integer; cgi_HapticEvent("shotgun_fire", 0, vr->right_handed ? (2 - saberNum) : (1 + saberNum), 100, 0, 0); diff --git a/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_players.cpp b/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_players.cpp index 1147f7e..4773fd1 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_players.cpp +++ b/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_players.cpp @@ -32,6 +32,7 @@ along with this program; if not, see . #include "../game/wp_saber.h" #include "bg_local.h" #include +#include #define LOOK_SWING_SCALE 0.5 @@ -4780,12 +4781,14 @@ Ghoul2 Insert End CG_DoSaber( org_, axis_[0], length, client->ps.saberLengthMax, saberColor, renderfx ); if (CG_getPlayer1stPersonSaber(cent) && - cent->gent->client->ps.saberEventFlags & (SEF_BLOCKED|SEF_PARRIED) && + cent->gent->client->ps.saberEventFlags & (SEF_BLOCKED|SEF_PARRIED) && + cent->gent->client->ps.saberBounceMove != LS_NONE && vr->saberBlockDebounce < cg.time) { - cvar_t *vr_saber_block_debounce_time = gi.cvar("vr_saber_block_debounce_time", "200", CVAR_ARCHIVE); // defined in VrCvars.h - vr->saberBlockDebounce = cg.time + vr_saber_block_debounce_time->integer; - + //cvar_t *vr_saber_block_debounce_time = gi.cvar("vr_saber_block_debounce_time", "1000", CVAR_ARCHIVE); // defined in VrCvars.h + //vr->saberBlockDebounce = cg.time + vr_saber_block_debounce_time->integer; + vr->saberBlockDebounce = cg.time + TBDC_SABER_BOUNCETIME; + vr->saberBounceMove = cent->gent->client->ps.saberBounceMove; cgi_HapticEvent("shotgun_fire", 0, 0, 100, 0, 0); } diff --git a/Projects/Android/jni/OpenJK/codeJK2/game/g_combat.cpp b/Projects/Android/jni/OpenJK/codeJK2/game/g_combat.cpp index def4cab..29376a8 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/game/g_combat.cpp +++ b/Projects/Android/jni/OpenJK/codeJK2/game/g_combat.cpp @@ -5352,10 +5352,10 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, vec3_ {//special case because this is shotgun-ish damage, we need to multiply the knockback knockback *= 12;//*6 for 6 flechette shots } - if(g_TeamBeefDirectorsCut->value) + else if(g_TeamBeefDirectorsCut->value) { knockback *= 2; - } + ` } G_ApplyKnockback( targ, newDir, knockback ); }