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
Trigger script when using any laudanum
palistov Offline
Posting Freak

Posts: 1,208
Threads: 67
Joined: Mar 2011
Reputation: 57
#6
RE: Trigger script when using any laudanum

Nah AddUseItemCallback triggers when an object is used on another object. You can create a loop which checks the player health...and if it jumps up by 15 HP instantly or so, you'll know they used a potion. Just know this won't work if the player uses a potion while at max health. Just an example of how you might go about it. Also notice the GetPlayerHealth() - 15.0f. This is to check if the player's health has changed by a value more than ~15 points. It depends on the heal amount of the potion. But realistically it could be something like 1.0f, because the player's health regenerates very slowly anyways.

PHP Code: (Select All)
void OnStart()
{
    
SetLocalVarFloat("PlayerLastHP"GetPlayerHealth());
    
HPCheck("HPCheckLoopTimer");
}

void HPCheck(string &in t)
{
    if(
GetPlayerHealth()-15.0f GetLocalVarFloat("PlayerLastHP"))
    {
        
PlayerUsedPotion();
    }
    
SetLocalVarFloat("PlayerLastHP"GetPlayerHealth());
    
AddTimer(t0.0166f"HPCheck");


(This post was last modified: 06-06-2012, 09:56 PM by palistov.)
06-06-2012, 09:54 PM
Find


Messages In This Thread
RE: Trigger script when using any laudanum - by palistov - 06-06-2012, 09:54 PM



Users browsing this thread: 1 Guest(s)