maxman
Well-known member
I'm using ondrawscript to draw the two lifebars for an enemy. I'm trying to retain the top bar as 50% health remaining while leaving the bottom bar as its max like the Punisher and some other games.

However, when I made this based on mine, @Kratus's, and @pudu's, it seems that all lifebar units reduce at the same time instead of having one lifebar wait for another.
Full double lifebar begins.

Starting to reduce at the same time.

Half of its unit remains.

Here's mine for the lifebar. I have trouble maintaining the length (X size) of the lifebars.
(What did I do wrong?)

However, when I made this based on mine, @Kratus's, and @pudu's, it seems that all lifebar units reduce at the same time instead of having one lifebar wait for another.
Full double lifebar begins.

Starting to reduce at the same time.

Half of its unit remains.

Here's mine for the lifebar. I have trouble maintaining the length (X size) of the lifebars.
C:
void main(){
bossHP();
}
void bossHP(){
void self = getlocalvar("self");
int currentHP = getentityproperty(self, "health");
int maxHP = getentityproperty(self, "maxhealth");
int xPos = 50; // BASE X POSITION
int yPos1 = 190; // FIRST BASE OF Y POSITION
int yPos2 = 200; // SECOND BASE OF Y POSITION
int xSize = 100; // BAR SIZE IN X AXIS
int ySize = 8; // BAR SIZE IN Y AXIS
int Layer = 5000;
int darkBlue = rgbcolor(0, 0, 100);
//int health1 = 100*currentHP/maxHP;
//int health2 = 100*
if(getentityvar(self, "enemigo") == NULL()){setentityvar(self, "enemigo", currentHP);}
// ONE HALF BAR
/*if(currentHP <= 0.5*maxHP){
//maxHP = 0.5*maxHP;
currentHP = (currentHP*xSize) / maxHP;
drawbox(xPos, yPos1, currentHP, ySize, Layer, darkBlue);
}
// FULL 2 HP BARS
if(currentHP >= xSize){
//full_health = maxHP;
currentHP = (currentHP * xSize) / maxHP;
drawbox(xPos, yPos1, currentHP, ySize, Layer, darkBlue);
drawbox(xPos, yPos2, currentHP, ySize, Layer, darkBlue);
}*/
if(currentHP > xSize){
drawbox(xPos, yPos1, getentityvar(self,"enemigo"), ySize, Layer, darkBlue);
drawbox(xPos, yPos2, getentityvar(self,"enemigo"), ySize, Layer, darkBlue);
}if(currentHP <= xSize){
drawbox(xPos, yPos1, getentityvar(self,"enemigo"), ySize, Layer, darkBlue);
//drawbox(xPos, yPos2, getentityvar(self,"enemigo"), ySize, Layer, darkBlue);
}
if(currentHP < getentityvar(self, "enemigo")){ // 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 tick
if(getentityvar(self,1) > 3){ //if timer over 7
setentityvar(self, "enemigo",getentityvar(self, "enemigo")-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
}
}
}
(What did I do wrong?)