From 7eff10b983e5c6387bee6505f84dbeb8188af0d2 Mon Sep 17 00:00:00 2001 From: yumirak Date: Mon, 4 Mar 2024 16:41:04 +0700 Subject: [PATCH] cgame: add cg_killbeep --- code/cgame/cg_event.c | 6 +++++- code/cgame/cg_local.h | 1 + code/cgame/cg_main.c | 10 ++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/code/cgame/cg_event.c b/code/cgame/cg_event.c index 30a57fe3bc..72bfcba3d6 100644 --- a/code/cgame/cg_event.c +++ b/code/cgame/cg_event.c @@ -83,6 +83,7 @@ static void CG_Obituary( entityState_t *ent ) { char attackerName[32]; gender_t gender; clientInfo_t *ci; + clientInfo_t *us; target = ent->otherEntityNum; attacker = ent->otherEntityNum2; @@ -92,6 +93,7 @@ static void CG_Obituary( entityState_t *ent ) { CG_Error( "CG_Obituary: target out of range" ); } ci = &cgs.clientinfo[target]; + us = &cgs.clientinfo[cg.snap->ps.clientNum]; if ( attacker < 0 || attacker >= MAX_CLIENTS ) { attacker = ENTITYNUM_WORLD; @@ -221,7 +223,9 @@ static void CG_Obituary( entityState_t *ent ) { #else CG_CenterPrint( s, SCREEN_HEIGHT * 0.30, BIGCHAR_WIDTH ); #endif - + if ( ( (cgs.gametype >= GT_TEAM && ci->team != us->team) || cgs.gametype < GT_TEAM ) && cg_killBeep.integer > 0 && cg_killBeep.integer <= 8) { + trap_S_StartLocalSound(cgs.media.killBeep[cg_killBeep.integer - 1], CHAN_LOCAL_SOUND); + } // print the text message as well } diff --git a/code/cgame/cg_local.h b/code/cgame/cg_local.h index cdf446e418..d62789143e 100644 --- a/code/cgame/cg_local.h +++ b/code/cgame/cg_local.h @@ -1281,6 +1281,7 @@ extern vmCvar_t cg_hudTextScale; extern vmCvar_t cg_announcer; extern vmCvar_t cg_lightningStyle; extern vmCvar_t cg_hitBeep; +extern vmCvar_t cg_killBeep; // extern vmCvar_t cg_kickScale; diff --git a/code/cgame/cg_main.c b/code/cgame/cg_main.c index 14419e19d6..734e8f84b1 100644 --- a/code/cgame/cg_main.c +++ b/code/cgame/cg_main.c @@ -223,6 +223,7 @@ vmCvar_t cg_hudTextScale; vmCvar_t cg_announcer; vmCvar_t cg_lightningStyle; vmCvar_t cg_hitBeep; +vmCvar_t cg_killBeep; // vmCvar_t cg_kickScale; vmCvar_t cg_screenDamageAlpha; @@ -369,6 +370,7 @@ static cvarTable_t cvarTable[] = { { &cg_lightningStyle, "cg_lightningStyle", "0", CVAR_ARCHIVE}, { &cg_announcer, "cg_announcer", "1", CVAR_ARCHIVE | CVAR_LATCH}, //FIXME: reload announcer without snd_restart ? { &cg_hitBeep, "cg_hitBeep", "1", CVAR_ARCHIVE}, + { &cg_killBeep, "cg_killBeep", "7", CVAR_ARCHIVE }, // ttf { &cg_forceBitmapFonts, "cg_forceBitmapFonts", "0", CVAR_ARCHIVE | CVAR_LATCH }, { &cg_hudTextScale, "cg_hudTextScale", "1", CVAR_ARCHIVE }, @@ -832,6 +834,14 @@ static void CG_RegisterSounds( void ) { for (i = 0; i < 4; i++) { cgs.media.hitSound[i] = trap_S_RegisterSound(va( "sound/feedback/hit%d.ogg", i ), qfalse); } + cgs.media.hitTeamSound = trap_S_RegisterSound("sound/feedback/hit_teammate.ogg", qfalse); + + for (i = 0; i < 6; i++) { + cgs.media.killBeep[i] = trap_S_RegisterSound(va("sound/feedback/impact%i.ogg", i + 1), qfalse); + } + cgs.media.killBeep[6] = trap_S_RegisterSound("sound/world/bell_01.ogg", qfalse); + cgs.media.killBeep[7] = trap_S_RegisterSound("sound/misc/chaching.ogg", qfalse); + cgs.media.watrInSound = trap_S_RegisterSound( "sound/player/watr_in.wav", qfalse); cgs.media.watrOutSound = trap_S_RegisterSound( "sound/player/watr_out.wav", qfalse); cgs.media.watrUnSound = trap_S_RegisterSound( "sound/player/watr_un.wav", qfalse);