Frictional Games Forum (read-only)

Full Version: Making a scream play when player enters a room?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4
Add this to the start of your code, before everything:

Code:
void OnEnter()
{
}

void OnLeave()
{
}

Pretty sure you need those for them to run.
Ok, so now I have this

Code:
void OnEnter()
{
}

void OnLeave()
{
}

void OnStart()
{
AddEntityCollideCallback("Player", "Scream_1", "Scream", true, 1);
}
void Scream_1(string &in asParent, string &in asChild, int alStates)
{
   AddTimer("Somenamedoesntreallymatter", 2.0f, "Scream_Trigger");
}

void Scream_Trigger(string &in asTimer)
{
   PlaySoundAtEntity("Scream_1", "04_scream.snt", "Scream_1", 0, false);
   StartPlayerLookAt("LookArea_1", 1, 1, "");
   AddTimer("Somenamedoesntreallymatter", 2.0f, "LookArea_Trigger");
}
void LookArea_Trigger(string &in asParent, string &in asChild, int alStates)
{
   StopPlayerLookAt();
}

And yet still nothing happens. This scripting is like Greek to me :/
Sorry, I made another booboo. D:

Put the Scream and Scream_1 back the way they were in the collide. That's the thing bout programming, one single, tiny thing can screw up everything! Big Grin

Edit: Oh wait, I just realized. Make them both Scream_1. Your area is also called Scream_1. D:

Basically you had a function to an area that didn't exist, lol.
lol, perfect! It worked!! Thank you so much! My very first script ^_^

I'm not gonna lie, I'm still very confused as to how C++ works (This is my first day with it) but I'm glad there are helpful people to help me out!
Now that that works, is there a script on the forums that shows me how to make the player whimper/startle? Like in Amnesia, when something frightens Daniel, he'll quietly whimper.
Glad to help. :3 Just try to learn from that script as to what's being done; it'll make it much easier to script later on! If you have any questions about certain parts of the script, just ask.

Edit: Uh, just use the same sound function you used for the scream, but make the entity Player and use the whimper sound file.
Okay, so I added the react sound all by myself and it works, but I realized Daniel won't stop looking at the door!

I'm stumped as to what the problem is. I put the StopPlayerLookAt();

Code:
void OnEnter()
{
}

void OnLeave()
{
}

void OnStart()
{
AddEntityCollideCallback("Player", "Scream_1", "Scream_1", true, 1);
}
void Scream_1(string &in asParent, string &in asChild, int alStates)
{
   AddTimer("Somenamedoesntreallymatter", 6.0f, "Scream_Trigger");
}

void Scream_Trigger(string &in asTimer)
{
   PlaySoundAtEntity("Scream_1", "12_girl_scream.snt", "Scream_1", 0, false);
   PlaySoundAtEntity("Scream_1", "react_scare.snt", "Scream_1", 0, false);
   StartPlayerLookAt("LookArea_1", 2, 2, "");
   AddTimer("Somenamedoesntreallymatter", 6.0f, "LookArea_Trigger");
}
void LookArea_Trigger(string &in asParent, string &in asChild, int alStates)
{
   StopPlayerLookAt();
}
The function has the arguments for a collide, it should have the asTimer in it only.
Awesome, got it working! Yay, I can actually do a little scripting on my own, all thanks to you Big Grin

Let's say I wanted to have some breathing from the Player after the scream, and maybe start some ambient music. Same idea as the react and scream sounds?
That script language isn't C++, it's Angelscript (though it's pretty similiar to C++). Wink
Woot! Tongue

Yep same thing, except for music, it's the function PlayMusic I think, just go to the function page in the wiki and do a search for "music", you'll find it. You should go through that page actually and look at the functions, most of them are self-explanatory.
Pages: 1 2 3 4