Motion controlled Force Push/Pull

This commit is contained in:
Simon 2022-11-07 23:57:10 +00:00
parent 62f1924dff
commit 0d70fae512
7 changed files with 536 additions and 460 deletions

View file

@ -1308,8 +1308,10 @@ void JKVR_Init()
vr_immersive_cinematics = Cvar_Get("vr_immersive_cinematics", "1", CVAR_ARCHIVE); vr_immersive_cinematics = Cvar_Get("vr_immersive_cinematics", "1", CVAR_ARCHIVE);
vr_screen_dist = Cvar_Get( "vr_screen_dist", "2.5", CVAR_ARCHIVE); vr_screen_dist = Cvar_Get( "vr_screen_dist", "2.5", CVAR_ARCHIVE);
vr_weapon_velocity_trigger = Cvar_Get( "vr_weapon_velocity_trigger", "2.3", CVAR_ARCHIVE); vr_weapon_velocity_trigger = Cvar_Get( "vr_weapon_velocity_trigger", "2.0", CVAR_ARCHIVE);
vr_force_velocity_trigger = Cvar_Get( "vr_force_velocity_trigger", "2.0", CVAR_ARCHIVE);
vr_two_handed_weapons = Cvar_Get ("vr_two_handed_weapons", "1", 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);
cvar_t *expanded_menu_enabled = Cvar_Get ("expanded_menu_enabled", "0", CVAR_ARCHIVE); cvar_t *expanded_menu_enabled = Cvar_Get ("expanded_menu_enabled", "0", CVAR_ARCHIVE);
if (FS_FileExists("expanded_menu.pk3")) { if (FS_FileExists("expanded_menu.pk3")) {

View file

@ -61,6 +61,7 @@ typedef struct {
bool primaryVelocityTriggeredAttack; bool primaryVelocityTriggeredAttack;
float secondaryswingvelocity; float secondaryswingvelocity;
bool secondaryVelocityTriggeredAttack; bool secondaryVelocityTriggeredAttack;
vec3_t secondaryVelocityTriggerLocation;
vec3_t offhandangles; vec3_t offhandangles;
vec3_t offhandangles_last; // Don't use this, it is just for calculating delta! vec3_t offhandangles_last; // Don't use this, it is just for calculating delta!

View file

@ -10,5 +10,7 @@ extern cvar_t *vr_switch_sticks;
extern cvar_t *vr_immersive_cinematics; extern cvar_t *vr_immersive_cinematics;
extern cvar_t *vr_screen_dist; extern cvar_t *vr_screen_dist;
extern cvar_t *vr_weapon_velocity_trigger; extern cvar_t *vr_weapon_velocity_trigger;
extern cvar_t *vr_force_velocity_trigger;
extern cvar_t *vr_two_handed_weapons; extern cvar_t *vr_two_handed_weapons;
extern cvar_t *vr_force_motion_controlled;

View file

@ -30,7 +30,9 @@ cvar_t *vr_switch_sticks;
cvar_t *vr_immersive_cinematics; cvar_t *vr_immersive_cinematics;
cvar_t *vr_screen_dist; cvar_t *vr_screen_dist;
cvar_t *vr_weapon_velocity_trigger; cvar_t *vr_weapon_velocity_trigger;
cvar_t *vr_force_velocity_trigger;
cvar_t *vr_two_handed_weapons; cvar_t *vr_two_handed_weapons;
cvar_t *vr_force_motion_controlled;
ovrInputStateTrackedRemote leftTrackedRemoteState_old; ovrInputStateTrackedRemote leftTrackedRemoteState_old;
ovrInputStateTrackedRemote leftTrackedRemoteState_new; ovrInputStateTrackedRemote leftTrackedRemoteState_new;

View file

@ -264,8 +264,6 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
} }
} }
//if (!vr.item_selector)
{
//Engage scope / virtual stock if conditions are right //Engage scope / virtual stock if conditions are right
bool scopeready = vr.weapon_stabilised && (distanceToHMD < SCOPE_ENGAGE_DISTANCE); bool scopeready = vr.weapon_stabilised && (distanceToHMD < SCOPE_ENGAGE_DISTANCE);
static bool lastScopeReady = qfalse; static bool lastScopeReady = qfalse;
@ -739,9 +737,41 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
} }
} }
//process force motion controls here
if (vr_force_motion_controlled->integer)
{
if (vr.secondaryswingvelocity > vr_force_velocity_trigger->value)
{
if (!vr.secondaryVelocityTriggeredAttack)
{
VectorCopy(vr.offhandposition, vr.secondaryVelocityTriggerLocation);
vr.secondaryVelocityTriggeredAttack = true;
}
}
else
{
if (vr.secondaryVelocityTriggeredAttack)
{
vec3_t delta1, delta2;
VectorSubtract(vr.offhandposition, vr.hmdposition, delta1);
VectorSubtract(vr.secondaryVelocityTriggerLocation, vr.hmdposition, delta2);
if (VectorLength(delta1) > VectorLength(delta2))
{
sendButtonActionSimple("useGivenForce 3"); // PULL
}
else
{
sendButtonActionSimple("useGivenForce 4"); // PUSH
}
vr.secondaryVelocityTriggeredAttack = false;
}
}
}
updateScopeAngles(); updateScopeAngles();
} }
}
//Save state //Save state
rightTrackedRemoteState_old = rightTrackedRemoteState_new; rightTrackedRemoteState_old = rightTrackedRemoteState_new;

