diff --git a/src/dehacked.c b/src/dehacked.c index 32b01a652..53bd3dc03 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -1172,6 +1172,15 @@ static void readlevelheader(MYFILE *f, INT32 num) else if (fastcmp(word, "MUSICINTER")) deh_strlcpy(mapheaderinfo[num-1]->musintername, word2, sizeof(mapheaderinfo[num-1]->musintername), va("Level header %d: intermission music", num)); + 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, "MUSICPOSTBOSSTRACK")) + mapheaderinfo[num-1]->muspostbosstrack = ((UINT16)i - 1); + else if (fastcmp(word, "MUSICPOSTBOSSPOS")) + mapheaderinfo[num-1]->muspostbosspos = (UINT32)get_number(word2); + else if (fastcmp(word, "MUSICPOSTBOSSFADEIN")) + mapheaderinfo[num-1]->muspostbossfadein = (UINT32)get_number(word2); else if (fastcmp(word, "FORCECHARACTER")) { strlcpy(mapheaderinfo[num-1]->forcecharacter, word2, SKINNAMESIZE+1); diff --git a/src/doomstat.h b/src/doomstat.h index 18300967c..b6c376d1c 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -327,6 +327,11 @@ typedef struct // Music stuff. UINT32 musinterfadeout; ///< Fade out level music on intermission screen in milliseconds char musintername[7]; ///< Intermission screen music. + + char muspostbossname[7]; ///< Post-bossdeath music. + UINT16 muspostbosstrack; ///< Post-bossdeath track. + UINT32 muspostbosspos; ///< Post-bossdeath position + UINT32 muspostbossfadein; ///< Post-bossdeath fade-in milliseconds. // Lua stuff. // (This is not ifdeffed so the map header structure can stay identical, just in case.) diff --git a/src/lua_maplib.c b/src/lua_maplib.c index 82843db4e..74b259921 100644 --- a/src/lua_maplib.c +++ b/src/lua_maplib.c @@ -2009,6 +2009,14 @@ static int mapheaderinfo_get(lua_State *L) lua_pushinteger(L, header->musinterfadeout); else if (fastcmp(field,"musintername")) lua_pushstring(L, header->musintername); + else if (fastcmp(field,"muspostbossname")) + lua_pushstring(L, header->muspostbossname); + else if (fastcmp(field,"muspostbosstrack")) + lua_pushinteger(L, header->muspostbosstrack); + else if (fastcmp(field,"muspostbosspos")) + lua_pushinteger(L, header->muspostbosspos); + else if (fastcmp(field,"muspostbossfadein")) + lua_pushinteger(L, header->muspostbossfadein); 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 782323226..3e7431e40 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -3812,6 +3812,24 @@ void A_BossDeath(mobj_t *mo) EV_DoElevator(&junk, elevateUp, false); junk.tag = LE_CAPSULE2; EV_DoElevator(&junk, elevateHighest, false); + + if (mapheaderinfo[gamemap-1]->muspostbossname[0] && + S_MusicExists(mapheaderinfo[gamemap-1]->muspostbossname, !midi_disabled, !digital_disabled)) + { + // Touching the egg trap button calls P_DoPlayerExit, which calls P_RestoreMusic. + // So just park ourselves in the mapmus variables. + boolean changed = strnicmp(mapheaderinfo[gamemap-1]->musname, mapmusname, 7); + strncpy(mapmusname, mapheaderinfo[gamemap-1]->muspostbossname, 7); + mapmusname[6] = 0; + mapmusflags = (mapheaderinfo[gamemap-1]->muspostbosstrack & MUSIC_TRACKMASK) | MUSIC_RELOADRESET; + mapmusposition = mapheaderinfo[gamemap-1]->muspostbosspos; + + // don't change if we're in another tune + // but in case we're in jingle, use our parked mapmus variables so the correct track restores + if (!changed) + S_ChangeMusicEx(mapmusname, mapmusflags, true, mapmusposition, (1*MUSICRATE)+(MUSICRATE/2), + mapheaderinfo[gamemap-1]->muspostbossfadein); + } } bossjustdie: diff --git a/src/p_setup.c b/src/p_setup.c index a089e0a8f..b7d53349b 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -217,6 +217,10 @@ static void P_ClearSingleMapHeaderInfo(INT16 i) mapheaderinfo[num]->muspos = 0; mapheaderinfo[num]->musinterfadeout = 0; mapheaderinfo[num]->musintername[0] = '\0'; + mapheaderinfo[num]->muspostbossname[6] = 0; + mapheaderinfo[num]->muspostbosstrack = 0; + mapheaderinfo[num]->muspostbosspos = 0; + mapheaderinfo[num]->muspostbossfadein = 0; mapheaderinfo[num]->forcecharacter[0] = '\0'; mapheaderinfo[num]->weather = 0; mapheaderinfo[num]->skynum = 1;