Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help Changing music mid level
serbusfish Offline
Member

Posts: 211
Threads: 75
Joined: Aug 2012
Reputation: 0
#1
Changing music mid level

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:

{
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?

02-10-2013, 05:07 PM
Find
serbusfish Offline
Member

Posts: 211
Threads: 75
Joined: Aug 2012
Reputation: 0
#2
RE: Changing music mid level

Anyone? Im sure ive seen this done in other CS so it has to be possible.

02-11-2013, 01:08 AM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#3
RE: Changing music mid level

What you use is:

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

void StopMusic(float afFadeTime, int alPrio);

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

Trying is the first step to success.
(This post was last modified: 02-11-2013, 07:51 AM by FlawlessHappiness.)
02-11-2013, 07:51 AM
Find




Users browsing this thread: 1 Guest(s)