mirror of
https://github.com/DrBeef/RTCWQuest.git
synced 2024-11-14 16:41:20 +00:00
Haptics (Release Candidate)
This commit is contained in:
parent
31ec8e1f54
commit
b0d53d4bcd
17 changed files with 92 additions and 13 deletions
|
@ -910,10 +910,31 @@ void RTCWVR_Vibrate( int duration, int channel, float intensity )
|
|||
|
||||
void RTCWVR_Haptic( int duration, int channel, float intensity, char *description, float yaw, float height )
|
||||
{
|
||||
/*if(strstr(description,"camera_shake") == NULL && strstr(description,"ignore") == NULL && strstr(description,"dead_") == NULL)
|
||||
Com_Printf("GBRTCW: Vibrate Description: %s (Yaw: %f Pitch: %f)", description, yaw, height);*/
|
||||
if(strstr(description,"camera_shake") == NULL && strstr(description,"ignore") == NULL && strstr(description,"dead_") == NULL)
|
||||
Com_Printf("GBRTCW: Vibrate Description: %s (Yaw: %f Pitch: %f)", description, yaw, height);
|
||||
|
||||
if(strstr(description,"damage_") != NULL) {
|
||||
if(strcmp(description,"player_dead") == 0) {
|
||||
RTCWVR_HapticEvent("player_dead", 0, 0, 100.0f * intensity, yaw, height);
|
||||
}
|
||||
else if(strcmp(description,"door_kick") == 0) {
|
||||
RTCWVR_HapticEvent("kick_door", 0, 0, 100.0f * intensity, yaw, height);
|
||||
}
|
||||
else if(strcmp(description,"door_open") == 0) {
|
||||
RTCWVR_HapticEvent("open_door", 0, 0, 100.0f * intensity, yaw, height);
|
||||
}
|
||||
else if(strcmp(description,"alarm_on") == 0) {
|
||||
RTCWVR_HapticEvent("heartbeat", 0, 0, 100.0f * intensity, yaw, height);
|
||||
}
|
||||
else if(strcmp(description,"end_alarm") == 0) {
|
||||
RTCWVR_HapticStopEvent("heartbeat");
|
||||
}
|
||||
else if(strcmp(description,"give_armor") == 0) {
|
||||
RTCWVR_HapticEvent(description, 0, 0, 100.0f * intensity, yaw, height);
|
||||
}
|
||||
else if(strcmp(description,"give_health") == 0) {
|
||||
RTCWVR_HapticEvent(description, 0, 0, 100.0f * intensity, yaw, height);
|
||||
}
|
||||
else if(strstr(description,"damage_") != NULL) {
|
||||
RTCWVR_HapticEvent(description, 0, 0, 100.0f * intensity, yaw, height);
|
||||
}
|
||||
else if(strstr(description,"stop_firing_") != NULL) {
|
||||
|
@ -1001,7 +1022,7 @@ void jni_haptic_disable();
|
|||
|
||||
void RTCWVR_HapticEvent(const char* event, int position, int flags, int intensity, float angle, float yHeight )
|
||||
{
|
||||
//Com_Printf( "Vibrate Event Fired: %s", event );
|
||||
//Com_Printf( "GBRTCW: Vibrate Event Fired: %s", event );
|
||||
jni_haptic_event(event, position, flags, intensity, angle, yHeight);
|
||||
}
|
||||
|
||||
|
|
|
@ -1706,6 +1706,8 @@ void CG_RumbleEfx( float pitch, float yaw ) {
|
|||
VectorCopy( recoil, cg.kickAVel );
|
||||
// set the recoil
|
||||
cg.recoilPitch -= pitchRecoilAdd;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2239,12 +2239,14 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) {
|
|||
ByteToDir( es->eventParm, dir );
|
||||
CG_Bullet( es->pos.trBase, es->otherEntityNum, dir, qfalse, ENTITYNUM_WORLD, qtrue, es->otherEntityNum2 );
|
||||
trap_S_StartSound( NULL, es->number, CHAN_AUTO, cgs.media.fkickwall );
|
||||
trap_Vibrate(1, 1, 0.8, "door_kick", 0.0, -0.5);
|
||||
break;
|
||||
|
||||
case EV_WOLFKICK_HIT_FLESH:
|
||||
DEBUGNAME( "EV_WOLFKICK_HIT_FLESH" );
|
||||
CG_Bullet( es->pos.trBase, es->otherEntityNum, dir, qtrue, es->eventParm, qtrue, es->otherEntityNum2 );
|
||||
trap_S_StartSound( NULL, es->number, CHAN_AUTO, cgs.media.fkickflesh );
|
||||
trap_Vibrate(1, 1, 0.7, "door_kick", 0.0, -0.5);
|
||||
break;
|
||||
|
||||
case EV_WOLFKICK_MISS:
|
||||
|
|
|
@ -2458,6 +2458,7 @@ int trap_Key_GetCatcher( void );
|
|||
void trap_Key_SetCatcher( int catcher );
|
||||
int trap_Key_GetKey( const char *binding );
|
||||
|
||||
int trap_Haptic( int duration, int channel, float intensity, char *description, float yaw, float height);
|
||||
int trap_Vibrate( int duration, int channel, float intensity, char *description, float yaw, float height);
|
||||
int trap_EnableHaptics();
|
||||
|
||||
|
|
|
@ -220,7 +220,8 @@ typedef enum {
|
|||
CG_GETMODELINFO,
|
||||
|
||||
CG_HAPTIC,
|
||||
CG_HAPTICENABLE
|
||||
CG_HAPTICENABLE,
|
||||
CG_HAPTICTRIGGER
|
||||
} cgameImport_t;
|
||||
|
||||
|
||||
|
|
|
@ -553,6 +553,10 @@ int trap_Vibrate( int duration, int channel, float intensity, char *description,
|
|||
return syscall( CG_HAPTIC, duration, channel, PASSFLOAT(intensity), description, PASSFLOAT(yaw), PASSFLOAT(height));
|
||||
}
|
||||
|
||||
int trap_Haptic( int duration, int channel, float intensity, char *description, float yaw, float height) {
|
||||
return syscall( CG_HAPTICTRIGGER, duration, channel, PASSFLOAT(intensity), description, PASSFLOAT(yaw), PASSFLOAT(height));
|
||||
}
|
||||
|
||||
int trap_EnableHaptics() {
|
||||
return syscall( CG_HAPTICENABLE );
|
||||
}
|
||||
|
|
|
@ -3379,10 +3379,10 @@ void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent
|
|||
if (wasfiring) {
|
||||
//Stop haptics
|
||||
char *fire_command = (char*)malloc(8 * sizeof(char));
|
||||
sprintf(fire_command, "stop_firing_%i", weaponNum);
|
||||
|
||||
trap_Vibrate(0, 0, 0.0, fire_command, 0.0, 0.0);
|
||||
trap_Vibrate(0, 1, 0.0, "ignore", 0.0, 0.0);
|
||||
//sprintf(fire_command, "stop_firing_%i", weaponNum);
|
||||
//trap_Vibrate(0, 0, 0.0, fire_command, 0.0, 0.0);
|
||||
trap_Vibrate(0, 0, 0.0, "ignore", 0.0, 0.0);
|
||||
trap_Vibrate(0, 1, 0.0, "ignore", 0.0, 0.0);
|
||||
wasfiring = qfalse;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -873,7 +873,14 @@ int CL_CgameSystemCalls( int *args ) {
|
|||
|
||||
RTCWVR_Haptic( args[1], args[2], VMF( 3 ), VMA(4), VMF(5), VMF(6) );
|
||||
return 0;
|
||||
case CG_HAPTICTRIGGER:
|
||||
//VMF(1) = Intensity
|
||||
//VMA(2) = Description
|
||||
//VMF(3) = Yaw
|
||||
//VMF(4) = Height
|
||||
|
||||
RTCWVR_Haptic( args[1], args[2], VMF( 3 ), VMA(4), VMF(5), VMF(6) );
|
||||
return 0;
|
||||
case CG_HAPTICENABLE:
|
||||
RTCWVR_HapticEnable();
|
||||
return 0;
|
||||
|
|
|
@ -97,12 +97,19 @@ void P_DamageFeedback( gentity_t *player ) {
|
|||
if (!client->ps.aiChar) {
|
||||
vec3_t viewangle;
|
||||
float_t pitch, yaw;
|
||||
pitch = (abs(angles[PITCH]) / 360.0) - 0.5;
|
||||
//pitch = (abs(angles[PITCH]) / 360.0) - 0.5;
|
||||
pitch = angles[PITCH];
|
||||
Com_Printf( "GBRTCW: damage location pitch = %f", pitch );
|
||||
if(pitch > -90)
|
||||
pitch = pitch / 180.0;
|
||||
else if(pitch < -270 && pitch > -360)
|
||||
pitch = (pitch + 360) / 180;
|
||||
VectorCopy( client->ps.viewangles, viewangle );
|
||||
//If this doesn't work try (+ 360) instead of abs
|
||||
//Com_Printf( "GBRTCW: viewangle yaw = %f", viewangle[YAW] );
|
||||
//Com_Printf( "GBRTCW: damage location yaw = %f", angles[YAW] );
|
||||
|
||||
|
||||
yaw = angles[YAW] - (viewangle[YAW] + 180.0f);
|
||||
if(yaw < 0.0f)
|
||||
yaw += 360.0f;
|
||||
|
|
|
@ -163,6 +163,8 @@ void alarmbox_use( gentity_t *ent, gentity_t *other, gentity_t *foo ) {
|
|||
alarmbox_updateparts( ent, qtrue );
|
||||
if ( other->client ) {
|
||||
G_AddEvent( ent, EV_GENERAL_SOUND, ent->soundPos3 );
|
||||
//TODO GB Add heartbeat
|
||||
trap_Haptic(1, 0, 1.0f, "alarm_on", 0.0f, 0.0f);
|
||||
}
|
||||
// G_Printf("touched alarmbox\n");
|
||||
|
||||
|
@ -183,6 +185,8 @@ void alarmbox_die( gentity_t *ent, gentity_t *inflictor, gentity_t *attacker, in
|
|||
ent->takedamage = qfalse;
|
||||
alarmbox_updateparts( ent, qtrue );
|
||||
|
||||
trap_Haptic(1, 0, 1.0f, "end_alarm", 0.0f, 0.0f);
|
||||
|
||||
// fire 'death' targets
|
||||
if ( ent->targetdeath ) {
|
||||
t = NULL;
|
||||
|
|
|
@ -359,8 +359,10 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int
|
|||
// if (self->client && self->client->hook)
|
||||
// Weapon_HookFree(self->client->hook);
|
||||
|
||||
trap_Haptic(1,0,1.0f,"player_dead",0,0);
|
||||
self->client->ps.pm_type = PM_DEAD;
|
||||
|
||||
|
||||
if ( attacker ) {
|
||||
killer = attacker->s.number;
|
||||
if ( attacker->client ) {
|
||||
|
|
|
@ -498,6 +498,12 @@ int Pickup_Weapon( gentity_t *ent, gentity_t *other ) {
|
|||
int Pickup_Health( gentity_t *ent, gentity_t *other ) {
|
||||
int max;
|
||||
int quantity = 0;
|
||||
float intensity = 1.0f;
|
||||
//Trigger a haptic for armor pickup
|
||||
intensity = ent->count / 100;
|
||||
if(intensity < 0.4)
|
||||
intensity = 0.4f;
|
||||
trap_Haptic(1,0,intensity,"give_health",0.0f, 0.0f);
|
||||
|
||||
// small and mega healths will go over the max
|
||||
if ( ent->item->quantity != 5 && ent->item->quantity != 100 ) {
|
||||
|
@ -548,6 +554,12 @@ int Pickup_Health( gentity_t *ent, gentity_t *other ) {
|
|||
//======================================================================
|
||||
|
||||
int Pickup_Armor( gentity_t *ent, gentity_t *other ) {
|
||||
|
||||
//Trigger a haptic for armor pickup
|
||||
if ( other->client->ps.stats[STAT_ARMOR] < 100 ) {
|
||||
trap_Haptic(1,0,1.0f,"give_armor",0.0f, 0.0f);
|
||||
}
|
||||
|
||||
other->client->ps.stats[STAT_ARMOR] += ent->item->quantity;
|
||||
// if ( other->client->ps.stats[STAT_ARMOR] > other->client->ps.stats[STAT_MAX_HEALTH] * 2 ) {
|
||||
// other->client->ps.stats[STAT_ARMOR] = other->client->ps.stats[STAT_MAX_HEALTH] * 2;
|
||||
|
|
|
@ -1215,6 +1215,7 @@ 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_Haptic( int duration, int channel, float intensity, char *description, float yaw, float height);
|
||||
int trap_Vibrate( int duration, int channel, float intensity, char *description, float yaw, float height);
|
||||
int trap_EnableHaptics();
|
||||
|
||||
|
|
|
@ -35,6 +35,9 @@ If you have questions concerning this license or the applicable additional terms
|
|||
*/
|
||||
|
||||
#include "g_local.h"
|
||||
#include "../../../RTCWVR/VrClientInfo.h"
|
||||
|
||||
extern vr_client_info_t* gVR;
|
||||
|
||||
char *hintStrings[] = {
|
||||
"", // HINT_NONE
|
||||
|
@ -769,13 +772,16 @@ void SetMoverState( gentity_t *ent, moverState_t moverState, int time ) {
|
|||
if ( kicked ) {
|
||||
f = 2000.0 / ent->gDuration; // double speed when kicked open
|
||||
ent->s.apos.trDuration = ent->gDuration / 2.0;
|
||||
|
||||
} else if ( soft ) {
|
||||
f = 500.0 / ent->gDuration; // 1/2 speed when soft opened
|
||||
ent->s.apos.trDuration = ent->gDuration * 2;
|
||||
//trap_Vibrate(1, gVR->right_handed ? 0 : 1, 0.5f, "door_open", 0, 0); //I've reversed the hands as I presume you will open it with the hand your gun isn't in.
|
||||
} else {
|
||||
f = 1000.0 / ent->gDuration;
|
||||
// ent->s.apos.trDuration = ent->gDurationBack; // (SA) durationback?
|
||||
ent->s.apos.trDuration = ent->gDuration;
|
||||
//trap_Vibrate(1, gVR->right_handed ? 0 : 1, 0.75f, "door_open", 0, 0); //not sure what this is
|
||||
}
|
||||
VectorScale( ent->rotate, f * ent->angle, ent->s.apos.trDelta );
|
||||
ent->s.apos.trType = TR_LINEAR_STOP;
|
||||
|
@ -2200,17 +2206,19 @@ void G_TryDoor( gentity_t *ent, gentity_t *other, gentity_t *activator ) {
|
|||
|
||||
Use_BinaryMover( ent->teammaster, activator, activator );
|
||||
G_UseTargets( ent->teammaster, activator );
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
ent->active = qtrue;
|
||||
if ( walking ) {
|
||||
ent->flags |= FL_SOFTACTIVATE; // no noise
|
||||
trap_Vibrate(1, gVR->right_handed ? 0 : 1, 1.0f, "door_open", 0, 0); //I've reversed the hands as I presume you will open it with the hand your gun isn't in.
|
||||
} else {
|
||||
trap_Vibrate(1, gVR->right_handed ? 0 : 1, 0.6f, "door_open", 0, 0); //I've reversed the hands as I presume you will open it with the hand your gun isn't in.
|
||||
if ( activator ) {
|
||||
soundrange = HEAR_RANGE_DOOR_OPEN;
|
||||
}
|
||||
}
|
||||
|
||||
Use_BinaryMover( ent, activator, activator );
|
||||
G_UseTargets( ent, activator );
|
||||
}
|
||||
|
|
|
@ -250,6 +250,7 @@ typedef enum {
|
|||
G_GETTAG,
|
||||
|
||||
G_HAPTIC,
|
||||
G_HAPTICTRIGGER,
|
||||
G_FULL_HAPTIC,
|
||||
|
||||
BOTLIB_SETUP = 200, // ( void );
|
||||
|
|
|
@ -259,6 +259,10 @@ int trap_Vibrate( int duration, int channel, float intensity, char *description,
|
|||
return syscall( G_HAPTIC, duration, channel, PASSFLOAT(intensity), description, PASSFLOAT(yaw), PASSFLOAT(height));
|
||||
}
|
||||
|
||||
int trap_Haptic( int duration, int channel, float intensity, char *description, float yaw, float height) {
|
||||
return syscall( G_HAPTICTRIGGER, duration, channel, PASSFLOAT(intensity), description, PASSFLOAT(yaw), PASSFLOAT(height));
|
||||
}
|
||||
|
||||
// BotLib traps start here
|
||||
int trap_BotLibSetup( void ) {
|
||||
return syscall( BOTLIB_SETUP );
|
||||
|
|
|
@ -483,7 +483,9 @@ int SV_GameSystemCalls( int *args ) {
|
|||
|
||||
RTCWVR_Haptic( args[1], args[2], VMF( 3 ), VMA(4), VMF(5), VMF(6) );
|
||||
return 0;
|
||||
|
||||
case G_HAPTICTRIGGER:
|
||||
RTCWVR_Haptic( args[1], args[2], VMF( 3 ), VMA(4), VMF(5), VMF(6) );
|
||||
return 0;
|
||||
//====================================
|
||||
|
||||
case BOTLIB_SETUP:
|
||||
|
|
Loading…
Reference in a new issue