Solved HP question.

Question that is answered or resolved.

DD Tokki

Well-known member
HP.PNG

Basic HP decreases at a right angle.
I want HP to decrease in a diagonal shape as shown in the picture.
I'd like to know how to do it.
 
Last edited:
:rolleyes: (sigh) Rocket Viper has the diagonal lifebar, but I don't know how the author made that since it's very complex for me to read. However, for mine, I do use drawbox for the character's lifebar. Each color line for health has a unit. It's a total of 6 lines, but one-color line's height size (bright yellow) at the very top is 2 pixels. The rest below the yellow one are 1 pixel high. For the player 1's side, it's depleted from left to right, while the player 2's side is depleted from right to left. Take a look at the script below regarding the health bars.

My Mod - 0884.png

My Mod - 0888.png

drawbox(x,y,width,height,z,color,alpha)

  • draw a filled box with specified position and size.
  • x,y: position values on screen
  • width,height: size values.
  • z: depth value, similar to setlayer command or entities, check it for details.
  • color: color index in palette, check you palette.
  • alpha: alpha blending effect from 1 to 6, this parameter is optional.
  • return: none

C:
void actual_main(){ // Player Main Hud
    health();
}
void health() // Player health
{//Update script with player lifebar
//Calling main player
    void self = getlocalvar("self");
    int P1 = getplayerproperty(0, "entity");
    int P2 = getplayerproperty(1, "entity");
    void P1Name = getentityproperty(P1, "name");
    void P2Name = getentityproperty(P2, "name");
    int P1HP = getentityproperty(P1, "health");
    int P2HP = getentityproperty(P2, "health");
    int P1MaxHP = getentityproperty(P1, "maxhealth");
    int P2MaxHP = getentityproperty(P2, "maxhealth");

    int P1Health = 114*P1HP/P1MaxHP;
    int P2Health = 114*P2HP/P2MaxHP;
    int P1Score = getplayerproperty(0, "score");
    int P2Score = getplayerproperty(1, "score");
    int hres = openborvariant("hresolution");
    void Branch = openborvariant("current_branch");
    void T1 = findtarget(P1);
    void T2 = findtarget(P2);
    int THP1 = getentityproperty(T1, "health");
    int THP2 = getentityproperty(T2, "health");
    
    if(getentityvar(self,0)==NULL()){setentityvar(self,0, P1Health);}
    if(getentityvar(self,0)==NULL()){setentityvar(self,0, P2Health);}
    
    if(P1 != NULL() && Branch != "Strength_Training"){ // Display lifebar in all stages except strength training stage
        drawbox((150-P1Health),6,P1Health,2,1800,rgbcolor(255,234,41),0);
        drawbox((150-P1Health),8,P1Health,1,1800,rgbcolor(255,226,0),0);
        drawbox((150-P1Health),9,P1Health,1,1800,rgbcolor(255,206,24),0);
        drawbox((150-P1Health),10,P1Health,1,1800,rgbcolor(246,194,0),0);
        drawbox((150-P1Health),11,P1Health,1,1800,rgbcolor(230,141,0),0);
        drawbox((150-P1Health),12,P1Health,1,1800,rgbcolor(222,92,0),0);
        drawstring(33, 55, 1, P1Name);
        drawstring(66, 43, 1, P1Score);
        changeentityproperty(P1, "iconposition", -56, 21);
        drawbox((150-getentityvar(self,0)),6,getentityvar(self,0),7,1700,rgbcolor(181,26,0),0); // drawbox(x,y,width,height,z,color);
        //drawbox(34, 21, 30, 30, 600, rgbcolor(0,64,0)); // Background color for player icon
    }if(P2 != NULL() && Branch != "Strength_Training"){
        drawbox(176,6,P2Health,2,1800,rgbcolor(255,234,41),0);
        drawbox(176,8,P2Health,1,1800,rgbcolor(255,226,0),0);
        drawbox(176,9,P2Health,1,1800,rgbcolor(255,206,24),0);
        drawbox(176,10,P2Health,1,1800,rgbcolor(246,194,0),0);
        drawbox(176,11,P2Health,1,1800,rgbcolor(230,141,0),0);
        drawbox(176,12,P2Health,1,1800,rgbcolor(222,92,0),0);
        drawbox(176,6,getentityvar(self,0),6,1700,rgbcolor(181,26,0),-1);
        //changeentityproperty(P2, "iconposition", 262, 21);
        drawstring(hres-27-strwidth(P2Name, 0), 55, 0, P2Name); // drawstring(x,y,font,text,z);
        drawstring(175, 43, 0, P2Score);
        //drawbox(262, 21, 30, 30, 600, rgbcolor(0,64,0)); // Background color for player icon
    }

    
    if(Branch == "Strength_Training"){
        if(P1 != NULL()){
            drawstring(33, 55, 1, P1Name);
            drawstring(66, 43, 1, P1Score);
            changeentityproperty(P1, "iconposition", -56, -41);
            drawbox((150-P1Health),-106,P1Health,2,1800,rgbcolor(255,234,41),0);
            drawbox((150-P1Health),-108,P1Health,1,1800,rgbcolor(255,226,0),0);
            drawbox((150-P1Health),-109,P1Health,1,1800,rgbcolor(255,206,24),0);
            drawbox((150-P1Health),-110,P1Health,1,1800,rgbcolor(246,194,0),0);
            drawbox((150-P1Health),-111,P1Health,1,1800,rgbcolor(230,141,0),0);
            drawbox((150-P1Health),-112,P1Health,1,1800,rgbcolor(222,92,0),0);
            drawbox((150-getentityvar(self,0)),-106,getentityvar(self,0),7,1700,rgbcolor(181,26,0),0);
        }
        if(P2 != NULL()){
            drawbox(176,-106,P2Health,2,1800,rgbcolor(255,234,41),0);
            drawbox(176,-108,P2Health,1,1800,rgbcolor(255,226,0),0);
            drawbox(176,-109,P2Health,1,1800,rgbcolor(255,206,24),0);
            drawbox(176,-110,P2Health,1,1800,rgbcolor(246,194,0),0);
            drawbox(176,-111,P2Health,1,1800,rgbcolor(230,141,0),0);
            drawbox(176,-112,P2Health,1,1800,rgbcolor(222,92,0),0);
            drawbox(176,-106,getentityvar(self,0),6,1700,rgbcolor(181,26,0),-1);
            changeentityproperty(P2, "iconposition", 262, -41);
            drawstring(hres-27-strwidth(P2Name, 0), 55, 0, P2Name); // drawstring(x,y,font,text,z);
            drawstring(175, 43, 0, P2Score);
            //drawbox(262, 21, 30, 30, 600, rgbcolor(0,64,0)); // Background color for player icon
        }
    }
    
    if(P1Health<getentityvar(self,0)){
        if(getentityvar(self,1)==NULL()){
            setentityvar(self,1,0);
        }
        setentityvar(self,1,getentityvar(self,1)+1);
        if(getentityvar(self,1) > 7){
            setentityvar(self,0,getentityvar(self,0)-1);
            setentityvar(self,1,0);
        }
    }
        
    if(P2Health<getentityvar(self,0)){
        if(getentityvar(self,1)==NULL()){
            setentityvar(self,1,0);
        }
        setentityvar(self,1,getentityvar(self,1)+1);
        if(getentityvar(self,1) > 7){
            setentityvar(self,0,getentityvar(self,0)-1);
            setentityvar(self,1,0);
        }
    }
}

