Frictional Games Forum (read-only)

Full Version: Get Sanity to drain in the dark and increase in the light?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Is there a way for sanity to act like it does in the original Amnesia storyline? Otherwise, in custom stories, it seems more like an added effect than a game mechanic. I love the idea of this game mechanic and would like to just "turn it on" instead of making fartloads of script.
Thats actually in custom stories too..
(04-11-2012, 03:34 PM)Datguy5 Wrote: [ -> ]Thats actually in custom stories too..
Maybe these effects are absent in debug mode, I dunno.
Is it possible to amplify this effect somehow?

Yeah, I'll sit in the dark, get chased by monsters, and when I check my sanity level, it's "Crystal Clear". Then again, that was only within the first few minutes of starting the level. I might have just not noticed it.

But yeah, is there a way to make the player more sensitive to it?
By any chance, did you use this function:
SetSanityDrainDisabled(true);

If so, then sanity will be disabled. Otherwise, the sanity mechanic should work completely normal in custom stories, unless you disabled it via script.

(04-11-2012, 03:42 PM)FragdaddyXXL Wrote: [ -> ]But yeah, is there a way to make the player more sensitive to it?

Full conversion.
I'm thinking that you could mess with the sanity effects, making you lose additional sanity by losing sanity. I've seen the sanity effects declared somewhere in a script file.
I guess you might be able to do an oldState/currentState thing. Where, if the old state (previous update) of sanity is higher than the current state, then you know you are losing sanity. If you know you are losing sanity, you can subtract a constant value (albeit a small one) from the sanity. But that may run into problems with gaining sanity. IDK, not a good time for me to think xD.
Well you could do a looping timer, which checks if (new_sanity >= old_sanity) 0.5 seconds ago.
If it isn't, it deducts x sanity from the player, and checks if (sanity >= (sanity - x)).
(If it is true it doesn't deduct sanity and recalls the timer)
This can loop every 0.5 seconds. x should be really small. The drawback is it will deduce extra sanity when you lose sanity other ways.

As mentioned earlier you can also make a full conversion, but if you weren't planning on making a full conversion in the first place, this is a pretty good alternative. (I've used it in my story Smile )
Code:
float sanityFactor = 10.0f;
float curSanity = 100.0f;
float oldSanity = 100.0f;

void OnStart()
{
    SetPlayerSanity(100.0f);
    AddTimer("SanityTimer", 0.5f, "UpdateSanity");  
}

void UpdateSanity(string &in asTimer)
{
    curSanity = GetPlayerSanity();
    float temp;
    if(curSanity < oldSanity)
    {
            temp = curSanity - sanityFactor;
            SetPlayerSanity(temp);
    }
    
    if (curSanity > oldSanity)
    {
        temp = curSanity + sanityFactor;
        if(temp <= 100.0f)
        {
            SetPlayerSanity(temp);
        }
        else
        {
            SetPlayerSanity(100.0f);
        }
    }  
    
    oldSanity = curSanity;    
    AddTimer("SanityTimer", 0.5f, "UpdateSanity");
}

I omitted any unrelated code (like lever turning lights on and off).
The draining works just fine when I turn the lights off, but as soon as I turn the lights, my sanity (no matter what) goes to "..."; basically, it doesn't gain sanity correctly. My code is insane somewhere.
Pages: 1 2