From 7023ccc239a0cb9c08bf26c2f718d1d5676a819f Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 29 Nov 2019 02:55:45 -0800 Subject: [PATCH] Death fades music Cvars are respawnfademusicout and respawnfademusicback. Both measure milliseconds. --- src/d_netcmd.c | 3 +++ src/g_game.c | 17 ++++++++++++++++- src/g_game.h | 3 +++ src/p_inter.c | 15 +++++++++++++++ 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 5cca6637f..7b274d0a1 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -988,6 +988,9 @@ void D_RegisterClientCommands(void) CV_RegisterVar(&cv_invincmusicfade); CV_RegisterVar(&cv_growmusicfade); + CV_RegisterVar(&cv_respawnfademusicout); + CV_RegisterVar(&cv_respawnfademusicback); + CV_RegisterVar(&cv_resume); // ingame object placing diff --git a/src/g_game.c b/src/g_game.c index 31baf6b3d..9e4a2df63 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -533,6 +533,9 @@ consvar_t cv_deadzone4 = {"joy4_deadzone", "0.5", CV_FLOAT|CV_SAVE, deadzone_con consvar_t cv_invincmusicfade = {"invincmusicfade", "300", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_growmusicfade = {"growmusicfade", "500", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_respawnfademusicout = {"respawnfademusicout", "1000", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_respawnfademusicback = {"respawnfademusicback", "500", CV_SAVE, CV_Unsigned, NULL, 0, NULL, NULL, 0, 0, NULL}; + consvar_t cv_resume = {"resume", "Yes", CV_SAVE, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; #if MAXPLAYERS > 16 @@ -2751,7 +2754,19 @@ void G_PlayerReborn(INT32 player) } } - P_RestoreMusic(p); + if (S_MusicPlaying()) + { + P_RestoreMusic(p); + /* mid-way fading out, fade back up */ + S_FadeMusic(100, cv_respawnfademusicback.value); + } + else + { + /* this could be considered a hack, but I like it ...kinda */ + S_SetRestoreMusicFadeInCvar(&cv_respawnfademusicback); + P_RestoreMusic(p); + } + if (songcredit) S_ShowMusicCredit(); diff --git a/src/g_game.h b/src/g_game.h index c5b3e5dc3..201db19d9 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -121,6 +121,9 @@ extern consvar_t cv_ghost_besttime, cv_ghost_bestlap, cv_ghost_last, cv_ghost_gu extern consvar_t cv_invincmusicfade; extern consvar_t cv_growmusicfade; +extern consvar_t cv_respawnfademusicout; +extern consvar_t cv_respawnfademusicback; + extern consvar_t cv_resume; typedef enum diff --git a/src/p_inter.c b/src/p_inter.c index 905cf1c1f..e4331e039 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -2116,6 +2116,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) { mobjtype_t item; mobj_t *mo; + int ms; //if (inflictor && (inflictor->type == MT_SHELL || inflictor->type == MT_FIREBALL)) // P_SetTarget(&target->tracer, inflictor); @@ -2330,6 +2331,20 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source) } target->player->playerstate = PST_DEAD; + if (netgame || multiplayer) + ms = cv_respawntime.value * 1000; + else + ms = 1000; + + /* + If the time spent with the music paused is less than half + a second, continue playing the song (just mute it). + */ + if (( ms - cv_respawnfademusicout.value ) < 500) + S_FadeMusic(0, cv_respawnfademusicout.value); + else + S_FadeOutStopMusic(cv_respawnfademusicout.value); + if (target->player == &players[consoleplayer]) { // don't die in auto map,