Look at X-Men VS Street Fighter or Marvel Super Heroes VS Street Fighter for the curved lifebar examples. Do you want those kinds?
 
:rolleyes: (sigh) Rocket Viper has the diagonal lifebar, but I don't know how the author made that since it's very complex for me to read. However, for mine, I do use drawbox for the character's lifebar. Each color line for health has a unit. It's a total of 6 lines, but one-color line's height size (bright yellow) at the very top is 2 pixels. The rest below the yellow one are 1 pixel high. For the player 1's side, it's depleted from left to right, while the player 2's side is depleted from right to left. Take a look at the script below regarding the health bars.

View attachment 7262

View attachment 7261



C:
void actual_main(){ // Player Main Hud
    health();
}
void health() // Player health
{//Update script with player lifebar
//Calling main player
    void self = getlocalvar("self");
    int P1 = getplayerproperty(0, "entity");
    int P2 = getplayerproperty(1, "entity");
    void P1Name = getentityproperty(P1, "name");
    void P2Name = getentityproperty(P2, "name");
    int P1HP = getentityproperty(P1, "health");
    int P2HP = getentityproperty(P2, "health");
    int P1MaxHP = getentityproperty(P1, "maxhealth");
    int P2MaxHP = getentityproperty(P2, "maxhealth");

    int P1Health = 114*P1HP/P1MaxHP;
    int P2Health = 114*P2HP/P2MaxHP;
    int P1Score = getplayerproperty(0, "score");
    int P2Score = getplayerproperty(1, "score");
    int hres = openborvariant("hresolution");
    void Branch = openborvariant("current_branch");
    void T1 = findtarget(P1);
    void T2 = findtarget(P2);
    int THP1 = getentityproperty(T1, "health");
    int THP2 = getentityproperty(T2, "health");
   
    if(getentityvar(self,0)==NULL()){setentityvar(self,0, P1Health);}
    if(getentityvar(self,0)==NULL()){setentityvar(self,0, P2Health);}
   
    if(P1 != NULL() && Branch != "Strength_Training"){ // Display lifebar in all stages except strength training stage
        drawbox((150-P1Health),6,P1Health,2,1800,rgbcolor(255,234,41),0);
        drawbox((150-P1Health),8,P1Health,1,1800,rgbcolor(255,226,0),0);
        drawbox((150-P1Health),9,P1Health,1,1800,rgbcolor(255,206,24),0);
        drawbox((150-P1Health),10,P1Health,1,1800,rgbcolor(246,194,0),0);
        drawbox((150-P1Health),11,P1Health,1,1800,rgbcolor(230,141,0),0);
        drawbox((150-P1Health),12,P1Health,1,1800,rgbcolor(222,92,0),0);
        drawstring(33, 55, 1, P1Name);
        drawstring(66, 43, 1, P1Score);
        changeentityproperty(P1, "iconposition", -56, 21);
        drawbox((150-getentityvar(self,0)),6,getentityvar(self,0),7,1700,rgbcolor(181,26,0),0); // drawbox(x,y,width,height,z,color);
        //drawbox(34, 21, 30, 30, 600, rgbcolor(0,64,0)); // Background color for player icon
    }if(P2 != NULL() && Branch != "Strength_Training"){
        drawbox(176,6,P2Health,2,1800,rgbcolor(255,234,41),0);
        drawbox(176,8,P2Health,1,1800,rgbcolor(255,226,0),0);
        drawbox(176,9,P2Health,1,1800,rgbcolor(255,206,24),0);
        drawbox(176,10,P2Health,1,1800,rgbcolor(246,194,0),0);
        drawbox(176,11,P2Health,1,1800,rgbcolor(230,141,0),0);
        drawbox(176,12,P2Health,1,1800,rgbcolor(222,92,0),0);
        drawbox(176,6,getentityvar(self,0),6,1700,rgbcolor(181,26,0),-1);
        //changeentityproperty(P2, "iconposition", 262, 21);
        drawstring(hres-27-strwidth(P2Name, 0), 55, 0, P2Name); // drawstring(x,y,font,text,z);
        drawstring(175, 43, 0, P2Score);
        //drawbox(262, 21, 30, 30, 600, rgbcolor(0,64,0)); // Background color for player icon
    }

   
    if(Branch == "Strength_Training"){
        if(P1 != NULL()){
            drawstring(33, 55, 1, P1Name);
            drawstring(66, 43, 1, P1Score);
            changeentityproperty(P1, "iconposition", -56, -41);
            drawbox((150-P1Health),-106,P1Health,2,1800,rgbcolor(255,234,41),0);
            drawbox((150-P1Health),-108,P1Health,1,1800,rgbcolor(255,226,0),0);
            drawbox((150-P1Health),-109,P1Health,1,1800,rgbcolor(255,206,24),0);
            drawbox((150-P1Health),-110,P1Health,1,1800,rgbcolor(246,194,0),0);
            drawbox((150-P1Health),-111,P1Health,1,1800,rgbcolor(230,141,0),0);
            drawbox((150-P1Health),-112,P1Health,1,1800,rgbcolor(222,92,0),0);
            drawbox((150-getentityvar(self,0)),-106,getentityvar(self,0),7,1700,rgbcolor(181,26,0),0);
        }
        if(P2 != NULL()){
            drawbox(176,-106,P2Health,2,1800,rgbcolor(255,234,41),0);
            drawbox(176,-108,P2Health,1,1800,rgbcolor(255,226,0),0);
            drawbox(176,-109,P2Health,1,1800,rgbcolor(255,206,24),0);
            drawbox(176,-110,P2Health,1,1800,rgbcolor(246,194,0),0);
            drawbox(176,-111,P2Health,1,1800,rgbcolor(230,141,0),0);
            drawbox(176,-112,P2Health,1,1800,rgbcolor(222,92,0),0);
            drawbox(176,-106,getentityvar(self,0),6,1700,rgbcolor(181,26,0),-1);
            changeentityproperty(P2, "iconposition", 262, -41);
            drawstring(hres-27-strwidth(P2Name, 0), 55, 0, P2Name); // drawstring(x,y,font,text,z);
            drawstring(175, 43, 0, P2Score);
            //drawbox(262, 21, 30, 30, 600, rgbcolor(0,64,0)); // Background color for player icon
        }
    }
   
    if(P1Health<getentityvar(self,0)){
        if(getentityvar(self,1)==NULL()){
            setentityvar(self,1,0);
        }
        setentityvar(self,1,getentityvar(self,1)+1);
        if(getentityvar(self,1) > 7){
            setentityvar(self,0,getentityvar(self,0)-1);
            setentityvar(self,1,0);
        }
    }
       
    if(P2Health<getentityvar(self,0)){
        if(getentityvar(self,1)==NULL()){
            setentityvar(self,1,0);
        }
        setentityvar(self,1,getentityvar(self,1)+1);
        if(getentityvar(self,1) > 7){
            setentityvar(self,0,getentityvar(self,0)-1);
            setentityvar(self,1,0);
        }
    }
}

