Added use of special music when Kline or the cloak fighter shows up.

This commit is contained in:
Layla Marchant 2021-04-03 12:13:44 -04:00
parent a9e98145fa
commit 82ffaebbc5
No known key found for this signature in database
GPG Key ID: 52FB5C20A8336782
5 changed files with 31 additions and 4 deletions

Binary file not shown.

View File

@ -26,6 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#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,6 +234,14 @@ void audio_playRandomTrack()
#ifndef OLD_MUSIC
case MISN_START:
case MISN_INTERCEPTION:
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:

View File

@ -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();

View File

@ -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)

View File

@ -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();