Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get Sanity to drain in the dark and increase in the light?
FragdaddyXXL Offline
Member

Posts: 136
Threads: 20
Joined: Apr 2012
Reputation: 7
#1
Get Sanity to drain in the dark and increase in the light?

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.

Dark Seclusion Here
04-11-2012, 03:30 PM
Find
Datguy5 Offline
Senior Member

Posts: 629
Threads: 25
Joined: Dec 2011
Reputation: 12
#2
RE: Get Sanity to drain in the dark and increase in the light?

Thats actually in custom stories too..

04-11-2012, 03:34 PM
Find
Cranky Old Man Offline
Posting Freak

Posts: 986
Threads: 20
Joined: Apr 2012
Reputation: 38
#3
RE: Get Sanity to drain in the dark and increase in the light?

(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?


Noob scripting tutorial: From Noob to Pro

(This post was last modified: 04-11-2012, 03:47 PM by Cranky Old Man.)
04-11-2012, 03:36 PM
Find
FragdaddyXXL Offline
Member

Posts: 136
Threads: 20
Joined: Apr 2012
Reputation: 7
#4
RE: Get Sanity to drain in the dark and increase in the light?

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?

Dark Seclusion Here
04-11-2012, 03:42 PM
Find
Putmalk Offline
Senior Member

Posts: 290
Threads: 13
Joined: Apr 2012
Reputation: 15
#5
RE: Get Sanity to drain in the dark and increase in the light?

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, 05:17 PM
Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#6
RE: Get Sanity to drain in the dark and increase in the light?

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

Full conversion.

Tutorials: From Noob to Pro
04-11-2012, 05:58 PM
Website Find
Cranky Old Man Offline
Posting Freak

Posts: 986
Threads: 20
Joined: Apr 2012
Reputation: 38
#7
RE: Get Sanity to drain in the dark and increase in the light?

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.

Noob scripting tutorial: From Noob to Pro

04-11-2012, 06:16 PM
Find
FragdaddyXXL Offline
Member

Posts: 136
Threads: 20
Joined: Apr 2012
Reputation: 7
#8
RE: Get Sanity to drain in the dark and increase in the light?

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.

Dark Seclusion Here
04-12-2012, 12:43 PM
Find
DRedshot Offline
Senior Member

Posts: 374
Threads: 23
Joined: Jun 2011
Reputation: 11
#9
RE: Get Sanity to drain in the dark and increase in the light?

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 )

(This post was last modified: 04-12-2012, 09:11 PM by DRedshot.)
04-12-2012, 09:09 PM
Find
FragdaddyXXL Offline
Member

Posts: 136
Threads: 20
Joined: Apr 2012
Reputation: 7
#10
RE: Get Sanity to drain in the dark and increase in the light?

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.

Dark Seclusion Here
04-13-2012, 01:28 AM
Find




Users browsing this thread: 2 Guest(s)