Frictional Games Forum (read-only)
How to input sound? - 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: How to input sound? (/thread-8855.html)

Pages: 1 2


How to input sound? - fuytko - 06-28-2011

Hello,

I want to know how to input sound in Level Editor ..
I want this : If someone catch any entity,it will play a sound.

Please can someone explain this in detail?

I am beginner in scripting and making maps..

I'm from Slovakia,so sorry for bad english.

Thanks for help !


RE: How to input sound? - Tanshaydar - 06-28-2011

You can use entity interact callback, which runs when player interacts with an entity.
For interact call back, you can play a sound.

SetEntityPlayerInteractCallback(string& asName, string& asCallback, bool abRemoveOnInteraction);
-> to this:
SetEntityPlayerInteractCallback("entity name", "Function", true);
if you want sound to play every time you interact with the object, then this:
SetEntityPlayerInteractCallback("entity name", "Function", false);

then you need to write a function:

void Function(string &in entity)
{
PlaySoundAtEntity("sound name", "sound you want to play with .snt extension", "entity you interacted", 0, false);
}


RE: How to input sound? - fuytko - 06-28-2011

I wrote this in my .HPS file

SetEntityPlayerInteractCallback(string& asName, string& asCallback, bool abRemoveOnInteraction);
SetEntityPlayerInteractCallback("human_skull_1", "Function", true);

void Function(string &in entity)
{
PlaySoundAtEntity("scare_walk_ghost", "scare_walk_ghost.snt", "human_skull_1", 0, false);

I don't know what i have to write in "Function"


RE: How to input sound? - Tanshaydar - 06-28-2011

You should have OnStart function on your file, like this:
Code:
void OnStart()
{
SetEntityPlayerInteractCallback("human_skull_1", "Function", true);
}

void Function(string &in entity)
{
PlaySoundAtEntity("scare_walk_ghost", "scare_walk_ghost.snt", "human_skull_1", 0, false);
}

Well, I think this should work.


RE: How to input sound? - fuytko - 06-28-2011

It doesn't work Sad

I have this in my .HPS file from map

void PickLetter(string &in asEntity, string &in asType)
{
PlayMusic("Letter_01", false, 0.7f, 0, 10, false);
}
void EntryRoom(string &in asTimer) {
SetMessage("Inventory","LucasMysteryEnterRoom",0);
}
void OnStart()
{
AddTimer("startlv",5,"EntryRoom");
PlayMusic("10_amb.ogg", true, 80, 1, 0, false);
AddUseItemCallback("", "Key_Marnica_01", "castle_3", "UsedKeyOnDoor", true);
}

{
SetEntityPlayerInteractCallback("human_skull_1", "OnPickup", true);
}

void Function(string &in entity)
{
PlaySoundAtEntity("scare_walk_ghost", "scare_walk_ghost.snt", "human_skull_1", 0, false);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("castle_3", false, true);
PlaySoundAtEntity("", "unlock_door", "castle_3", 0, false);
RemoveItem("Key_Marnica_01");
}


RE: How to input sound? - Tanshaydar - 06-28-2011

Well, tell me if this works

Code:
void OnStart()
{
    AddTimer("startlv",5,"EntryRoom");
    PlayMusic("10_amb.ogg", true, 80, 1, 0, false);
    AddUseItemCallback("", "Key_Marnica_01", "castle_3", "UsedKeyOnDoor", true);
    SetEntityPlayerInteractCallback("human_skull_1", "OnPickup", true);
}

void Function(string &in entity)
{
    PlaySoundAtEntity("scare_walk_ghost", "scare_walk_ghost.snt", "human_skull_1", 0, false);
}
void PickLetter(string &in entity)
{
    PlayMusic("Letter_01", false, 0.7f, 0, 10, false);
}

void EntryRoom(string &in asTimer)
{
    SetMessage("Inventory","LucasMysteryEnterRoom",0);
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
    SetSwingDoorLocked("castle_3", false, true);
    PlaySoundAtEntity("", "unlock_door", "castle_3", 0, false);
    RemoveItem("Key_Marnica_01");
}



RE: How to input sound? - fuytko - 06-28-2011

It still doesn't work

I don't know where I'm doing mistake

Do I have to do something in Level Editor ??


RE: How to input sound? - Tanshaydar - 06-28-2011

Well, none of us born with knowledge of scripting or modding.
What doesn't work? Map loads but what you want to do doesn't work? Or map doesn't load at all?


RE: How to input sound? - fuytko - 06-28-2011

Yeah,i know..

Map loads,but If I catch the human_skull_1,it doesn't play a sound (scare_walk_ghost)




RE: How to input sound? - Tanshaydar - 06-28-2011

Oh, I'm so sorry, I made a mistake...

Code:
void OnStart()
{
     AddTimer("startlv",5,"EntryRoom");
     PlayMusic("10_amb.ogg", true, 80, 1, 0, false);
     AddUseItemCallback("", "Key_Marnica_01", "castle_3", "UsedKeyOnDoor", true);
     SetEntityPlayerInteractCallback("human_skull_1", "OnPickup", true);
}

void OnPickup(string &in entity)
{
     PlaySoundAtEntity("scare_walk_ghost", "scare_walk_ghost.snt", "human_skull_1", 0, false);
}
void PickLetter(string &in entity)
{
     PlayMusic("Letter_01", false, 0.7f, 0, 10, false);
}

void EntryRoom(string &in asTimer)
{
     SetMessage("Inventory","LucasMysteryEnterRoom",0);
}
void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
     SetSwingDoorLocked("castle_3", false, true);
     PlaySoundAtEntity("", "unlock_door", "castle_3", 0, false);
     RemoveItem("Key_Marnica_01");
}

Sorry, I'm a bit sleepy at the moment but I think this time it will work Smile