[SCRIPT] Cure all Players and NPC with item

O Ilusionista

Captain 100K
I've adapted a script by Matman to make an item to be able to heal all available players and NPC on screen when you get an item.
The amount of HP added is the same of the item health.

For memory sake, we need to use two files - one is just to import the second, to avoid the code to be compiled again each time you add on a new entity.

1 - Save both files under your scripts/didhit folder (create a folder inside the SCRIPTS folder called "didhit")as:

cureall.c
Code:
#import "data/scripts/didhit/cureall_actual.c"

void main()
{
    actual_main();
}

cureall_actual.c
Code:
void actual_main(){
	//Heals all PLAYER and NPC on screen with the item HEALTH value
	//Based on Matman's script
	// Douglas Baldan / O Ilusionista - 2018.07.28
	// www.brazilmugenteam.com
    void    vEnt;                                                                           //Entity placeholder.
    int     iType;                                                                          //Entity type.
    int     iValid;                                                                         //Entity valid.
    int     iDead;                                                                          //Entity death status.
    int     iECnt;                                                                          //Current # of entities in play.
    int     iEnt;                                                                           //Entity counter.
    void self = getlocalvar("self");														//Caller
	int itemHP = getentityproperty(self,"health"); 											//get item health
	int iHP;
    iECnt   = openborvariant("count_entities");                                             //Get current entity count.
	
	
    for(iEnt=0; iEnt<iECnt; iEnt++)                                                         //Loop entity collection.
      {
        vEnt    = getentity(iEnt);                                                          //Get entity handle.

        if(vEnt)                                                                            //Valid handle?
        {
            iValid  = getentityproperty(vEnt, "exists");                                    //Get exists confirmation.
            iDead   = getentityproperty(vEnt, "dead");                                      //Get death status.
            iType   = getentityproperty(vEnt, "type");                                      //Get type.
			iHP   = getentityproperty(vEnt, "health");                                      //Get type.


            if(iValid && !iDead && (iType == openborconstant("TYPE_PLAYER") || iType == openborconstant("TYPE_NPC"))) // Is valid, not dead and the right type
            {
               changeentityproperty(vEnt, "health", iHP+itemHP);							// restore health based on item
            }
        }
      }
}

2- Call the script in your character header:
didhitscript data/scripts/didhit/cureall.c

And that is it. The script can be easily converted to restore MP too - just change "health" for "mp".
 
Back
Top Bottom