Frictional Games Forum (read-only)
Playing different music in different areas - 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 (https://www.frictionalgames.com/forum/forum-35.html)
+--- Thread: Playing different music in different areas (/thread-6165.html)



Playing different music in different areas - Tony32 - 01-11-2011

Hello again, yet I've stumbled on another problem. This time I'm wondering how the music playing really works for different rooms. I've read that the built in sound in the level editor is bad for this task, so I guess I'll have to do it using scripts.

How is it supposed to work? Create one area for each room and play sounds if they are in it? How am I supposed to loop the sounds while the player is inside the area? Also, which function to play the music should I use? PlayGuiSound or PlayMusic?
Ex.
If (insideKitchen)
play sound X

If(InsideHallway)
play sound Y

Is it supposed to be like that or have I got it all wrong? x)

Thanks in advance ^^


RE: Playing different music in different areas - ModManDann - 01-11-2011

I think you'd have to create area's and add a collide call back (for the player and the area) and in this call back use the following function:

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



RE: Playing different music in different areas - Andross - 01-11-2011

I would use collision callbacks for the areas surrounding rooms.
Code:
AddEntityCollideCallback("Player", "RoomArea1", "OnCollideRoom1", false, 0);
Then, start or stop the according music.
Code:
void OnCollideRoom1(string &in parent, string &in child, int state)
{
    if (state == 1) // start
        ....
    if (state == -1) // stop
        ....
}
The functions for the music would be PlayMusic() and StopMusic(). Music sounds should loop automatically until they are stopped explicitly.


RE: Playing different music in different areas - ModManDann - 01-12-2011

music stops if another music starts to play, so there's no need to stop the music everytime. Just start a new one.


RE: Playing different music in different areas - Frontcannon - 01-12-2011

(01-12-2011, 02:00 AM)ModManDann Wrote: music stops if another music starts to play, so there's no need to stop the music everytime. Just start a new one.

Depends on alPrio.