diff --git a/music/sources/last_cyber_dance.mmpz b/music/sources/last_cyber_dance.mmpz new file mode 100644 index 0000000..4dce650 Binary files /dev/null and b/music/sources/last_cyber_dance.mmpz differ diff --git a/src/audio.c b/src/audio.c index 8109f00..9f5173d 100644 --- a/src/audio.c +++ b/src/audio.c @@ -26,6 +26,7 @@ along with this program. If not, see . #include "defs.h" #include "structs.h" +#include "alien.h" #include "game.h" #include "engine.h" #include "screen.h" @@ -170,6 +171,14 @@ void audio_setMusicVolume(int volume) #endif } +void audio_setMusicPosition(double position) +{ +#ifndef NOSOUND + if (engine.useMusic && engine.useAudio) + Mix_SetMusicPosition(position); +#endif +} + void audio_playMusic(const char *filename, int loops, int amplified) { #ifndef NOSOUND @@ -225,7 +234,15 @@ void audio_playRandomTrack() #ifndef OLD_MUSIC case MISN_START: case MISN_INTERCEPTION: - audio_playMusic("music/railjet_short.ogg", -1, 0); + if ((aliens[ALIEN_KLINE].classDef == CD_KLINE) + && aliens[ALIEN_KLINE].active) + audio_playMusic("music/last_cyber_dance.ogg", -1, 0); + else if ((game.system == SYSTEM_MORDOR) + && (aliens[ALIEN_BOSS].classDef == CD_CLOAKFIGHTER) + && aliens[ALIEN_BOSS].active) + audio_playMusic("music/space_dimensions.ogg", -1, 0); + else + audio_playMusic("music/railjet_short.ogg", -1, 0); break; case MISN_HAIL: case MISN_JOLDAR: diff --git a/src/audio.h b/src/audio.h index a1c2df5..84c227a 100644 --- a/src/audio.h +++ b/src/audio.h @@ -29,6 +29,7 @@ void audio_haltMusic(); void audio_pauseMusic(); void audio_resumeMusic(); void audio_setMusicVolume(int volume); +void audio_setMusicPosition(double position); void audio_playMusic(const char *filename, int loops, int amplified); void audio_playRandomTrack(); void audio_free(); diff --git a/src/game.c b/src/game.c index 5291c54..ae26b04 100644 --- a/src/game.c +++ b/src/game.c @@ -2577,7 +2577,7 @@ int game_mainLoop() // Some specifics for interception missions if (game.area == MISN_INTERCEPTION) { - if ((game.system > SYSTEM_EYANANTH) && ((rand() % 5) == 0)) + if ((game.system > SYSTEM_EYANANTH) && CHANCE(1. / 5.)) { aliens[ALIEN_KLINE] = alien_defs[CD_KLINE]; aliens[ALIEN_KLINE].owner = &aliens[ALIEN_KLINE]; @@ -2590,7 +2590,7 @@ int game_mainLoop() if ((game.system == SYSTEM_MORDOR) && (game.experimentalShield > 0)) { - if ((rand() % 5) > 0) + if (CHANCE(4. / 5.)) { aliens[ALIEN_BOSS] = alien_defs[CD_CLOAKFIGHTER]; aliens[ALIEN_BOSS].owner = &aliens[ALIEN_BOSS]; @@ -2603,6 +2603,13 @@ int game_mainLoop() aliens[ALIEN_BOSS].shield = game.experimentalShield; } } + + // Note: music is started here only for interceptions. For + // regular missions, it is instead started by + // mission_showStartScreen(). This is necessary to ensure the + // proper music can be played when Kline or the cloak fighter + // are active. + audio_playRandomTrack(); } if (game.area == MISN_VENUS) diff --git a/src/mission.c b/src/mission.c index f4fc73d..b1f1f0c 100644 --- a/src/mission.c +++ b/src/mission.c @@ -1175,10 +1175,12 @@ void mission_showStartScreen() gfx_createTextObject(TS_POWER, "Power", 0, 0, FONT_WHITE); gfx_createTextObject(TS_OUTPUT, "Output", 0, 0, FONT_WHITE); gfx_createTextObject(TS_COOLER, "Cooler", 0, 0, FONT_WHITE); - audio_playRandomTrack(); if (game.area != MISN_INTERCEPTION) { + // Note: music is started here only for regular missions. For + // interceptions, it is instead started by game_mainLoop(). + audio_playRandomTrack(); renderer_update(); player_flushInput();