Frictional Games Forum (read-only)

Full Version: Changing music mid level
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
The scenario; a scream is heard, the normal level music stops and goes silent, then when the player interacts with a script area a monster noise plays and different (tense) music plays, then once the tense music has finished the normal music comes back on.

Now I have already done most of this, the only bit im having trouble with is making the normal music start playing again, here is my current script:

Code:
{
AddEntityCollideCallback("Player", "ScriptArea_1", "LoudNoise", true, 1);
AddEntityCollideCallback("Player", "ScriptArea_5", "SuddenScare", true, 1);
}

void LoudNoise(string &in asParent, string &in asChild, int alState)
    
                         {
                             PlaySoundAtEntity("", "05_event_door_bang", "ScriptArea_3", 0, false);
                             StartPlayerLookAt("ScriptArea_3", 3, 1, "");
                             SetPlayerMoveSpeedMul(0);
                             SetPlayerRunSpeedMul(0);
                             SetPlayerLookSpeedMul(0);
                             AddTimer("Murder", 3, "Murder");
                             StopMusic(1, 1);
                            
                         }
                        
                     void Murder(string &in asTimer)
                        
                         {
                             PlaySoundAtEntity("", "react_scare", "Player", 0.0f, false);
                             StopPlayerLookAt();
                             SetPlayerMoveSpeedMul(1);
                             SetPlayerRunSpeedMul(1);
                             SetPlayerLookSpeedMul(1);
                            
                         }
                        
                     void SuddenScare(string &in asParent, string &in asChild, int alState)
                    
                         {
                             PlaySoundAtEntity("", "04_break", "ScriptArea_4", 0, false);
                             PlaySoundAtEntity("", "04_break02", "ScriptArea_4", 0, false);
                             StartPlayerLookAt("ScriptArea_4", 5, 5, "");
                             SetPlayerMoveSpeedMul(0);
                             SetPlayerRunSpeedMul(0);
                             SetPlayerLookSpeedMul(0);
                             AddTimer("ScarySound", 3, "ScarySound");
                            
                         }
                        
                     void ScarySound(string &in asTimer)
                    
                         {
                             PlayMusic("01_event_dust", false, 2, 4, 0, true);
                             StopPlayerLookAt();
                             SetPlayerMoveSpeedMul(1);
                             SetPlayerRunSpeedMul(1);
                             SetPlayerLookSpeedMul(1);
}

As it stands if I try to add the level music in it will start playing at the same time as the tense music, is there anyway to delay it with a timer or something?
Anyone? Im sure ive seen this done in other CS so it has to be possible.
What you use is:

Code:
void PlayMusic(string& asMusicFile, bool abLoop, float afVolume, float afFadeTime, int alPrio, bool abResume);

Plays music.asMusicFile - the music to play + extension .ogg
abLoop - determines whether a music track should loop
afVolume - volume of the music
afFadeTime - time in seconds until music reaches full volume
alPrio - priority of the music. Note that only the music with the highest priority can be heard! 0 - lowest, 1 - higher, etc.
abResume - if true, playback will be continued from where the track stopped after the call to StopMusic(); if false, the track will be restarted.


And

Code:
void StopMusic(float afFadeTime, int alPrio);

Stops music.afFadeTime - time in seconds until music stops
alPrio - the priority of the music that should stop