@MuadDib's Usable-objects-hint

This commit is contained in:
Simon 2023-03-05 08:50:51 +00:00
parent b00d5053dd
commit 5ba176fced
21 changed files with 486 additions and 40 deletions

View file

@ -3695,11 +3695,13 @@ qboolean cg_usingInFrontOf = qfalse;
qboolean CanUseInfrontOf(gentity_t*);
static void CG_UseIcon()
{
cg_usingInFrontOf = CanUseInfrontOf(cg_entities[cg.snap->ps.clientNum].gent);
if (cg_usingInFrontOf)
{
cgi_R_SetColor( NULL );
CG_DrawPic( 50, 285, 64, 64, cgs.media.useableHint );
if (cg_usableObjectsHint.integer) {
cg_usingInFrontOf = CanUseInfrontOf(cg_entities[cg.snap->ps.clientNum].gent);
if (cg_usingInFrontOf)
{
cgi_R_SetColor( NULL );
CG_DrawPic( 50, 285, 64, 64, cgs.media.useableHint );
}
}
}

View file

@ -655,6 +655,7 @@ extern vmCvar_t cg_gunAutoFirst;
extern vmCvar_t cg_debugSaberCombat;
extern vmCvar_t cg_saberBurnMarkCoolDownTime;
extern vmCvar_t cg_autoUseBacta;
extern vmCvar_t cg_usableObjectsHint;
extern vmCvar_t cg_zProj;
extern vmCvar_t cg_stereoSeparation;

View file

@ -310,6 +310,7 @@ vmCvar_t cg_gunAutoFirst;
vmCvar_t cg_debugSaberCombat;
vmCvar_t cg_saberBurnMarkCoolDownTime;
vmCvar_t cg_autoUseBacta;
vmCvar_t cg_usableObjectsHint;
vmCvar_t cg_thirdPersonAlpha;
vmCvar_t cg_thirdPersonAutoAlpha;
@ -471,6 +472,8 @@ static cvarTable_t cvarTable[] = {
{ &cg_saberAutoThird, "cg_saberAutoThird", "0", CVAR_ARCHIVE },
{ &cg_gunAutoFirst, "cg_gunAutoFirst", "1", CVAR_ARCHIVE },
{ &cg_usableObjectsHint, "cg_usableObjectsHint", "1", CVAR_ARCHIVE },
{ &cg_pano, "pano", "0", 0 },
{ &cg_panoNumShots, "panoNumShots", "10", 0 },

View file

@ -1672,23 +1672,9 @@ qboolean CanUseInfrontOf(gentity_t *ent)
//FIXME: this does not match where the new accurate crosshair aims...
//cg.refdef.vieworg, basically
if (ent->client->ps.clientNum == 0) {
vec3_t angles;
// TODO Not sure with this, function CanUseInfrontOf seems to be used only to
// show "usable hint" which i guess will be better based on gaze direction
if (vr->useGestureState & USE_GESTURE_OFF_HAND) {
BG_CalculateVROffHandPosition(src, angles);
} else {
BG_CalculateVRWeaponPosition(src, angles);
}
AngleVectors(angles, vf, NULL, NULL);
} else {
VectorCopy(ent->client->renderInfo.eyePoint, src);
AngleVectors(ent->client->ps.viewangles, vf, NULL,
NULL);//ent->client->renderInfo.eyeAngles was cg.refdef.viewangles, basically
}
VectorCopy( ent->client->renderInfo.eyePoint, src );
AngleVectors( ent->client->ps.viewangles, vf, NULL, NULL );
//extend to find end of use trace
VectorMA( src, USE_DISTANCE, vf, dest );

View file

@ -2555,6 +2555,19 @@ static qboolean CG_RenderingFromMiscCamera()
return qfalse;
}
qboolean cg_usingInFrontOf = qfalse;
qboolean CanUseInfrontOf(gentity_t*);
static void CG_UseIcon()
{
if (cg_usableObjectsHint.integer) {
cg_usingInFrontOf = CanUseInfrontOf(cg_entities[cg.snap->ps.clientNum].gent);
if (cg_usingInFrontOf)
{
cgi_R_SetColor( NULL );
CG_DrawPic( 50, 285, 64, 64, cgs.media.useableHint );
}
}
}
/*
-------------------------
@ -2773,6 +2786,8 @@ static void CG_Draw2D( void )
CG_DrawForceSelect();
CG_DrawPickupItem();
CG_UseIcon();
}
CG_SaberClashFlare();

View file

@ -631,6 +631,7 @@ extern vmCvar_t cg_gunAutoFirst;
extern vmCvar_t cg_debugSaberCombat;
extern vmCvar_t cg_saberBurnMarkCoolDownTime;
extern vmCvar_t cg_autoUseBacta;
extern vmCvar_t cg_usableObjectsHint;
extern vmCvar_t cg_zProj;
extern vmCvar_t cg_stereoSeparation;

View file

@ -302,6 +302,7 @@ vmCvar_t cg_gunAutoFirst;
vmCvar_t cg_debugSaberCombat;
vmCvar_t cg_saberBurnMarkCoolDownTime;
vmCvar_t cg_autoUseBacta;
vmCvar_t cg_usableObjectsHint;
vmCvar_t cg_thirdPersonAlpha;
vmCvar_t cg_thirdPersonAutoAlpha;
@ -457,6 +458,7 @@ static cvarTable_t cvarTable[] = {
{ &cg_debugSaberCombat, "cg_debugSaberCombat", "0", CVAR_ARCHIVE },
{ &cg_saberBurnMarkCoolDownTime, "cg_saberBurnMarkCoolDownTime", "0", CVAR_ARCHIVE },
{ &cg_autoUseBacta, "cg_autoUseBacta", "0", CVAR_ARCHIVE },
{ &cg_usableObjectsHint, "cg_usableObjectsHint", "1", CVAR_ARCHIVE },
{ &cg_pano, "pano", "0", 0 },
{ &cg_panoNumShots, "panoNumShots", "10", 0 },
@ -1405,6 +1407,7 @@ static void CG_RegisterGraphics( void ) {
// battery charge shader when using a gonk
cgs.media.batteryChargeShader = cgi_R_RegisterShader( "gfx/2d/battery" );
cgi_R_RegisterShader( "gfx/2d/droid_view" );
cgs.media.useableHint = cgi_R_RegisterShader("gfx/hud/useableHint");
// Load force tics
for (i=0;i<MAX_TICS;i++)

View file

@ -239,6 +239,7 @@ typedef struct {
qhandle_t messageObjCircle;
qhandle_t batteryChargeShader;
qhandle_t useableHint;
qhandle_t levelLoad;

View file

@ -1260,6 +1260,260 @@ qboolean ValidUseTarget( gentity_t *ent )
return qtrue;
}
static qboolean G_ValidActivateBehavior (gentity_t* self, int bset)
{
if ( !self )
{
return qfalse;
}
const char *bs_name = self->behaviorSet[bset];
if( !(VALIDSTRING( bs_name )) )
{
return qfalse;
}
return qtrue;
}
static qboolean G_IsTriggerUsable(gentity_t* self, gentity_t* other)
{
if ( self->svFlags & SVF_INACTIVE )
{//set by target_deactivate
return qfalse;
}
if( self->noDamageTeam )
{
if ( other->client->playerTeam != self->noDamageTeam )
{
return qfalse;
}
}
if ( self->spawnflags & 4 )
{//USE_BUTTON
if ( !other->client )
{
return qfalse;
}
}
else
{
return qfalse;
}
if ( self->spawnflags & 2 )
{//FACING
vec3_t forward;
if ( other->client )
{
AngleVectors( other->client->ps.viewangles, forward, NULL, NULL );
}
else
{
AngleVectors( other->currentAngles, forward, NULL, NULL );
}
if ( DotProduct( self->movedir, forward ) < 0.5 )
{//Not Within 45 degrees
return qfalse;
}
}
if ((!G_ValidActivateBehavior (self, BSET_USE) && !self->target) ||
(self->target &&
(Q_stricmp(self->target, "n") == 0 ||
(Q_stricmp(self->target, "neveropen") == 0 ||
(Q_stricmp(self->target, "run_gran_drop") == 0) ||
(Q_stricmp(self->target, "speaker") == 0) ||
(Q_stricmp(self->target, "locked") == 0)
))))
{
return qfalse;
}
/*
//NOTE: This doesn't stop you from using it, just delays the use action!
if(self->delay && self->painDebounceTime < (level.time + self->delay) )
{
return qfalse;
}
*/
return qtrue;
}
static qboolean CanUseInfrontOfPartOfLevel(gentity_t* ent ) //originally from VV
{
int i, num;
gentity_t *touch[MAX_GENTITIES], *hit;
vec3_t mins, maxs;
const vec3_t range = { 40, 40, 52 };
if ( !ent->client ) {
return qfalse;
}
VectorSubtract( ent->client->ps.origin, range, mins );
VectorAdd( ent->client->ps.origin, range, maxs );
num = gi.EntitiesInBox( mins, maxs, touch, MAX_GENTITIES );
// can't use ent->absmin, because that has a one unit pad
VectorAdd( ent->client->ps.origin, ent->mins, mins );
VectorAdd( ent->client->ps.origin, ent->maxs, maxs );
for ( i=0 ; i<num ; i++ ) {
hit = touch[i];
if ( (hit->e_TouchFunc == touchF_NULL) && (ent->e_TouchFunc == touchF_NULL) ) {
continue;
}
if ( !( hit->contents & CONTENTS_TRIGGER ) ) {
continue;
}
if ( !gi.EntityContact( mins, maxs, hit ) ) {
continue;
}
if ( hit->e_TouchFunc != touchF_NULL ) {
switch (hit->e_TouchFunc )
{
case touchF_Touch_Multi:
if (G_IsTriggerUsable(hit, ent))
{
return qtrue;
}
continue;
break;
default:
continue;
}
}
}
return qfalse;
}
#define USE_DISTANCE 64.0f
qboolean CanUseInfrontOf(gentity_t *ent)
{
gentity_t *target;
trace_t trace;
vec3_t src, dest, vf;
if ( ent->s.number && ent->client->NPC_class == CLASS_ATST )
{//a player trying to get out of his ATST
// GEntity_UseFunc( ent->activator, ent, ent );
return qfalse;
}
if (ent->client->ps.viewEntity != ent->s.number)
{
ent = &g_entities[ent->client->ps.viewEntity];
if ( !Q_stricmp( "misc_camera", ent->classname ) )
{ // we are in a camera
gentity_t *next = 0;
if ( ent->target2 != NULL )
{
next = G_Find( NULL, FOFS(targetname), ent->target2 );
}
if ( next )
{//found another one
if ( !Q_stricmp( "misc_camera", next->classname ) )
{//make sure it's another camera
return qtrue;
}
}
else //if ( ent->health > 0 )
{//I was the last (only?) one, clear out the viewentity
return qfalse;
}
}
}
if ( !ent->client ) {
return qfalse;
}
//FIXME: this does not match where the new accurate crosshair aims...
//cg.refdef.vieworg, basically
VectorCopy( ent->client->renderInfo.eyePoint, src );
AngleVectors( ent->client->ps.viewangles, vf, NULL, NULL );
//extend to find end of use trace
VectorMA( src, USE_DISTANCE, vf, dest );
//Trace ahead to find a valid target
gi.trace( &trace, src, vec3_origin, vec3_origin, dest, ent->s.number, MASK_OPAQUE|CONTENTS_SOLID|CONTENTS_TERRAIN|CONTENTS_BODY|CONTENTS_ITEM|CONTENTS_CORPSE , G2_NOCOLLIDE, 10);
if ( trace.fraction == 1.0f || trace.entityNum >= ENTITYNUM_WORLD )
{
return (CanUseInfrontOfPartOfLevel(ent));
}
target = &g_entities[trace.entityNum];
if ( target && target->client && target->client->NPC_class == CLASS_ATST )
{
// Attempt to board this vehicle.
return qtrue;
}
//Check for a use command
if (ValidUseTarget( target )) {
if ( target->s.eType == ET_ITEM )
{//item, see if we could actually pick it up
if ( (target->spawnflags&128/*ITMSF_USEPICKUP*/) )
{//player has to be touching me and hit use to pick it up, so don't allow this
if ( !G_BoundsOverlap( target->absmin, target->absmax, ent->absmin, ent->absmax ) )
{//not touching
return qfalse;
}
}
if ( !BG_CanItemBeGrabbed( &target->s, &ent->client->ps ) )
{//nope, so don't indicate that we can use it
return qfalse;
}
}
else if ( target->e_UseFunc == useF_misc_atst_use )
{//drivable AT-ST from JK2
if ( ent->client->ps.groundEntityNum != target->s.number )
{//must be standing on it to use it
return qfalse;
}
}
else if ( target->NPC!=NULL && target->health<=0 )
{
return qfalse;
}
return qtrue;
}
if ( target->client
&& target->client->ps.pm_type < PM_DEAD
&& target->NPC!=NULL
&& target->client->playerTeam
&& (target->client->playerTeam == ent->client->playerTeam || target->client->playerTeam == TEAM_NEUTRAL)
&& !(target->NPC->scriptFlags&SCF_NO_RESPONSE)
&& G_ValidActivateBehavior (target, BSET_USE))
{
return qtrue;
}
if (CanUseInfrontOfPartOfLevel(ent)) {
return qtrue;
}
return qfalse;
}
/*
==============
TryUse

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

View file

@ -0,0 +1,12 @@
gfx/hud/useablehint
{
{
map gfx/hud/useablehint_circle
blendFunc GL_ONE GL_ONE
rgbGen wave sawtooth 0 1 0 0.75
}
{
map gfx/hud/useablehint
blendFunc GL_SRC_ALPHA GL_ONE_MINUS_SRC_ALPHA
}
}

View file

@ -3,7 +3,7 @@ CONFIG W:\bin\striped.cfg
ID 100
REFERENCE MENUS_VR
DESCRIPTION "VR Menu Localizations"
COUNT 142
COUNT 144
INDEX 0
{
REFERENCE COMMON_CONTROLS_ITEM
@ -714,3 +714,13 @@ INDEX 141
REFERENCE HUD_YOFFSET_DESC
TEXT_LANGUAGE1 "Y-Offset of the HUD in VR."
}
INDEX 142
{
REFERENCE USABLE_OBJECT_HINT_ITEM
TEXT_LANGUAGE1 "Usable Objects Hint:"
}
INDEX 143
{
REFERENCE USABLE_OBJECT_HINT_DESC
TEXT_LANGUAGE1 "Show icon when looking at objects that can be used."
}

View file

@ -2400,6 +2400,38 @@
}
itemDef
{
name usablehint
group options
type ITEM_TYPE_YESNO
text @MENUS_VR_USABLE_OBJECT_HINT_ITEM
cvar "cg_usableObjectsHint"
rect 305 251 300 20
textalign ITEM_ALIGN_RIGHT
textalignx 165
textaligny -2
font 2
textscale 0.8
forecolor 1 1 1 1
visible 0
descText @MENUS_VR_USABLE_OBJECT_HINT_DESC
action
{
play "sound/interface/button1.wav"
}
mouseenter
{
show highlight5
}
mouseexit
{
hide highlight5
}
}
itemDef
{
name slowmo
@ -2417,7 +2449,7 @@
@MENUS2_FREQUENTLY 5
@MENUS2_EXCESSIVELY 6
}
rect 305 251 300 20
rect 305 271 300 20
textalign ITEM_ALIGN_RIGHT
textalignx 165
textaligny -2
@ -2434,11 +2466,11 @@
mouseenter
{
show highlight5
show highlight6
}
mouseexit
{
hide highlight5
hide highlight6
}
}

View file

@ -2489,6 +2489,38 @@
}
itemDef
{
name usablehint
group options
type ITEM_TYPE_YESNO
text @MENUS_VR_USABLE_OBJECT_HINT_ITEM
cvar "cg_usableObjectsHint"
rect 305 251 300 20
textalign ITEM_ALIGN_RIGHT
textalignx 165
textaligny -2
font 2
textscale 0.8
forecolor 1 1 1 1
visible 0
descText @MENUS_VR_USABLE_OBJECT_HINT_DESC
action
{
play "sound/interface/button1.wav"
}
mouseenter
{
show highlight5
}
mouseexit
{
hide highlight5
}
}
itemDef
{
name slowmo
@ -2506,7 +2538,7 @@
@MENUS2_FREQUENTLY 5
@MENUS2_EXCESSIVELY 6
}
rect 305 251 300 20
rect 305 271 300 20
textalign ITEM_ALIGN_RIGHT
textalignx 165
textaligny -2
@ -2523,11 +2555,11 @@
}
mouseenter
{
show highlight5
show highlight6
}
mouseexit
{
hide highlight5
hide highlight6
}
}

View file

@ -442,4 +442,10 @@ LANG_ENGLISH "VR HUD Y-Offset:"
REFERENCE HUD_YOFFSET_DESC
LANG_ENGLISH "Y-Offset of the HUD in VR."
REFERENCE USABLE_OBJECT_HINT_ITEM
LANG_ENGLISH "Usable Objects Hint:"
REFERENCE USABLE_OBJECT_HINT_DESC
LANG_ENGLISH "Show icon when looking at objects that can be used."
ENDMARKER

View file

@ -585,4 +585,12 @@ REFERENCE HUD_YOFFSET_DESC
LANG_ENGLISH "Y-Offset of the HUD in VR."
LANG_FRENCH "#same"
REFERENCE USABLE_OBJECT_HINT_ITEM
LANG_ENGLISH "Usable Objects Hint:"
LANG_FRENCH "#same"
REFERENCE USABLE_OBJECT_HINT_DESC
LANG_ENGLISH "Show icon when looking at objects that can be used."
LANG_FRENCH "#same"
ENDMARKER

View file

@ -585,4 +585,12 @@ REFERENCE HUD_YOFFSET_DESC
LANG_ENGLISH "Y-Offset of the HUD in VR."
LANG_GERMAN "#same"
REFERENCE USABLE_OBJECT_HINT_ITEM
LANG_ENGLISH "Usable Objects Hint:"
LANG_GERMAN "#same"
REFERENCE USABLE_OBJECT_HINT_DESC
LANG_ENGLISH "Show icon when looking at objects that can be used."
LANG_GERMAN "#same"
ENDMARKER

View file

@ -585,4 +585,12 @@ REFERENCE HUD_YOFFSET_DESC
LANG_ENGLISH "Y-Offset of the HUD in VR."
LANG_SPANISH "#same"
REFERENCE USABLE_OBJECT_HINT_ITEM
LANG_ENGLISH "Usable Objects Hint:"
LANG_SPANISH "#same"
REFERENCE USABLE_OBJECT_HINT_DESC
LANG_ENGLISH "Show icon when looking at objects that can be used."
LANG_SPANISH "#same"
ENDMARKER

View file

@ -2206,6 +2206,38 @@
}
itemDef
{
name usablehint
group options
type ITEM_TYPE_YESNO
text @MENUS_VR_USABLE_OBJECT_HINT_ITEM
cvar "cg_usableObjectsHint"
rect 260 244 340 14
textalign ITEM_ALIGN_RIGHT
textalignx 174
textaligny 0
font 4
textscale 1
forecolor .615 .615 .956 1
visible 0
descText @MENUS_VR_USABLE_OBJECT_HINT_DESC
action
{
play "sound/interface/button1.wav"
}
mouseenter
{
show highlight5
}
mouseexit
{
hide highlight5
}
}
itemDef
{
name slowmo
@ -2223,7 +2255,7 @@
@MENUS_FREQUENTLY 5
@MENUS_EXCESSIVELY 6
}
rect 260 244 340 14
rect 260 258 340 14
textalign ITEM_ALIGN_RIGHT
textalignx 174
textaligny 0
@ -2239,11 +2271,11 @@
}
mouseenter
{
show highlight5
show highlight6
}
mouseexit
{
hide highlight5
hide highlight6
}
}
@ -2262,7 +2294,7 @@
@MENUS_SOUNDS_AND_EFFECTS 2
@MENUS_SOUNDS_EFFECTS_GRAPHICS 3
}
rect 260 258 340 14
rect 260 272 340 14
textalign ITEM_ALIGN_RIGHT
textalignx 174
textaligny 0
@ -2276,11 +2308,11 @@
}
mouseenter
{
show highlight6
show highlight7
}
mouseexit
{
hide highlight6
hide highlight7
}
}

View file

@ -2227,6 +2227,38 @@
}
itemDef
{
name usablehint
group options
type ITEM_TYPE_YESNO
text @MENUS_VR_USABLE_OBJECT_HINT_ITEM
cvar "cg_usableObjectsHint"
rect 260 244 340 14
textalign ITEM_ALIGN_RIGHT
textalignx 174
textaligny 0
font 4
textscale 1
forecolor .615 .615 .956 1
visible 0
descText @MENUS_VR_USABLE_OBJECT_HINT_DESC
action
{
play "sound/interface/button1.wav"
}
mouseenter
{
show highlight5
}
mouseexit
{
hide highlight5
}
}
itemDef
{
name slowmo
@ -2244,7 +2276,7 @@
@MENUS_FREQUENTLY 5
@MENUS_EXCESSIVELY 6
}
rect 260 244 340 14
rect 260 258 340 14
textalign ITEM_ALIGN_RIGHT
textalignx 174
textaligny 0
@ -2260,11 +2292,11 @@
}
mouseenter
{
show highlight5
show highlight6
}
mouseexit
{
hide highlight5
hide highlight6
}
}
@ -2283,7 +2315,7 @@
@MENUS_SOUNDS_AND_EFFECTS 2
@MENUS_SOUNDS_EFFECTS_GRAPHICS 3
}
rect 260 258 340 14
rect 260 272 340 14
textalign ITEM_ALIGN_RIGHT
textalignx 174
textaligny 0
@ -2297,11 +2329,11 @@
}
mouseenter
{
show highlight6
show highlight7
}
mouseexit
{
hide highlight6
hide highlight7
}
}