Look at X-Men VS Street Fighter or Marvel Super Heroes VS Street Fighter for the curved lifebar examples. Do you want those kinds?
1708346770435.png
yes. I asked a question because the life bar style used in the game is a slanted concept.
 
Drawing curved or odd shaped meters isn't too difficult, you just need to reach back into your school day geometry lessons.

Work the math to form your shape, and then draw them by the pixel with drawdot(). Here's one example using a sine wave.

WHF - 0027.png

There's also the option of using a series of small sprites, or of course a combination of things. It really just depends on the design you want to achieve.

DC
 
another method: you can script a screen and use the lifebar as a sprite, with the tilted design.
You would move your sprite to the left using script.
Since screens clips anmything that is outsite of the screen size, your sprite wont "bleed out" the screen :)
(its basically what mugen does)
 
1708353473616.png

Since I don't have much understanding of the tilted life bar, it would be nice to have an example. Drawing is not a problem, but the purpose is to tilt when your stamina decreases. I don't have a life script right now, so I don't really understand it.
 
Sorry, I don't understand what you're asking for. Your meters already work, and Rocket Viper doesn't do anything special other than a an occasional gleam effect on the bars.

DC
 
Sorry, I don't understand what you're asking for. Your meters already work, and Rocket Viper doesn't do anything special other than a an occasional gleam effect on the bars.

