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"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.drbeef.jk2quest"
android:versionCode="23"
android:versionName="0.3.4" android:installLocation="auto" >
android:versionCode="25"
android:versionName="0.3.6" android:installLocation="auto" >
<!-- Tell the system this app requires OpenGL ES 3.1. -->
<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];
*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) {
*forward = remote_movementForward;
*pos_forward = positional_movementForward;

View File

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

View File

@ -21,6 +21,7 @@ Authors : Simon Brown
#include "qcommon/q_shared.h"
#include <qcommon/qcommon.h>
#include <client/client.h>
#include <statindex.h>
#include "android/sys_local.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[2] - pOff->HeadPose.Pose.Position.z, 2));
float controllerYawHeading = 0.0f;
//Turn on weapon stabilisation?
bool offhandGripPushed = (pOffTrackedRemoteNew->Buttons & ovrButton_GripTrigger);
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 &&
vr_two_handed_weapons->integer &&
vr.weaponid > WP_SABER) {
cl.frame.ps.weapon >= WP_SABER) {
vr.weapon_stabilised = true;
} else {
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
if (dominantGripPushed) {
if (vr.item_selector == 0) {
if (vr.item_selector == 0 && !vr.misc_camera) {
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 (between(-0.2f, primaryJoystickX, 0.2f)) {
sendButtonAction("+attack", between(0.8f, pPrimaryJoystick->y, 1.0f));
sendButtonAction("+altattack", between(-1.0f, pPrimaryJoystick->y, -0.8f));
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("+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");
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
if (vr.weaponid == WP_MELEE) {
if (cl.frame.ps.weapon == WP_MELEE) {
//Does weapon velocity trigger attack (melee) and is it fast enough
if (vr.velocitytriggered) {
static bool fired = false;
@ -355,7 +380,7 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
ALOGV("**WEAPON EVENT** veocity triggered -attack");
sendButtonAction("+attack", vr.secondaryVelocityTriggeredAttack);
}
} else if (vr.weaponid == WP_SABER) {
} else if (cl.frame.ps.weapon == WP_SABER) {
//Does weapon velocity trigger attack
if (vr.velocitytriggered) {
static bool fired = false;
@ -556,20 +581,20 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
sendButtonAction("+moveup", (primaryButtonsNew & primaryButton1));
}
//Alt Fire (B Button)
//B Button
if ((primaryButtonsNew & primaryButton2) != (primaryButtonsOld & primaryButton2)) {
if (vr.cgzoommode > 0)
if (vr.cgzoommode == 1 || vr.cgzoommode == 3)
{
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
if (primaryButtonsNew & primaryButton2) {
sendButtonActionSimple("togglesaber");
}
}
else
else if (cl.frame.ps.weapon != WP_DISRUPTOR)
{
sendButtonAction("+altattack", (primaryButtonsNew & primaryButton2));
}
@ -581,7 +606,7 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
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;
previous_throwing = throwing;
@ -757,11 +782,11 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
VectorSubtract(vr.secondaryVelocityTriggerLocation, vr.hmdposition, delta2);
if (VectorLength(delta1) > VectorLength(delta2))
{
sendButtonActionSimple("useGivenForce 3"); // PULL
sendButtonActionSimple(va("useGivenForce %i", FP_PULL));
}
else
{
sendButtonActionSimple("useGivenForce 4"); // PUSH
sendButtonActionSimple(va("useGivenForce %i", FP_PUSH));
}
vr.secondaryVelocityTriggeredAttack = false;

View File

@ -35,7 +35,7 @@ void HandleInput_WeaponAlign( ovrInputStateTrackedRemote *pDominantTrackedRemote
/*
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];
Cvar_VariableStringBuffer(cvar_name, weapon_adjustment, 256);
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]));
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];
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;
}
vr->weaponid = cg.snap->ps.weapon;
calcedMp = qfalse;
//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)
{
// 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)
{
@ -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.
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;
}
}

View File

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

View File

@ -2765,6 +2765,8 @@ void CG_DrawActive( stereoFrame_t stereoView ) {
VectorNormalize( vright_n );
VectorNormalize( vup_n );
vr->cgzoommode = cg.zoomMode;
cg.refdef.stereoView = stereoView;
switch ( stereoView ) {
case STEREO_CENTER:
@ -2790,6 +2792,7 @@ void CG_DrawActive( stereoFrame_t stereoView ) {
cg.refdef.worldscale = cg_worldScale.value;
if (!in_camera &&
!in_misccamera &&
cg.zoomMode != 2 &&
!cg.renderingThirdPerson)
{
VectorCopy(vr->hmdorientation, cg.refdef.viewangles);
@ -2798,6 +2801,15 @@ void CG_DrawActive( stereoFrame_t stereoView ) {
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 &&
!in_misccamera &&
cg.renderingThirdPerson)

View File

@ -4886,12 +4886,6 @@ void CG_Player(centity_t *cent ) {
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) {
vr->velocitytriggered = (!cg.renderingThirdPerson &&
(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 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( )
{
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 )
{
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;
G_SoundOnEnt( pm->gent, CHAN_AUTO, "sound/weapons/disruptor/zoomstart.wav" );
cg.zoomLocked = qfalse;
}
}

View File

@ -3976,9 +3976,12 @@ void WP_RunSaber( gentity_t *self, gentity_t *saber )
//figure out where saber should be
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);
//Ignore roll
fwdangles[ROLL] = 0;
}
else {
VectorCopy(self->client->ps.viewangles, fwdangles);