Multiple changes

- New Hand models for relaxed and force hands and textures (@baggyg)
- Additional selector screen when using the saber to change stance
- show current item in the selector
- Allow player to restart game if they die holding the saber

Co-Authored-By: Grant Bagwell <general@grantbagwell.co.uk>
This commit is contained in:
Simon 2022-10-14 23:51:31 +01:00
parent 7a37500c70
commit 086949eedd
14 changed files with 220 additions and 29 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="16"
android:versionName="0.2.1" android:installLocation="auto" >
android:versionCode="17"
android:versionName="0.2.2" android:installLocation="auto" >
<!-- Tell the system this app requires OpenGL ES 3.1. -->
<uses-feature android:glEsVersion="0x00030001" android:required="true"/>

View file

@ -162,16 +162,16 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
bool offhandGripPushed = (pOffTrackedRemoteNew->Buttons & ovrButton_GripTrigger);
if ( (offhandGripPushed != (pOffTrackedRemoteOld->Buttons & ovrButton_GripTrigger)) &&
offhandGripPushed && (distance < STABILISATION_DISTANCE))
#ifndef DEBUG
//#ifndef DEBUG
{
stabilised = qtrue;
}
}/*
#else
{
Cvar_Set("vr_control_scheme", "99");
}
#endif
*/
dominantGripPushed = (pDominantTrackedRemoteNew->Buttons &
ovrButton_GripTrigger) != 0;
bool dominantButton1Pushed = (pDominantTrackedRemoteNew->Buttons &
@ -230,7 +230,7 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
}
}
if (vr.cgzoommode > 1)
if (vr.cgzoommode > 0)
{
if (between(-0.2f, primaryJoystickX, 0.2f)) {
sendButtonAction("+attack", between(0.8f, pPrimaryJoystick->y, 1.0f));
@ -557,15 +557,45 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
{
sendButtonActionSimple("invuse");
}
else {
else if (vr.weaponid == WP_SABER && vr.velocitytriggered)
{
//B button toggles saber on/off in first person
if (primaryButtonsNew & primaryButton2) {
sendButtonActionSimple("togglesaber");
}
}
else
{
sendButtonAction("+altattack", (primaryButtonsNew & primaryButton2));
}
}
static bool firing = false;
static bool throwing = false;
if (!vr.velocitytriggered) // Don't fire velocity triggered weapons
int thirdPerson = Cvar_VariableIntegerValue("cg_thirdPerson");
if (vr.weaponid == WP_SABER && !thirdPerson && vr.cgzoommode == 0)
{
static bool previous_throwing = false;
previous_throwing = throwing;
if (!throwing &&
vr.primaryVelocityTriggeredAttack &&
(pDominantTrackedRemoteNew->Buttons & ovrButton_Trigger))
{
throwing = true;
}
else if (throwing && !(pDominantTrackedRemoteNew->Buttons & ovrButton_Trigger))
{
throwing = false;
}
if (previous_throwing != throwing) {
sendButtonAction("+altattack", throwing);
}
}
else if (!vr.velocitytriggered) // Don't fire velocity triggered weapons
{
//Fire Primary - Doesn't trigger the saber
if ((pDominantTrackedRemoteNew->Buttons & ovrButton_Trigger) !=
@ -576,14 +606,12 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
firing = (pDominantTrackedRemoteNew->Buttons & ovrButton_Trigger);
sendButtonAction("+attack", firing);
}
}
else if (vr.weaponid == WP_SABER)
{
if ((pDominantTrackedRemoteNew->Buttons & ovrButton_Trigger) !=
(pDominantTrackedRemoteOld->Buttons & ovrButton_Trigger)) {
if (pDominantTrackedRemoteNew->Buttons & ovrButton_Trigger) {
sendButtonActionSimple("togglesaber");
}
if (throwing)
{
//if throwing is still activated here, just disable
throwing = false;
sendButtonAction("+altattack", throwing);
}
}

View file

@ -444,7 +444,7 @@ typedef struct {
int weaponAnimation;
int weaponAnimationTime;
int itemSelectorType; // 0 - weapons, 1 - force powers, 2 - gadgets
int itemSelectorType; // 0 - weapons, 1 - force powers, 2 - gadgets, 3 - fighting-style
int itemSelectorSelection;
int itemSelectorTime;
vec3_t itemSelectorAngles;

View file

@ -1293,6 +1293,10 @@ static void CG_RegisterGraphics( void ) {
cgs.media.cloakedShader = cgi_R_RegisterShader( "gfx/effects/cloakedShader" );
cgi_R_RegisterShader( "gfx/misc/ion_shield" );
//VR Hand models
cgs.media.handModel_relaxed = cgi_R_RegisterModel( "models/players/kyle/lhand_r.md3" );
cgs.media.handModel_force = cgi_R_RegisterModel( "models/players/kyle/lhand_f.md3" );
cgs.media.boltShader = cgi_R_RegisterShader( "gfx/misc/blueLine" );
// FIXME: do these conditionally

View file

@ -137,6 +137,11 @@ typedef struct {
qhandle_t explosionModel;
qhandle_t surfaceExplosionShader;
//Hand models
qhandle_t handModel_relaxed;
qhandle_t handModel_force;
qhandle_t solidWhiteShader;
qhandle_t electricBodyShader;
qhandle_t electricBody2Shader;

View file

@ -3450,6 +3450,7 @@ void CG_AddRefEntityWithPowerups( refEntity_t *ent, int powerups, centity_t *cen
hiltEnt.hModel = cgi_R_RegisterModel( "models/weapons2/saber/saber_w.md3" );
vec3_t angles;
BG_CalculateVRSaberPosition(hiltEnt.origin, hiltEnt.angles);
hiltEnt.angles[ROLL] += 180;
VectorCopy(hiltEnt.origin, hiltEnt.oldorigin);
vec3_t axis[3];
AnglesToAxis(hiltEnt.angles, axis);
@ -4457,7 +4458,7 @@ void CG_AddSaberBlade( centity_t *cent, centity_t *scent, refEntity_t *saber, in
return;
}
if (vr->item_selector)
if (vr->item_selector && !cg.renderingThirdPerson)
{
return;
}
@ -4858,7 +4859,11 @@ void CG_Player(centity_t *cent ) {
return;
}
vr->weaponid = cg.snap->ps.weapon;
if (cg.snap->ps.stats[STAT_HEALTH] > 0) {
vr->weaponid = cg.snap->ps.weapon;
} else {
vr->weaponid = WP_NONE;
}
//Get the player's light level for stealth calculations
CG_GetPlayerLightLevel( cent );

View file

@ -2026,7 +2026,17 @@ wasForceSpeed=isForceSpeed;
handEnt.renderfx = RF_DEPTHHACK;
handEnt.hModel = cgi_R_RegisterModel( "models/players/kyle/lhand_r.md3" );
if (cg.snap->ps.powerups[PW_FORCE_PUSH] > cg.time ||
(cg.snap->ps.forcePowersActive & (1<<FP_GRIP)) ||
(cg.snap->ps.forcePowersActive & (1<<FP_LIGHTNING)))
{
handEnt.hModel = cgs.media.handModel_force;
}
else
{
handEnt.hModel = cgs.media.handModel_relaxed;
}
VectorCopy(handEnt.origin, handEnt.oldorigin);
AnglesToAxis(handEnt.angles, handEnt.axis);

View file

@ -2702,6 +2702,10 @@ void CG_ItemSelectorSelect_f( void )
Cmd_UseInventory_f(player);
}
}
else //fighting style
{
cgi_SendConsoleCommand(va( "setSaberLevel %i\n", cg.itemSelectorSelection + 1));
}
//reset ready for next time
cg.itemSelectorSelection = -1;
@ -2709,14 +2713,20 @@ void CG_ItemSelectorSelect_f( void )
void CG_ItemSelectorNext_f( void )
{
cg.itemSelectorType = (cg.itemSelectorType+1) % 3;
centity_t *cent = &cg_entities[cg.snap->ps.clientNum];
int selectors = ((cent->gent->client->ps.forcePowersKnown & ( 1 << FP_SABER_OFFENSE )) &&
cent->currentState.weapon == WP_SABER) ? 4 : 3;
cg.itemSelectorType = (cg.itemSelectorType+1) % selectors;
cg.itemSelectorTime = cg.time;
}
void CG_ItemSelectorPrev_f( void )
{
centity_t *cent = &cg_entities[cg.snap->ps.clientNum];
int selectors = ((cent->gent->client->ps.forcePowersKnown & ( 1 << FP_SABER_OFFENSE )) &&
cent->currentState.weapon == WP_SABER) ? 4 : 3;
if (--cg.itemSelectorType < 0)
cg.itemSelectorType = 2;
cg.itemSelectorType = selectors-1;
cg.itemSelectorTime = cg.time;
}
@ -2788,11 +2798,13 @@ void CG_DrawItemSelector( void )
}
centity_t *cent = &cg_entities[cg.snap->ps.clientNum];
int count;
switch (cg.itemSelectorType)
{
case 0: //weapons
count = WP_EMPLACED_GUN;
count = WP_MELEE;
break;
case 1: // force powers
count = MAX_SHOWPOWERS;
@ -2800,6 +2812,79 @@ void CG_DrawItemSelector( void )
case 2: //gadgets
count = INV_GOODIE_KEY;
break;
case 3: //fighting style
count = 3;
break;
}
if (cg.itemSelectorType == 0) // weapons
{
refEntity_t sprite;
memset(&sprite, 0, sizeof(sprite));
VectorCopy(wheelOrigin, sprite.origin);
sprite.reType = RT_SPRITE;
sprite.customShader = cg_weapons[cg.weaponSelect].weaponIcon;
sprite.radius = 1.8f;
memset(sprite.shaderRGBA, 0xff, 4);
cgi_R_AddRefEntityToScene(&sprite);
}
else if (cg.itemSelectorType == 1) // force powers
{
refEntity_t sprite;
memset(&sprite, 0, sizeof(sprite));
VectorCopy(wheelOrigin, sprite.origin);
sprite.reType = RT_SPRITE;
sprite.customShader = force_icons[showPowers[cg.forcepowerSelect]];
sprite.radius = 1.8f;
memset(sprite.shaderRGBA, 0xff, 4);
cgi_R_AddRefEntityToScene(&sprite);
}
else if (cg.itemSelectorType == 3) // fighting style
{
//For the fighting style show the active one in the middle
int level = cent->gent->client->ps.saberAnimLevel;
if (cent->gent->client->ps.forcePowersKnown & (1 << FP_SABER_OFFENSE) &&
level > FORCE_LEVEL_0) {
refEntity_t sprite;
memset(&sprite, 0, sizeof(sprite));
VectorCopy(wheelOrigin, sprite.origin);
sprite.reType = RT_SPRITE;
switch (level) {
case FORCE_LEVEL_1:
sprite.customShader = cgs.media.HUDSaberStyleFast;
break;
case FORCE_LEVEL_2:
sprite.customShader = cgs.media.HUDSaberStyleMed;
break;
case FORCE_LEVEL_3:
sprite.customShader = cgs.media.HUDSaberStyleStrong;
break;
}
sprite.radius = 1.8f;
memset(sprite.shaderRGBA, 0xff, 4);
cgi_R_AddRefEntityToScene(&sprite);
}
}
if (cg.itemSelectorType != 2) {
for (int s = -1; s < 2; s += 2) {
refEntity_t sprite;
memset(&sprite, 0, sizeof(sprite));
vec3_t right;
AngleVectors(wheelAngles, NULL, right, NULL);
float offset = ((float) s * 2.0f) + (((float) s * 0.3f) * sinf(DEG2RAD(
AngleNormalize360(
cg.time -
cg.itemSelectorTime))));
VectorMA(wheelOrigin, offset, right, sprite.origin);
sprite.reType = RT_SPRITE;
sprite.customShader = cgs.media.binocularArrow;
sprite.radius = 0.6f;
sprite.rotation = 180.0f * ((s - 1.0f) / 2.0f);
memset(sprite.shaderRGBA, 0xff, 4);
cgi_R_AddRefEntityToScene(&sprite);
}
}
qboolean selected = qfalse;
@ -2842,6 +2927,15 @@ void CG_DrawItemSelector( void )
case 2: //gadgets
selectable = CG_InventorySelectable(itemId) && inv_icons[itemId];
break;
case 3: //fighting style
{
if (cent->gent->client->ps.forcePowersKnown & ( 1 << FP_SABER_OFFENSE )) {
selectable = itemId < cent->gent->client->ps.forcePowerLevel[FP_SABER_OFFENSE];
} else {
selectable = false;
}
}
break;
}
if (selectable) {
@ -2851,7 +2945,7 @@ void CG_DrawItemSelector( void )
angles[YAW] = wheelAngles[YAW];
angles[PITCH] = wheelAngles[PITCH];
angles[ROLL] =
(360 / count) * (itemId - 1);
(float)(360 / (count - ((cg.itemSelectorType == 0) ? 1 : 0))) * index;
vec3_t forward, up;
AngleVectors(angles, forward, NULL, up);
@ -2911,6 +3005,20 @@ void CG_DrawItemSelector( void )
case 2: //gadgets
sprite.customShader = inv_icons[itemId];
break;
case 3: //fighting style
switch ( itemId )
{
case 0://FORCE_LEVEL_1:
sprite.customShader = cgs.media.HUDSaberStyleFast;
break;
case 1://FORCE_LEVEL_2:
sprite.customShader = cgs.media.HUDSaberStyleMed;
break;
case 2://FORCE_LEVEL_3:
sprite.customShader = cgs.media.HUDSaberStyleStrong;
break;
}
break;
}
sprite.radius =

View file

@ -259,11 +259,11 @@ static void Svcmd_ForceSetLevel_f( int forcePower )
{
return;
}
if ( !g_cheats->integer )
/* if ( !g_cheats->integer )
{
gi.SendServerCommand( 0, "print \"Cheats are not enabled on this server.\n\"");
return;
}
}*/
const char *newVal = gi.argv(1);
if ( !VALIDSTRING( newVal ) )
{
@ -373,6 +373,36 @@ void Svcmd_SaberAttackCycle_f( void )
#endif
}
void Svcmd_SaberSetLevel_f( void )
{
if ( !&g_entities[0] || !g_entities[0].client )
{
return;
}
gentity_t *self = G_GetSelfForPlayerCmd();
if ( self->s.weapon != WP_SABER )
{
return;
}
const char *newVal = gi.argv(1);
int saberAnimLevel = atoi(newVal);
if ( saberAnimLevel > self->client->ps.forcePowerLevel[FP_SABER_OFFENSE] )
{//wrap around
saberAnimLevel = FORCE_LEVEL_1;
}
if ( !self->s.number )
{
cg.saberAnimLevelPending = saberAnimLevel;
}
else
{
self->client->ps.saberAnimLevel = saberAnimLevel;
}
}
template <int32_t power>
static void Svcmd_ForceSetLevel_f(void)
{
@ -573,13 +603,14 @@ static svcmd_t svcmds[] = {
{ "setForceGrip", Svcmd_ForceSetLevel_f<FP_GRIP>, CMD_CHEAT },
{ "setForceLightning", Svcmd_ForceSetLevel_f<FP_LIGHTNING>, CMD_CHEAT },
{ "setMindTrick", Svcmd_ForceSetLevel_f<FP_TELEPATHY>, CMD_CHEAT },
{ "setSaberDefense", Svcmd_ForceSetLevel_f<FP_SABER_DEFENSE>, CMD_CHEAT },
{ "setSaberOffense", Svcmd_ForceSetLevel_f<FP_SABER_OFFENSE>, CMD_CHEAT },
{ "setSaberDefense", Svcmd_ForceSetLevel_f<FP_SABER_DEFENSE>, CMD_NONE },
{ "setSaberOffense", Svcmd_ForceSetLevel_f<FP_SABER_OFFENSE>, CMD_NONE },
{ "setSaberLevel", Svcmd_SaberSetLevel_f, CMD_NONE },
{ "setForceAll", Svcmd_SetForceAll_f, CMD_CHEAT },
{ "setSaberAll", Svcmd_SetSaberAll_f, CMD_CHEAT },
{ "saberAttackCycle", Svcmd_SaberAttackCycle_f, CMD_NONE },
{ "runscript", Svcmd_RunScript_f, CMD_CHEAT },
{ "playerTeam", Svcmd_PlayerTeam_f, CMD_CHEAT },

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 118 KiB

After

Width:  |  Height:  |  Size: 864 KiB