zexika
Member
I looked at the forums and while there are a few modifications posted, I am trying to get the HP bar to display ABOVE the enemy spawned that uses this script, rather than under their feet. I understand that by modifying the DRAWBOX code by leaving X alone and modifying V gives me partial success, the bar will display above the the enemy spawn, but it's erratic. The bar will move up and down, and when the enemy falls, it floats in the air instead of following the enemy to the ground. Perhaps that's why this script is written to display the hp bar under the enemy to begin with.
I'm not a C+ programmer, nor will I pretend to be. Anyone able to to help me out with this one?
I'm not a C+ programmer, nor will I pretend to be. Anyone able to to help me out with this one?
Code:
void main()
{//floating hp bars by msmalik681
void self = getlocalvar("self"); //get calling entity
int time = openborvariant("elapsed_time"); //current time in game
float x = getentityproperty(self, "x") - openborvariant("xpos")-16; //get caller x value minus 25
float z = getentityproperty(self, "z"); //get caller z value
float y = getentityproperty(self, "y"); //get caller y value
int mp = getentityproperty(self, "mp"); //get current mp
float v = z - y - 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 / 3; // work out current hp percentage and half it
if(!getlocalvar("dam"+self)){setlocalvar("dam"+self,health);} //set damage to same as hp
if(getlocalvar("dam"+self))
{
drawbox(x,v,health,4,z+10,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,v,getlocalvar("dam"+self),4,z+9,rgbcolor(181,26,0),0); //second box to show damage with a z+1 value so its under hp bar and dam controls its size
drawbox(x,v,33,4,z+8,rgbcolor(0,0,100),0); //black box in background to show how much original life bar was
drawbox(x-1,v-1,35,6,z+7,rgbcolor(8,80,232),0); //life bar border
drawbox(x-3,v+1,35,6,z+6,rgbcolor(0,24,112),0); //life bar border
//drawstring(x,v+10,4,hp);
}
if(health<getlocalvar("dam"+self) && time%50==0) // if hp box smaller then damage box reduce damage every 50 tics
{
setlocalvar("dam"+self,getlocalvar("dam"+self)-1); //reduce damage by 1
}
}