Frictional Games Forum (read-only)
Trigger script when using any laudanum - 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: Trigger script when using any laudanum (/thread-15894.html)

Pages: 1 2


RE: Trigger script when using any laudanum - Damascus - 06-07-2012

PHP Code:
void HPCheck(string &in t)
{
    if(
GetPlayerHealth()-5.0f GetLocalVarFloat("PlayerLastHP"))
    {
        
PlayerUsedPotion();
    }
    else if(
GetPlayerHealth() > 95)
    {
        
PlayerUsedPotion();
    }
    else
    {
        
SetLocalVarFloat("PlayerLastHP"GetPlayerHealth());
        
AddTimer(t0.0166f"HPCheck");
    }


Like this?

(I also put the end of the script in it's own "else" bracket so that the timer stops repeating if one of the conditions is satisfied.)


RE: Trigger script when using any laudanum - SilentStriker - 06-07-2012

Does it work properly if you put the timer and LocalVar inside a else statement? If it do then it looks good Smile


RE: Trigger script when using any laudanum - FragdaddyXXL - 06-07-2012

logical or: ||

PHP Code:
void HPCheck(string &in t)
{
    if(
GetPlayerHealth()-5.0f GetLocalVarFloat("PlayerLastHP") || 
     
GetPlayerHealth() > 95)
    {
        
PlayerUsedPotion();
    }
    else
    {
        
SetLocalVarFloat("PlayerLastHP"GetPlayerHealth());
        
AddTimer(t0.0166f"HPCheck");
    }