Scripted healing

AkuShadow

Member
I have a script that restores MP:
@script
void self = getlocalvar("self"); //get the self var
void power = getentityproperty(self,"mp"); // get target's current mp
changeentityproperty(self, "mp", power+10);
@end_script

Is there a way I can make this script also restore HP at a slower rate?
I am learning through trial and error so please explain as if I know nothing.
 
Solution
This worked with without editing anything other than the character text file:


Code:
@script
    void self = getlocalvar("self");
    if(!self) return;
    int which = getentityproperty(self, "playerindex");
    int hp = getentityproperty(self, "health");
    int maxHP = getentityproperty(self, "maxhealth");
    if(hp < maxHP)
    {
        int newHP = hp + 1;
        changeentityproperty(self, "health", newHP);
        if(which == 0) // Player 1
            setentityvar(self, "playerOne", newHP);
        else if(which == 1) // Player 2
            setentityvar(self, "playerTwo", newHP);
    }
    int mp = getentityproperty(self, "mp");
    changeentityproperty(self, "mp", mp + 10);
@end_script
This worked with without editing anything other than the character text file:


Code:
@script
    void self = getlocalvar("self");
    if(!self) return;
    int which = getentityproperty(self, "playerindex");
    int hp = getentityproperty(self, "health");
    int maxHP = getentityproperty(self, "maxhealth");
    if(hp < maxHP)
    {
        int newHP = hp + 1;
        changeentityproperty(self, "health", newHP);
        if(which == 0) // Player 1
            setentityvar(self, "playerOne", newHP);
        else if(which == 1) // Player 2
            setentityvar(self, "playerTwo", newHP);
    }
    int mp = getentityproperty(self, "mp");
    changeentityproperty(self, "mp", mp + 10);
@end_script
 
Solution
Back
Top Bottom