From a3ed60d7bd1b36ca785df18829177e6e58e3214f Mon Sep 17 00:00:00 2001 From: mazmazz <mar.marcoz@outlook.com> Date: Sat, 25 Aug 2018 15:21:55 -0400 Subject: [PATCH] Added MUSICPOSTBOSS level header for boss post-defeat music --- src/dehacked.c | 3 +++ src/doomstat.h | 3 +++ src/lua_maplib.c | 2 ++ src/p_enemy.c | 13 ++++++++++++- src/p_setup.c | 1 + 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/dehacked.c b/src/dehacked.c index 52b1623d2..f30ec58e7 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -1151,6 +1151,9 @@ static void readlevelheader(MYFILE *f, INT32 num) #endif else if (fastcmp(word, "MUSICTRACK")) mapheaderinfo[num-1]->mustrack = ((UINT16)i - 1); + else if (fastcmp(word, "MUSICPOSTBOSS")) + deh_strlcpy(mapheaderinfo[num-1]->muspostbossname, word2, + sizeof(mapheaderinfo[num-1]->muspostbossname), va("Level header %d: post-boss music", num)); else if (fastcmp(word, "FORCECHARACTER")) { strlcpy(mapheaderinfo[num-1]->forcecharacter, word2, SKINNAMESIZE+1); diff --git a/src/doomstat.h b/src/doomstat.h index 092fce418..38be6968c 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -256,6 +256,9 @@ typedef struct UINT8 numGradedMares; ///< Internal. For grade support. nightsgrades_t *grades; ///< NiGHTS grades. Allocated dynamically for space reasons. Be careful. + // Music stuff. + char muspostbossname[7]; ///< Post-bossdeath music. + // Lua stuff. // (This is not ifdeffed so the map header structure can stay identical, just in case.) UINT8 numCustomOptions; ///< Internal. For Lua custom value support. diff --git a/src/lua_maplib.c b/src/lua_maplib.c index b929fc0bc..d4bea333e 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -1760,6 +1760,8 @@ static int mapheaderinfo_get(lua_State *L) lua_pushstring(L, header->musname); else if (fastcmp(field,"mustrack")) lua_pushinteger(L, header->mustrack); + else if (fastcmp(field,"muspostbossname")) + lua_pushstring(L, header->muspostbossname); else if (fastcmp(field,"forcecharacter")) lua_pushstring(L, header->forcecharacter); else if (fastcmp(field,"weather")) diff --git a/src/p_enemy.c b/src/p_enemy.c index 9235a1d0f..83b50a0cc 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -3529,6 +3529,17 @@ void A_BossDeath(mobj_t *mo) EV_DoElevator(&junk, elevateUp, false); junk.tag = 682; EV_DoElevator(&junk, elevateHighest, false); + + // change the music if specified + if (mapheaderinfo[gamemap-1]->muspostbossname && !strncmp(mapheaderinfo[gamemap-1]->musname, mapmusname, 7)) + { + // Touching the egg trap button calls P_DoPlayerExit, which calls P_RestoreMusic. + // So just park ourselves in the mapmus variables. + strncpy(mapmusname, mapheaderinfo[gamemap-1]->muspostbossname, 7); + mapmusname[6] = 0; + mapmusflags = MUSIC_RELOADRESET; + S_ChangeMusicAdvanced(mapmusname, mapmusflags, true, 0, (1*MUSICRATE)+(MUSICRATE/2), 0); + } } bossjustdie: @@ -11636,4 +11647,4 @@ void A_CheckFlags2(mobj_t *actor) if (actor->flags2 & locvar1) P_SetMobjState(actor, (statenum_t)locvar2); -} \ No newline at end of file +} diff --git a/src/p_setup.c b/src/p_setup.c index c62f281b3..f451401ae 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -208,6 +208,7 @@ static void P_ClearSingleMapHeaderInfo(INT16 i) snprintf(mapheaderinfo[num]->musname, 7, "%sM", G_BuildMapName(i)); mapheaderinfo[num]->musname[6] = 0; mapheaderinfo[num]->mustrack = 0; + mapheaderinfo[num]->muspostbossname[6] = 0; mapheaderinfo[num]->forcecharacter[0] = '\0'; mapheaderinfo[num]->weather = 0; mapheaderinfo[num]->skynum = 1; -- GitLab