Frictional Games Forum (read-only)
The trick with the 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 (https://www.frictionalgames.com/forum/forum-35.html)
+--- Thread: The trick with the sound (/thread-4457.html)

Pages: 1 2


The trick with the sound - Dismortal - 09-17-2010

Hello.

First, i must say sorry if my englisch is awful. I´ve never write scripts and now I really need help. I had read the threads with questions about sounds and scripting and tried some. Nothing works. I had read the original scripts from the game to get an idea to script. It dont work.

What dont work? I´ve tried to play a simple sound when I use a looked door.
After spending hours in trying I get discouraged. Undecided

Can someone help and explane me the "magic" of scripting?
Befor I forget. I dont have the problem to write a understandable script for the game. The script just dont do what I want.

Thanks for your patience und help.


RE: The trick with the sound - jens - 09-17-2010

Hard to give any advice without you showing what you have done. Post the script with the part for the door and that is a starting point.


RE: The trick with the sound - Dismortal - 09-17-2010

Quote:void PlaySoundAtEntity
{
PlaySoundAtEntity("ScriptArea_1", "21_screams.snt", "Player", 1, false);
}

This is all what i have. I know I need more than that.


RE: The trick with the sound - jens - 09-17-2010

I think best is to look through http://hpl2.frictionalgames.com/tutorials:amnesia_script:tutorial_1

Short version: You need to select the door in the level editor and in the Entity tab, under PlayerInteractCallback type InteractingWithDoor

Then you have to have a proper default script file to begin with (there is one in the tutorial).

Open your you default script file and anywhere that is NOT in OnStart, OnEnter or OnLeave write the function for that callback you just type into the editor. Like this:

Code:
void InteractingWithDoor(string &in asEntity)
{
    PlaySoundAtEntity("ScriptArea_1", "21_screams.snt", "Player", 1, false);

    AddDebugMessage("Playing Sound!", false);
}

Also make sure that you really have that ScriptArea_1 in the level. If you do not see the debug message or hear the sound, the function was not triggered at all.


RE: The trick with the sound - Dismortal - 09-17-2010

Wow, it works Smile
Thank you Jens. Now I know my problem. It was the association between the script and the callback function in the level editor.

I will read the tutorial to improve my knowledge about scripting.
After I know that, I feel like a fool. Blush
Thanks again.


RE: The trick with the sound - Cgturner - 09-17-2010

Jens, I used this:
Code:
void InteractingWithDoor(string &in asEntity)
{
    PlaySoundAtEntity("doorinteract", "21_screams.snt", "key_1", 1, false);
}
The sound plays perfectly, and forgive me if I just missed it, but how would you make it so the sound only plays once, and not every time you interact with the door?


RE: The trick with the sound - jens - 09-17-2010

You check the box that is below the PlayerINteractCallback in the level editor. I think the name is PlayerInteractCallbackAutoRemove.


RE: The trick with the sound - Cgturner - 09-17-2010

(09-17-2010, 04:24 PM)jens Wrote: You check the box that is below the PlayerINteractCallback in the level editor. I think the name is PlayerInteractCallbackAutoRemove.
Why yes it is! I knew I missed something. Thank you for the swift and helpful response.


RE: The trick with the sound - Requiem - 09-19-2010

Hi

I want to play a sound when the player go across an area, but I have to admit, my script doesn't work : / xD it look like :

void CollidePlayerWithAreaCreep()
{
PlaySoundAtEntity("Creep", "scare_animal_squeal.snt", "Player", 1, false);
}

Who can help me ?? ^^

Thx =p


RE: The trick with the sound - Pandemoneus - 09-19-2010

void CollidePlayerWithAreaCreep(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("Creep", "scare_animal_squeal.snt", "Player", 1, false);
}

Here you go!