DC
1708355375754.png

Usually, when physical strength decreases, it decreases in a straight line.
I want it to tilt diagonally like Rocket Viper 2 so that its stamina decreases.
 
View attachment 7271

Usually, when physical strength decreases, it decreases in a straight line.
I want it to tilt diagonally like Rocket Viper 2 so that its stamina decreases.

Ahh, OK. There's a couple of ways to achieve this, but the simplest is using drawline(). This is a function that draws a single pixel width line from point to point. Then you stack several of them together to look like an HP bar. You can find an example in UTunnels Golden Axe Remake. It's how he was able to give the bars a vertical color gradient.

1708356435861.png

To get the "tilt" effect, you just draw a few of them slightly shorter than the others as HP/MP is lost.

1708356226617.png

HTH,
DC
 
I don't know what else to explain. I'm not going to reprint things verbatim that are in the manual.

I will consider doing a live coding session tomorrow where I build a demo to show how it works.

DC
 
@DD Tokki

Is your life bar in percentage mode or in the native mode (multi-color bar)? The code is not too complicated, like @DCurrent said there's a lot of ways to do it but before posting more details about my current life bar code I would like to know which mode you are using.

This is the code I used in the video, I prefer to use the drawbox in this case because just attaching the health amount to the width is enough to make it work properly.
C:
//YELLOW BAR, LIFE REMAINING
if(pLife > 0){
    drawbox(xPos+xAdd+4, yPos, pLife, ySize, layer2, healthColor); //LINE 1
    drawbox(xPos+xAdd+3, yPos+1, pLife, ySize, layer2, healthColor); //LINE 2
    drawbox(xPos+xAdd+2, yPos+2, pLife, ySize, layer2, healthColor); //LINE 3
    drawbox(xPos+xAdd+1, yPos+3, pLife, ySize, layer2, healthColor); //LINE 4
    drawbox(xPos+xAdd, yPos+4, pLife, ySize, layer2, healthColor); //LINE 5
}



 
Last edited:
Back
Top Bottom