Frictional Games Forum (read-only)
Need help with scripting music to 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 - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: Need help with scripting music to areas (/thread-24989.html)

Pages: 1 2


Need help with scripting music to areas - scj0nes - 04-03-2014

Hi all,

I am currently working on a mod in Amnesia the dark descent for a project for my dissertation. My only problem is that I need to include different music to the different rooms for my experiment at hand. Only problem is that ... i have no idea how to add it to my current script and I am really struggling trying to add it to area boxes.

This is my current code:

Run first time starting map
void OnStart()
{
AddUseItemCallback("", "key_1", "locked_door1", "UsedKeyOnDoor", true);
SetEntityCallbackFunc("key_1", "OnPickup");
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("locked_door1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "locked_door1", 0, false);
RemoveItem("key_1");
}
void OnPickup(string &in asEntity, string &in type)
{
SetEntityActive("monster_grunt", true);
ShowEnemyPlayerPosition("monster_grunt");
}


////////////////////////////
// Run when entering map
void OnEnter()
{
FadeOut(0);

FadeIn(50);
AddEntityCollideCallback("Player", "Bedroom", "Start", true, 1);
}
void start(string &in asParent, string &in asChild, int alstate)
{
PlaySoundAtEntity("", "06_amb.ogg", "Player", 0, false);
}

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

}

Any heads up would be greatly appreciated Smile Thanks


RE: Need help with scripting music to areas - Mudbill - 04-03-2014

Use a collide callback on the area, then execute the music function. All of these are found on the scripts page:
http://wiki.frictionalgames.com/hpl2/amnesia/script_functions Just ctrl/cmd-F to look them up, then read the documentation so you'll know what to input in the parameters.

AddEntityCollideCallback should be in OnStart, or possibly OnEnter depending on what you want.

PlayMusic is run inside the MyFunc function that is made using the collide callback.


RE: Need help with scripting music to areas - PutraenusAlivius - 04-03-2014

You might also want to put different priorities to different areas so the script will know which one to stop.


RE: Need help with scripting music to areas - Daemian - 04-03-2014

Or just place a sound object on every room with a different music.
Change max. range to match the room.


RE: Need help with scripting music to areas - Mudbill - 04-03-2014

(04-03-2014, 03:36 PM)Amn Wrote: Or just place a sound object on every room with a different music.
Change max. range to match the room.

Aren't sound objects just for looping, ambient sounds? Like critter sounds, for example.
I don't use them at all, so I'm not sure. I think they're bugged on OS X anyway because the file browser remains empty.


RE: Need help with scripting music to areas - Wapez - 04-03-2014

(04-03-2014, 03:36 PM)Amn Wrote: Or just place a sound object on every room with a different music.
Change max. range to match the room.

Sound objects read .snt files, not .ogg files.

Changing an integer when entering a new room, and playing specific music depending on the integers value would be the simplest way here I believe.


RE: Need help with scripting music to areas - Daemian - 04-03-2014

(04-03-2014, 04:01 PM)Mudbill Wrote:
(04-03-2014, 03:36 PM)Amn Wrote: Or just place a sound object on every room with a different music.
Change max. range to match the room.

Aren't sound objects just for looping, ambient sounds? Like critter sounds, for example.
I don't use them at all, so I'm not sure. I think they're bugged on OS X anyway because the file browser remains empty.
Yep. It's a quick and easy solution for his scenario, don't you think?

(04-03-2014, 06:59 PM)Wapez Wrote: Sound objects read .snt files, not .ogg files.
Yes, you don't like .snt? He needs it to change the range and maybe volume.


RE: Need help with scripting music to areas - Mudbill - 04-03-2014

By "looping, ambient sounds" I mean area effects. I don't get the impression that background music would work well as an area effect.


RE: Need help with scripting music to areas - Wapez - 04-03-2014

(04-03-2014, 07:41 PM)Amn Wrote: Yes, you don't like .snt? He needs it to change the range and maybe volume.

The music he's trying to play is an .ogg file, as well as the rest of the music in Amnesia.


RE: Need help with scripting music to areas - Daemian - 04-04-2014

(04-03-2014, 07:53 PM)Mudbill Wrote: By "looping, ambient sounds" I mean area effects. I don't get the impression that background music would work well as an area effect.
Oh ok. Your opinion.

(04-03-2014, 09:02 PM)Wapez Wrote: The music he's trying to play is an .ogg file, as well as the rest of the music in Amnesia.
.ogg may be called via .snt, as well as the rest of music/sounds in Amnesia.

Smile