I have just updated my HP Bar script it now shows a non image yellow bar above enemies head. Again set its height by adding a MP value for each enemy. New feature it now shows damage when enemy is hit there will be a red damage indicator that catches up the current hp just like in most modern fighting games this give you a feel for how damaging your combo was (but as it works on a percentage not that accurate as each enemy has different health lol).
to apply it save the below script to a .c text file then declare in enemy header with: ondrawscript data/scripts/hpbar.c or whatever you named it. be aware this script uses entity var 0 and 1 you can change if you have reserved these also rgb colours can be changed to customize and finally you can edit the value for timer to make damage drain slower or faster.
**Edit by DC**: Use Code tags for posting script and text files.
to apply it save the below script to a .c text file then declare in enemy header with: ondrawscript data/scripts/hpbar.c or whatever you named it. be aware this script uses entity var 0 and 1 you can change if you have reserved these also rgb colours can be changed to customize and finally you can edit the value for timer to make damage drain slower or faster.
Code:
void main()
{
void self = getlocalvar("self"); //get calling entity
float x = getentityproperty(self, "x") - openborvariant("xpos") - 25; //get caller x value minus 25
float z = getentityproperty(self, "z"); //get caller z value
float a = getentityproperty(self, "a"); //get caller a value
float y = z - a - openborvariant("ypos") - getentityproperty(self, "maxmp"); // get caller y position and move it up by entity max mp value
int maxhp = getentityproperty(self,"maxhealth"); // get caller max hp
int hp = getentityproperty(self,"health"); // get caller current hp
int health = hp / 0.01 / maxhp / 2; // work out current hp percentage and half it
if(getentityvar(self,0)==NULL()){setentityvar(self,0, health);} //set enity var to 0 if no value (null)
drawbox(x,y,health,5,z+2,rgbcolor(223,214,73),0); //draw hp box using x and y cords also z value is +2 so its on top of other 2 boxes
drawbox(x,y,getentityvar(self,0),5,z+1,rgbcolor(181,26,0),0); //second box to show damage with a z+1 value so its under hp bar and entity var 0 controls its size
drawbox(x,y,50,5,z,0,0); //black box in background to show how much original life bar was
if(health<getentityvar(self,0)) // if hp box smaller then damage box
{
if(getentityvar(self,1)==NULL()){setentityvar(self,1,0);} //set entity var 1 to zero if null this is a timer
setentityvar(self,1,getentityvar(self,1)+1); //add 1 to timer this will run every game tic
if(getentityvar(self,1) > 50) //if timer over 50
{
setentityvar(self,0,getentityvar(self,0)-1); //reduce displayed damage by 1
setentityvar(self,1,0); //reset timer to zero this will cause a loop untill damage is the same as hp
}
}
}
**Edit by DC**: Use Code tags for posting script and text files.