Updates to Vibrate (to contain extra information)

This commit is contained in:
Grant Bagwell 2021-05-15 17:30:28 +02:00
parent 44abd7b7a1
commit 7898c7cdd8
12 changed files with 50 additions and 25 deletions

View file

@ -3575,8 +3575,8 @@ void CG_ApplyShakeCamera() {
if (VectorLength(cg.cameraShakeAngles) > 0.1f)
{
trap_Vibrate(10, 0, Com_Clamp(0.0f, 1.0f, fabs(cg.cameraShakeAngles[0])));
trap_Vibrate(10, 1, Com_Clamp(0.0f, 1.0f, fabs(cg.cameraShakeAngles[1])));
trap_Vibrate(10, 0, Com_Clamp(0.0f, 1.0f, fabs(cg.cameraShakeAngles[0])),"camera_shake_left",fabs(cg.cameraShakeAngles[0]),fabs(cg.cameraShakeAngles[1]));
trap_Vibrate(10, 0, Com_Clamp(0.0f, 1.0f, fabs(cg.cameraShakeAngles[1])),"camera_shake_right",fabs(cg.cameraShakeAngles[0]),fabs(cg.cameraShakeAngles[1]));
}
}

View file

@ -2458,7 +2458,7 @@ int trap_Key_GetCatcher( void );
void trap_Key_SetCatcher( int catcher );
int trap_Key_GetKey( const char *binding );
int trap_Vibrate(int duration, int channel, float intensity );
int trap_Vibrate( int duration, int channel, float intensity, char *description, float yaw, float height);
// RF
void trap_SendMoveSpeedsToGame( int entnum, char *movespeeds );

View file

@ -221,6 +221,13 @@ void CG_DamageFeedback( int yawByte, int pitchByte, int damage ) {
vd->damageDuration = kick * 50 * ( 1 + 2 * ( !vd->damageX && !vd->damageY ) );
cg.damageTime = cg.snap->serverTime;
cg.damageIndex = slot;
//GB - Add a haptic event
//Ensure a decent level of haptic feedback for any damage
//float hapticLevel = 80 + min(damage * 4, 120.0);
//Indicate head damage if appropriate
//RTCWVR_HapticEvent("damage", 0, 0, hapticLevel, yaw, pitch);
}

View file

@ -549,6 +549,6 @@ qboolean trap_GetModelInfo( int clientNum, char *modelName, animModelInfo_t **mo
return syscall( CG_GETMODELINFO, clientNum, modelName, modelInfo );
}
int trap_Vibrate( int duration, int channel, float intensity ) {
return syscall( CG_HAPTIC, duration, channel, PASSFLOAT(intensity) );
int trap_Vibrate( int duration, int channel, float intensity, char *description, float yaw, float height) {
return syscall( CG_HAPTIC, duration, channel, PASSFLOAT(intensity), description, PASSFLOAT(yaw), PASSFLOAT(height));
}

View file

@ -1666,8 +1666,8 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView, qboolean demo
//Don't allow long running haptics to continue once dead
if ( cg.predictedPlayerState.stats[STAT_HEALTH] <= 0 ) {
trap_Vibrate(0, 0, 0.0);
trap_Vibrate(0, 1, 0.0);
trap_Vibrate(0, 0, 0.0, "dead_left", 0.0, 0.0);
trap_Vibrate(0, 1, 0.0, "dead_right", 0.0, 0.0);
}
DEBUGTIME

View file

@ -2229,10 +2229,10 @@ static void CG_FlamethrowerFlame( centity_t *cent, vec3_t origin ) {
CG_FireFlameChunks(cent, origin, angles, 1.0, qtrue, 1);
trap_Vibrate(-1, cgVR->right_handed ? 1 : 0, 0.6);
trap_Vibrate(-1, cgVR->right_handed ? 1 : 0, 0.6, "fire_flames", 0.0, 0.0);
if (cgVR->weapon_stabilised)
{
trap_Vibrate(-1, cgVR->right_handed ? 0 : 1, 0.5);
trap_Vibrate(-1, cgVR->right_handed ? 0 : 1, 0.5, "fire_flames", 0.0, 0.0);
}
}
@ -2776,10 +2776,10 @@ 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);
trap_Vibrate(-1, cgVR->right_handed ? 1 : 0, 0.8, "fire_tesla", 0.0, 0.0);
if (cgVR->weapon_stabilised)
{
trap_Vibrate(-1, cgVR->right_handed ? 0 : 1, 0.8);
trap_Vibrate(-1, cgVR->right_handed ? 0 : 1, 0.8, "fire_tesla", 0.0, 0.0);
}
// shake the camera a bit
@ -3378,8 +3378,8 @@ void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent
if (wasfiring) {
//Stop haptics
trap_Vibrate(0, 0, 0.0);
trap_Vibrate(0, 1, 0.0);
trap_Vibrate(0, 0, 0.0, "stop_firing", 0.0, 0.0);
trap_Vibrate(0, 1, 0.0, "stop_firing", 0.0, 0.0);
wasfiring = qfalse;
}
}

View file

