From dfa54a439a74d86914757a3b9a646275903b51b1 Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 21 May 2023 22:38:42 +0100 Subject: [PATCH] A number of changes - Made Melee available - punch stormtroopers to death! (default melee damage is now 25) - Draw hand models when in melee (to be replaced with fists soon) - Made movement not reactivate saber by default (cvar controlled) - Draw open hand when saber is thrown --- .../Android/jni/JKXR/JKXR_SurfaceView.cpp | 5 +- Projects/Android/jni/JKXR/VrClientInfo.h | 1 + Projects/Android/jni/JKXR/VrCvars.h | 1 + Projects/Android/jni/JKXR/VrInputCommon.cpp | 1 + Projects/Android/jni/JKXR/VrInputDefault.cpp | 47 +++++++++++-------- .../Android/jni/OpenJK/code/cgame/cg_main.cpp | 1 + .../Android/jni/OpenJK/code/cgame/cg_media.h | 1 + .../jni/OpenJK/code/cgame/cg_players.cpp | 12 +++-- .../Android/jni/OpenJK/code/cgame/cg_view.cpp | 36 +++++++++----- .../jni/OpenJK/code/cgame/cg_weapons.cpp | 18 +++---- .../Android/jni/OpenJK/code/game/g_client.cpp | 4 +- .../Android/jni/OpenJK/code/game/wp_melee.cpp | 2 +- .../jni/OpenJK/codeJK2/cgame/cg_main.cpp | 1 + .../jni/OpenJK/codeJK2/cgame/cg_media.h | 1 + .../jni/OpenJK/codeJK2/cgame/cg_players.cpp | 17 +++++-- .../jni/OpenJK/codeJK2/cgame/cg_view.cpp | 30 ++++++++++-- .../jni/OpenJK/codeJK2/cgame/cg_weapons.cpp | 33 ++++++++++--- .../jni/OpenJK/codeJK2/game/g_client.cpp | 4 +- .../Android/jni/OpenJK/codeJK2/game/weapons.h | 2 +- .../jni/OpenJK/codeJK2/game/wp_melee.cpp | 2 +- 20 files changed, 148 insertions(+), 71 deletions(-) diff --git a/Projects/Android/jni/JKXR/JKXR_SurfaceView.cpp b/Projects/Android/jni/JKXR/JKXR_SurfaceView.cpp index 8c1b0f7..15d5114 100644 --- a/Projects/Android/jni/JKXR/JKXR_SurfaceView.cpp +++ b/Projects/Android/jni/JKXR/JKXR_SurfaceView.cpp @@ -343,6 +343,7 @@ 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_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); @@ -573,8 +574,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 diff --git a/Projects/Android/jni/JKXR/VrClientInfo.h b/Projects/Android/jni/JKXR/VrClientInfo.h index 5a4d46f..df31ba3 100644 --- a/Projects/Android/jni/JKXR/VrClientInfo.h +++ b/Projects/Android/jni/JKXR/VrClientInfo.h @@ -91,6 +91,7 @@ typedef struct { int item_selector; // 1 - weapons/gadgets/saber stance, 2 - Force powers bool velocitytriggered; + bool velocitytriggeractive; float primaryswingvelocity; bool primaryVelocityTriggeredAttack; float secondaryswingvelocity; diff --git a/Projects/Android/jni/JKXR/VrCvars.h b/Projects/Android/jni/JKXR/VrCvars.h index 4089298..936ac38 100644 --- a/Projects/Android/jni/JKXR/VrCvars.h +++ b/Projects/Android/jni/JKXR/VrCvars.h @@ -13,6 +13,7 @@ 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_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; diff --git a/Projects/Android/jni/JKXR/VrInputCommon.cpp b/Projects/Android/jni/JKXR/VrInputCommon.cpp index bf1d7aa..e7be7b5 100644 --- a/Projects/Android/jni/JKXR/VrInputCommon.cpp +++ b/Projects/Android/jni/JKXR/VrInputCommon.cpp @@ -26,6 +26,7 @@ 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_motion_enable_saber; cvar_t *vr_crouch_toggle; cvar_t *vr_irl_crouch_enabled; cvar_t *vr_irl_crouch_to_stand_ratio; diff --git a/Projects/Android/jni/JKXR/VrInputDefault.cpp b/Projects/Android/jni/JKXR/VrInputDefault.cpp index d9e2ccd..e05fa14 100644 --- a/Projects/Android/jni/JKXR/VrInputDefault.cpp +++ b/Projects/Android/jni/JKXR/VrInputDefault.cpp @@ -500,7 +500,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", @@ -519,7 +519,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", @@ -538,27 +538,34 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew, cl.frame.ps.weapon == WP_STUN_BATON) { //Does weapon velocity trigger attack if (vr.velocitytriggered) { - static bool fired = false; - - 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) + if (vr.velocitytriggeractive) { - vr.secondaryVelocityTriggeredAttack = (vr.secondaryswingvelocity > velocityRequired); - } + static bool fired = false; - bool triggered = vr.primaryVelocityTriggeredAttack || (vr.dualsabers && vr.secondaryVelocityTriggeredAttack); - if (fired != triggered) - { - ALOGV("**WEAPON EVENT** veocity triggered %s", - triggered ? "+attack" : "-attack"); + float velocityRequired = (cl.frame.ps.weapon == WP_SABER) + ? vr_weapon_velocity_trigger->value : + (vr_weapon_velocity_trigger->value / 2.0f); - //normal attack is a punch with the left hand - sendButtonAction("+attack", triggered); - fired = triggered; + 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; + } } } else if (vr.primaryVelocityTriggeredAttack || vr.secondaryVelocityTriggeredAttack) { //send a stop attack as we have an unfinished velocity attack diff --git a/Projects/Android/jni/OpenJK/code/cgame/cg_main.cpp b/Projects/Android/jni/OpenJK/code/cgame/cg_main.cpp index d0b66e8..e05a4b1 100644 --- a/Projects/Android/jni/OpenJK/code/cgame/cg_main.cpp +++ b/Projects/Android/jni/OpenJK/code/cgame/cg_main.cpp @@ -1441,6 +1441,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_r.md3" ); cgs.media.handModel_force = cgi_R_RegisterModel( "models/players/kyle/lhand_f.md3" ); diff --git a/Projects/Android/jni/OpenJK/code/cgame/cg_media.h b/Projects/Android/jni/OpenJK/code/cgame/cg_media.h index 69a8676..633968f 100644 --- a/Projects/Android/jni/OpenJK/code/cgame/cg_media.h +++ b/Projects/Android/jni/OpenJK/code/cgame/cg_media.h @@ -186,6 +186,7 @@ typedef struct { //Hand models qhandle_t handModel_relaxed; + qhandle_t handModel_fist; qhandle_t handModel_force; qhandle_t halfShieldModel; diff --git a/Projects/Android/jni/OpenJK/code/cgame/cg_players.cpp b/Projects/Android/jni/OpenJK/code/cgame/cg_players.cpp index 3362f0d..a45c4c6 100644 --- a/Projects/Android/jni/OpenJK/code/cgame/cg_players.cpp +++ b/Projects/Android/jni/OpenJK/code/cgame/cg_players.cpp @@ -6992,9 +6992,11 @@ 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 && (g_entities[0].client->ps.SaberActive() || vr_motion_enable_saber->integer)) || + cg.snap->ps.weapon == WP_MELEE || cg.snap->ps.weapon == WP_STUN_BATON; } - G_RagDoll(cent->gent, cent->lerpAngles); if ( cent->currentState.weapon ) @@ -7037,7 +7039,7 @@ 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 } @@ -7045,7 +7047,7 @@ Ghoul2 Insert Start } 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 } @@ -8156,7 +8158,7 @@ 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 } @@ -8164,7 +8166,7 @@ Ghoul2 Insert End } 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 } diff --git a/Projects/Android/jni/OpenJK/code/cgame/cg_view.cpp b/Projects/Android/jni/OpenJK/code/cgame/cg_view.cpp index 1c1bc9f..1878809 100644 --- a/Projects/Android/jni/OpenJK/code/cgame/cg_view.cpp +++ b/Projects/Android/jni/OpenJK/code/cgame/cg_view.cpp @@ -2355,13 +2355,13 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView ) { } //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.viewEntity < ENTITYNUM_WORLD && g_entities[cg.snap->ps.viewEntity].client && !(g_entities[cg.snap->ps.viewEntity].client->ps.dualSabers && cg.snap->ps.weapon == WP_SABER) - && cg.snap->ps.weapon != WP_MELEE && !vr->weapon_stabilised && !vr->in_vehicle && !cg_pano.integer @@ -2388,6 +2388,10 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView ) { { 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; @@ -2399,20 +2403,28 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView ) { VectorScale( handEnt.axis[i], (vr->right_handed || i != 1) ? 1.0f : -1.0f, handEnt.axis[i] ); } - centity_t *cent = &cg_entities[cg.snap->ps.clientNum]; - if (!cent) - { - cgi_R_AddRefEntityToScene(&handEnt); - } - else - { - CG_AddRefEntityWithPowerups(&handEnt, cent->currentState.powerups, cent, true); - } + 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 ); diff --git a/Projects/Android/jni/OpenJK/code/cgame/cg_weapons.cpp b/Projects/Android/jni/OpenJK/code/cgame/cg_weapons.cpp index 1b3211e..6721826 100644 --- a/Projects/Android/jni/OpenJK/code/cgame/cg_weapons.cpp +++ b/Projects/Android/jni/OpenJK/code/cgame/cg_weapons.cpp @@ -3118,8 +3118,7 @@ void CG_DrawItemSelector( void ) if (cg.itemSelectorType == ST_WEAPON) // weapons { - if (cg.weaponSelect != WP_NONE && - cg.weaponSelect != WP_MELEE) { + if (cg.weaponSelect != WP_NONE) { refEntity_t sprite; memset(&sprite, 0, sizeof(sprite)); VectorCopy(wheelOrigin, sprite.origin); @@ -3206,10 +3205,9 @@ void CG_DrawItemSelector( void ) } else { - itemId = index + 1; // We need to ignore WP_NONE for weapons - if (itemId == count) + if (itemId == 0) { - break; + itemId = WP_MELEE; } CG_RegisterWeapon(itemId); @@ -3245,8 +3243,7 @@ void CG_DrawItemSelector( void ) VectorClear(angles); angles[YAW] = wheelAngles[YAW]; angles[PITCH] = wheelAngles[PITCH]; - angles[ROLL] = - (float)(360 / (count - ((cg.itemSelectorType == ST_WEAPON && !vr->in_vehicle) ? 1 : 0))) * index; + angles[ROLL] = (float)(360 / count) * index; vec3_t forward, up; AngleVectors(angles, forward, NULL, up); @@ -3487,7 +3484,9 @@ void CG_FireWeapon( centity_t *cent, qboolean alt_fire ) //Haptics switch (ent->weapon) { case WP_SABER: - if (cent->gent->client->ps.dualSabers) + case WP_MELEE: + if (cent->gent->client->ps.dualSabers || + ent->weapon == WP_MELEE) { if (vr->primaryVelocityTriggeredAttack && vr->secondaryVelocityTriggeredAttack) { @@ -3506,7 +3505,8 @@ void CG_FireWeapon( centity_t *cent, qboolean alt_fire ) position = -1; } } - cgi_HapticEvent("chainsaw_fire", position, 0, 40, 0, 0); + + cgi_HapticEvent( "chainsaw_fire", position, 0, 40, 0, 0); break; case WP_BRYAR_PISTOL: case WP_BOWCASTER: diff --git a/Projects/Android/jni/OpenJK/code/game/g_client.cpp b/Projects/Android/jni/OpenJK/code/game/g_client.cpp index c3e3426..6f3d1de 100644 --- a/Projects/Android/jni/OpenJK/code/game/g_client.cpp +++ b/Projects/Android/jni/OpenJK/code/game/g_client.cpp @@ -2260,7 +2260,7 @@ qboolean ClientSpawn(gentity_t *ent, SavedGameJustLoaded_e eSavedGameJustLoaded // give default weapons //these are precached in g_items, ClearRegisteredItems() - client->ps.stats[STAT_WEAPONS] = ( 1 << WP_NONE ); + client->ps.stats[STAT_WEAPONS] = ( 1 << WP_MELEE ); //client->ps.inventory[INV_ELECTROBINOCULARS] = 1; //ent->client->ps.inventory[INV_BACTA_CANISTER] = 1; @@ -2406,7 +2406,7 @@ qboolean ClientSpawn(gentity_t *ent, SavedGameJustLoaded_e eSavedGameJustLoaded if ( spawnPoint->spawnflags & 64 ) //NOWEAPON {//player starts with absolutely no weapons - ent->client->ps.stats[STAT_WEAPONS] = ( 1 << WP_NONE ); + ent->client->ps.stats[STAT_WEAPONS] = ( 1 << WP_MELEE ); ent->client->ps.ammo[weaponData[WP_NONE].ammoIndex] = 32000; ent->client->ps.weapon = WP_NONE; ent->client->ps.weaponstate = WEAPON_READY; diff --git a/Projects/Android/jni/OpenJK/code/game/wp_melee.cpp b/Projects/Android/jni/OpenJK/code/game/wp_melee.cpp index a010be9..1dbd794 100644 --- a/Projects/Android/jni/OpenJK/code/game/wp_melee.cpp +++ b/Projects/Android/jni/OpenJK/code/game/wp_melee.cpp @@ -32,7 +32,7 @@ void WP_Melee( gentity_t *ent ) gentity_t *tr_ent; trace_t tr; vec3_t mins, maxs, end; - int damage = ent->s.number ? (g_spskill->integer*2)+1 : 3; + int damage = ent->s.number ? (g_spskill->integer*2)+1 : 25; float range = ent->s.number ? 64 : 32; VectorMA( muzzle, range, forwardVec, end ); diff --git a/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_main.cpp b/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_main.cpp index f769620..5b3f1a6 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_main.cpp +++ b/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_main.cpp @@ -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_r.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" ); diff --git a/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_media.h b/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_media.h index 101666d..35a3821 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_media.h +++ b/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_media.h @@ -144,6 +144,7 @@ typedef struct { //Hand models qhandle_t handModel_relaxed; + qhandle_t handModel_fist; qhandle_t handModel_force; qhandle_t saberHilt; diff --git a/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_players.cpp b/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_players.cpp index 4773fd1..6843509 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_players.cpp +++ b/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_players.cpp @@ -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) ) { @@ -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.. @@ -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 @@ -5076,7 +5085,7 @@ 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 } @@ -5084,7 +5093,7 @@ Ghoul2 Insert Start } 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 } @@ -5749,7 +5758,7 @@ 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 } @@ -5757,7 +5766,7 @@ Ghoul2 Insert End } 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 } diff --git a/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_view.cpp b/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_view.cpp index 9f43997..3075f99 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_view.cpp +++ b/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_view.cpp @@ -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 @@ -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; @@ -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); - 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 ); @@ -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); } } } diff --git a/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_weapons.cpp b/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_weapons.cpp index 79a3043..4ed6595 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_weapons.cpp +++ b/Projects/Android/jni/OpenJK/codeJK2/cgame/cg_weapons.cpp @@ -2953,8 +2953,7 @@ void CG_DrawItemSelector( void ) if (cg.itemSelectorType == ST_WEAPON) // weapons { - if (cg.weaponSelect != WP_NONE && - cg.weaponSelect != WP_MELEE) { + if (cg.weaponSelect != WP_NONE) { refEntity_t sprite; memset(&sprite, 0, sizeof(sprite)); VectorCopy(wheelOrigin, sprite.origin); @@ -3036,10 +3035,9 @@ void CG_DrawItemSelector( void ) } else { - itemId = index + 1; // We need to ignore WP_NONE for weapons - if (itemId == count) + if (itemId == WP_NONE) { - break; + itemId = WP_MELEE; } } } @@ -3078,8 +3076,7 @@ void CG_DrawItemSelector( void ) VectorClear(angles); angles[YAW] = wheelAngles[YAW]; angles[PITCH] = wheelAngles[PITCH]; - angles[ROLL] = - (float)(360 / (count - ((cg.itemSelectorType == ST_WEAPON && !vr->in_vehicle) ? 1 : 0))) * index; + angles[ROLL] = (float)(360 / count) * index; vec3_t forward, up; AngleVectors(angles, forward, NULL, up); @@ -3311,6 +3308,28 @@ void CG_FireWeapon( centity_t *cent, qboolean alt_fire ) case WP_SABER: cgi_HapticEvent("chainsaw_fire", position, 0, 40, 0, 0); break; + case WP_MELEE: + { + if (vr->primaryVelocityTriggeredAttack && vr->secondaryVelocityTriggeredAttack) + { + position = 4; + } + else if (vr->primaryVelocityTriggeredAttack) + { + position = (vr->right_handed ? 2 : 1); + } + else if (vr->secondaryVelocityTriggeredAttack) // secondary triggered + { + position = (vr->right_handed ? 1 : 2); + } + else + { + position = -1; + } + + cgi_HapticEvent( "chainsaw_fire", position, 0, 50, 0, 0); + } + break; case WP_BRYAR_PISTOL: case WP_BOWCASTER: case WP_BLASTER: diff --git a/Projects/Android/jni/OpenJK/codeJK2/game/g_client.cpp b/Projects/Android/jni/OpenJK/codeJK2/game/g_client.cpp index 5ea04b6..091e443 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/game/g_client.cpp +++ b/Projects/Android/jni/OpenJK/codeJK2/game/g_client.cpp @@ -1645,7 +1645,7 @@ qboolean ClientSpawn(gentity_t *ent, SavedGameJustLoaded_e eSavedGameJustLoaded client->ps.clientNum = index; // give default weapons - client->ps.stats[STAT_WEAPONS] = ( 1 << WP_NONE ); + client->ps.stats[STAT_WEAPONS] = ( 1 << WP_MELEE ); client->ps.stats[STAT_WEAPONS] |= ( 1 << WP_BRYAR_PISTOL ); //these are precached in g_items, ClearRegisteredItems() client->ps.inventory[INV_ELECTROBINOCULARS] = 1; @@ -1766,7 +1766,7 @@ qboolean ClientSpawn(gentity_t *ent, SavedGameJustLoaded_e eSavedGameJustLoaded if ( spawnPoint->spawnflags & 64 ) {//player starts with absolutely no weapons - ent->client->ps.stats[STAT_WEAPONS] = ( 1 << WP_NONE ); + ent->client->ps.stats[STAT_WEAPONS] = ( 1 << WP_MELEE ); ent->client->ps.ammo[weaponData[WP_NONE].ammoIndex] = 32000; // checkme ent->client->ps.weapon = WP_NONE; ent->client->ps.weaponstate = WEAPON_READY; diff --git a/Projects/Android/jni/OpenJK/codeJK2/game/weapons.h b/Projects/Android/jni/OpenJK/codeJK2/game/weapons.h index f796fc6..cea3740 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/game/weapons.h +++ b/Projects/Android/jni/OpenJK/codeJK2/game/weapons.h @@ -84,7 +84,7 @@ typedef enum //# weapon_e } weapon_t; #define FIRST_WEAPON WP_SABER // this is the first weapon for next and prev weapon switching -#define MAX_PLAYER_WEAPONS WP_STUN_BATON // this is the max you can switch to and get with the give all. +#define MAX_PLAYER_WEAPONS WP_MELEE // this is the max you can switch to and get with the give all. // AMMO_NONE must be first and AMMO_MAX must be last, cause weapon load validates based off of these vals typedef enum //# ammo_e diff --git a/Projects/Android/jni/OpenJK/codeJK2/game/wp_melee.cpp b/Projects/Android/jni/OpenJK/codeJK2/game/wp_melee.cpp index a6237c4..68646ea 100644 --- a/Projects/Android/jni/OpenJK/codeJK2/game/wp_melee.cpp +++ b/Projects/Android/jni/OpenJK/codeJK2/game/wp_melee.cpp @@ -36,7 +36,7 @@ void WP_Melee( gentity_t *ent ) gentity_t *tr_ent; trace_t tr; vec3_t mins, maxs, end; - int damage = ent->s.number ? (g_spskill->integer*2)+1 : 3; + int damage = ent->s.number ? (g_spskill->integer*2)+1 : 25; float range = ent->s.number ? 64 : 32; VectorMA( wpMuzzle, range, wpFwd, end );