Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions 3rdparty/cs16client-extras/gfx/shell/kb_act.lst
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
"blank" "=========================="
"blank" "#Valve_Movement_Title"
"blank" "=========================="
"+forward" "#Valve_Move_Forward"
"+back" "#Valve_Move_Back"
"+left" "#Valve_Turn_Left"
"+right" "#Valve_Turn_Right"
"+moveleft" "#Valve_Move_Left"
"+moveright" "#Valve_Move_Right"
"+speed" "#Valve_Walk"
"+jump" "#Valve_Jump"
"+duck" "#Valve_Duck"
"+moveup" "#Valve_Swim_Up"
"+movedown" "#Valve_Swim_Down"
"+lookup" "#Valve_Look_Up"
"+lookdown" "#Valve_Look_Down"
"force_centerview" "#Cstrike_Reset_View"
"+strafe" "#Valve_Strafe_Modifier"
"+mlook" "#Cstrike_Mouse_Look"
"+klook" "#Cstrike_Keyboard_Look"
"blank" "=========================="
"blank" "#Valve_Communication_Title"
"blank" "=========================="
"+voicerecord" "#Valve_Use_Voice_Communication"
"radio1" "#Cstrike_Standard_Radio"
"radio2" "#Cstrike_Group_Radio"
"radio3" "#Cstrike_Report_Radio"
"+commandmenu" "#Valve_Activate_In_Game_GUI"
"messagemode" "#Valve_Chat_Message"
"messagemode2" "#Valve_Team_Message"
"blank" "=========================="
"blank" "#Cstrike_Menu_Title"
"blank" "=========================="
"buy" "#Cstrike_Buy_Menu"
"buyammo1" "#Cstrike_Buy_Primary_Ammo"
"buyammo2" "#Cstrike_Buy_Secondary_Ammo"
"buyequip" "#Cstrike_Buy_Equip_Menu"
"autobuy" "#Cstrike_Auto_Buy"
"rebuy" "#Cstrike_ReBuy"
"chooseteam" "#Cstrike_Select_Team"
"slot10" "#Cstrike_Menu_Item_0"
"slot1" "#Cstrike_Menu_Item_1"
"slot2" "#Cstrike_Menu_Item_2"
"slot3" "#Cstrike_Menu_Item_3"
"slot4" "#Cstrike_Menu_Item_4"
"slot5" "#Cstrike_Menu_Item_5"
"slot6" "#Cstrike_Menu_Item_6"
"slot7" "#Cstrike_Menu_Item_7"
"slot8" "#Cstrike_Menu_Item_8"
"slot9" "#Cstrike_Menu_Item_9"
"+showscores" "#Valve_Display_Scores"
"showbriefing" "#Cstrike_Mission_Briefing"
"blank" "=========================="
"blank" "#Cstrike_Combat_Title"
"blank" "=========================="
"+attack" "#Cstrike_Fire"
"+attack2" "#Cstrike_Weapon_Special_Func"
"+reload" "#Valve_Reload_Weapon"
"invprev" "#Valve_Previous_Weapon"
"invnext" "#Valve_Next_Weapon"
"lastinv" "#Valve_Last_Weapon_Used"
"nightvision" "#Cstrike_Nightvision"
"drop" "#Cstrike_Drop_Weapon"
"blank" "=========================="
"blank" "#Valve_Miscellaneous_Title"
"blank" "=========================="
"+use" "#Valve_Use_Items"
"impulse 100" "#Valve_Flashlight"
"impulse 201" "#Valve_Spray_Logo"
"snapshot" "#Valve_Take_Screen_Shot"
"quit" "#Valve_Quit_Game"
"blank" "=========================="
"blank" "CS16Client"
"blank" "=========================="
"+aimassist" "Aim Assist"
12 changes: 12 additions & 0 deletions cl_dll/entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ int DLLEXPORT HUD_AddEntity( int type, struct cl_entity_s *ent, const char *mode
VectorCopy(ent->curstate.origin, ent->origin);
VectorCopy(ent->curstate.angles, ent->angles);
}
// aim assist: glow shell over the highlighted target.
// Enabled by either the dedicated highlight cvar or the master debug cvar.
if( ent->player && g_iAimAssistTarget && ent->index == g_iAimAssistTarget
&& ( ( aim_assist_highlight && aim_assist_highlight->value )
|| ( aim_assist_debug && aim_assist_debug->value ) ) )
{
ent->curstate.renderfx = kRenderFxGlowShell;
ent->curstate.rendercolor.r = 0;
ent->curstate.rendercolor.g = 255;
ent->curstate.rendercolor.b = 0;
ent->curstate.renderamt = 75; // shell thickness
}
break;
case ET_BEAM:
case ET_TEMPENTITY:
Expand Down
1 change: 1 addition & 0 deletions cl_dll/hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ void CHud :: Init( void )
m_StatusIcons.Init();
m_Radar.Init();
m_Scenario.Init();
m_AimAssist.Init();

