mirror of
https://github.com/DrBeef/JKXR.git
synced 2024-11-21 19:51:33 +00:00
Put force power selector on off-hand
This commit is contained in:
parent
a2669f4873
commit
c30950dca0
7 changed files with 108 additions and 83 deletions
|
@ -38,7 +38,7 @@ typedef struct {
|
|||
vec3_t weaponoffset_history[NUM_WEAPON_SAMPLES];
|
||||
float weaponoffset_history_timestamp[NUM_WEAPON_SAMPLES];
|
||||
|
||||
bool item_selector;
|
||||
int item_selector = 0; // 1 - weapons/gadgets/saber stance, 2 - Force powers
|
||||
|
||||
bool pistol; // True if the weapon is a pistol
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
#include "VrCommon.h"
|
||||
|
||||
#define STABILISATION_DISTANCE 0.5
|
||||
#define STABILISATION_DISTANCE 0.25
|
||||
#define SCOPE_ENGAGE_DISTANCE 0.25
|
||||
#define VSTOCK_ENGAGE_DISTANCE 0.25
|
||||
#define BINOCULAR_ENGAGE_DISTANCE 0.25
|
||||
|
|
|
@ -45,7 +45,6 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
|
|||
vr_control_scheme->value == 99; // Always right-handed for weapon calibration
|
||||
|
||||
static bool dominantGripPushed = false;
|
||||
static float dominantGripPushTime = 0.0f;
|
||||
static bool canUseBackpack = false;
|
||||
static bool canUseQuickSave = false;
|
||||
|
||||
|
@ -158,20 +157,28 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
|
|||
|
||||
float controllerYawHeading = 0.0f;
|
||||
//Turn on weapon stabilisation?
|
||||
bool stabilised = qfalse;
|
||||
bool offhandGripPushed = (pOffTrackedRemoteNew->Buttons & ovrButton_GripTrigger);
|
||||
if ( (offhandGripPushed != (pOffTrackedRemoteOld->Buttons & ovrButton_GripTrigger)) &&
|
||||
offhandGripPushed && (distance < STABILISATION_DISTANCE))
|
||||
//#ifndef DEBUG
|
||||
if (offhandGripPushed)
|
||||
{
|
||||
stabilised = qtrue;
|
||||
}/*
|
||||
#else
|
||||
{
|
||||
Cvar_Set("vr_control_scheme", "99");
|
||||
if (!vr.weapon_stabilised && vr.item_selector == 0)
|
||||
{
|
||||
if (distance < STABILISATION_DISTANCE) {
|
||||
vr.weapon_stabilised = true;
|
||||
} else {
|
||||
vr.item_selector = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
else if (vr.item_selector == 2)
|
||||
{
|
||||
sendButtonActionSimple("itemselectorselect");
|
||||
vr.item_selector = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
vr.weapon_stabilised = false;
|
||||
}
|
||||
|
||||
dominantGripPushed = (pDominantTrackedRemoteNew->Buttons &
|
||||
ovrButton_GripTrigger) != 0;
|
||||
bool dominantButton1Pushed = (pDominantTrackedRemoteNew->Buttons &
|
||||
|
@ -180,22 +187,15 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
|
|||
domButton2) != 0;
|
||||
|
||||
//Do this early so we can suppress other button actions when item selector is up
|
||||
if (dominantGripPushed) {
|
||||
if (vr.item_selector == 0) {
|
||||
vr.item_selector = 1;
|
||||
}
|
||||
}
|
||||
else if (vr.item_selector == 1)
|
||||
{
|
||||
if (dominantGripPushed) {
|
||||
if (dominantGripPushTime == 0) {
|
||||
dominantGripPushTime = GetTimeInMilliSeconds();
|
||||
}
|
||||
vr.item_selector = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
dominantGripPushTime = 0;
|
||||
if (vr.item_selector)
|
||||
{
|
||||
sendButtonActionSimple("itemselectorselect");
|
||||
vr.item_selector = false;
|
||||
}
|
||||
}
|
||||
sendButtonActionSimple("itemselectorselect");
|
||||
vr.item_selector = 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -255,8 +255,6 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
|
|||
}
|
||||
}
|
||||
|
||||
vr.weapon_stabilised = stabilised;
|
||||
|
||||
//if (!vr.item_selector)
|
||||
{
|
||||
//Engage scope / virtual stock if conditions are right
|
||||
|
|
|
@ -444,7 +444,7 @@ typedef struct {
|
|||
int weaponAnimation;
|
||||
int weaponAnimationTime;
|
||||
|
||||
int itemSelectorType; // 0 - weapons, 1 - force powers, 2 - gadgets, 3 - fighting-style
|
||||
int itemSelectorType; // 0 - weapons, 1 - gadgets, 2 - fighting-style, 3 - force powers
|
||||
int itemSelectorSelection;
|
||||
int itemSelectorTime;
|
||||
vec3_t itemSelectorAngles;
|
||||
|
|
|
@ -4458,7 +4458,7 @@ void CG_AddSaberBlade( centity_t *cent, centity_t *scent, refEntity_t *saber, in
|
|||
return;
|
||||
}
|
||||
|
||||
if (vr->item_selector && !cg.renderingThirdPerson)
|
||||
if (vr->item_selector && cent->gent->client->ps.clientNum == 0 && !cg.renderingThirdPerson)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1994,8 +1994,6 @@ wasForceSpeed=isForceSpeed;
|
|||
cgi_CM_SnapPVS( cg.refdef.vieworg, cg.snap->areamask );
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (vr->item_selector)
|
||||
{
|
||||
CG_DrawItemSelector();
|
||||
|
|
|
@ -2670,7 +2670,7 @@ void CG_ItemSelectorSelect_f( void )
|
|||
return;
|
||||
}
|
||||
|
||||
if (cg.itemSelectorType == 0)
|
||||
if (cg.itemSelectorType == 0) // weapons
|
||||
{
|
||||
if (cg.weaponSelect == cg.itemSelectorSelection)
|
||||
{
|
||||
|
@ -2680,17 +2680,7 @@ void CG_ItemSelectorSelect_f( void )
|
|||
cg.weaponSelectTime = cg.time;
|
||||
cg.weaponSelect = cg.itemSelectorSelection;
|
||||
}
|
||||
else if (cg.itemSelectorType == 1)
|
||||
{
|
||||
if (cg.forcepowerSelect == cg.itemSelectorSelection)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
cg.forcepowerSelectTime = cg.time;
|
||||
cg.forcepowerSelect = cg.itemSelectorSelection;
|
||||
}
|
||||
else if (cg.itemSelectorType == 2)
|
||||
else if (cg.itemSelectorType == 1) // gadgets
|
||||
{
|
||||
cg.inventorySelectTime = cg.time;
|
||||
cg.inventorySelect = cg.itemSelectorSelection;
|
||||
|
@ -2701,10 +2691,20 @@ void CG_ItemSelectorSelect_f( void )
|
|||
Cmd_UseInventory_f(player);
|
||||
}
|
||||
}
|
||||
else //fighting style
|
||||
else if (cg.itemSelectorType == 2) //fighting style
|
||||
{
|
||||
cgi_SendConsoleCommand(va( "setSaberLevel %i\n", cg.itemSelectorSelection + 1));
|
||||
}
|
||||
else // 3 - force powers
|
||||
{
|
||||
if (cg.forcepowerSelect == cg.itemSelectorSelection)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
cg.forcepowerSelectTime = cg.time;
|
||||
cg.forcepowerSelect = cg.itemSelectorSelection;
|
||||
}
|
||||
|
||||
//reset ready for next time
|
||||
cg.itemSelectorSelection = -1;
|
||||
|
@ -2712,18 +2712,28 @@ void CG_ItemSelectorSelect_f( void )
|
|||
|
||||
void CG_ItemSelectorNext_f( void )
|
||||
{
|
||||
if (cg.itemSelectorType == 3)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
cent->currentState.weapon == WP_SABER) ? 3 : 2;
|
||||
cg.itemSelectorType = (cg.itemSelectorType+1) % selectors;
|
||||
cg.itemSelectorTime = cg.time;
|
||||
}
|
||||
|
||||
void CG_ItemSelectorPrev_f( void )
|
||||
{
|
||||
if (cg.itemSelectorType == 3)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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;
|
||||
cent->currentState.weapon == WP_SABER) ? 3 : 2;
|
||||
if (--cg.itemSelectorType < 0)
|
||||
cg.itemSelectorType = selectors-1;
|
||||
cg.itemSelectorTime = cg.time;
|
||||
|
@ -2739,9 +2749,20 @@ void CG_DrawItemSelector( void )
|
|||
if (cg.itemSelectorTime == 0)
|
||||
{
|
||||
cg.itemSelectorTime = cg.time;
|
||||
VectorCopy(vr->weaponangles, cg.itemSelectorAngles);
|
||||
VectorCopy(vr->weaponposition, cg.itemSelectorOrigin);
|
||||
VectorCopy(vr->weaponoffset, cg.itemSelectorOffset);
|
||||
|
||||
if (vr->item_selector == 2)
|
||||
{
|
||||
cg.itemSelectorType = 3;
|
||||
VectorCopy(vr->offhandangles, cg.itemSelectorAngles);
|
||||
VectorCopy(vr->offhandposition, cg.itemSelectorOrigin);
|
||||
VectorCopy(vr->offhandoffset, cg.itemSelectorOffset);
|
||||
}
|
||||
else {
|
||||
cg.itemSelectorType = 0;
|
||||
VectorCopy(vr->weaponangles, cg.itemSelectorAngles);
|
||||
VectorCopy(vr->weaponposition, cg.itemSelectorOrigin);
|
||||
VectorCopy(vr->weaponoffset, cg.itemSelectorOffset);
|
||||
}
|
||||
}
|
||||
|
||||
float dist = 10.0f;
|
||||
|
@ -2756,8 +2777,16 @@ void CG_DrawItemSelector( void )
|
|||
cgi_Cvar_Set("timescale", "0.22");
|
||||
|
||||
vec3_t controllerOrigin, controllerAngles, controllerOffset, selectorOrigin;
|
||||
BG_CalculateVRWeaponPosition(controllerOrigin, controllerAngles);
|
||||
VectorSubtract(vr->weaponposition, cg.itemSelectorOrigin, controllerOffset);
|
||||
if (cg.itemSelectorType == 3)
|
||||
{
|
||||
BG_CalculateVROffHandPosition(controllerOrigin, controllerAngles);
|
||||
VectorSubtract(vr->offhandposition, cg.itemSelectorOrigin, controllerOffset);
|
||||
}
|
||||
else
|
||||
{
|
||||
BG_CalculateVRWeaponPosition(controllerOrigin, controllerAngles);
|
||||
VectorSubtract(vr->weaponposition, cg.itemSelectorOrigin, controllerOffset);
|
||||
}
|
||||
|
||||
vec3_t wheelAngles, wheelOrigin, beamOrigin, wheelForward, wheelRight, wheelUp;
|
||||
cg.itemSelectorAngles[YAW] = vr->hmdorientation[YAW];
|
||||
|
@ -2805,15 +2834,15 @@ void CG_DrawItemSelector( void )
|
|||
case 0: //weapons
|
||||
count = WP_MELEE;
|
||||
break;
|
||||
case 1: // force powers
|
||||
count = MAX_SHOWPOWERS;
|
||||
break;
|
||||
case 2: //gadgets
|
||||
case 1: //gadgets
|
||||
count = INV_GOODIE_KEY;
|
||||
break;
|
||||
case 3: //fighting style
|
||||
case 2: //fighting style
|
||||
count = 3;
|
||||
break;
|
||||
case 3: // force powers
|
||||
count = MAX_SHOWPOWERS;
|
||||
break;
|
||||
}
|
||||
|
||||
if (cg.itemSelectorType == 0) // weapons
|
||||
|
@ -2827,18 +2856,7 @@ void CG_DrawItemSelector( void )
|
|||
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
|
||||
else if (cg.itemSelectorType == 2) // fighting style
|
||||
{
|
||||
//For the fighting style show the active one in the middle
|
||||
int level = cent->gent->client->ps.saberAnimLevel;
|
||||
|
@ -2865,8 +2883,19 @@ void CG_DrawItemSelector( void )
|
|||
cgi_R_AddRefEntityToScene(&sprite);
|
||||
}
|
||||
}
|
||||
else if (cg.itemSelectorType == 3) // 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);
|
||||
}
|
||||
|
||||
if (cg.itemSelectorType != 2) {
|
||||
if (cg.itemSelectorType != 1) {
|
||||
for (int s = -1; s < 2; s += 2) {
|
||||
refEntity_t sprite;
|
||||
memset(&sprite, 0, sizeof(sprite));
|
||||
|
@ -2920,13 +2949,10 @@ void CG_DrawItemSelector( void )
|
|||
case 0: //weapons
|
||||
selectable = CG_WeaponSelectable(itemId, cg.weaponSelect, qfalse) && cg.snap->ps.ammo[weaponData[itemId].ammoIndex];
|
||||
break;
|
||||
case 1: // force powers
|
||||
selectable = ForcePower_Valid(itemId);
|
||||
break;
|
||||
case 2: //gadgets
|
||||
case 1: //gadgets
|
||||
selectable = CG_InventorySelectable(itemId) && inv_icons[itemId];
|
||||
break;
|
||||
case 3: //fighting style
|
||||
case 2: //fighting style
|
||||
{
|
||||
if (cent->gent->client->ps.forcePowersKnown & ( 1 << FP_SABER_OFFENSE )) {
|
||||
selectable = itemId < cent->gent->client->ps.forcePowerLevel[FP_SABER_OFFENSE];
|
||||
|
@ -2935,6 +2961,9 @@ void CG_DrawItemSelector( void )
|
|||
}
|
||||
}
|
||||
break;
|
||||
case 3: // force powers
|
||||
selectable = ForcePower_Valid(itemId);
|
||||
break;
|
||||
}
|
||||
|
||||
if (selectable) {
|
||||
|
@ -2998,13 +3027,10 @@ void CG_DrawItemSelector( void )
|
|||
case 0: //weapons
|
||||
sprite.customShader = cg_weapons[itemId].weaponIcon;
|
||||
break;
|
||||
case 1: // force powers
|
||||
sprite.customShader = force_icons[showPowers[itemId]];
|
||||
break;
|
||||
case 2: //gadgets
|
||||
case 1: //gadgets
|
||||
sprite.customShader = inv_icons[itemId];
|
||||
break;
|
||||
case 3: //fighting style
|
||||
case 2: //fighting style
|
||||
switch ( itemId )
|
||||
{
|
||||
case 0://FORCE_LEVEL_1:
|
||||
|
@ -3018,6 +3044,9 @@ void CG_DrawItemSelector( void )
|
|||
break;
|
||||
}
|
||||
break;
|
||||
case 3: // force powers
|
||||
sprite.customShader = force_icons[showPowers[itemId]];
|
||||
break;
|
||||
}
|
||||
|
||||
sprite.radius =
|
||||
|
|
Loading…
Reference in a new issue