mirror of
https://github.com/DrBeef/RTCWQuest.git
synced 2025-04-23 07:20:51 +00:00
AKIMBO!
This commit is contained in:
parent
5fab5734fe
commit
460cf56d71
7 changed files with 71 additions and 50 deletions
|
@ -854,6 +854,9 @@ void setHMDPosition( float x, float y, float z )
|
|||
|
||||
//Record player height on transition
|
||||
playerHeight = y;
|
||||
|
||||
//Resync yaw on transition
|
||||
RTCWVR_ResyncClientYawWithGameYaw();
|
||||
}
|
||||
|
||||
if (!RTCWVR_useScreenLayer())
|
||||
|
|
|
@ -19,6 +19,8 @@ Authors : Simon Brown
|
|||
|
||||
#include "../rtcw/src/client/client.h"
|
||||
|
||||
#define WP_AKIMBO 20
|
||||
|
||||
cvar_t *sv_cheats;
|
||||
|
||||
void CG_CenterPrint( const char *str, int y, int charWidth );
|
||||
|
@ -43,13 +45,23 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
|
|||
// }
|
||||
|
||||
//Need this for the touch screen
|
||||
ovrTracking * pWeapon = pDominantTracking;
|
||||
ovrTracking * pOff = pOffTracking;
|
||||
if (vr.weaponid == WP_AKIMBO &&
|
||||
!vr.right_handed)
|
||||
{
|
||||
//Revert to same weapon controls as right-handed if using akimbo
|
||||
pWeapon = pOffTracking;
|
||||
pOff = pDominantTracking;
|
||||
}
|
||||
|
||||
{
|
||||
//Set gun angles - We need to calculate all those we might need (including adjustments) for the client to then take its pick
|
||||
vec3_t rotation = {0};
|
||||
rotation[PITCH] = 10;
|
||||
QuatToYawPitchRoll(pDominantTracking->HeadPose.Pose.Orientation, rotation, vr.weaponangles_knife);
|
||||
QuatToYawPitchRoll(pWeapon->HeadPose.Pose.Orientation, rotation, vr.weaponangles_knife);
|
||||
rotation[PITCH] = vr_weapon_pitchadjust->value;
|
||||
QuatToYawPitchRoll(pDominantTracking->HeadPose.Pose.Orientation, rotation, vr.weaponangles);
|
||||
QuatToYawPitchRoll(pWeapon->HeadPose.Pose.Orientation, rotation, vr.weaponangles);
|
||||
|
||||
VectorSubtract(vr.weaponangles_last, vr.weaponangles, vr.weaponangles_delta);
|
||||
VectorCopy(vr.weaponangles, vr.weaponangles_last);
|
||||
|
@ -103,13 +115,13 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
|
|||
|
||||
|
||||
|
||||
float distance = sqrtf(powf(pOffTracking->HeadPose.Pose.Position.x - pDominantTracking->HeadPose.Pose.Position.x, 2) +
|
||||
powf(pOffTracking->HeadPose.Pose.Position.y - pDominantTracking->HeadPose.Pose.Position.y, 2) +
|
||||
powf(pOffTracking->HeadPose.Pose.Position.z - pDominantTracking->HeadPose.Pose.Position.z, 2));
|
||||
float distance = sqrtf(powf(pOff->HeadPose.Pose.Position.x - pWeapon->HeadPose.Pose.Position.x, 2) +
|
||||
powf(pOff->HeadPose.Pose.Position.y - pWeapon->HeadPose.Pose.Position.y, 2) +
|
||||
powf(pOff->HeadPose.Pose.Position.z - pWeapon->HeadPose.Pose.Position.z, 2));
|
||||
|
||||
float distanceToHMD = sqrtf(powf(vr.hmdposition[0] - pDominantTracking->HeadPose.Pose.Position.x, 2) +
|
||||
powf(vr.hmdposition[1] - pDominantTracking->HeadPose.Pose.Position.y, 2) +
|
||||
powf(vr.hmdposition[2] - pDominantTracking->HeadPose.Pose.Position.z, 2));
|
||||
float distanceToHMD = sqrtf(powf(vr.hmdposition[0] - pWeapon->HeadPose.Pose.Position.x, 2) +
|
||||
powf(vr.hmdposition[1] - pWeapon->HeadPose.Pose.Position.y, 2) +
|
||||
powf(vr.hmdposition[2] - pWeapon->HeadPose.Pose.Position.z, 2));
|
||||
|
||||
//Turn on weapon stabilisation?
|
||||
if ((pOffTrackedRemoteNew->Buttons & ovrButton_GripTrigger) !=
|
||||
|
@ -170,18 +182,18 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
|
|||
vr.weaponoffset_history_timestamp[0] = vr.weaponoffset_timestamp;
|
||||
|
||||
///Weapon location relative to view
|
||||
vr.weaponoffset[0] = pDominantTracking->HeadPose.Pose.Position.x - vr.hmdposition[0];
|
||||
vr.weaponoffset[1] = pDominantTracking->HeadPose.Pose.Position.y - vr.hmdposition[1];
|
||||
vr.weaponoffset[2] = pDominantTracking->HeadPose.Pose.Position.z - vr.hmdposition[2];
|
||||
vr.weaponoffset[0] = pWeapon->HeadPose.Pose.Position.x - vr.hmdposition[0];
|
||||
vr.weaponoffset[1] = pWeapon->HeadPose.Pose.Position.y - vr.hmdposition[1];
|
||||
vr.weaponoffset[2] = pWeapon->HeadPose.Pose.Position.z - vr.hmdposition[2];
|
||||
vr.weaponoffset_timestamp = Sys_Milliseconds( );
|
||||
|
||||
//Does weapon velocity trigger attack (knife) and is it fast enough
|
||||
if (vr.velocitytriggered)
|
||||
{
|
||||
static qboolean fired = qfalse;
|
||||
float velocity = sqrtf(powf(pDominantTracking->HeadPose.LinearVelocity.x, 2) +
|
||||
powf(pDominantTracking->HeadPose.LinearVelocity.y, 2) +
|
||||
powf(pDominantTracking->HeadPose.LinearVelocity.z, 2));
|
||||
float velocity = sqrtf(powf(pWeapon->HeadPose.LinearVelocity.x, 2) +
|
||||
powf(pWeapon->HeadPose.LinearVelocity.y, 2) +
|
||||
powf(pWeapon->HeadPose.LinearVelocity.z, 2));
|
||||
|
||||
ALOGV(" Velocity: %f", velocity);
|
||||
|
||||
|
@ -193,9 +205,9 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
|
|||
|
||||
if (vr.weapon_stabilised || vr.dualwield)
|
||||
{
|
||||
float z = pOffTracking->HeadPose.Pose.Position.z - pDominantTracking->HeadPose.Pose.Position.z;
|
||||
float x = pOffTracking->HeadPose.Pose.Position.x - pDominantTracking->HeadPose.Pose.Position.x;
|
||||
float y = pOffTracking->HeadPose.Pose.Position.y - pDominantTracking->HeadPose.Pose.Position.y;
|
||||
float z = pOff->HeadPose.Pose.Position.z - pWeapon->HeadPose.Pose.Position.z;
|
||||
float x = pOff->HeadPose.Pose.Position.x - pWeapon->HeadPose.Pose.Position.x;
|
||||
float y = pOff->HeadPose.Pose.Position.y - pWeapon->HeadPose.Pose.Position.y;
|
||||
float zxDist = length(x, z);
|
||||
|
||||
if (zxDist != 0.0f && z != 0.0f) {
|
||||
|
@ -305,12 +317,12 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
|
|||
float controllerYawHeading = 0.0f;
|
||||
//off-hand stuff
|
||||
{
|
||||
vr.offhandoffset[0] = pOffTracking->HeadPose.Pose.Position.x - vr.hmdposition[0];
|
||||
vr.offhandoffset[1] = pOffTracking->HeadPose.Pose.Position.y - vr.hmdposition[1];
|
||||
vr.offhandoffset[2] = pOffTracking->HeadPose.Pose.Position.z - vr.hmdposition[2];
|
||||
vr.offhandoffset[0] = pOff->HeadPose.Pose.Position.x - vr.hmdposition[0];
|
||||
vr.offhandoffset[1] = pOff->HeadPose.Pose.Position.y - vr.hmdposition[1];
|
||||
vr.offhandoffset[2] = pOff->HeadPose.Pose.Position.z - vr.hmdposition[2];
|
||||
|
||||
vec3_t rotation = {0};
|
||||
QuatToYawPitchRoll(pOffTracking->HeadPose.Pose.Orientation, rotation, vr.offhandangles);
|
||||
QuatToYawPitchRoll(pOff->HeadPose.Pose.Orientation, rotation, vr.offhandangles);
|
||||
|
||||
if (vr_walkdirection->value == 0) {
|
||||
controllerYawHeading = vr.offhandangles[YAW] - vr.hmdorientation[YAW];
|
||||
|
@ -323,11 +335,6 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
|
|||
|
||||
//Right-hand specific stuff
|
||||
{
|
||||
ALOGV(" Right-Controller-Position: %f, %f, %f",
|
||||
pDominantTracking->HeadPose.Pose.Position.x,
|
||||
pDominantTracking->HeadPose.Pose.Position.y,
|
||||
pDominantTracking->HeadPose.Pose.Position.z);
|
||||
|
||||
//This section corrects for the fact that the controller actually controls direction of movement, but we want to move relative to the direction the
|
||||
//player is facing for positional tracking
|
||||
vec2_t v;
|
||||
|
@ -434,11 +441,6 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
|
|||
|
||||
//Left-hand specific stuff
|
||||
{
|
||||
ALOGV(" Left-Controller-Position: %f, %f, %f",
|
||||
pOffTracking->HeadPose.Pose.Position.x,
|
||||
pOffTracking->HeadPose.Pose.Position.y,
|
||||
pOffTracking->HeadPose.Pose.Position.z);
|
||||
|
||||
//"Use" (open doors etc)
|
||||
if ((pDominantTrackedRemoteNew->Buttons & ovrButton_Joystick) !=
|
||||
(pDominantTrackedRemoteOld->Buttons & ovrButton_Joystick)) {
|
||||
|
|
|
@ -108,8 +108,7 @@ void HandleInput_WeaponAlign( ovrInputStateTrackedRemote *pDominantTrackedRemote
|
|||
|
||||
//We need to record if we have started firing primary so that releasing trigger will stop firing, if user has pushed grip
|
||||
//in meantime, then it wouldn't stop the gun firing and it would get stuck
|
||||
static bool firingPrimary = false;
|
||||
if (!firingPrimary && dominantGripPushed && (GetTimeInMilliSeconds() - dominantGripPushTime) > vr_reloadtimeoutms->integer && !vr.scopedweapon)
|
||||
if (dominantGripPushed)
|
||||
{
|
||||
//Fire Secondary
|
||||
if (((pDominantTrackedRemoteNew->Buttons & ovrButton_Trigger) !=
|
||||
|
@ -126,8 +125,7 @@ void HandleInput_WeaponAlign( ovrInputStateTrackedRemote *pDominantTrackedRemote
|
|||
(pDominantTrackedRemoteNew->Buttons & ovrButton_Trigger) !=
|
||||
(pDominantTrackedRemoteOld->Buttons & ovrButton_Trigger)) {
|
||||
|
||||
firingPrimary = (pDominantTrackedRemoteNew->Buttons & ovrButton_Trigger);
|
||||
sendButtonAction("+attack", firingPrimary);
|
||||
sendButtonAction("+attack", (pDominantTrackedRemoteNew->Buttons & ovrButton_Trigger));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -149,7 +147,7 @@ void HandleInput_WeaponAlign( ovrInputStateTrackedRemote *pDominantTrackedRemote
|
|||
float* items[7] = {&vr.test_scale, &(vr.test_offset[0]), &(vr.test_offset[1]), &(vr.test_offset[2]),
|
||||
&(vr.test_angles[PITCH]), &(vr.test_angles[YAW]), &(vr.test_angles[ROLL])};
|
||||
char* item_names[7] = {"scale", "right", "up", "forward", "pitch", "yaw", "roll"};
|
||||
float item_inc[7] = {0.002, 0.02, 0.02, 0.02, 0.2, 0.2, 0.2};
|
||||
float item_inc[7] = {0.002, 0.02, 0.02, 0.02, 0.1, 0.1, 0.1};
|
||||
|
||||
//Weapon/Inventory Chooser
|
||||
static qboolean itemSwitched = false;
|
||||
|
@ -183,7 +181,6 @@ void HandleInput_WeaponAlign( ovrInputStateTrackedRemote *pDominantTrackedRemote
|
|||
*(items[item_index]) = 0.0;
|
||||
}
|
||||
|
||||
|
||||
//Left-hand specific stuff
|
||||
{
|
||||
if (((pOffTrackedRemoteNew->Buttons & offButton1) !=
|
||||
|
|
|
@ -1970,9 +1970,15 @@ void convertFromVR(vec3_t in, vec3_t offset, vec3_t out)
|
|||
}
|
||||
}
|
||||
|
||||
static void CG_CalculateVRWeaponPosition( vec3_t origin, vec3_t angles ) {
|
||||
void CG_CalculateVRWeaponPosition( int weaponNum, vec3_t origin, vec3_t angles ) {
|
||||
|
||||
if (weaponNum != WP_AKIMBO || BG_AkimboFireSequence(weaponNum, cg.predictedPlayerState.ammoclip[WP_AKIMBO], cg.predictedPlayerState.ammoclip[WP_COLT] ))
|
||||
{
|
||||
convertFromVR(cgVR->weaponoffset, cg.refdef.vieworg, origin);
|
||||
} else{
|
||||
convertFromVR(cgVR->offhandoffset, cg.refdef.vieworg, origin);
|
||||
}
|
||||
|
||||
convertFromVR(cgVR->weaponoffset, cg.refdef.vieworg, origin);
|
||||
origin[2] -= 64;
|
||||
origin[2] += (cgVR->hmdposition[1] + cg_heightAdjust.value) * cg_worldScale.value;
|
||||
|
||||
|
@ -1998,7 +2004,7 @@ CG_CalculateWeaponPositionAndScale
|
|||
|
||||
static float CG_CalculateWeaponPositionAndScale( playerState_t *ps, vec3_t origin, vec3_t angles ) {
|
||||
|
||||
CG_CalculateVRWeaponPosition(origin, angles);
|
||||
CG_CalculateVRWeaponPosition(0, origin, angles);
|
||||
|
||||
vec3_t offset;
|
||||
|
||||
|
@ -2204,7 +2210,7 @@ static void CG_FlamethrowerFlame( centity_t *cent, vec3_t origin ) {
|
|||
CG_FireFlameChunks(cent, origin, cent->lerpAngles, 1.0, qtrue, 0);
|
||||
} else {
|
||||
vec3_t origin, angles;
|
||||
CG_CalculateVRWeaponPosition(origin, angles);
|
||||
CG_CalculateVRWeaponPosition(0, origin, angles);
|
||||
|
||||
CG_FireFlameChunks(cent, origin, angles, 1.0, qtrue, 1);
|
||||
|
||||
|
@ -3528,7 +3534,7 @@ void CG_AddViewWeapon( playerState_t *ps ) {
|
|||
vec3_t endForward, endRight, endUp;
|
||||
vec3_t angles;
|
||||
clientInfo_t ci;
|
||||
CG_CalculateVRWeaponPosition( origin, angles );
|
||||
CG_CalculateVRWeaponPosition( 0, origin, angles );
|
||||
|
||||
vec3_t forward, right, up;
|
||||
AngleVectors(angles, forward, right, up);
|
||||
|
@ -6502,17 +6508,17 @@ static qboolean CG_CalcMuzzlePoint( int entityNum, vec3_t muzzle ) {
|
|||
vec3_t forward, right, up;
|
||||
centity_t *cent;
|
||||
int anim;
|
||||
|
||||
cent = &cg_entities[entityNum];
|
||||
if ( entityNum == cg.snap->ps.clientNum ) {
|
||||
vec3_t angles;
|
||||
CG_CalculateVRWeaponPosition(muzzle, angles);
|
||||
CG_CalculateVRWeaponPosition(cent->currentState.weapon, muzzle, angles);
|
||||
|
||||
AngleVectors( angles, forward, NULL, NULL );
|
||||
VectorMA( muzzle, 14, forward, muzzle );
|
||||
return qtrue;
|
||||
}
|
||||
|
||||
cent = &cg_entities[entityNum];
|
||||
|
||||
//----(SA) removed check. is this still necessary? (this way works for ai's firing mg42) should I check for mg42?
|
||||
// if ( !cent->currentValid ) {
|
||||
// return qfalse;
|
||||
|
|
|
@ -961,10 +961,19 @@ void Bullet_Fire( gentity_t *ent, float spread, int damage ) {
|
|||
LOGI("Bullet_Fire %i %i %i",(int)end[0],(int)end[1],(int)end[2]);
|
||||
|
||||
if (!ent->aiCharacter) {
|
||||
trap_Vibrate(100, gVR->right_handed ? 1 : 0, 1.0);
|
||||
if (gVR->weapon_stabilised) {
|
||||
trap_Vibrate(100, gVR->right_handed ? 0 : 1, 0.7);
|
||||
}
|
||||
|
||||
qboolean right = gVR->right_handed;
|
||||
if (ent->s.weapon == WP_AKIMBO)
|
||||
{
|
||||
right = BG_AkimboFireSequence(ent->s.weapon, ent->client->ps.ammoclip[WP_AKIMBO], ent->client->ps.ammoclip[WP_COLT] );
|
||||
trap_Vibrate(100, right ? 1 : 0, 1.0);
|
||||
|
||||
} else{
|
||||
trap_Vibrate(100, right ? 1 : 0, 1.0);
|
||||
if (gVR->weapon_stabilised) {
|
||||
trap_Vibrate(100, right ? 0 : 1, 0.7);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//If we have an autoaim target and player shooting..
|
||||
|
|
|
@ -609,6 +609,7 @@ void SV_SendClientGameState( client_t *client ) {
|
|||
SV_ClientEnterWorld
|
||||
==================
|
||||
*/
|
||||
void RTCWVR_ResyncClientYawWithGameYaw();
|
||||
void SV_ClientEnterWorld( client_t *client, usercmd_t *cmd ) {
|
||||
int clientNum;
|
||||
sharedEntity_t *ent;
|
||||
|
@ -628,6 +629,9 @@ void SV_ClientEnterWorld( client_t *client, usercmd_t *cmd ) {
|
|||
|
||||
// call the game begin function
|
||||
VM_Call( gvm, GAME_CLIENT_BEGIN, client - svs.clients );
|
||||
|
||||
//Trigger yaw resync
|
||||
RTCWVR_ResyncClientYawWithGameYaw();
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
// put the weapon id at the end of the cvar name, so the knife is vr_weapon_adjustment_1
|
||||
// Values are: scale,right,up,forward,pitch,yaw,roll
|
||||
|
||||
seta vr_weapon_adjustment_20 "0.50,-7.00,10.40,-20.42,0.80,-1.40,0.00"
|
||||
seta vr_weapon_adjustment_20 "0.50,-10.0,12.40,-22.42,0.80,-1.40,0.00"
|
||||
seta vr_weapon_adjustment_19 "0.50,-9.12,10.72,-20.60,-2.80,-4.60,0.00"
|
||||
seta vr_weapon_adjustment_14 "0.54,-10.78,14.78,-19.89,0.00,7.20,-8.00"
|
||||
seta vr_weapon_adjustment_8 "0.54,-9.08,8.38,-6.61,0.00,0.00,0.00"
|
||||
|
|
Loading…
Reference in a new issue