Several fixes

- Disruptor scope now working pretty much as expected
- Fix to menu hints now rendering correctly (@MuadDib)
- Removed roll from thrown saber angles
This commit is contained in:
Simon 2022-11-08 21:43:12 +00:00
parent 73ea7a970d
commit baafc2ec8d
13 changed files with 88 additions and 39 deletions

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.drbeef.jk2quest" package="com.drbeef.jk2quest"
android:versionCode="23" android:versionCode="25"
android:versionName="0.3.4" android:installLocation="auto" > android:versionName="0.3.6" android:installLocation="auto" >
<!-- Tell the system this app requires OpenGL ES 3.1. --> <!-- Tell the system this app requires OpenGL ES 3.1. -->
<uses-feature android:glEsVersion="0x00030002" android:required="true"/> <uses-feature android:glEsVersion="0x00030002" android:required="true"/>

View file

@ -874,6 +874,17 @@ void JKVR_GetMove(float *forward, float *side, float *pos_forward, float *pos_si
*pitch = vr.weaponangles[PITCH]; *pitch = vr.weaponangles[PITCH];
*roll = 0.0f; *roll = 0.0f;
} }
else if (vr.cgzoommode == 2)
{
*forward = 0.0f;
*pos_forward = 0.0f;
*up = 0.0f;
*side = 0.0f;
*pos_side = 0.0f;
*yaw = vr.snapTurn + vr.weaponangles[YAW];
*pitch = vr.weaponangles[PITCH];
*roll = vr.hmdorientation[ROLL];
}
else if (!vr.third_person) { else if (!vr.third_person) {
*forward = remote_movementForward; *forward = remote_movementForward;
*pos_forward = positional_movementForward; *pos_forward = positional_movementForward;

View file

@ -16,7 +16,6 @@ typedef struct {
bool player_moving; bool player_moving;
int cgzoommode; int cgzoommode;
int weaponid;
int forceid; int forceid;
vec3_t hmdposition; vec3_t hmdposition;

View file

@ -21,6 +21,7 @@ Authors : Simon Brown
#include "qcommon/q_shared.h" #include "qcommon/q_shared.h"
#include <qcommon/qcommon.h> #include <qcommon/qcommon.h>
#include <client/client.h> #include <client/client.h>
#include <statindex.h>
#include "android/sys_local.h" #include "android/sys_local.h"
#include "weapons.h" #include "weapons.h"
@ -155,16 +156,18 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
powf(vr.hmdposition[1] - pOff->HeadPose.Pose.Position.y, 2) + powf(vr.hmdposition[1] - pOff->HeadPose.Pose.Position.y, 2) +
powf(vr.hmdposition[2] - pOff->HeadPose.Pose.Position.z, 2)); powf(vr.hmdposition[2] - pOff->HeadPose.Pose.Position.z, 2));
float controllerYawHeading = 0.0f; float controllerYawHeading = 0.0f;
//Turn on weapon stabilisation? //Turn on weapon stabilisation?
bool offhandGripPushed = (pOffTrackedRemoteNew->Buttons & ovrButton_GripTrigger); bool offhandGripPushed = (pOffTrackedRemoteNew->Buttons & ovrButton_GripTrigger);
if (offhandGripPushed) if (offhandGripPushed)
{ {
if (!vr.weapon_stabilised && vr.item_selector == 0) if (!vr.weapon_stabilised && vr.item_selector == 0 &&
!vr.misc_camera)
{ {
if (distance < STABILISATION_DISTANCE && if (distance < STABILISATION_DISTANCE &&
vr_two_handed_weapons->integer && vr_two_handed_weapons->integer &&
vr.weaponid > WP_SABER) { cl.frame.ps.weapon >= WP_SABER) {
vr.weapon_stabilised = true; vr.weapon_stabilised = true;
} else { } else {
vr.item_selector = 2; vr.item_selector = 2;
@ -190,7 +193,7 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
//Do this early so we can suppress other button actions when item selector is up //Do this early so we can suppress other button actions when item selector is up
if (dominantGripPushed) { if (dominantGripPushed) {
if (vr.item_selector == 0) { if (vr.item_selector == 0 && !vr.misc_camera) {
vr.item_selector = 1; vr.item_selector = 1;
} }
} }
@ -232,14 +235,36 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
} }
} }
//Should we trigger the disruptor scope?
if (cl.frame.ps.weapon == WP_DISRUPTOR &&
cl.frame.ps.stats[STAT_HEALTH] > 0)
{
if (vr.weapon_stabilised &&
VectorLength(vr.weaponoffset) < 0.24f &&
vr.cgzoommode == 0) {
sendButtonAction("+altattack", true);
} else if ((VectorLength(vr.weaponoffset) >= 0.24f || !vr.weapon_stabilised) &&
vr.cgzoommode == 2) {
sendButtonActionSimple("exitzoom");
}
//We don't need to send the -altattack as the block below in the next frame will send it for us
}
if (vr.cgzoommode > 0) if (vr.cgzoommode > 0)
{ {
if (between(-0.2f, primaryJoystickX, 0.2f)) { if (between(-0.2f, primaryJoystickX, 0.2f)) {
if (cl.frame.ps.weapon == WP_DISRUPTOR)
{
sendButtonAction("+altattack", between(0.8f, pPrimaryJoystick->y, 1.0f));
}
else
{
sendButtonAction("+attack", between(0.8f, pPrimaryJoystick->y, 1.0f)); sendButtonAction("+attack", between(0.8f, pPrimaryJoystick->y, 1.0f));
sendButtonAction("+altattack", between(-1.0f, pPrimaryJoystick->y, -0.8f)); sendButtonAction("+altattack", between(-1.0f, pPrimaryJoystick->y, -0.8f));
} }
} }
else if (vr.weaponid == WP_SABER) }
else if (cl.frame.ps.weapon == WP_SABER)
{ {
int mode = (int)Cvar_VariableValue("cg_thirdPerson"); int mode = (int)Cvar_VariableValue("cg_thirdPerson");
static bool switched = false; static bool switched = false;
@ -316,7 +341,7 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
//For melee right hand is alt attack and left hand is attack //For melee right hand is alt attack and left hand is attack
if (vr.weaponid == WP_MELEE) { if (cl.frame.ps.weapon == WP_MELEE) {
//Does weapon velocity trigger attack (melee) and is it fast enough //Does weapon velocity trigger attack (melee) and is it fast enough
if (vr.velocitytriggered) { if (vr.velocitytriggered) {
static bool fired = false; static bool fired = false;
@ -355,7 +380,7 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
ALOGV("**WEAPON EVENT** veocity triggered -attack"); ALOGV("**WEAPON EVENT** veocity triggered -attack");
sendButtonAction("+attack", vr.secondaryVelocityTriggeredAttack); sendButtonAction("+attack", vr.secondaryVelocityTriggeredAttack);
} }
} else if (vr.weaponid == WP_SABER) { } else if (cl.frame.ps.weapon == WP_SABER) {
//Does weapon velocity trigger attack //Does weapon velocity trigger attack
if (vr.velocitytriggered) { if (vr.velocitytriggered) {
static bool fired = false; static bool fired = false;
@ -556,20 +581,20 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
sendButtonAction("+moveup", (primaryButtonsNew & primaryButton1)); sendButtonAction("+moveup", (primaryButtonsNew & primaryButton1));
} }
//Alt Fire (B Button) //B Button
if ((primaryButtonsNew & primaryButton2) != (primaryButtonsOld & primaryButton2)) { if ((primaryButtonsNew & primaryButton2) != (primaryButtonsOld & primaryButton2)) {
if (vr.cgzoommode > 0) if (vr.cgzoommode == 1 || vr.cgzoommode == 3)
{ {
sendButtonActionSimple("invuse"); sendButtonActionSimple("invuse");
} }
else if (vr.weaponid == WP_SABER && vr.velocitytriggered) else if (cl.frame.ps.weapon == WP_SABER && vr.velocitytriggered)
{ {
//B button toggles saber on/off in first person //B button toggles saber on/off in first person
if (primaryButtonsNew & primaryButton2) { if (primaryButtonsNew & primaryButton2) {
sendButtonActionSimple("togglesaber"); sendButtonActionSimple("togglesaber");
} }
} }
else else if (cl.frame.ps.weapon != WP_DISRUPTOR)
{ {
sendButtonAction("+altattack", (primaryButtonsNew & primaryButton2)); sendButtonAction("+altattack", (primaryButtonsNew & primaryButton2));
} }
@ -581,7 +606,7 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
int thirdPerson = Cvar_VariableIntegerValue("cg_thirdPerson"); int thirdPerson = Cvar_VariableIntegerValue("cg_thirdPerson");
if (vr.weaponid == WP_SABER && !thirdPerson && vr.cgzoommode == 0) if (cl.frame.ps.weapon == WP_SABER && !thirdPerson && vr.cgzoommode == 0)
{ {
static bool previous_throwing = false; static bool previous_throwing = false;
previous_throwing = throwing; previous_throwing = throwing;
@ -757,11 +782,11 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
VectorSubtract(vr.secondaryVelocityTriggerLocation, vr.hmdposition, delta2); VectorSubtract(vr.secondaryVelocityTriggerLocation, vr.hmdposition, delta2);
if (VectorLength(delta1) > VectorLength(delta2)) if (VectorLength(delta1) > VectorLength(delta2))
{ {
sendButtonActionSimple("useGivenForce 3"); // PULL sendButtonActionSimple(va("useGivenForce %i", FP_PULL));
} }
else else
{ {
sendButtonActionSimple("useGivenForce 4"); // PUSH sendButtonActionSimple(va("useGivenForce %i", FP_PUSH));
} }
vr.secondaryVelocityTriggeredAttack = false; vr.secondaryVelocityTriggeredAttack = false;

View file

@ -35,7 +35,7 @@ void HandleInput_WeaponAlign( ovrInputStateTrackedRemote *pDominantTrackedRemote
/* /*
char cvar_name[64]; char cvar_name[64];
Com_sprintf(cvar_name, sizeof(cvar_name), "vr_weapon_adjustment_%i", vr.weaponid); Com_sprintf(cvar_name, sizeof(cvar_name), "vr_weapon_adjustment_%i", cl.frame.ps.weapon);
char weapon_adjustment[256]; char weapon_adjustment[256];
Cvar_VariableStringBuffer(cvar_name, weapon_adjustment, 256); Cvar_VariableStringBuffer(cvar_name, weapon_adjustment, 256);
sscanf(weapon_adjustment, "%f,%f,%f,%f,%f,%f,%f", &vr.test_scale, sscanf(weapon_adjustment, "%f,%f,%f,%f,%f,%f,%f", &vr.test_scale,
@ -250,7 +250,7 @@ void HandleInput_WeaponAlign( ovrInputStateTrackedRemote *pDominantTrackedRemote
Com_sprintf(vr.test_name, sizeof(vr.test_name), "%s: %.3f", item_names[item_index], *(items[item_index])); Com_sprintf(vr.test_name, sizeof(vr.test_name), "%s: %.3f", item_names[item_index], *(items[item_index]));
char cvar_name[64]; char cvar_name[64];
Com_sprintf(cvar_name, sizeof(cvar_name), "vr_weapon_adjustment_%i", vr.weaponid); Com_sprintf(cvar_name, sizeof(cvar_name), "vr_weapon_adjustment_%i", cl.frame.ps.weapon);
char buffer[256]; char buffer[256];
Com_sprintf(buffer, sizeof(buffer), "%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f", vr.test_scale, (vr.test_offset[0] / vr.test_scale), (vr.test_offset[1] / vr.test_scale), (vr.test_offset[2] / vr.test_scale), Com_sprintf(buffer, sizeof(buffer), "%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f", vr.test_scale, (vr.test_offset[0] / vr.test_scale), (vr.test_offset[1] / vr.test_scale), (vr.test_offset[2] / vr.test_scale),

View file

@ -6846,8 +6846,6 @@ void CG_Player( centity_t *cent ) {
return; return;
} }
vr->weaponid = cg.snap->ps.weapon;
calcedMp = qfalse; calcedMp = qfalse;
//Get the player's light level for stealth calculations //Get the player's light level for stealth calculations

View file

@ -8261,7 +8261,7 @@ static qboolean Item_Paint(itemDef_t *item, qboolean bDraw)
while (1) while (1)
{ {
// FIXME - add some type of parameter in the menu file like descfont to specify the font for the descriptions for this menu. // FIXME - add some type of parameter in the menu file like descfont to specify the font for the descriptions for this menu.
textWidth = DC->textWidth(textPtr, fDescScale, 4); // item->font); textWidth = DC->textWidth(textPtr, fDescScale, 0); // item->font);
if (parent->descAlignment == ITEM_ALIGN_RIGHT) if (parent->descAlignment == ITEM_ALIGN_RIGHT)
{ {
@ -8297,7 +8297,7 @@ static qboolean Item_Paint(itemDef_t *item, qboolean bDraw)
} }
// FIXME - add some type of parameter in the menu file like descfont to specify the font for the descriptions for this menu. // FIXME - add some type of parameter in the menu file like descfont to specify the font for the descriptions for this menu.
DC->drawText(xPos, parent->descY + iYadj, fDescScale, parent->descColor, textPtr, 0, parent->descTextStyle, 4); //item->font); DC->drawText(xPos, parent->descY + iYadj, fDescScale, parent->descColor, textPtr, 0, parent->descTextStyle, 0); //item->font);
break; break;
} }
} }

View file

@ -141,8 +141,6 @@ void CG_ToggleBinoculars( void )
cg.zoomTime = cg.time; cg.zoomTime = cg.time;
cgi_S_StartSound( NULL, cg.snap->ps.clientNum, CHAN_AUTO, cgs.media.zoomEnd ); cgi_S_StartSound( NULL, cg.snap->ps.clientNum, CHAN_AUTO, cgs.media.zoomEnd );
} }
vr->cgzoommode = cg.zoomMode;
} }
void CG_ToggleLAGoggles( void ) void CG_ToggleLAGoggles( void )
@ -185,8 +183,6 @@ void CG_ToggleLAGoggles( void )
cg.zoomTime = cg.time; cg.zoomTime = cg.time;
cgi_S_StartSound( NULL, cg.snap->ps.clientNum, CHAN_AUTO, cgs.media.zoomEnd ); cgi_S_StartSound( NULL, cg.snap->ps.clientNum, CHAN_AUTO, cgs.media.zoomEnd );
} }
vr->cgzoommode = cg.zoomMode;
} }
void CG_LoadHud_f( void) void CG_LoadHud_f( void)
@ -211,6 +207,7 @@ void CG_ItemSelectorSelect_f( void );
void CG_ItemSelectorNext_f( void ); void CG_ItemSelectorNext_f( void );
void CG_ItemSelectorPrev_f( void ); void CG_ItemSelectorPrev_f( void );
void CG_ToggleSaber_f( void ); void CG_ToggleSaber_f( void );
void CG_ExitZoom_f( void );
/* This array MUST be sorted correctly by alphabetical name field */ /* This array MUST be sorted correctly by alphabetical name field */
static consoleCommand_t commands[] = { static consoleCommand_t commands[] = {
@ -253,6 +250,7 @@ static consoleCommand_t commands[] = {
{ "itemselectornext", CG_ItemSelectorNext_f }, { "itemselectornext", CG_ItemSelectorNext_f },
{ "itemselectorprev", CG_ItemSelectorPrev_f }, { "itemselectorprev", CG_ItemSelectorPrev_f },
{ "togglesaber", CG_ToggleSaber_f }, { "togglesaber", CG_ToggleSaber_f },
{ "exitzoom", CG_ExitZoom_f },
}; };
static const size_t numCommands = ARRAY_LEN( commands ); static const size_t numCommands = ARRAY_LEN( commands );

View file

@ -2765,6 +2765,8 @@ void CG_DrawActive( stereoFrame_t stereoView ) {
VectorNormalize( vright_n ); VectorNormalize( vright_n );
VectorNormalize( vup_n ); VectorNormalize( vup_n );
vr->cgzoommode = cg.zoomMode;
cg.refdef.stereoView = stereoView; cg.refdef.stereoView = stereoView;
switch ( stereoView ) { switch ( stereoView ) {
case STEREO_CENTER: case STEREO_CENTER:
@ -2790,6 +2792,7 @@ void CG_DrawActive( stereoFrame_t stereoView ) {
cg.refdef.worldscale = cg_worldScale.value; cg.refdef.worldscale = cg_worldScale.value;
if (!in_camera && if (!in_camera &&
!in_misccamera && !in_misccamera &&
cg.zoomMode != 2 &&
!cg.renderingThirdPerson) !cg.renderingThirdPerson)
{ {
VectorCopy(vr->hmdorientation, cg.refdef.viewangles); VectorCopy(vr->hmdorientation, cg.refdef.viewangles);
@ -2798,6 +2801,15 @@ void CG_DrawActive( stereoFrame_t stereoView ) {
AnglesToAxis(cg.refdef.viewangles, cg.refdef.viewaxis); AnglesToAxis(cg.refdef.viewangles, cg.refdef.viewaxis);
} }
if (cg.zoomMode == 2)
{
cg.refdef.viewangles[ROLL] = vr->clientviewangles[ROLL];
cg.refdef.viewangles[PITCH] = vr->weaponangles[PITCH];
cg.refdef.viewangles[YAW] = (vr->clientviewangles[YAW] - vr->hmdorientation[YAW])
+ vr->weaponangles[YAW] + SHORT2ANGLE(cg.snap->ps.delta_angles[YAW]);
AnglesToAxis(cg.refdef.viewangles, cg.refdef.viewaxis);
}
if (!in_camera && if (!in_camera &&
!in_misccamera && !in_misccamera &&
cg.renderingThirdPerson) cg.renderingThirdPerson)

View file

@ -4886,12 +4886,6 @@ void CG_Player(centity_t *cent ) {
return; return;
} }
if (cg.snap->ps.stats[STAT_HEALTH] > 0) {
vr->weaponid = cg.snap->ps.weapon;
} else {
vr->weaponid = WP_NONE;
}
if (cent->gent->client->ps.clientNum == 0) { if (cent->gent->client->ps.clientNum == 0) {
vr->velocitytriggered = (!cg.renderingThirdPerson && vr->velocitytriggered = (!cg.renderingThirdPerson &&
(cg.snap->ps.weapon == WP_SABER || cg.snap->ps.weapon == WP_MELEE)); (cg.snap->ps.weapon == WP_SABER || cg.snap->ps.weapon == WP_MELEE));

View file

@ -2651,6 +2651,18 @@ void CG_Weapon_f( void )
void Cmd_UseInventory_f(gentity_t *ent); void Cmd_UseInventory_f(gentity_t *ent);
void CG_ExitZoom_f( )
{
if ( cg.zoomMode == 2 )
{
G_SoundOnEnt( pm->gent, CHAN_AUTO, "sound/weapons/disruptor/zoomend.wav" );
// already zooming, so must be wanting to turn it off
cg.zoomMode = 0;
cg.zoomTime = cg.time;
cg.zoomLocked = qfalse;
}
}
void CG_ToggleSaber_f( ) void CG_ToggleSaber_f( )
{ {
player->client->ps.saberActive = (qboolean)!player->client->ps.saberActive; player->client->ps.saberActive = (qboolean)!player->client->ps.saberActive;

View file

@ -8589,10 +8589,7 @@ void PM_AdjustAttackStates( pmove_t *pm )
} }
else if ( cg.zoomMode == 2 ) else if ( cg.zoomMode == 2 )
{ {
G_SoundOnEnt( pm->gent, CHAN_AUTO, "sound/weapons/disruptor/zoomend.wav" ); G_SoundOnEnt( pm->gent, CHAN_AUTO, "sound/weapons/disruptor/zoomstart.wav" );
// already zooming, so must be wanting to turn it off
cg.zoomMode = 0;
cg.zoomTime = cg.time;
cg.zoomLocked = qfalse; cg.zoomLocked = qfalse;
} }
} }

View file

@ -3976,9 +3976,12 @@ void WP_RunSaber( gentity_t *self, gentity_t *saber )
//figure out where saber should be //figure out where saber should be
vec3_t forward, saberHome, saberDest, fwdangles = {0}; vec3_t forward, saberHome, saberDest, fwdangles = {0};
if (self->client->ps.clientNum == 0) if (self->client->ps.clientNum == 0 && !cg.renderingThirdPerson)
{ {
BG_CalculateVRWeaponPosition(saberHome, fwdangles); BG_CalculateVRWeaponPosition(saberHome, fwdangles);
//Ignore roll
fwdangles[ROLL] = 0;
} }
else { else {
VectorCopy(self->client->ps.viewangles, fwdangles); VectorCopy(self->client->ps.viewangles, fwdangles);