Frictional Games Forum (read-only)
Forcing view of the player to look at a door when it slams shut - 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: Forcing view of the player to look at a door when it slams shut (/thread-13282.html)



Forcing view of the player to look at a door when it slams shut - DrDean - 02-12-2012

Hi, I'm trying to do exactly what the thread title states. I got the door slam part down, but I'm having difficulty having the view change work. I should probably mention that I have no programming background, so this is all new to me.

Looking at the script functions list on the Wiki, it seems like this is exactly what I need:
Code:
void StartPlayerLookAt(string& asEntityName, float afSpeedMul, float afMaxSpeed, string& asAtTargetCallback);
void StopPlayerLookAt();

However, I have absolutely no idea how to plop it into my current door-slam script. Where should I put it? What variables am I changing? I'm not asking you to do my work for me, but I need a push.

This is what I currently have:

void OnStart()
{
AddEntityCollideCallback("Player", "pooarea", "func_slam", true, 1);
}


void func_slam(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("mansion_1", true, true);
PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false);
PlaySoundAtEntity("", "react_scare", "Player", 0, false); PlaySoundAtEntity("", "close_door.snt", "Player", 0, false);
GiveSanityDamage(5.0f, true);
}


Thanks in advance, guys.


RE: Forcing view of the player to look at a door when it slams shut - Darkaroth - 02-12-2012

use StartPlayerLookAt(string& asEntityName, float afSpeedMul, float afMaxSpeed, string& asAtTargetCallback);

go to [url]http://wiki.frictionalgames.com/hpl2/amnesia/script_functions#general2[/url] and search for the command it should say what to fill in where.
then put it below void func_slam. next to setswingdoorclosed ect.



RE: Forcing view of the player to look at a door when it slams shut - DrDean - 02-12-2012

I'm trying this, but it's giving me curly bracket errors.


void OnStart()
{
AddEntityCollideCallback("Player", "pooarea", "func_slam", true, 1); //Func for door slam/player look
}




void func_slam(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("mansion_1", true, true);
PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false);
PlaySoundAtEntity("", "react_scare", "Player", 0, false); PlaySoundAtEntity("", "close_door.snt", "Player", 0, false);
GiveSanityDamage(5.0f, true);
}


void StartPlayerLookAt(string& mansion_1, 1, 1, string& func_slam);
{ //Gives the error here
}
void StopPlayerLookAt();
{ //And here
}

If I'm doing this correctly, which I'm obviously not, the player's view should shift to the door (mansion_1) when they enter the script area (pooarea aka func_slam)



RE: Forcing view of the player to look at a door when it slams shut - Prelauncher - 02-12-2012

You should put the "StartPlayerLookAt" under the "func_slam" function. The computer doesn´t call that function in the script´s current state. You should also add a timer which after an aproperiate time call the function, for example; addtimer("StopLook", 3, "NoLooking");

void NoLooking(string &in as Timer)
{
StopPlayerLookAt();
}


RE: Forcing view of the player to look at a door when it slams shut - onv - 02-12-2012

Use this :


void OnStart()
{
AddEntityCollideCallback("Player", "pooarea", "func_slam", true, 1);
}

void func_slam(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("mansion_1", true, true);
PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false);
PlaySoundAtEntity("", "react_scare", "Player", 0, false);
PlaySoundAtEntity("", "close_door.snt", "Player", 0, false);

GiveSanityDamage(5.0f, true);
SetPlayerActive(false);
StartPlayerLookAt("mansion_1", 3.0f, 5.0f, "");
AddTimer("timer01", 1.5f, "StopLook");

void StopLook(string &in asTimer)
{
StopPlayerLookAt();
SetPlayerActive(true);
}


RE: Forcing view of the player to look at a door when it slams shut - DrDean - 02-12-2012

Yes! I got it. This is fun. Thanks, man.


RE: Forcing view of the player to look at a door when it slams shut - onv - 02-12-2012

Having fun scaring your friends ! Big Grin


Note: i just saw that there is an error , in the wiki script (so , in yours too)


Add ".snt" at the end of "react_scare" like so :


PlaySoundAtEntity("", "react_scare.snt", "Player", 0, false);


RE: Forcing view of the player to look at a door when it slams shut - Myselium - 02-22-2012

Doesn't work for me... Sad

EDIT: Nevermind, got it working! Big Grin