Frictional Games Forum (read-only)
Music problem? - 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: Music problem? (/thread-8985.html)

Pages: 1 2


Music problem? - Zypherzemus - 07-06-2011

Ok, I'm trying to set up music between 4 different levels, hub level playing one track in the beginning when you first enter the map, then once you leave to another level, it stops (This part is true) Heres the problem, once I leave the first level and go back to the hub level, the music from the first level continues to play, even though I put the "StopMusic" command in the "OnLeave" section on the .hps file for that particular map. and I wouldn't know how to play a different track once you re-enter the hub level, help?


RE: Music problem? - Juby - 07-06-2011

You want to place the PlayMusic action in the OnEnter function. For the StopMusic action, make sure the priority of it is set to 1. Like this "StopMusic(4, 1);"




RE: Music problem? - Zypherzemus - 07-06-2011

(07-06-2011, 11:21 AM)Juby Wrote: You want to place the PlayMusic action in the OnEnter function. For the StopMusic action, make sure the priority of it is set to 1. Like this "StopMusic(4, 1);"

Here's the thing though, I have the hub level set up to where, when you walk into a script area, the music starts to play (When you first start the map that is). When I leave the map, the music stops, would the same thing work if I used a different track?

ex: You first start the map, you walk into a scripted area and music plays, you leave map (music stops) you re-enter the map but a different track plays right when you spawn.


RE: Music problem? - DRedshot - 07-06-2011

You may need to use a globalvar
Try greating a global.hps file (if your map doesn't already have one) and add the line:

void OnGameStart()
{
SetGlobalVarInt("name" , 0);
}

then you can create a line in your map .hps file, under void onleave(), which sets this globalvariable to 1.

Finally under void OnEnter() create a couple of if statements:
if (globalvar == 0) play "music1"
else if (globalvar == 1) play "music2"

This way will definately work, but there may be a more efficient way of doing it
Tongue


RE: Music problem? - Zypherzemus - 07-06-2011

Basic set up of an global.hps file?

//void OnGameStart()
{

}

void OnGameEnter()
{

}

void OnGameLeave()
{

}

right?


RE: Music problem? - Tanshaydar - 07-06-2011

No Game word is needed, where did you get that? It should be OnStart, OnEnter, OnLeave.


RE: Music problem? - DRedshot - 07-06-2011

he's talking about the global.hps file - as far as im aware you only need:
void OnGameStart()

I dont think the global file uses the other two


RE: Music problem? - Tanshaydar - 07-06-2011

Oh, for global.hps only an OnGameStart is needed, yes.


RE: Music problem? - Zypherzemus - 07-07-2011

(07-06-2011, 05:50 PM)DRedshot Wrote: You may need to use a globalvar
Try greating a global.hps file (if your map doesn't already have one) and add the line:

void OnGameStart()
{
SetGlobalVarInt("name" , 0);
}

then you can create a line in your map .hps file, under void onleave(), which sets this globalvariable to 1.

Finally under void OnEnter() create a couple of if statements:
if (globalvar == 0) play "music1"
else if (globalvar == 1) play "music2"

This way will definately work, but there may be a more efficient way of doing it
Tongue


one last thing, by "name" you mean?
and the line in the OnLeave would be?
and they're both on the same hps file right?
just making sure


RE: Music problem? - DRedshot - 07-07-2011

"name" can be anything you want, it is the name of your GlobalVarInt
the line OnLeave would be:
SetGlobalVarInt("name" , 1);
The code under OnEnter and the code under OnLeave are in the same .hps yes, but the code under OnGameStart is in the Global.hps

also, that code under OnEnter is simplified and would not work, it should be
Code:
if (GetGlobalInt("name") == 0)
{
PlayMusic("Music1", true , float , float , int , true);
}
else if (GetGlobalInt("name") == 0)
{
PlayMusic("Music2", true , float , float , int , true);
}