Frictional Games Forum (read-only)

Full Version: Function Not Calling, But Debug Message Shows Up
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Okay, here is my issue:

I have a global variable script for note pick ups. It's the same script used in multiple maps. So far, it works in the first two, but not in the third. I've copied everything over exactly as it is in the others, but the functions just will not call, however the debug message does show up, so now I am majorly confused.

Why will the script work fine in the other two maps, but not this one?

I thought, maybe because this map has music already playing in the background and the others don't, but even then, wouldn't the AddPlayerSanity still call? But nothing happens except the debug message.

Code:
void NotePickUp(string &in asEntity, string &in type)
{
    AddGlobalVarInt("Notes", 1);  
  
    if(GetGlobalVarInt("Notes") == 20)
    {
        SetEntityActive("blueboy", true);
    }
    
    PlayMusic("myuu_nightmares_loop", true, 0.5f, 0.0f, 1, false);
    
    AddTimer("stoploop", 1.5f, "EndLoop");
    
    AddPlayerSanity(25);
    AddDebugMessage("DeBug", true);
}

void EndLoop(string &in asTimer)
{
    StopMusic(1.5f, 1);
}
If the debug message calls, then the function calls.

Is it possible the AddPlayerSanity function isn't calling because the player is at maximum sanity?
So what happened was I forgot to check the initial script calling for that background music to play. For some crazy reason, I had the priority set to 10!

But still the AddPlayerSanity doesn't seem to always work, but that just might be something on my end, so for now I'll leave it as is until it comes time for playtesting, and see if it is just my end that's being weird.
You can try to do something like GiveSanityDamage without effects so that the player's sanity is reduced slightly before you give them the sanity boost, because like Flawless says, the effect won't show up if the player is already at max sanity.
Before the AddPlayerSanity (trying to up sanity by 25), the player had "a slight headache". I'm not sure how much sanity damage that is in terms of points.
If you use the in-game debug menu you can enable player stats. It's probably one of the "Show _____ info".

This should display text in the upper left corner, and you should be able to locate "Sanity" in there. The number represented should be between 0 and 100, possibly with a lot of decimals.
(06-19-2017, 03:44 PM)AGP Wrote: [ -> ]Before the AddPlayerSanity (trying to up sanity by 25), the player had "a slight headache". I'm not sure how much sanity damage that is in terms of points.

Code:
>  0  < 25 ...
>= 25 < 50 Head is pounding and hands shaking
>= 50 < 75 A slight headache
>= 75      Crystal Clear

Should be these values :3