Frictional Games Forum (read-only)
Music starting/ending? - 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 starting/ending? (/thread-9180.html)



Music starting/ending? - JoeBradleyUK - 07-16-2011

How do i make music start when I play a particular map? And how do i stop it when leaving the map? I gave it a try but failed.


RE: Music starting/ending? - Tanshaydar - 07-16-2011

http://wiki.frictionalgames.com/hpl2/amnesia/script_functions

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 - highest, 1 - lower, etc
void StopMusic(float afFadeTime, int alPrio);

Stops music.

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



Place play music in OnEnter, and place stop music in OnExit


RE: Music starting/ending? - JoeBradleyUK - 07-16-2011

(07-16-2011, 07:53 PM)Tanshaydar Wrote: http://wiki.frictionalgames.com/hpl2/amnesia/script_functions

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 - highest, 1 - lower, etc
void StopMusic(float afFadeTime, int alPrio);

Stops music.

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



Place play music in OnEnter, and place stop music in OnExit

Do I need the void included?


RE: Music starting/ending? - Tanshaydar - 07-16-2011

Nope.


RE: Music starting/ending? - JoeBradleyUK - 07-16-2011

I got an error something about 'or' or something like that, here is my .hps file:

////////////////////////////
// Run when starting map
void OnStart()
{

}


void FirstDiary(string &in item, int index)
{
ReturnOpenJournal(true);
}




////////////////////////////
// Run when entering map
void OnEnter()
{
PlayMusic(04_amb.ogg, true, 0.7, 0.1, 0, true);
}

////////////////////////////
// Run when leaving map
void OnLeave()
{

}




RE: Music starting/ending? - Tanshaydar - 07-16-2011

PlayMusic("04_amb.ogg", true, 0.7, 0.1, 0, true);


RE: Music starting/ending? - JoeBradleyUK - 07-16-2011

(07-16-2011, 09:14 PM)Tanshaydar Wrote: PlayMusic("04_amb.ogg", true, 0.7, 0.1, 0, true);

Oh, thanks Big Grin