Frictional Games Forum (read-only)
[SCRIPT] Music reverting upon death/map change - 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 reverting upon death/map change (/thread-24731.html)



Music reverting upon death/map change - Damascus - 03-01-2014

I'm currently working on a scene where the player enters a room that spawns a monster. At the moment he enters, suspenseful music starts playing. When he is killed by the monster, the music changes to a sad piece, and is meant to play throughout the death hint, and keep playing as he changes maps and respawns in a previous map. However, for some reason, the sad music abruptly reverts to a previous ambient as soon as the map starts changing.

Before the scene, the music playing is this one:

PlayMusic("ACD_03_amb", true, 0.5f, 5, 0, true);

When the player enters the room where the monster is activated, I set a check point, and play some event music:

PHP Code:
void EnterMaster(string &in asParentstring &in asChildint alState)
{
    
CheckPoint ("third""PlayerStartArea_1""reset3""""");
    
PlayMusic("music_reactor_pre_kyrie.ogg"false0.7f010false);
}

void reset3(string &in asNameint alCount)
{
    
ChangeMap("chateau1.map""PlayerStartArea_1""""");


I have a timer checking the player's HP, and when it drops below 1, I use the following script:

PHP Code:
void BellMusic(string &in asTimer)
{
    
PlayMusic("music_reactor_children_temp.ogg"false0.7f10false);


Now, when the player dies and the death hint plays, the "music_reactor_children_temp.ogg" music is still playing. But when the death hint fades away and the map starts changing, the music abruptly changes back to "ACD_03_amb." There is nothing under OnLeave for this map or OnStart/OnEnter for the map it's changing to, so I don't know what's causing the music to suddenly end. Can anyone help me with this?


RE: Music reverting upon death/map change - Neelke - 03-01-2014

Try putting StopMusic(0.0f, 0) in the timer. It might make the script understand to not use the ACD_03_amb music again. At least until you enter this map again.


RE: Music reverting upon death/map change - Damascus - 03-02-2014

Didn't work. I even tried stopping both 0 and 10 priority to make sure nothing should be scripted to play except the "music_reactor_children_temp.ogg" music, but as soon as the map loading screen comes up it immediately switches back to "ACD_03_amb."


RE: Music reverting upon death/map change - PutraenusAlivius - 03-02-2014

One idea to do this is to assign different priorities to it. Stop the music that has the lowest priority. This should let your earlier music to stop, and newest to begin.


RE: Music reverting upon death/map change - Damascus - 03-03-2014

Update: The only thing I got to work was by stopping ACD_03_amb in the PREVIOUS map, in which case the music plays through the death as intended. But if I stop it IN the map where the death occurs, the music will revert. Of course, that solution doesn't work for me, as I have to play with no ambient music for the entire map.


RE: Music reverting upon death/map change - Mudbill - 03-03-2014

Your ACD and temp music lines both use '0' as the priority. This could perhaps cause problems.
Also, did you try playing the temp music within the reset3 block, which is ran when you respawn?