// chat, death notice, status bars and other
m_SayText.Init();
Expand Down
2 changes: 2 additions & 0 deletions cl_dll/hud.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ class CHudAmmoSecondary: public CHudBase

#include "health.h"
#include "radar.h"
#include "aimassist.h"

#define FADE_TIME 100

Expand Down Expand Up @@ -1089,6 +1090,7 @@ class CHud
CHudRadar m_Radar;
CHudSpectatorGui m_SpectatorGui;
CHudScenario m_Scenario;
CHudAimAssist m_AimAssist;

// user messages
CHudMsgFunc(Damage);
Expand Down
147 changes: 147 additions & 0 deletions cl_dll/hud/aimassist.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
/*
aimassist.cpp -- debug overlay + target highlight for the gamepad aim assist
*/

#define _USE_MATH_DEFINES // for M_PI (used by DEG2RAD on MSVC)
#include "stdio.h"
#include "math.h"
#include "hud.h"
#include "cl_util.h"
#include "draw_util.h"
#include "triangleapi.h"
#include "cl_entity.h"
#include "aimassist.h"

// Project a world point to screen pixels. Returns false if behind the viewer.
static bool AA_Project( float *world, int &sx, int &sy )
{
vec3_t screen;
if( gEngfuncs.pTriAPI->WorldToScreen( world, screen ) )
return false;
sx = (int)XPROJECT( screen[0] );
sy = (int)YPROJECT( screen[1] );
return true;
}

int CHudAimAssist::Init( void )
{
gHUD.AddHudElem( this );
m_iFlags = HUD_DRAW;
return 1;
}

int CHudAimAssist::VidInit( void )
{
return 1;
}