@ -862,7 +862,24 @@ int CL_CgameSystemCalls( int *args ) {
return SV_GetModelInfo( args[1], VMA( 2 ), VMA( 3 ) );
case CG_HAPTIC:
//VMF(3) = Intensity
//VMA(4) = Description
//VMF(5) = Yaw
//VMF(6) = Height
RTCWVR_Vibrate( args[1], args[2], VMF( 3 ) );
float shakeScale = 1.0f - Com_Clamp(0.0f, 1.0f, ( VMF(3) * ( 1.0f / 4000.0f ) ) + 0.25f ); // 0...4000 -> max...min rumble
float highMag = shakeScale;
int highDuration = FloatAsInt(300.0f * shakeScale);
float lowMag = shakeScale * 0.75f;
int lowDuration = FloatAsInt(500.0f * shakeScale);
//generic rumbling - keep it low
RTCWVR_HapticEvent("rumble_front", 0, 0, 30.0f * Com_Clamp(0.1, 1.0, VMF(3)*2.0f + 0.1f), highDuration, 0);
RTCWVR_HapticEvent("rumble_back", 0, 0, 30.0f * Com_Clamp(0.1, 1.0, VMF(3)*2.0f + 0.1f), highDuration, 0);
return 0;
default:

View file

@ -95,8 +95,8 @@ void P_DamageFeedback( gentity_t *player ) {
client->ps.damageCount = count;
if (!client->ps.aiChar) {
trap_Vibrate(1000, 1, (count / 255.0) + 0.5f);
trap_Vibrate(1000, 0, (count / 255.0) + 0.5f);
trap_Vibrate(1000, 1, (count / 255.0) + 0.5f, "damage", client->ps.damageYaw, client->ps.damagePitch);
trap_Vibrate(1000, 0, (count / 255.0) + 0.5f, "ignore", 0.0, 0.0);
}

View file

@ -1214,7 +1214,8 @@ void trap_GetUsercmd( int clientNum, usercmd_t *cmd );
qboolean trap_GetEntityToken( char *buffer, int bufferSize );
qboolean trap_GetTag( int clientNum, char *tagName, orientation_t * or );
int trap_Vibrate(int duration, int channel, float intensity );
//int trap_Vibrate(int duration, int channel, float intensity );
int trap_Vibrate( int duration, int channel, float intensity, char *description, float yaw, float height);
int trap_DebugPolygonCreate( int color, int numPoints, vec3_t *points );
void trap_DebugPolygonDelete( int id );

View file

@ -250,6 +250,7 @@ typedef enum {
G_GETTAG,
G_HAPTIC,
G_FULL_HAPTIC,
BOTLIB_SETUP = 200, // ( void );
BOTLIB_SHUTDOWN, // ( void );

View file

@ -255,8 +255,8 @@ qboolean trap_GetTag( int clientNum, char *tagName, orientation_t *or ) {
return syscall( G_GETTAG, clientNum, tagName, or );
}
int trap_Vibrate(int duration, int channel, float intensity ) {
return syscall( G_HAPTIC, duration, channel, PASSFLOAT(intensity) );
int trap_Vibrate( int duration, int channel, float intensity, char *description, float yaw, float height) {
return syscall( G_HAPTIC, duration, channel, PASSFLOAT(intensity), description, PASSFLOAT(yaw), PASSFLOAT(height));
}
// BotLib traps start here

View file

@ -141,7 +141,7 @@ void Weapon_Knife( gentity_t *ent ) {
tent->s.weapon = ent->s.weapon;
//we hit something
trap_Vibrate(100, gVR->right_handed ? 1 : 0, 0.9);
trap_Vibrate(100, gVR->right_handed ? 1 : 0, 0.9, "knife_hit", 0.0, 0.0);
if ( tr.entityNum == ENTITYNUM_WORLD ) { // don't worry about doing any damage
return;
@ -966,12 +966,11 @@ void Bullet_Fire( gentity_t *ent, float spread, int damage ) {
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);
trap_Vibrate(100, right ? 1 : 0, 1.0, printf("fire_%i", ent->s.weapon), 0.0, 0.0);
} else{
trap_Vibrate(100, right ? 1 : 0, 1.0);
trap_Vibrate(100, right ? 1 : 0, 1.0, printf("fire_%i", ent->s.weapon), 0.0, 0.0);
if (gVR->weapon_stabilised) {
trap_Vibrate(100, right ? 0 : 1, 0.7);
trap_Vibrate(100, right ? 0 : 1, 0.7, printf("fire_%i", ent->s.weapon), 0.0, 0.0);
}
}
}
@ -2033,9 +2032,9 @@ void FireWeapon( gentity_t *ent ) {
ent->client->ps.classWeaponTime = level.time; // JPW NERVE
Weapon_RocketLauncher_Fire( ent, aimSpreadScale );
if (!ent->aiCharacter) {
trap_Vibrate(200, gVR->right_handed ? 1 : 0, 1.0);
trap_Vibrate(200, gVR->right_handed ? 1 : 0, 1.0, "fire_rocket", 0.0, 0.0);
if (gVR->weapon_stabilised) {
trap_Vibrate(200, gVR->right_handed ? 0 : 1, 0.7);
trap_Vibrate(200, gVR->right_handed ? 0 : 1, 0.7, "fire_rocket", 0.0, 0.0);
}
}
break;