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
looping timer not working
RaXZerGamingZ Offline
Junior Member

Posts: 11
Threads: 3
Joined: Jan 2019
Reputation: 0
#1
looping timer not working

Hello,

I have a looping timer (thanks to mudbill) however it does not work no matter what i try, no clue what i'm doing wrong if anyone can help would be much appreciated:

void OnStart()
{
        SetPlayerSanity(1);
        AddTimer("loop", 1, "Timer");
}

void Timer(string &in asTimer)
{
    if (GetPlayerSanity() <= 0.0f)
    {
        GivePlayerDamage(20.0f, "BloodSplat", false, true);
        AddPlayerSanity(1.0f);
    }
       AddTimer("loop", 1, "Timer");
}
03-16-2019, 12:10 AM
Find
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#2
RE: looping timer not working

What are you trying to accomplish with your timer?

Your timer is working, but your if-statement isn't, assuming you are trying to give damage when sanity is at its minimum. Test your if statement by checking if your sanity is less than 0.1f instead and see if that works.

PHP Code: (Select All)
void Timer(string &in asTimer)
{
     if(
GetPlayerSanity() < 0.1f)
     {
          
//code
     
}


You may opt for "finer" values if you want to be more specific about when to carry out the if-block (0.05f, 0.007f, etc).

Make sure, if you have not yet, to Set up the Developer Environment in Amnesia so that you can see your exact sanity values when you tick some of the options in the Debug Menu (Pressing F1 in game).

Discord: Romulator#0001
[Image: 3f6f01a904.png]
(This post was last modified: 03-16-2019, 12:39 PM by Romulator.)
03-16-2019, 12:38 PM
Find
RaXZerGamingZ Offline
Junior Member

Posts: 11
Threads: 3
Joined: Jan 2019
Reputation: 0
#3
RE: looping timer not working

thank you very much, changing that value did it, really didn't expect that to be it
03-16-2019, 05:56 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#4
RE: looping timer not working

Most likely the game doesn't use the value 0.0 for sanity, at least not for long enough for the timer to pick it up. Perhaps once it hits 0.0, the value is immediately bumped up to the recovery value as the sanity collapse happens.

03-16-2019, 11:38 PM
Find
RaXZerGamingZ Offline
Junior Member

Posts: 11
Threads: 3
Joined: Jan 2019
Reputation: 0
#5
RE: looping timer not working

the lowest sanity goes by draining from darkness is 0.001250 i think, the strange part is i originally put in the code " <=0.0f "
03-17-2019, 12:09 AM
Find
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#6
RE: looping timer not working

Mudbill Wrote:Most likely the game doesn't use the value 0.0 for sanity, at least not for long enough for the timer to pick it up. Perhaps once it hits 0.0, the value is immediately bumped up to the recovery value as the sanity collapse happens.

When Daniel gets back up at the end of the sanity collapse is when it restores to the recovery value - the game keeps Sanity locked down at the "min" value but it doesn't update/lower when Daniel collapses.

RaXZerGamingZ Wrote:the lowest sanity goes by draining from darkness is 0.001250 i think, the strange part is i originally put in the code " <=0.0f "

By that logic, the if-conditional would have been correct if sanity reached a point where it was less than 0.0 with a bunch of zeros appended, since 0.0 implies just 0. This would also therefore work if no matter low sanity must be 0 exact for Daniel to collapse, then any sort of "negative" sanity (an instance where you receive sanity damage at an already low enough state) should reset the sanity to be exactly 0.

The issue is, if the engine is doing rounding to determine when Daniel is to collapse, it doesn't exactly correspond with the sanity value. If Daniel collapses but still is at 0.000125 sanity, the sanity is still technically greater than 0. Therefore, it didn't pass the if check but continued to loop correctly.

This is why I mentioned looking at the sanity values for when Daniel collapses. With a few tweaks to the game.cfg file, I bet you can find an "exact" value to test for to see when Daniel collapses, and then update your if to check if the sanity is less than or equal to that value. Smile

Discord: Romulator#0001
[Image: 3f6f01a904.png]
(This post was last modified: 03-17-2019, 04:39 AM by Romulator.)
03-17-2019, 04:38 AM
Find
RaXZerGamingZ Offline
Junior Member

Posts: 11
Threads: 3
Joined: Jan 2019
Reputation: 0
#7
RE: looping timer not working

well i put it to <= 0.001250 and that works just fine as far as i've noticed
03-17-2019, 12:44 PM
Find




Users browsing this thread: 1 Guest(s)