Eh, although my answer is technically correct, when it comes to healing, enemies and NPCs need to check if they need to heal first before performing healing. That's why in Rise of Warduke, Iuz Priest (enemy healer) runs script in his IDLE to check if he needs healing or not.
He also checks other enemies' HP before deciding to heal any of them or not.
I'll share reduced script for self healing later.
[Later]
Here's the reduced script declared on IDLE and WALK:
C:
@script
if(frame >= 1){
void self = getlocalvar("self");
int MHP = getentityproperty(self, "maxhealth");
int HP = getentityproperty(self, "health");
int MP = getentityproperty(self,"mp");
if(HP < MHP/3 && MP > 20){
changeentityproperty(self, "velocity", 0, 0, 0);
performattack(self,openborconstant("ANI_FOLLOW4"));
}
}
@end_script
...
This script means the enemy will stop and perform FOLLOW4 (the self healing animation) if their HP falls below 1/3 of maxHP and has MP more than 20.
This is the FOLLOW4:
C:
anim follow4
@script
if(frame == 13){ // 14th frame
void self = getlocalvar("self");
int HP = getentityproperty(self, "health");
int MP = getentityproperty(self,"mp");
changeentityproperty(self, "health", HP + 40);
changeentityproperty(self, "mp", MP-20);
}
@end_script
...
Iuz Priest does the healing at 14th frame so if your enemy has less frames or heals at different frame, please adjust the frame.
HTH