diff --git a/code/cgame/cg_local.h b/code/cgame/cg_local.h index 5ed607213..77ac586ae 100644 --- a/code/cgame/cg_local.h +++ b/code/cgame/cg_local.h @@ -1032,8 +1032,8 @@ typedef struct { sfxHandle_t oneLifeSound; sfxHandle_t hitSound; - sfxHandle_t hitSoundHighArmor; - sfxHandle_t hitSoundLowArmor; + sfxHandle_t hitShieldSound; + sfxHandle_t hitNoShieldSound; sfxHandle_t hitTeamSound; sfxHandle_t excellentSound; sfxHandle_t snackattackSound; @@ -1318,6 +1318,7 @@ extern vmCvar_t cg_cineDrawLetterBox; extern vmCvar_t cg_glowModel; extern vmCvar_t cg_glowModelTeam; +extern vmCvar_t cg_advHitSound; extern vmCvar_t cg_warmupReady; extern vmCvar_t cg_curWarmupReady; diff --git a/code/cgame/cg_main.c b/code/cgame/cg_main.c index 864e3690f..491a7ae87 100644 --- a/code/cgame/cg_main.c +++ b/code/cgame/cg_main.c @@ -184,6 +184,7 @@ vmCvar_t cg_cineDrawLetterBox; vmCvar_t cg_glowModel; vmCvar_t cg_glowModelTeam; +vmCvar_t cg_advHitSound; vmCvar_t cg_warmupReady; vmCvar_t cg_curWarmupReady; @@ -322,6 +323,7 @@ static cvarTable_t cvarTable[] = { // bk001129 {&cg_glowModel, "cg_glowModel", "", CVAR_ARCHIVE}, {&cg_glowModelTeam, "cg_glowModelTeam", "", CVAR_ARCHIVE}, + {&cg_advHitSound, "cg_advHitSound", "0", CVAR_ARCHIVE}, /* NOTE: We can't easily extend CS_WARMUP as SV_MapRestart_f() directly sets it */ {&cg_warmupReady, "g_warmupReady", "", CVAR_SYSTEMINFO}, @@ -753,6 +755,8 @@ static void CG_RegisterSounds(void) { cgs.media.landSound = trap_S_RegisterSound("sound/padplayer/land", qfalse); cgs.media.hitSound = trap_S_RegisterSound("sound/feedback/hit", qfalse); + cgs.media.hitShieldSound = trap_S_RegisterSound("sound/feedback/hit_shield", qfalse ); + cgs.media.hitNoShieldSound = trap_S_RegisterSound("sound/feedback/hit_noshield", qfalse ); cgs.media.excellentSound = trap_S_RegisterSound("sound/feedback/awards/excellent", qtrue); cgs.media.snackattackSound = trap_S_RegisterSound("sound/feedback/awards/snackattack", qtrue); diff --git a/code/cgame/cg_playerstate.c b/code/cgame/cg_playerstate.c index 16f14cb35..86011c3ec 100644 --- a/code/cgame/cg_playerstate.c +++ b/code/cgame/cg_playerstate.c @@ -256,6 +256,8 @@ CG_CheckLocalSounds ================== */ static void CG_CheckLocalSounds(playerState_t *ps, playerState_t *ops) { + int health, armor; + int advHitSound; qboolean reward = qfalse; // don't play the sounds if the player just changed teams @@ -265,7 +267,16 @@ static void CG_CheckLocalSounds(playerState_t *ps, playerState_t *ops) { // hit changes if (ps->persistant[PERS_HITS] > ops->persistant[PERS_HITS]) { - trap_S_StartLocalSound(cgs.media.hitSound, CHAN_LOCAL_SOUND); + armor = ps->persistant[PERS_ATTACKEE_ARMOR] & 0xff; + health = ps->persistant[PERS_ATTACKEE_ARMOR] >> 8; + advHitSound = cg_advHitSound.integer; + if (armor > 50 && advHitSound) { + trap_S_StartLocalSound(cgs.media.hitShieldSound, CHAN_LOCAL_SOUND); + } else if (!armor && advHitSound) { + trap_S_StartLocalSound(cgs.media.hitNoShieldSound, CHAN_LOCAL_SOUND); + } else { + trap_S_StartLocalSound(cgs.media.hitSound, CHAN_LOCAL_SOUND); + } } else if (ps->persistant[PERS_HITS] < ops->persistant[PERS_HITS]) { trap_S_StartLocalSound(cgs.media.hitTeamSound, CHAN_LOCAL_SOUND); } diff --git a/code/game/bg_public.h b/code/game/bg_public.h index fb81a9483..c7cc69a50 100644 --- a/code/game/bg_public.h +++ b/code/game/bg_public.h @@ -291,6 +291,7 @@ typedef enum { PERS_SPAWN_COUNT, // incremented every respawn PERS_PLAYEREVENTS, // 16 bits that can be flipped for events PERS_ATTACKER, // clientnum of last damage inflicter + PERS_ATTACKEE_ARMOR, // health/armor of last person we attacked PERS_KILLED, // count of the number of times you died // player awards tracking PERS_EXCELLENT_COUNT, // two successive kills in a short amount of time diff --git a/code/game/g_combat.c b/code/game/g_combat.c index 2a677cae6..84053e7f3 100644 --- a/code/game/g_combat.c +++ b/code/game/g_combat.c @@ -882,6 +882,7 @@ void G_Damage(gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, vec3_t } else { attacker->client->ps.persistant[PERS_HITS]++; } + attacker->client->ps.persistant[PERS_ATTACKEE_ARMOR] = (targ->health << 8) | (client->ps.stats[STAT_ARMOR]); } // always give half damage if hurting self diff --git a/code/ui/ui_preferences.c b/code/ui/ui_preferences.c index a5b27282b..7abc121c7 100644 --- a/code/ui/ui_preferences.c +++ b/code/ui/ui_preferences.c @@ -78,6 +78,7 @@ PREFERENCES MENU #define ID_SYNCEVERYFRAME 38 #define ID_FORCEMODEL 39 #define ID_GLOWMODEL 40 +#define ID_HITSOUND 41 #define ID_CONNOTIFY 50 #define ID_CHATHEIGHT 51 @@ -135,6 +136,7 @@ typedef struct { menuradiobutton_s synceveryframe; menuradiobutton_s forcemodel; menulist_s glowmodel; + menuradiobutton_s hitsound; menulist_s connotify; menulist_s chatheight; @@ -193,6 +195,7 @@ static menucommon_s *g_game_options[] = { (menucommon_s *)&s_preferences.synceveryframe, (menucommon_s *)&s_preferences.forcemodel, (menucommon_s *)&s_preferences.glowmodel, + (menucommon_s *)&s_preferences.hitsound, NULL }; @@ -278,12 +281,12 @@ static void UI_Preferences_SetMenuItems(void) { s_preferences.ingamevideo.curvalue = trap_Cvar_VariableValue("r_inGameVideo") != 0; s_preferences.synceveryframe.curvalue = trap_Cvar_VariableValue("r_finish") != 0; s_preferences.forcemodel.curvalue = (trap_Cvar_VariableValue("cg_forcemodel") != 0); - if (!Q_stricmp(UI_Cvar_VariableString("cg_glowModel"), "")) { s_preferences.glowmodel.curvalue = 0; } else { s_preferences.glowmodel.curvalue = (trap_Cvar_VariableValue("cg_glowModel") + 1); } + s_preferences.hitsound.curvalue = (trap_Cvar_VariableValue("cg_advHitSound") != 0); notify = UI_GetCvarInt("con_notifytime"); if (notify < 0) { @@ -533,6 +536,10 @@ static void UI_Preferences_Event(void *ptr, int notification) { UI_Preferences_UpdateMenuItems(); break; + case ID_HITSOUND: + trap_Cvar_SetValue("cg_advHitSound", s_preferences.hitsound.curvalue); + break; + case ID_CONNOTIFY: switch (s_preferences.connotify.curvalue) { case 0: @@ -928,6 +935,18 @@ static void UI_Preferences_MenuInit(void) { "to that weapon when 'better', only auto-switch to that weapon when 'new and better'. Default is " "'new and better'."; + y += (BIGCHAR_HEIGHT + 2); + s_preferences.hitsound.generic.type = MTYPE_RADIOBUTTON; + s_preferences.hitsound.generic.name = "Advanced Hit Sound:"; + s_preferences.hitsound.generic.flags = QMF_SMALLFONT | QMF_HIDDEN; + s_preferences.hitsound.generic.callback = UI_Preferences_Event; + s_preferences.hitsound.generic.id = ID_HITSOUND; + s_preferences.hitsound.generic.x = XPOSITION; + s_preferences.hitsound.generic.y = y; + s_preferences.hitsound.generic.toolTip = + "Enable to play an alternate set of hit sounds indicating your opponent's shield status. " + "Default is off."; + y += (BIGCHAR_HEIGHT + 2); s_preferences.simpleitems.generic.type = MTYPE_RADIOBUTTON; s_preferences.simpleitems.generic.name = "Simple Items:"; @@ -1303,6 +1322,7 @@ static void UI_Preferences_MenuInit(void) { Menu_AddItem(&s_preferences.menu, &s_preferences.ups); Menu_AddItem(&s_preferences.menu, &s_preferences.autoswitch); + Menu_AddItem(&s_preferences.menu, &s_preferences.hitsound); Menu_AddItem(&s_preferences.menu, &s_preferences.simpleitems); Menu_AddItem(&s_preferences.menu, &s_preferences.wallmarks); Menu_AddItem(&s_preferences.menu, &s_preferences.dynamiclights); diff --git a/wop/sound.pk3dir/sound/feedback/hit_team.wav b/wop/sound.pk3dir/sound/feedback/hit_noshield.wav similarity index 100% rename from wop/sound.pk3dir/sound/feedback/hit_team.wav rename to wop/sound.pk3dir/sound/feedback/hit_noshield.wav diff --git a/wop/sound.pk3dir/sound/feedback/hit_shield.wav b/wop/sound.pk3dir/sound/feedback/hit_shield.wav new file mode 100644 index 000000000..4158b74c9 --- /dev/null +++ b/wop/sound.pk3dir/sound/feedback/hit_shield.wav @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:dc1075fbaa19317d91e697473335b7ae0a914ec59a3d55f53c52fd36ca9eb326 +size 10582 diff --git a/wop/sound.pk3dir/sound/feedback/hit_team.ogg b/wop/sound.pk3dir/sound/feedback/hit_team.ogg new file mode 100644 index 000000000..31c63fb11 --- /dev/null +++ b/wop/sound.pk3dir/sound/feedback/hit_team.ogg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:29def59d3b2dfe5f36e8f136b66be5b70523a1e7a29fab2a0c27e6dc762503d7 +size 5232