View file

@ -1980,6 +1980,40 @@ usually be a couple times for each server frame on fast clients.
*/ */
extern int G_FindLocalInterestPoint( gentity_t *self ); extern int G_FindLocalInterestPoint( gentity_t *self );
extern void ForceGrip(gentity_t *ent);
extern void ForceLightning(gentity_t *ent);
extern void ForceTelepathy(gentity_t *ent);
extern void ForceHeal(gentity_t *ent);
extern void ForceThrowEx( gentity_t *self, qboolean pull, qboolean aimByViewAngles );
static void ProcessGenericCmd(gentity_t *ent, byte cmd)
{
switch(cmd) {
default:
break;
case GENCMD_FORCE_HEAL:
ForceHeal( ent );
break;
case GENCMD_FORCE_SPEED:
ForceSpeed( ent );
break;
case GENCMD_FORCE_THROW:
ForceThrowEx(ent, qfalse, qtrue);
break;
case GENCMD_FORCE_PULL:
ForceThrowEx(ent, qtrue, qtrue);
break;
case GENCMD_FORCE_DISTRACT:
ForceTelepathy(ent);
break;
case GENCMD_FORCE_GRIP:
ForceGrip(ent);
break;
case GENCMD_FORCE_LIGHTNING:
ForceLightning(ent);
break;
}
}
void ClientThink_real( gentity_t *ent, usercmd_t *ucmd ) void ClientThink_real( gentity_t *ent, usercmd_t *ucmd )
{ {
gclient_t *client; gclient_t *client;
@ -2768,6 +2802,8 @@ extern cvar_t *g_skippingcin;
// perform a pmove // perform a pmove
Pmove( &pm ); Pmove( &pm );
ProcessGenericCmd(ent, pm.cmd.generic_cmd);
// save results of pmove // save results of pmove
if ( ent->client->ps.eventSequence != oldEventSequence ) if ( ent->client->ps.eventSequence != oldEventSequence )
{ {

View file

@ -5599,7 +5599,13 @@ void WP_ForceKnockdown( gentity_t *self, gentity_t *pusher, qboolean pull, qbool
self->forcePushTime = level.time + 600; // let the push effect last for 600 ms self->forcePushTime = level.time + 600; // let the push effect last for 600 ms
} }
void ForceThrowEx( gentity_t *self, qboolean pull, qboolean aimByViewAngles );
void ForceThrow( gentity_t *self, qboolean pull ) void ForceThrow( gentity_t *self, qboolean pull )
{
ForceThrowEx(self, pull, qfalse);
}
void ForceThrowEx( gentity_t *self, qboolean pull, qboolean aimByViewAngles )
{//FIXME: pass in a target ent so we (an NPC) can push/pull just one targeted ent. {//FIXME: pass in a target ent so we (an NPC) can push/pull just one targeted ent.
//shove things in front of you away //shove things in front of you away
float dist; float dist;
@ -5721,10 +5727,11 @@ void ForceThrow( gentity_t *self, qboolean pull )
G_Sound( self, soundIndex ); G_Sound( self, soundIndex );
vec3_t origin, angles; vec3_t origin, angles;
if (self->client->ps.clientNum == 0 && !cg.renderingThirdPerson) if (self->client->ps.clientNum == 0 && !cg.renderingThirdPerson && !aimByViewAngles)
{ {
BG_CalculateVROffHandPosition(origin, fwdangles); BG_CalculateVROffHandPosition(origin, fwdangles);
AngleVectors( fwdangles, forward, right, NULL );
VectorCopy( origin, center );
} }
else else
{ {
@ -8178,9 +8185,7 @@ static void WP_ForcePowerRun( gentity_t *self, forcePowers_t forcePower, usercmd
self->client->ps.forceGripEntityInitialDist == ENTITYNUM_NONE) self->client->ps.forceGripEntityInitialDist == ENTITYNUM_NONE)
{ {
vec3_t diff; vec3_t diff;
diff[2] = 0; VectorSubtract(vr->offhandposition, vr->hmdposition, diff);
VectorSubtract2(self->client->renderInfo.handLPoint,
self->client->renderInfo.eyePoint, diff);
self->client->ps.forceGripEntityInitialDist = VectorLength(diff); self->client->ps.forceGripEntityInitialDist = VectorLength(diff);
} }
@ -8199,13 +8204,11 @@ static void WP_ForcePowerRun( gentity_t *self, forcePowers_t forcePower, usercmd
{//carry {//carry
if (isFirstPersonPlayer) { if (isFirstPersonPlayer) {
vec3_t diff; vec3_t diff;
diff[2] = 0; VectorSubtract(vr->offhandposition, vr->hmdposition, diff);
VectorSubtract2(self->client->renderInfo.handLPoint,
self->client->renderInfo.eyePoint, diff);
float length = VectorLength(diff); float length = VectorLength(diff);
if (fabs(length - self->client->ps.forceGripEntityInitialDist) > 1.0f) { float movedLength = (length - self->client->ps.forceGripEntityInitialDist) * cg_worldScale.value;
dist += (length - self->client->ps.forceGripEntityInitialDist) * if (fabs(movedLength) > 1.0f) {
5.0f; dist += movedLength * 5.0f;
} }
if (dist > 384) { if (dist > 384) {
dist = 384; dist = 384;