int CHudAimAssist::Draw( float flTime )
{
if( !aim_assist_debug || !aim_assist_debug->value )
return 1;

int lh = gHUD.m_iFontHeight + 1;
int x = XRES( 8 );
int y = YRES( 70 );
char line[128];

// background box
FillRGBA( x - 4, y - 4, XRES( 240 ), lh * 5 + 8, 0, 0, 0, 150 );

DrawUtils::DrawHudString( x, y, ScreenWidth, "AIM ASSIST DEBUG", 255, 200, 0 );
y += lh;

snprintf( line, sizeof( line ), "enabled: %s key: %s",
( aim_assist && aim_assist->value ) ? "ON" : "OFF",
g_bAimAssistKey ? "HELD" : "released" );
DrawUtils::DrawHudString( x, y, ScreenWidth, line, 255, 255, 255 );
y += lh;

if( g_iAimAssistTarget )
{
const char *name = g_PlayerInfoList[g_iAimAssistTarget].name;
snprintf( line, sizeof( line ), "target: %s (#%d) d=%.0f a=%.1f",
name ? name : "?", g_iAimAssistTarget, g_flAimAssistDist, g_flAimAssistAngle );
DrawUtils::DrawHudString( x, y, ScreenWidth, line, 0, 255, 0 );
}
else
{
DrawUtils::DrawHudString( x, y, ScreenWidth, "target: none", 255, 100, 100 );
}
y += lh;

if( g_iAimAssistNearestIdx )
snprintf( line, sizeof( line ), "nearest enemy: %.1f deg (lock_fov %.0f)",
g_flAimAssistNearestAngle, aim_assist_lock_fov ? aim_assist_lock_fov->value : 0.0f );
else
snprintf( line, sizeof( line ), "nearest enemy: none (team/alive/range)" );
DrawUtils::DrawHudString( x, y, ScreenWidth, line, 200, 200, 200 );
y += lh;

snprintf( line, sizeof( line ), "applying: %s", g_bAimAssistApplying ? "YES" : "no" );
DrawUtils::DrawHudString( x, y, ScreenWidth, line, 255, 255, 255 );

// --- view cone + computed aim direction (to diagnose eye/forward) ---
// magenta dot = where the assist thinks you aim (eye + fwd). It MUST sit on
// your crosshair (screen center); if it is off-center, eye/forward is wrong.
{
vec3_t p;
int px, py;
for( int j = 0; j < 3; j++ )
p[j] = g_vecAimEye[j] + g_vecAimFwd[j] * 300.0f;
if( AA_Project( p, px, py ) )
FillRGBA( px - 3, py - 3, 6, 6, 255, 0, 255, 255 );

// cone edge ring at the acquisition fov, projected into the world
float fov = aim_assist_lock_fov ? aim_assist_lock_fov->value : 45.0f;
float cf = cos( DEG2RAD( fov ) ), sf = sin( DEG2RAD( fov ) );
for( int k = 0; k < 24; k++ )
{
float a = DEG2RAD( k * 15.0f );
float ca = cos( a ), sa = sin( a );
vec3_t dir, q;
int qx, qy;
for( int j = 0; j < 3; j++ )
{
dir[j] = g_vecAimFwd[j] * cf + ( g_vecAimRight[j] * ca + g_vecAimUp[j] * sa ) * sf;
q[j] = g_vecAimEye[j] + dir[j] * 300.0f;
}
if( AA_Project( q, qx, qy ) )
FillRGBA( qx - 1, qy - 1, 3, 3, 0, 200, 255, 220 );
}
}

// nearest enemy (yellow) even if outside the cone -- shows where it projects
if( g_iAimAssistNearestIdx )
{
cl_entity_t *n = gEngfuncs.GetEntityByIndex( g_iAimAssistNearestIdx );
int nx, ny;
if( n && AA_Project( n->curstate.origin, nx, ny ) )
FillRGBA( nx - 4, ny - 4, 8, 8, 255, 255, 0, 220 );
}

// floating marker over the target's head
if( g_iAimAssistTarget )
{
cl_entity_t *t = gEngfuncs.GetEntityByIndex( g_iAimAssistTarget );
if( t )
{
vec3_t head, screen;
VectorCopy( t->origin, head );
head[2] += 40.0f; // approx. above the head

// WorldToScreen returns non-zero when the point is behind the viewer
if( gEngfuncs.pTriAPI->WorldToScreen( head, screen ) == 0 )
{
int sx = XPROJECT( screen[0] );
int sy = YPROJECT( screen[1] );
int s = XRES( 5 );
int r = g_bAimAssistApplying ? 0 : 255;
int g = g_bAimAssistApplying ? 255 : 200;
FillRGBA( sx - s, sy - s, s * 2, s * 2, r, g, 0, 220 );
}
}
}

return 1;
}
37 changes: 37 additions & 0 deletions cl_dll/include/hud/aimassist.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
aimassist.h - debug overlay + target highlight for the gamepad aim assist
*/
#pragma once
#ifndef AIMASSIST_H
#define AIMASSIST_H

// Shared state produced by the aim assist in input_xash3d.cpp and consumed by
// the HUD overlay (this element) and the model highlight (entity.cpp).
extern bool g_bAimAssistKey; // dedicated aim button is held
extern int g_iAimAssistTarget; // entity index of the chosen target (0 = none)
extern bool g_bAimAssistApplying; // assist actively steering (key held + target)
extern float g_flAimAssistDist; // distance to the chosen target
extern float g_flAimAssistAngle; // angular separation (deg) to the chosen target
extern int g_iAimAssistNearestIdx; // nearest visible enemy by angle, ignoring the cone
extern float g_flAimAssistNearestAngle; // its angle (to diagnose a too-tight cone)

extern vec3_t g_vecAimEye; // camera origin used by the assist (for the debug cone)
extern vec3_t g_vecAimFwd; // view forward
extern vec3_t g_vecAimRight; // view right
extern vec3_t g_vecAimUp; // view up

extern cvar_t *aim_assist; // master on/off (shown in the overlay)
extern cvar_t *aim_assist_debug; // text overlay + floating head marker
extern cvar_t *aim_assist_highlight; // glow shell over the target model
extern cvar_t *aim_assist_fov; // legacy tight cone
extern cvar_t *aim_assist_lock_fov; // acquisition cone (shown in the overlay / drawn as the ring)

class CHudAimAssist : public CHudBase
{
public:
int Init( void );
int VidInit( void );
int Draw( float flTime );
};

#endif // AIMASSIST_H
Loading