Skip to content
This repository has been archived by the owner on Dec 23, 2023. It is now read-only.

Commit

Permalink
Update for 1.1.7 public release of JKO changes
Browse files Browse the repository at this point in the history
  • Loading branch information
DrBeef committed May 29, 2023
1 parent 1d462bc commit cf333a2
Show file tree
Hide file tree
Showing 28 changed files with 193 additions and 107 deletions.
4 changes: 2 additions & 2 deletions Projects/Android/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.drbeef.jkxr"
android:versionCode="56"
android:versionName="1.1.4" android:installLocation="auto" >
android:versionCode="59"
android:versionName="1.1.7" android:installLocation="auto" >

<!-- Tell the system this app requires OpenGL ES 3.1. -->
<uses-feature android:glEsVersion="0x00030002" android:required="true"/>
Expand Down
7 changes: 5 additions & 2 deletions Projects/Android/jni/JKXR/JKXR_SurfaceView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,9 @@ void VR_Init()
vr_force_distance_trigger = Cvar_Get( "vr_force_distance_trigger", "0.15", CVAR_ARCHIVE);
vr_two_handed_weapons = Cvar_Get ("vr_two_handed_weapons", "1", CVAR_ARCHIVE);
vr_force_motion_controlled = Cvar_Get ("vr_force_motion_controlled", "1", CVAR_ARCHIVE);
vr_force_motion_push = Cvar_Get ("vr_force_motion_push", "3", CVAR_ARCHIVE);
vr_force_motion_pull = Cvar_Get ("vr_force_motion_pull", "4", CVAR_ARCHIVE);
vr_motion_enable_saber = Cvar_Get ("vr_motion_enable_saber", "0", CVAR_ARCHIVE);
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);
Expand Down Expand Up @@ -529,8 +532,8 @@ void VR_HapticEvent(const char* event, int position, int flags, int intensity, f
}
else if (strcmp(event, "chainsaw_fire") == 0) // Saber
{
//Special handling for dual sabers
if (vr.dualsabers)
//Special handling for dual sabers / melee
if (vr.dualsabers || cl.frame.ps.weapon == WP_MELEE)
{
if (position == 4 ||
position == 0) // both hands
Expand Down
1 change: 1 addition & 0 deletions Projects/Android/jni/JKXR/VrClientInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ typedef struct {
int item_selector; // 1 - weapons/gadgets/saber stance, 2 - Force powers

bool velocitytriggered;
bool velocitytriggeractive;
float primaryswingvelocity;
bool primaryVelocityTriggeredAttack;
float secondaryswingvelocity;
Expand Down
3 changes: 3 additions & 0 deletions Projects/Android/jni/JKXR/VrCvars.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ extern cvar_t *vr_force_velocity_trigger;
extern cvar_t *vr_force_distance_trigger;
extern cvar_t *vr_two_handed_weapons;
extern cvar_t *vr_force_motion_controlled;
extern cvar_t *vr_force_motion_push;
extern cvar_t *vr_force_motion_pull;
extern cvar_t *vr_motion_enable_saber;
extern cvar_t *vr_crouch_toggle;
extern cvar_t *vr_irl_crouch_enabled;
extern cvar_t *vr_irl_crouch_to_stand_ratio;
Expand Down
3 changes: 3 additions & 0 deletions Projects/Android/jni/JKXR/VrInputCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ cvar_t *vr_force_velocity_trigger;
cvar_t *vr_force_distance_trigger;
cvar_t *vr_two_handed_weapons;
cvar_t *vr_force_motion_controlled;
cvar_t *vr_force_motion_push;
cvar_t *vr_force_motion_pull;
cvar_t *vr_motion_enable_saber;
cvar_t *vr_crouch_toggle;
cvar_t *vr_irl_crouch_enabled;
cvar_t *vr_irl_crouch_to_stand_ratio;
Expand Down
50 changes: 29 additions & 21 deletions Projects/Android/jni/JKXR/VrInputDefault.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
if (vr.velocitytriggered) {
static bool fired = false;
vr.primaryVelocityTriggeredAttack = (vr.primaryswingvelocity >
vr_weapon_velocity_trigger->value);
(vr_weapon_velocity_trigger->value / 2.0f));

if (fired != vr.primaryVelocityTriggeredAttack) {
ALOGV("**WEAPON EVENT** veocity triggered %s",
Expand All @@ -518,7 +518,7 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
if (vr.velocitytriggered) {
static bool fired = false;
vr.secondaryVelocityTriggeredAttack = (vr.secondaryswingvelocity >
vr_weapon_velocity_trigger->value);
(vr_weapon_velocity_trigger->value / 2.0f));

if (fired != vr.secondaryVelocityTriggeredAttack) {
ALOGV("**WEAPON EVENT** veocity triggered %s",
Expand All @@ -537,26 +537,33 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
cl.frame.ps.weapon == WP_STUN_BATON) {
//Does weapon velocity trigger attack
if (vr.velocitytriggered) {
static bool fired = false;
if (vr.velocitytriggeractive)
{
static bool fired = false;

float velocityRequired = (cl.frame.ps.weapon == WP_SABER) ? vr_weapon_velocity_trigger->value :
(vr_weapon_velocity_trigger->value / 2.0f);
float velocityRequired = (cl.frame.ps.weapon == WP_SABER)
? vr_weapon_velocity_trigger->value :
(vr_weapon_velocity_trigger->value / 2.0f);

vr.primaryVelocityTriggeredAttack = (vr.primaryswingvelocity > velocityRequired);
//player has to be dual wielding for this to be true
if (vr.dualsabers)
{
vr.secondaryVelocityTriggeredAttack = (vr.secondaryswingvelocity > velocityRequired);
}
vr.primaryVelocityTriggeredAttack = (vr.primaryswingvelocity >
velocityRequired);
//player has to be dual wielding for this to be true
if (vr.dualsabers)
{
vr.secondaryVelocityTriggeredAttack = (vr.secondaryswingvelocity >
velocityRequired);
}

bool triggered = vr.primaryVelocityTriggeredAttack || (vr.dualsabers && vr.secondaryVelocityTriggeredAttack);
if (fired != triggered)
{
ALOGV("**WEAPON EVENT** veocity triggered %s",
triggered ? "+attack" : "-attack");
//normal attack is a punch with the left hand
sendButtonAction("+attack", triggered);
fired = triggered;
bool triggered = vr.primaryVelocityTriggeredAttack ||
(vr.dualsabers && vr.secondaryVelocityTriggeredAttack);
if (fired != triggered)
{
ALOGV("**WEAPON EVENT** veocity triggered %s",
triggered ? "+attack" : "-attack");
//normal attack is a punch with the left hand
sendButtonAction("+attack", triggered);
fired = triggered;
}
}
} else if (vr.primaryVelocityTriggeredAttack || vr.secondaryVelocityTriggeredAttack) {
//send a stop attack as we have an unfinished velocity attack
Expand Down Expand Up @@ -905,6 +912,7 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,

//process force motion controls here
if (vr_force_motion_controlled->integer &&
cl.frame.ps.weapon != WP_MELEE &&
!vr.weapon_stabilised &&
// If dual sabers we can't really use motion control force as the off hand could be swinging for an attack
!vr.dualsabers)
Expand Down Expand Up @@ -952,11 +960,11 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
if (fabs(deltaLength) > vr_force_distance_trigger->value) {
if (deltaLength < 0 && !palmAway)
{
sendButtonActionSimple(va("useGivenForce %i", FP_PULL));
sendButtonActionSimple(va("useGivenForce %i", vr_force_motion_pull->integer));
}
else if (deltaLength > 0 && palmAway)
{
sendButtonActionSimple(va("useGivenForce %i", FP_PUSH));
sendButtonActionSimple(va("useGivenForce %i", vr_force_motion_push->integer));
}

vr.secondaryVelocityTriggeredAttack = false;
Expand Down
1 change: 1 addition & 0 deletions Projects/Android/jni/OpenJK/code/cgame/cg_media.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ typedef struct {

//Hand models
qhandle_t handModel_relaxed;
qhandle_t handModel_fist;
qhandle_t handModel_force;

qhandle_t halfShieldModel;
Expand Down
2 changes: 1 addition & 1 deletion Projects/Android/jni/OpenJK/code/client/snd_music.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ static qboolean Music_ParseLeveldata( gsl::czstring psLevelName )
{
// then this must be "action" music under current rules...
//
assert( !strcmp(psMusicStateType, Music_BaseStateToString(eBGRNDTRACK_ACTION) ? Music_BaseStateToString(eBGRNDTRACK_ACTION):"") );
//assert( !strcmp(psMusicStateType, Music_BaseStateToString(eBGRNDTRACK_ACTION) ? Music_BaseStateToString(eBGRNDTRACK_ACTION):"") );
//
// does this marker exist in the explore piece?
//
Expand Down
2 changes: 1 addition & 1 deletion Projects/Android/jni/OpenJK/code/game/w_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void WP_EmplacedFire( gentity_t *ent );
void prox_mine_think( gentity_t *ent );
void prox_mine_stick( gentity_t *self, gentity_t *other, trace_t *trace );
void WP_FireFlechette( gentity_t *ent, qboolean alt_fire );
void WP_Melee( gentity_t *ent );
void WP_Melee( gentity_t *ent, qboolean alt_fire );
void WP_FireNoghriStick( gentity_t *ent );
void WP_FireRepeater( gentity_t *ent, qboolean alt_fire );
void rocketThink( gentity_t *ent );
Expand Down
10 changes: 4 additions & 6 deletions Projects/Android/jni/OpenJK/code/qcommon/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -990,13 +990,11 @@ void Com_ExecuteCfg(void)
// skip the q3config.cfg and autoexec.cfg if "safe" is on the command line
Cbuf_ExecuteText(EXEC_NOW, "exec " Q3CONFIG_NAME "\n");
Cbuf_Execute();
Cbuf_ExecuteText(EXEC_NOW, "exec autoexec_sp.cfg\n");
//Execute to overwrite weapon locations with our desired adjustments
#ifdef JK2_MODE
Cbuf_AddText( "exec weapons_vr_jo.cfg\n" );
#else
Cbuf_AddText( "exec weapons_vr_ja.cfg\n" );
#endif
Cbuf_ExecuteText(EXEC_NOW, "exec weapons_vr.cfg\n" );
Cbuf_Execute();
// Execute autoexec last (allowing to re-adjust weapons)
Cbuf_ExecuteText(EXEC_NOW, "exec autoexec_sp.cfg\n");
Cbuf_Execute();
}
}
Expand Down
2 changes: 1 addition & 1 deletion Projects/Android/jni/OpenJK/code/qcommon/stv_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
// Current version of the single player game
#define VERSION_STRING_DOTTED "1.0.1.1"

#define JKXR_VERSION "1.1.4"
#define JKXR_VERSION "1.1.7"

#ifdef _DEBUG
#define Q3_VERSION "(debug)OpenJK: v" VERSION_STRING_DOTTED " JKXR: " JKXR_VERSION
Expand Down
6 changes: 1 addition & 5 deletions Projects/Android/jni/OpenJK/code/ui/ui_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6519,11 +6519,7 @@ void UI_ResetDefaults( void )
ui.Cmd_ExecuteText( EXEC_APPEND, "cvar_restart\n");
Controls_SetDefaults();
ui.Cmd_ExecuteText( EXEC_APPEND, "exec default.cfg\n");
#ifdef JK2_MODE
ui.Cmd_ExecuteText( EXEC_APPEND, "exec weapons_vr_jo.cfg\n");
#else
ui.Cmd_ExecuteText( EXEC_APPEND, "exec weapons_vr_ja.cfg\n");
#endif
ui.Cmd_ExecuteText( EXEC_APPEND, "exec weapons_vr.cfg\n");
ui.Cmd_ExecuteText( EXEC_APPEND, "vid_restart\n" );
}

Expand Down
2 changes: 1 addition & 1 deletion Projects/Android/jni/OpenJK/codeJK2/cgame/cg_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ void CG_DrawCenterString( void );
//
void CG_Player( centity_t *cent );
void CG_ResetPlayerEntity( centity_t *cent );
void CG_AddRefEntityWithPowerups( refEntity_t *ent, int powerups, centity_t *cent );
void CG_AddRefEntityWithPowerups( refEntity_t *ent, int powerups, centity_t *cent, bool forceShownInFirstPerson = false );
void CG_GetTagWorldPosition( refEntity_t *model, char *tag, vec3_t pos, vec3_t axis[3] );

//
Expand Down
1 change: 1 addition & 0 deletions Projects/Android/jni/OpenJK/codeJK2/cgame/cg_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1317,6 +1317,7 @@ static void CG_RegisterGraphics( void ) {

//VR Hand models
cgs.media.handModel_relaxed = cgi_R_RegisterModel( "models/players/kyle/lhand_r.md3" );
cgs.media.handModel_fist = cgi_R_RegisterModel( "models/players/kyle/lhand_force_fisting.md3" );
cgs.media.handModel_force = cgi_R_RegisterModel( "models/players/kyle/lhand_f.md3" );
cgs.media.saberHilt = cgi_R_RegisterModel( "models/weapons2/saber/saber_w.md3" );

Expand Down
1 change: 1 addition & 0 deletions Projects/Android/jni/OpenJK/codeJK2/cgame/cg_media.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ typedef struct {

//Hand models
qhandle_t handModel_relaxed;
qhandle_t handModel_fist;
qhandle_t handModel_force;

qhandle_t saberHilt;
Expand Down
21 changes: 15 additions & 6 deletions Projects/Android/jni/OpenJK/codeJK2/cgame/cg_players.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3400,7 +3400,7 @@ CG_AddRefEntityWithPowerups
Adds a piece with modifications or duplications for powerups
===============
*/
void CG_AddRefEntityWithPowerups( refEntity_t *ent, int powerups, centity_t *cent )
void CG_AddRefEntityWithPowerups( refEntity_t *ent, int powerups, centity_t *cent, bool forceShownInFirstPerson )
{
if ( !cent )
{
Expand Down Expand Up @@ -3431,7 +3431,7 @@ void CG_AddRefEntityWithPowerups( refEntity_t *ent, int powerups, centity_t *cen
// cgi_S_AddLoopingSound( 0, cent->lerpOrigin, vec3_origin, cgs.media.overchargeLoopSound );
// }

if (player1stPersonSaber) {
if (player1stPersonSaber && !forceShownInFirstPerson) {
ent->renderfx = RF_THIRD_PERSON;
}

Expand Down Expand Up @@ -4588,6 +4588,9 @@ Ghoul2 Insert End
{
if ( (trace.contents&CONTENTS_WATER) || (trace.contents&CONTENTS_SLIME) )
{
int position = (vr->right_handed ? 2 : 1);
cgi_HapticEvent("chainsaw_fire", position, 0, 25, 0, 0);

/*
if ( !(cent->gent->client->ps.saberEventFlags&SEF_INWATER) )
{
Expand All @@ -4607,6 +4610,9 @@ Ghoul2 Insert End
}
else
{
int position = (vr->right_handed ? 2 : 1);
cgi_HapticEvent("chainsaw_fire", position, 0, 25, 0, 0);

theFxScheduler.PlayEffect( "spark", trace.endpos, trace.plane.normal );
// All I need is a bool to mark whether I have a previous point to work with.
//....come up with something better..
Expand Down Expand Up @@ -4897,6 +4903,9 @@ void CG_Player(centity_t *cent ) {
if (cent->gent->client->ps.clientNum == 0) {
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);
}

//Get the player's light level for stealth calculations
Expand Down Expand Up @@ -5076,15 +5085,15 @@ Ghoul2 Insert Start
{//no viewentity
if ( cent->currentState.number == cg.snap->ps.clientNum )
{//I am the player
if ( cg.snap->ps.weapon != WP_SABER && cg.snap->ps.weapon != WP_MELEE )
if ( cg.snap->ps.weapon != WP_SABER )
{//not using saber or fists
ent.renderfx = RF_THIRD_PERSON; // only draw in mirrors
}
}
}
else if ( cent->currentState.number == cg.snap->ps.viewEntity )
{//I am the view entity
if ( cg.snap->ps.weapon != WP_SABER && cg.snap->ps.weapon != WP_MELEE )
if ( cg.snap->ps.weapon != WP_SABER )
{//not using first person saber test or, if so, not using saber
ent.renderfx = RF_THIRD_PERSON; // only draw in mirrors
}
Expand Down Expand Up @@ -5749,15 +5758,15 @@ Ghoul2 Insert End
{//no viewentity
if ( cent->currentState.number == cg.snap->ps.clientNum )
{//I am the player
if ( cg.snap->ps.weapon != WP_SABER && cg.snap->ps.weapon != WP_MELEE )
if ( cg.snap->ps.weapon != WP_SABER )
{//not using saber or fists
renderfx = RF_THIRD_PERSON; // only draw in mirrors
}
}
}
else if ( cent->currentState.number == cg.snap->ps.viewEntity )
{//I am the view entity
if ( cg.snap->ps.weapon != WP_SABER && cg.snap->ps.weapon != WP_MELEE )
if ( cg.snap->ps.weapon != WP_SABER )
{//not using saber or fists
renderfx = RF_THIRD_PERSON; // only draw in mirrors
}
Expand Down
30 changes: 25 additions & 5 deletions Projects/Android/jni/OpenJK/codeJK2/cgame/cg_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2033,10 +2033,10 @@ wasForceSpeed=isForceSpeed;
}

//Render hand models when appropriate
if (!in_camera
if (cg.snap->ps.clientNum == 0
&& !in_camera
&& !cg.renderingThirdPerson
&& cg.predicted_player_state.stats[STAT_HEALTH] > 0
&& cg.snap->ps.weapon != WP_MELEE
&& !vr->weapon_stabilised
&& !vr->in_vehicle
&& !cg_pano.integer
Expand All @@ -2060,6 +2060,10 @@ wasForceSpeed=isForceSpeed;
{
handEnt.hModel = cgs.media.handModel_force;
}
else if (cg.snap->ps.weapon == WP_MELEE)
{
handEnt.hModel = cgs.media.handModel_fist;
}
else
{
handEnt.hModel = cgs.media.handModel_relaxed;
Expand All @@ -2071,12 +2075,28 @@ wasForceSpeed=isForceSpeed;
VectorScale( handEnt.axis[i], (vr->right_handed || i != 1) ? 1.0f : -1.0f, handEnt.axis[i] );
}

cgi_R_AddRefEntityToScene(&handEnt);
centity_t *cent = &cg_entities[0];
CG_AddRefEntityWithPowerups(&handEnt, cent->currentState.powerups, cent, true);

if (cg.snap->ps.weapon == WP_NONE)
if (cg.snap->ps.weapon == WP_NONE ||
cg.snap->ps.weapon == WP_MELEE ||
(cg.snap->ps.weapon == WP_SABER && cg.snap->ps.saberInFlight))
{
BG_CalculateVRDefaultPosition(0, handEnt.origin, handEnt.angles);

if (cg.snap->ps.weapon == WP_SABER && cg.snap->ps.saberInFlight)
{
handEnt.hModel = cgs.media.handModel_force;
}
else if (cg.snap->ps.weapon == WP_MELEE)
{
handEnt.hModel = cgs.media.handModel_fist;
}
else
{
handEnt.hModel = cgs.media.handModel_relaxed;
}

//Move it back a bit?
AngleVectors(handEnt.angles, forward, NULL, NULL);
VectorMA( handEnt.origin, -3.0f, forward, handEnt.origin );
Expand All @@ -2088,7 +2108,7 @@ wasForceSpeed=isForceSpeed;
VectorScale( handEnt.axis[i], (!vr->right_handed || i != 1) ? 1.0f : -1.0f, handEnt.axis[i] );
}

cgi_R_AddRefEntityToScene(&handEnt);
CG_AddRefEntityWithPowerups(&handEnt, cent->currentState.powerups, cent);
}
}
}
Expand Down
Loading

0 comments on commit cf333a2

Please sign in to comment.