Frictional Games Forum (read-only)
How do i increase sanity to a player? - 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: How do i increase sanity to a player? (/thread-25481.html)



How do i increase sanity to a player? - BIgcheker12 - 06-15-2014

Question in title..
I want to do it like this:
Player touches Entity=Gets Sanity (without drinking sanity potion)
I know how to increase the Insanity, but i need to increase the sanity.


Thanks for all the answers.


RE: How do i increase sanity to a player? - Romulator - 06-15-2014

(06-15-2014, 01:43 PM)BIgcheker12 Wrote: I know how to increase the Insanity, but i need to increase the sanity.

So your saying that if the player touches an entity, they get more sane? Like the effects of the Sanity Potion? If so, quite easy! Smile

PHP Code:
void OnStart()
{
SetEntityPlayerInteractCallback("<Name_Of_Item_to_interact_with>""give_me_sanity"false);
}
//Change the Name_of_Item... to the item you're touching in the Level Editor :3, still within the ""

void give_me_sanity(string &in asEntity)
{
AddPlayerSanity(10.0f);


Change the false in the SetEntityPlayerInteractCallback to true if you only want the player to get their sanity once.
And Change the 10.0f to however much Sanity you want the player to receive.

If you want the "sanity effect" to show up (screen flashes white), instead of AddPlayerSanity, use either:

PHP Code:
GiveSanityBoost();
//OR
GiveSanityBoostSmall(); 

ALL of Amnesia's scripts can be found at the wiki at this page:
https://wiki.frictionalgames.com/doku.php?id=hpl2/amnesia/script_functions


RE: How do i increase sanity to a player? - BIgcheker12 - 06-15-2014

(06-15-2014, 01:53 PM)Romulator Wrote:
(06-15-2014, 01:43 PM)BIgcheker12 Wrote: I know how to increase the Insanity, but i need to increase the sanity.

So your saying that if the player touches an entity, they get more sane? Like the effects of the Sanity Potion? If so, quite easy! Smile

PHP Code:
void OnStart()
{
SetEntityPlayerInteractCallback("<Name_Of_Item_to_interact_with>""give_me_sanity"false);
}
//Change the Name_of_Item... to the item you're touching in the Level Editor :3, still within the ""

void give_me_sanity(string &in asEntity)
{
AddPlayerSanity(10.0f);


Change the false in the SetEntityPlayerInteractCallback to true if you only want the player to get their sanity once.
And Change the 10.0f to however much Sanity you want the player to receive.

If you want the "sanity effect" to show up (screen flashes white), instead of AddPlayerSanity, use either:

PHP Code:
GiveSanityBoost();
//OR
GiveSanityBoostSmall(); 

ALL of Amnesia's scripts can be found at the wiki at this page:
https://wiki.frictionalgames.com/doku.php?id=hpl2/amnesia/script_functions

Alright 2 more questions: 1. Whats the max sanity you can have? And 2. Can you make it work, that when you touch this item, your game will be auto-saved?

Trying to do something completely new Big Grin


RE: How do i increase sanity to a player? - DnALANGE - 06-15-2014

MAX sanity = 100 ... you will fall on the ground with the high pitch sound.
Like AddPlayerSanity(100); // will be the highest number available ( max sanity )
---
void give_me_sanity(string &in asEntity)
{
AddPlayerSanity(10.0f);
AutoSave();
}


RE: How do i increase sanity to a player? - Romulator - 06-15-2014

(06-15-2014, 02:07 PM)DnALANGE Wrote: MAX sanity = 100 ... you will fall on the ground with the high pitch sound.

Actually, other way around, when Sanity is 0, you fall on the ground :3

But yes, Maximum Sanity is 100 or 100.0f, so Crystal Clear would appear in the Inventory (>74.999999999...)


RE: How do i increase sanity to a player? - DnALANGE - 06-15-2014

Yeah Rom... still when you use AddPlayerSanity(100); that is the MAX amounth to give Tongue
We know what we mean Wink hehhe


RE: How do i increase sanity to a player? - BIgcheker12 - 06-15-2014

(06-15-2014, 02:10 PM)DnALANGE Wrote: Yeah Rom... still when you use AddPlayerSanity(100); that is the MAX amounth to give Tongue
We know what we mean Wink hehhe

Alright and what about touching an Item and then your game saves automatically?


RE: How do i increase sanity to a player? - Mudbill - 06-15-2014

DnALANGE already answered that. All you need is a simple AutoSave(); line.