Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Need help with scripting music to areas
scj0nes Offline
Junior Member

Posts: 1
Threads: 1
Joined: Apr 2014
Reputation: 0
#1
Information  Need help with scripting music to areas

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
04-03-2014, 02:55 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#2
RE: Need help with scripting music to areas

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/amn..._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.

(This post was last modified: 04-03-2014, 03:21 PM by Mudbill.)
04-03-2014, 03:19 PM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#3
RE: Need help with scripting music to areas

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

"Veni, vidi, vici."
"I came, I saw, I conquered."
04-03-2014, 03:22 PM
Find
Daemian Offline
Posting Freak

Posts: 1,129
Threads: 42
Joined: Dec 2012
Reputation: 49
#4
RE: Need help with scripting music to areas

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

04-03-2014, 03:36 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#5
RE: Need help with scripting music to areas

(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.

04-03-2014, 04:01 PM
Find
Wapez Offline
Senior Member

Posts: 360
Threads: 37
Joined: Mar 2012
Reputation: 19
#6
RE: Need help with scripting music to areas

(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.

Founder & Legally Accountable Publisher of Red Line Games.
Environment & Gameplay Designer and Scripter.
http://moddb.com/mods/in-lucys-eyes
04-03-2014, 06:59 PM
Find
Daemian Offline
Posting Freak

Posts: 1,129
Threads: 42
Joined: Dec 2012
Reputation: 49
#7
RE: Need help with scripting music to areas

(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.

04-03-2014, 07:41 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#8
RE: Need help with scripting music to areas

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

04-03-2014, 07:53 PM
Find
Wapez Offline
Senior Member

Posts: 360
Threads: 37
Joined: Mar 2012
Reputation: 19
#9
RE: Need help with scripting music to areas

(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.

Founder & Legally Accountable Publisher of Red Line Games.
Environment & Gameplay Designer and Scripter.
http://moddb.com/mods/in-lucys-eyes
04-03-2014, 09:02 PM
Find
Daemian Offline
Posting Freak

Posts: 1,129
Threads: 42
Joined: Dec 2012
Reputation: 49
#10
RE: Need help with scripting music to areas

(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

04-04-2014, 02:18 AM
Find




Users browsing this thread: 3 Guest(s)