Frictional Games Forum (read-only)
[SCRIPT] Music Replaying In Different Levels? - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: [SCRIPT] Music Replaying In Different Levels? (/thread-29799.html)



Music Replaying In Different Levels? - dailycreepypasta - 04-05-2015

I've been recently trying to test out my custom story, and I have music in one certain level that plays just fine in the level that I put it in, but when I try going to different maps, the music continues playing in that level. I don't know if it's my computer or not, but I don't want that happening when I release it, Pleas help?


RE: Music Replaying In Different Levels? - Daemian - 04-05-2015

In every level's script add this function:

PHP Code:
void OnEnter()
{
    
StopMusic1);
    
StopMusic1);
    
StopMusic1);
    
    
StopPlayerLookAt();
    
ChangePlayerStateToNormal();
    


The first three lines stops the music of priority 0,1 and 2.
StopPlayerLookAt() stops the camera in case the previous level called a StartPlayerLookAt() and couldn't end it.
Then, ChangePlayerStateToNormal(); resets some stats, but I don't remember why I put this here, but it stops strange behavior brought from the previous level.


RE: Music Replaying In Different Levels? - FlawlessHappiness - 04-05-2015

...That depends on if you want to stop certain things.

At least, StopMusic stops the music in OnEnter.
If you don't want it to stop in a certain level just remove StopMusic.


RE: Music Replaying In Different Levels? - Darkfire - 04-05-2015

Why do it like this ?
I always do this:
Code:
OnEnter
{
StartMusic(yaddda yadda, 1) <---priority of music is important
}

OnLeave
{
StopMusic(yadda yadda, 1)
}



RE: Music Replaying In Different Levels? - FlawlessHappiness - 04-05-2015

That's also a way.
There's no real way to do it.
As long as you understand StopMusic stops the music, you can decide on your own wherever you want it.