mirror of
https://github.com/DrBeef/RTCWQuest.git
synced 2025-02-28 14:21:16 +00:00
Throwable Grenades etc
This commit is contained in:
parent
fc2a648796
commit
9afcd3110a
11 changed files with 137 additions and 7 deletions
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.drbeef.rtcwquest"
|
||||
android:versionCode="7"
|
||||
android:versionName="0.7.0" android:installLocation="auto" >
|
||||
android:versionCode="8"
|
||||
android:versionName="0.8.0" android:installLocation="auto" >
|
||||
|
||||
<!-- Tell the system this app requires OpenGL ES 3.1. -->
|
||||
<uses-feature android:glEsVersion="0x00030001" android:required="true"/>
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#if !defined(vr_client_info_h)
|
||||
#define vr_client_info_h
|
||||
|
||||
#define NUM_WEAPON_SAMPLES 72
|
||||
|
||||
typedef struct {
|
||||
float fov;
|
||||
qboolean weapon_stabilised;
|
||||
|
@ -20,6 +22,9 @@ typedef struct {
|
|||
vec3_t weaponangles_delta;
|
||||
|
||||
vec3_t weaponoffset;
|
||||
float weaponoffset_timestamp;
|
||||
vec3_t weaponoffset_history[NUM_WEAPON_SAMPLES];
|
||||
float weaponoffset_history_timestamp[NUM_WEAPON_SAMPLES];
|
||||
|
||||
qboolean scopeengaged; // Scope has been engaged on a scoped weapon
|
||||
qboolean scopeready; // Scope can be engaged
|
||||
|
|
|
@ -147,10 +147,20 @@ void HandleInput_Default( ovrInputStateTrackedRemote *pDominantTrackedRemoteNew,
|
|||
|
||||
//dominant hand stuff first
|
||||
{
|
||||
//Record recent weapon position for trajectory based stuff
|
||||
for (int i = (NUM_WEAPON_SAMPLES-1); i != 0; --i)
|
||||
{
|
||||
VectorCopy(vr.weaponoffset_history[i-1], vr.weaponoffset_history[i]);
|
||||
vr.weaponoffset_history_timestamp[i] = vr.weaponoffset_history_timestamp[i-1];
|
||||
}
|
||||
VectorCopy(vr.weaponoffset, vr.weaponoffset_history[0]);
|
||||
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_timestamp = Sys_Milliseconds( );
|
||||
|
||||
if (vr.weapon_stabilised)
|
||||
{
|
||||
|
|
|
@ -216,7 +216,9 @@ typedef enum {
|
|||
CG_INGAME_CLOSEPOPUP, // NERVE - SMF
|
||||
CG_LIMBOCHAT, // NERVE - SMF
|
||||
|
||||
CG_GETMODELINFO
|
||||
CG_GETMODELINFO,
|
||||
|
||||
CG_HAPTIC
|
||||
} cgameImport_t;
|
||||
|
||||
|
||||
|
|
|
@ -544,3 +544,7 @@ void trap_UI_ClosePopup( const char *arg0 ) {
|
|||
qboolean trap_GetModelInfo( int clientNum, char *modelName, animModelInfo_t **modelInfo ) {
|
||||
return syscall( CG_GETMODELINFO, clientNum, modelName, modelInfo );
|
||||
}
|
||||
|
||||
qboolean trap_Vibrate( float duration, int channel, float intensity ) {
|
||||
return syscall( CG_HAPTIC, PASSFLOAT(duration), channel, PASSFLOAT(intensity) );
|
||||
}
|
||||
|
|
|
@ -1969,6 +1969,12 @@ static void CG_FlamethrowerFlame( centity_t *cent, vec3_t origin ) {
|
|||
CG_CalculateVRWeaponPosition(origin, angles);
|
||||
|
||||
CG_FireFlameChunks(cent, origin, angles, 1.0, qtrue, 1);
|
||||
|
||||
trap_Vibrate(-1, cgVR->right_handed ? 1 : 0, 0.6);
|
||||
if (cgVR->weapon_stabilised)
|
||||
{
|
||||
trap_Vibrate(-1, cgVR->right_handed ? 0 : 1, 0.5);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -2511,6 +2517,11 @@ void CG_PlayerTeslaCoilFire( centity_t *cent, vec3_t flashorigin ) {
|
|||
trap_R_AddLightToScene( tr.endpos, 256 + 600 * tr.fraction, 0.2, 0.6, 1, 0 );
|
||||
}
|
||||
|
||||
trap_Vibrate(-1, cgVR->right_handed ? 1 : 0, 0.8);
|
||||
if (cgVR->weapon_stabilised)
|
||||
{
|
||||
trap_Vibrate(-1, cgVR->right_handed ? 0 : 1, 0.8);
|
||||
}
|
||||
|
||||
// shake the camera a bit
|
||||
CG_StartShakeCamera( 0.05, 200, cent->lerpOrigin, 100 );
|
||||
|
|
|
@ -44,6 +44,7 @@ extern qboolean getCameraInfo( int camNum, int time, vec3_t *origin, vec3_t *ang
|
|||
// RF, this is only used when running a local server
|
||||
extern void SV_SendMoveSpeedsToGame( int entnum, char *text );
|
||||
extern qboolean SV_GetModelInfo( int clientNum, char *modelName, animModelInfo_t **modelInfo );
|
||||
void RTCWVR_Vibrate(float duration, int channel, float intensity );
|
||||
|
||||
|
||||
/*
|
||||
|
@ -853,6 +854,10 @@ int CL_CgameSystemCalls( int *args ) {
|
|||
case CG_GETMODELINFO:
|
||||
return SV_GetModelInfo( args[1], VMA( 2 ), VMA( 3 ) );
|
||||
|
||||
case CG_HAPTIC:
|
||||
RTCWVR_Vibrate( VMF(1), args[2], VMF( 3 ) );
|
||||
return 0;
|
||||
|
||||
default:
|
||||
Com_Error( ERR_DROP, "Bad cgame system trap: %i", args[0] );
|
||||
}
|
||||
|
|
|
@ -30,10 +30,13 @@ If you have questions concerning this license or the applicable additional terms
|
|||
#include "g_local.h"
|
||||
|
||||
#include "ai_cast_fight.h" // need these for avoidance
|
||||
#include "../../../RTCWVR/VrClientInfo.h"
|
||||
|
||||
|
||||
extern void G_CheckForCursorHints( gentity_t *ent );
|
||||
|
||||
extern vr_client_info_t* gVR;
|
||||
|
||||
|
||||
/*
|
||||
===============
|
||||
|
@ -91,6 +94,10 @@ void P_DamageFeedback( gentity_t *player ) {
|
|||
|
||||
client->ps.damageCount = count;
|
||||
|
||||
trap_Vibrate(300, 1, (count / 255.0) + 0.5f);
|
||||
trap_Vibrate(300, 0, (count / 255.0) + 0.5f);
|
||||
|
||||
|
||||
//
|
||||
// clear totals
|
||||
//
|
||||
|
|
|
@ -1051,7 +1051,7 @@ gentity_t *fire_grenade( gentity_t *self, vec3_t start, vec3_t dir, int grenadeW
|
|||
bolt->clipmask = MASK_MISSILESHOT;
|
||||
|
||||
bolt->s.pos.trType = TR_GRAVITY;
|
||||
bolt->s.pos.trTime = level.time - MISSILE_PRESTEP_TIME; // move a bit on the very first frame
|
||||
bolt->s.pos.trTime = level.time;// - MISSILE_PRESTEP_TIME; // move a bit on the very first frame
|
||||
VectorCopy( start, bolt->s.pos.trBase );
|
||||
VectorCopy( dir, bolt->s.pos.trDelta );
|
||||
SnapVector( bolt->s.pos.trDelta ); // save net bandwidth
|
||||
|
|
|
@ -112,7 +112,7 @@ void Weapon_Knife( gentity_t *ent ) {
|
|||
if (gVR != NULL) {
|
||||
VectorCopy(gVR->weaponangles_unadjusted, angles);
|
||||
angles[YAW] = ent->client->ps.viewangles[YAW] +
|
||||
(gVR->weaponangles[YAW] - gVR->hmdorientation[YAW]);
|
||||
(gVR->weaponangles_unadjusted[YAW] - gVR->hmdorientation[YAW]);
|
||||
}
|
||||
|
||||
AngleVectors( angles, forward, right, up );
|
||||
|
@ -1212,6 +1212,84 @@ gentity_t *weapon_crowbar_throw( gentity_t *ent ) {
|
|||
return m;
|
||||
}
|
||||
|
||||
#define OLDEST_READING 24
|
||||
#define NEWEST_READING 20
|
||||
|
||||
gentity_t *weapon_grenadelauncher_fire_vr( gentity_t *ent, int grenType ) {
|
||||
gentity_t *m, *te; // JPW NERVE
|
||||
float power = 1;
|
||||
vec3_t tosspos;
|
||||
vec3_t trajectory;
|
||||
|
||||
if (gVR != NULL) {
|
||||
|
||||
|
||||
//Caclulate speed between two controller position readings
|
||||
float distance = VectorDistance(gVR->weaponoffset_history[NEWEST_READING], gVR->weaponoffset_history[OLDEST_READING]);
|
||||
float t = gVR->weaponoffset_history_timestamp[NEWEST_READING] - gVR->weaponoffset_history_timestamp[OLDEST_READING];
|
||||
float worldscale = trap_Cvar_VariableIntegerValue("cg_worldScale");
|
||||
float velocity = distance / (t/(float)1000.0);
|
||||
|
||||
//Calculate trajectory
|
||||
VectorSubtract(gVR->weaponoffset_history[NEWEST_READING], gVR->weaponoffset_history[OLDEST_READING], trajectory);
|
||||
VectorNormalize( trajectory );
|
||||
convertFromVR(worldscale, ent, trajectory, NULL, trajectory);
|
||||
VectorScale(trajectory, velocity, trajectory);
|
||||
}
|
||||
|
||||
// pineapples are not thrown as far as mashers
|
||||
if ( grenType == WP_GRENADE_LAUNCHER )
|
||||
{
|
||||
power = 6;
|
||||
} else if ( grenType == WP_GRENADE_PINEAPPLE )
|
||||
{
|
||||
power = 4;
|
||||
}
|
||||
else { // WP_DYNAMITE
|
||||
power = 3;
|
||||
}
|
||||
|
||||
//And then throw..
|
||||
VectorScale( trajectory, power, trajectory );
|
||||
VectorCopy( muzzleEffect, tosspos );
|
||||
m = fire_grenade( ent, tosspos, trajectory, grenType );
|
||||
|
||||
|
||||
//m->damage *= s_quadFactor;
|
||||
m->damage = 0; // Ridah, grenade's don't explode on contact
|
||||
m->splashDamage *= s_quadFactor;
|
||||
|
||||
if ( ent->aiCharacter == AICHAR_VENOM ) { // poison gas grenade
|
||||
m->think = G_ExplodeMissilePoisonGas;
|
||||
m->s.density = 1;
|
||||
}
|
||||
|
||||
// JPW NERVE
|
||||
if ( grenType == WP_GRENADE_SMOKE ) {
|
||||
if ( ent->client->sess.sessionTeam == TEAM_RED ) { // store team so we can generate red or blue smoke
|
||||
m->s.otherEntityNum2 = 1;
|
||||
} else {
|
||||
m->s.otherEntityNum2 = 0;
|
||||
}
|
||||
m->nextthink = level.time + 4000;
|
||||
m->think = weapon_callAirStrike;
|
||||
|
||||
te = G_TempEntity( m->s.pos.trBase, EV_GLOBAL_SOUND );
|
||||
te->s.eventParm = G_SoundIndex( "sound/scenaric/forest/me109_flight.wav" );
|
||||
// te->r.svFlags |= SVF_BROADCAST | SVF_USE_CURRENT_ORIGIN;
|
||||
}
|
||||
// jpw
|
||||
|
||||
//----(SA) adjust for movement of character. TODO: Probably comment in later, but only for forward/back not strafing
|
||||
// VectorAdd( m->s.pos.trDelta, ent->client->ps.velocity, m->s.pos.trDelta ); // "real" physics
|
||||
|
||||
// let the AI know which grenade it has fired
|
||||
ent->grenadeFired = m->s.number;
|
||||
|
||||
// Ridah, return the grenade so we can do some prediction before deciding if we really want to throw it or not
|
||||
return m;
|
||||
}
|
||||
|
||||
gentity_t *weapon_grenadelauncher_fire( gentity_t *ent, int grenType ) {
|
||||
gentity_t *m, *te; // JPW NERVE
|
||||
float upangle = 0; // start with level throwing and adjust based on angle
|
||||
|
@ -1981,7 +2059,12 @@ void FireWeapon( gentity_t *ent ) {
|
|||
if ( ent->s.weapon == WP_DYNAMITE ) {
|
||||
ent->client->ps.classWeaponTime = level.time; // JPW NERVE
|
||||
}
|
||||
if (ent->aiCharacter) {
|
||||
weapon_grenadelauncher_fire(ent, ent->s.weapon);
|
||||
}
|
||||
else {
|
||||
weapon_grenadelauncher_fire_vr(ent, ent->s.weapon);
|
||||
}
|
||||
break;
|
||||
case WP_FLAMETHROWER:
|
||||
// RF, this is done client-side only now
|
||||
|
|
|
@ -42,7 +42,7 @@ seta vr_weapon_adjustment_1 "0.5,-8.0,8.0,-15.0"
|
|||
seta vr_weapon_adjustment_2 "0.5,-10,17.0,-20.1"
|
||||
|
||||
// MP40
|
||||
seta vr_weapon_adjustment_3 "0.6,-9.8,10.0,-14.1"
|
||||
seta vr_weapon_adjustment_3 "0.6,-9.8,9.5,-14.1"
|
||||
|
||||
// Grenade Launcher
|
||||
seta vr_weapon_adjustment_6 "0.55,-10,18.0,-24.0"
|
||||
|
@ -68,3 +68,6 @@ seta vr_weapon_adjustment_10 "0.72,-9.8,11.3,-12.1"
|
|||
// Garand (snooper scope sniper rifle)
|
||||
seta vr_weapon_adjustment_13 "0.59,-9.8,10.0,-12.0"
|
||||
|
||||
// Dynamite
|
||||
seta vr_weapon_adjustment_22 "0.55,-10,18.0,-24.0"
|
||||
|
||||
|
|
Loading…
Reference in a new issue