Frictional Games Forum (read-only)
Function Not Calling, But Debug Message Shows Up - 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: Function Not Calling, But Debug Message Shows Up (/thread-53776.html)



Function Not Calling, But Debug Message Shows Up - AGP - 06-18-2017

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);
}



RE: Function Not Calling, But Debug Message Shows Up - FlawlessHappiness - 06-18-2017

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?


RE: Function Not Calling, But Debug Message Shows Up - AGP - 06-19-2017

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.


RE: Function Not Calling, But Debug Message Shows Up - Mudbill - 06-19-2017

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.


RE: Function Not Calling, But Debug Message Shows Up - AGP - 06-19-2017

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.


RE: Function Not Calling, But Debug Message Shows Up - FlawlessHappiness - 06-19-2017

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.


RE: Function Not Calling, But Debug Message Shows Up - Romulator - 06-20-2017

(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