Frictional Games Forum (read-only)
[SCRIPT] GiveSanityDamage - 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: [SCRIPT] GiveSanityDamage (/thread-14511.html)



GiveSanityDamage - kiruclanz - 04-05-2012

Yeah, I'm a bit of a noob. I'm terrible at "Experimenting" with amnesia level editor due to it having one bad line of code the entire game crashes. So I just follow tutorials exactly as they tell me lol. What I want to do is make the player reduce sanity when looking at something. (Like a dead body, etc) so could anyone tell me how? (Not just the lien of code, I mean like where to put it and stuff Tongue)

--EDIT: Also, how do I make a sound play when I look at it?



RE: GiveSanityDamage - Kreekakon - 04-05-2012

First let's start off in the level editor. Take a dead body, put it where you want, and name it "deadbody".

Then let's start from the basics in your script. Your barebone script file will look something like this:

Code:
////////////////////////////
// Run first time starting map
void OnStart()
{
}
////////////////////////////
// Run when entering map
void OnEnter()
{

}


////////////////////////////
// Run when leaving map
void OnLeave()
{
}


Then take a look at this taken from the engine scripts:
Quote:
Code:
void SetEntityPlayerLookAtCallback(string& asName, string& asCallback, bool abRemoveWhenLookedAt);

Calls a function when the player looks at a certain entity.
Callback syntax: void MyFunc(string &in asEntity, int alState)

alState: 1 = looking, -1 = not looking
asName - internal name
asCallback - function to call
abRemoveWhenLookedAt - determines whether the callback should be removed when the player looked at the entity

EDIT: I removed the previously above text, as it seemed that it wasn't correct, and I couldn't get it to work either.