mirror of
https://github.com/DrBeef/JKXR.git
synced 2024-11-21 19:51:33 +00:00
Motion controlled Force Push/Pull
This commit is contained in:
parent
62f1924dff
commit
0d70fae512
7 changed files with 536 additions and 460 deletions
|
@ -1308,8 +1308,10 @@ void JKVR_Init()
|
|||
|
||||
vr_immersive_cinematics = Cvar_Get("vr_immersive_cinematics", "1", 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_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);
|
||||
if (FS_FileExists("expanded_menu.pk3")) {
|
||||
|
|
|
@ -61,6 +61,7 @@ typedef struct {
|
|||
bool primaryVelocityTriggeredAttack;
|
||||
float secondaryswingvelocity;
|
||||
bool secondaryVelocityTriggeredAttack;
|
||||
vec3_t secondaryVelocityTriggerLocation;
|
||||
|
||||
vec3_t offhandangles;
|
||||
vec3_t offhandangles_last; // Don't use this, it is just for calculating delta!
|
||||
|
|
|
@ -10,5 +10,7 @@ extern cvar_t *vr_switch_sticks;
|
|||
extern cvar_t *vr_immersive_cinematics;
|
||||
extern cvar_t *vr_screen_dist;
|
||||
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_force_motion_controlled;
|
||||
|
||||
|
|
|
@ -30,7 +30,9 @@ cvar_t *vr_switch_sticks;
|
|||
cvar_t *vr_immersive_cinematics;
|
||||
cvar_t *vr_screen_dist;
|
||||
cvar_t *vr_weapon_velocity_trigger;
|
||||
cvar_t *vr_force_velocity_trigger;
|
||||
cvar_t *vr_two_handed_weapons;
|
||||
cvar_t *vr_force_motion_controlled;
|
||||
|
||||
ovrInputStateTrackedRemote leftTrackedRemoteState_old;
|
||||
ovrInputStateTrackedRemote leftTrackedRemoteState_new;
|
||||
|
|
|
@ -264,8 +264,6 @@ void HandleInput_Default( ovrInputStateGamepad *pFootTrackingNew, ovrInputStateG
|
|||
}
|
||||
}
|
||||
|
||||
//if (!vr.item_selector)
|
||||
{
|
||||
//Engage scope / virtual stock if conditions are right
|
||||
bool scopeready = vr.weapon_stabilised && (distanceToHMD < SCOPE_ENGAGE_DISTANCE);
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Save state
|
||||
rightTrackedRemoteState_old = rightTrackedRemoteState_new;
|
||||
|
|
|
@ -1980,6 +1980,40 @@ usually be a couple times for each server frame on fast clients.
|
|||
*/
|
||||
|
||||
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 )
|
||||
{
|
||||
gclient_t *client;
|
||||
|
@ -2768,6 +2802,8 @@ extern cvar_t *g_skippingcin;
|
|||
// perform a pmove
|
||||
Pmove( &pm );
|
||||
|
||||
ProcessGenericCmd(ent, pm.cmd.generic_cmd);
|
||||
|
||||
// save results of pmove
|
||||
if ( ent->client->ps.eventSequence != oldEventSequence )
|
||||
{
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
void ForceThrowEx( gentity_t *self, qboolean pull, qboolean aimByViewAngles );
|
||||
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.
|
||||
//shove things in front of you away
|
||||
float dist;
|
||||
|
@ -5721,10 +5727,11 @@ void ForceThrow( gentity_t *self, qboolean pull )
|
|||
G_Sound( self, soundIndex );
|
||||
|
||||
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);
|
||||
|
||||
AngleVectors( fwdangles, forward, right, NULL );
|
||||
VectorCopy( origin, center );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -8178,9 +8185,7 @@ static void WP_ForcePowerRun( gentity_t *self, forcePowers_t forcePower, usercmd
|
|||
self->client->ps.forceGripEntityInitialDist == ENTITYNUM_NONE)
|
||||
{
|
||||
vec3_t diff;
|
||||
diff[2] = 0;
|
||||
VectorSubtract2(self->client->renderInfo.handLPoint,
|
||||
self->client->renderInfo.eyePoint, diff);
|
||||
VectorSubtract(vr->offhandposition, vr->hmdposition, diff);
|
||||
self->client->ps.forceGripEntityInitialDist = VectorLength(diff);
|
||||
}
|
||||
|
||||
|
@ -8199,13 +8204,11 @@ static void WP_ForcePowerRun( gentity_t *self, forcePowers_t forcePower, usercmd
|
|||
{//carry
|
||||
if (isFirstPersonPlayer) {
|
||||
vec3_t diff;
|
||||
diff[2] = 0;
|
||||
VectorSubtract2(self->client->renderInfo.handLPoint,
|
||||
self->client->renderInfo.eyePoint, diff);
|
||||
VectorSubtract(vr->offhandposition, vr->hmdposition, diff);
|
||||
float length = VectorLength(diff);
|
||||
if (fabs(length - self->client->ps.forceGripEntityInitialDist) > 1.0f) {
|
||||
dist += (length - self->client->ps.forceGripEntityInitialDist) *
|
||||
5.0f;
|
||||
float movedLength = (length - self->client->ps.forceGripEntityInitialDist) * cg_worldScale.value;
|
||||
if (fabs(movedLength) > 1.0f) {
|
||||
dist += movedLength * 5.0f;
|
||||
}
|
||||
if (dist > 384) {
|
||||
dist = 384;
|
||||
|
|
Loading…
Reference in a new issue