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
delay in scares
lllDash Offline
Member

Posts: 108
Threads: 12
Joined: Apr 2012
Reputation: 3
#1
Question  delay in scares

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. ^_^
04-20-2012, 07:04 PM
Find
Datguy5 Offline
Senior Member

Posts: 629
Threads: 25
Joined: Dec 2011
Reputation: 12
#2
RE: delay in scares

Use timers.Nuff said

04-20-2012, 07:14 PM
Find
DRedshot Offline
Senior Member

Posts: 374
Threads: 23
Joined: Jun 2011
Reputation: 11
#3
RE: delay in scares

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: (Select All)
// 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: (Select All)
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);


(This post was last modified: 04-20-2012, 07:19 PM by DRedshot.)
04-20-2012, 07:16 PM
Find
lllDash Offline
Member

Posts: 108
Threads: 12
Joined: Apr 2012
Reputation: 3
#4
RE: delay in scares

Thanks DRedshot. It works great!
04-20-2012, 08:00 PM
Find
lllDash Offline
Member

Posts: 108
Threads: 12
Joined: Apr 2012
Reputation: 3
#5
RE: delay in scares

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.
04-24-2012, 03:45 PM
Find
Prelauncher Offline
Senior Member

Posts: 451
Threads: 11
Joined: May 2011
Reputation: 13
#6
RE: delay in scares

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

Socialism (noun): A great way to run out of other people's money.
04-24-2012, 07:06 PM
Find
lllDash Offline
Member

Posts: 108
Threads: 12
Joined: Apr 2012
Reputation: 3
#7
RE: delay in scares

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?
04-25-2012, 06:56 PM
Find
lllDash Offline
Member

Posts: 108
Threads: 12
Joined: Apr 2012
Reputation: 3
#8
RE: delay in scares

. . . . . Confused I guess not. (sigh) I guess I'll have to rely on loops
(This post was last modified: 04-29-2012, 03:02 PM by lllDash.)
04-29-2012, 03:01 PM
Find




Users browsing this thread: 1 Guest(s)