Frictional Games Forum (read-only)
delay in scares - 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: delay in scares (/thread-14953.html)



delay in scares - lllDash - 04-20-2012

I was wondering if anybody knows how to add a tiny scare delay after an event (like a monster spawning).
It would be nice if the player freaks out only shortly after a sound made by the monster.
here is what I have so far:


----------------------------------------------------------------------------------
void OnStart()

{
AddEntityCollideCallback("Player", "ScriptArea_1", "MonsterFunction_1", true, 1);

}
void MonsterFunction_1(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("servant_grunt_1", true);
PlaySoundAtEntity("", "react_scare", "Player", 0, false);
GiveSanityDamage(5.0f, true);
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_1", 0.001, "");
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_2", 0.001, "");
}
----------------------------------------------------------------
How would you modify this? If you can give me an example that would be great! thanks. ^_^


RE: delay in scares - Datguy5 - 04-20-2012

Use timers.Nuff said


RE: delay in scares - DRedshot - 04-20-2012

This is what I do, It is probably the easiest way to do this, because you don't have to create a unique function for each react sound.

Stick this bit of code at the bottom of your .hps file
PHP Code:
// Player React Function
void React(string &in asTimer){
    
PlayGuiSound("react_"+asTimer+".snt" 1.0f);


This function can be called at any part of your script with "AddTimer("scare" , 0.5f , "React");"
"scare" can be any of the react sounds, such as "breath" "breath_slow" "sigh" etc. I'll give a complete example below:

PHP Code:
void Collide(string &in asParent string &in asChilc int alState// Player Hits area
{
   
// Scary stuff happens
   
AddTimer("scare" 0.4f "React"); // Player is scared
   
AddTimer("breath" 1.0f "React"); // Player takes a deep breath
}


// Player React Function
void React(string &in asTimer){
    
PlayGuiSound("react_"+asTimer+".snt" 1.0f);




RE: delay in scares - lllDash - 04-20-2012

Thanks DRedshot. It works great!


RE: delay in scares - lllDash - 04-24-2012

Instead of posting a new thread on this next question I thought I would just post it here:
Now I know how to delay a sound but how do I make random repeats of sounds placed in the level editor?
AND/OR
How do I get Areas to trigger sounds placed in the map editor?

The reason why I ask is I know how to get areas to trigger sounds but I dont know make the sound come from a certain direction in the map, and I know how to place sounds in the editor but they always play right when the map loads.

Thanx in advance.


RE: delay in scares - Prelauncher - 04-24-2012

There might be a way to trigger the sounds you place in the level editor, I don´t know, but there´s no need for you to do that. Instead what you do is create the area that you want to use to trigger the sound, after you´ve decided where you want the sound to come from you either create a new small area there or use the name of an entity you want the sound to come from.
Then in the script, example: PlaySoundAtEntity("", "react_scare", "Player", 0, false);
Locate the sound you want to use in the sounds folder in your Amnesia TDD folder, here you´ll find a bunch off .snt and .ogg files. The .ogg files are the sounds themselves but the .snt files are what you use in the script to trigger a sound. "react_scare" in your script is the name of a .snt file that you have told the game to play "on" the player. So when this part of the script is called the game will locate the .snt file named react_scare which will tell the game which of the .ogg files should be played, then when the game have the sound it is played on the player since that is what you´ve written in the code. Smile



RE: delay in scares - lllDash - 04-25-2012

Really? It's that simple? I've already tried that a while back and it did not work.....I think I must've made a tiny mistake because now it works. Thanks for the help. *sigh* Scripting is so hard because just one little mistake can ruin everything. I'm gonna have to be extra careful in the future and triple check the spelling of everything.

Now I just need to find out if random replay sounds are possible. Does anyone else know?


RE: delay in scares - lllDash - 04-29-2012

. . . . . Confused I guess not. (sigh) I guess I'll have to rely on loops