Frictional Games Forum (read-only)
Making a scream play when player enters a room? - 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: Making a scream play when player enters a room? (/thread-6998.html)

Pages: 1 2 3 4


RE: Making a scream play when player enters a room? - MrBigzy - 03-23-2011

Whoops, it's supposed to be StartPlayerLookAt, not the other way around.


Also, You'll need to add a timer, and then a StopPlayerLookAt(); to stop him from looking, or else he'll look at it forever.


RE: Making a scream play when player enters a room? - Austums - 03-23-2011

So does this all look good then?

Code:
void OnStart()
{
AddEntityCollideCallback("Player", "Scream", "Scream_1", 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, "");
   StopPlayerLookAt();
}
void LookArea_1(string &in as Parent, string &in as Child, int alStates)
{
   AddTimer("Somenamedoesntreallymatter", 2.0f, "LookArea_Trigger");
}

Just got a new error.

"main (16,31) : ERR: Expected ')' or ','


RE: Making a scream play when player enters a room? - MrBigzy - 03-23-2011

as Parent and as Child are one word. And you should add the timer into the Scream_Trigger function, then put the stoplook into that function. If you put the start and stoplook in the same function without a timer, he'll start looking, and then stop a millisecond later, so basically nothing will happen. I'd do a 2 second timer to the stoplook, or whatever suits you.


RE: Making a scream play when player enters a room? - Austums - 03-23-2011

So liek this?

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

void Scream_Trigger(string &in asTimer)
{
   PlaySoundAtEntity("Scream_1", "04_scream.snt", "Scream_1", 0, false);
   StartPlayerLookAt("LookArea_1", 1, 1, "");
}



RE: Making a scream play when player enters a room? - MrBigzy - 03-23-2011

Nono, keep the timer you had before in Scream_1, put another one in Scream_Trigger, call another function with it, Scream_Trigger. Put the StopPlayerLookAt function in there. So basically, Scream_1 triggers a timer, after 2 seconds the sound plays, you look at the door, and another timer is called, then 2 seconds or more later, the player stops looking at the door.

Code:
void OnStart()
{
AddEntityCollideCallback("Player", "Scream", "Scream_1", 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();
}

It's all a consecutive thing, this way the timers just from function to function.


RE: Making a scream play when player enters a room? - Austums - 03-23-2011

Okay, I think I get it. I put the script you just did in my .hps but when I go into the room where the scream and look is supposed to happen, nothing happens. Am I supposed to edit the Area Scripts in the Level Editor or just name them? I can post my level for you if you think that would help


RE: Making a scream play when player enters a room? - MrBigzy - 03-23-2011

You just have to make sure the script areas are named Scream_1 and LookArea_1, and that Scream_1 is in a position that you'll run into it. If you post the map I'll look at it.


RE: Making a scream play when player enters a room? - Austums - 03-23-2011

Everything is named correctly... Hmmm Huh

Anyways, here's the .map


RE: Making a scream play when player enters a room? - MrBigzy - 03-23-2011

Just realized, change entity collide to this: AddEntityCollideCallback("Player", "Scream_1", "Scream", true, 1);

The function and the script area were switched. Confused

Also, you should probably make the scream area go to the ground, just in case.


RE: Making a scream play when player enters a room? - Austums - 03-23-2011

Changed it so the script is this

Code:
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();
}

But it still does nothing when I walk through the door and wait. Confused