Skip to content

Commit 5787df9

Browse files
committed
client: add kill sound feature (configured via cl_killsound and cl_killsound_path cvars)
1 parent 8009c16 commit 5787df9

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

cl_dll/death.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,18 @@ static int DEATHNOTICE_DISPLAY_TIME = 6;
4545

4646
DeathNoticeItem rgDeathNoticeList[ MAX_DEATHNOTICES + 1 ];
4747

48+
cvar_t *cl_killsound;
49+
cvar_t *cl_killsound_path;
50+
4851
int CHudDeathNotice :: Init( void )
4952
{
5053
gHUD.AddHudElem( this );
5154

5255
HOOK_MESSAGE( gHUD.m_DeathNotice, DeathMsg );
5356

5457
hud_deathnotice_time = CVAR_CREATE( "hud_deathnotice_time", "6", FCVAR_ARCHIVE );
58+
cl_killsound = CVAR_CREATE( "cl_killsound", "0", FCVAR_ARCHIVE );
59+
cl_killsound_path = CVAR_CREATE( "cl_killsound_path", "buttons/bell1.wav", FCVAR_ARCHIVE );
5560
m_iFlags = 0;
5661

5762
return 1;
@@ -248,6 +253,14 @@ int CHudDeathNotice :: MsgFunc_DeathMsg( const char *pszName, int iSize, void *p
248253

249254
rgDeathNoticeList[i].flDisplayTime = gHUD.m_flTime + hud_deathnotice_time->value;
250255

256+
// Play kill sound
257+
if ((g_PlayerInfoList[killer].thisplayer || g_iUser2 == killer) &&
258+
!rgDeathNoticeList[i].bNonPlayerKill &&
259+
!rgDeathNoticeList[i].bSuicide &&
260+
cl_killsound->value > 0.0f)
261+
{
262+
PlaySound(cl_killsound_path->string, cl_killsound->value);
263+
}
251264

252265
if (rgDeathNoticeList[i].bNonPlayerKill)
253266
{

0 commit comments

Comments
 (0)