mpbar backfill of npc(s) like that on of the player

Steven1985

Active member
Hi, to draw mpbar of npc(s) I use two types of mpbar, the classic one or rpg style.
C:
void main()
{//Draw mp bar in the screen for NPCs

    if(openborvariant("in_level")){ //IN ANY LEVEL??
        void self    = getlocalvar("self");
        void type    = getentityproperty(self, "type");
        //void sType    = getentityproperty(self, "subtype");

        if(type == openborconstant("TYPE_NPC")){ //&& sType == openborconstant("SUBTYPE_FOLLOW")){
            int maxMp        = getentityproperty(self, "maxmp");
            int mp            = getentityproperty(self, "mp");
            int x            = 201; //X POSITION
            int y            = 19; //Y POSITION
            int z            = 1001; //LAYER
            int colorBlue    = rgbcolor(0,0,255);
            int colorBlack    = rgbcolor(0,0,0);
            int colorWhite    = rgbcolor(255,255,255);
            int colorCyan    =  rgbcolor(0,255,255);
            float xSize        = 100; //BAR WIDTH INCREASE FACTOR, MORE VALUE IS MORE SIZE
            float ySize        = 3; //BAR HEIGHT INCREASE FACTOR, MORE VALUE IS MORE SIZE
            
            //DRAW MP BAR
            mp            = (mp*xSize)/maxMp; //CALCULATE REMAINING MP BAR SIZE
            maxMp        = (maxMp*xSize)/maxMp; //CALCULATE MAX MP BAR SIZE
            drawbox(x, y, mp, ySize, z+3, colorCyan, 0); //DRAW MP REMAINING
            drawbox(x, y, maxMp, ySize, z+1, colorBlue, 0); //DRAW BACKFILL
            drawbox(x-1, y-1, maxMp+2, ySize+2, z, colorWhite, 0); //DRAW WHITE BORDER
        }
    }
}
C:
if(openborvariant("in_level")){ //IN ANY LEVEL??
        int maxmp    = getentityproperty(self, "maxmp");
        int mp     = getentityproperty(self, "mp");
        int x         = getentityproperty(self, "x");
        int y         = getentityproperty(self, "y");
        int z         = getentityproperty(self, "z");
        float xPos     = openborvariant("xpos");
        float yPos     = openborvariant("ypos");
        float xSize    = 30; //BAR WIDTH INCREASE FACTOR, MORE VALUE IS MORE SIZE
        float ySize    = 2; //BAR HEIGHT INCREASE FACTOR, MORE VALUE IS MORE SIZE
        float xDif    = 0; //BAR POSITION IN X AXIS, USE THIS TO MOVE ALL BARS TOGETHER
        float yDif    = 0; //BAR POSITION IN Y AXIS, USE THIS TO MOVE ALL BARS TOGETHER // DEFAULT 5
        void type        = getentityproperty(self, "type");
        
        if(mp >= 0){ //ENTITY IS ALIVE??
            if(type == openborconstant("TYPE_PLAYER") || type == openborconstant("TYPE_NPC")){
                mp         = (mp*xSize)/(maxmp); //CALCULATE REMAINING mp BAR SIZE
                maxmp        = (maxmp*xSize)/(maxmp); //CALCULATE MAX mp BAR SIZE
                x             = x-xPos-(maxmp/2)+xDif; //CALCULATE X POSITION TO BIND BAR IN THE ENTITY, OFFSET IS ALWAYS THE CENTER
                y             = z-yPos-y+yDif; //CALCULATE Y POSITION TO BIND BAR IN THE ENTITY
                drawbox(x, y, mp, ySize, z+3, rgbcolor(0x00,0xFF,0xFF), 0); //CYAN BAR, MP REMAINING
                drawbox(x, y, maxmp, ySize, z+1, rgbcolor(0x00,0x00,0xFF), 0); //BLUE BAR, MP LOST
                drawbox(x, y-1, maxmp, ySize*2, z, rgbcolor(0xFF,0xFF,0xFF), 0); //WHITE BORDER (UP/DOWN)
                drawbox(x-1, y, maxmp+2, ySize, z, rgbcolor(0xFF,0xFF,0xFF), 0); //WHITE BORDER (LEFT/RIGHT)
            }
        }
    }   
}
I'd like to know if it is possble to have the backfill without color like that one of the player.
Thank you in advance.
 
Hi, to draw mpbar of npc(s) I use two types of mpbar, the classic one or rpg style.
C:
void main()
{//Draw mp bar in the screen for NPCs

    if(openborvariant("in_level")){ //IN ANY LEVEL??
        void self    = getlocalvar("self");
        void type    = getentityproperty(self, "type");
        //void sType    = getentityproperty(self, "subtype");

        if(type == openborconstant("TYPE_NPC")){ //&& sType == openborconstant("SUBTYPE_FOLLOW")){
            int maxMp        = getentityproperty(self, "maxmp");
            int mp            = getentityproperty(self, "mp");
            int x            = 201; //X POSITION
            int y            = 19; //Y POSITION
            int z            = 1001; //LAYER
            int colorBlue    = rgbcolor(0,0,255);
            int colorBlack    = rgbcolor(0,0,0);
            int colorWhite    = rgbcolor(255,255,255);
            int colorCyan    =  rgbcolor(0,255,255);
            float xSize        = 100; //BAR WIDTH INCREASE FACTOR, MORE VALUE IS MORE SIZE
            float ySize        = 3; //BAR HEIGHT INCREASE FACTOR, MORE VALUE IS MORE SIZE
           
            //DRAW MP BAR
            mp            = (mp*xSize)/maxMp; //CALCULATE REMAINING MP BAR SIZE
            maxMp        = (maxMp*xSize)/maxMp; //CALCULATE MAX MP BAR SIZE
            drawbox(x, y, mp, ySize, z+3, colorCyan, 0); //DRAW MP REMAINING
            drawbox(x, y, maxMp, ySize, z+1, colorBlue, 0); //DRAW BACKFILL
            drawbox(x-1, y-1, maxMp+2, ySize+2, z, colorWhite, 0); //DRAW WHITE BORDER
        }
    }
}
C:
if(openborvariant("in_level")){ //IN ANY LEVEL??
        int maxmp    = getentityproperty(self, "maxmp");
        int mp     = getentityproperty(self, "mp");
        int x         = getentityproperty(self, "x");
        int y         = getentityproperty(self, "y");
        int z         = getentityproperty(self, "z");
        float xPos     = openborvariant("xpos");
        float yPos     = openborvariant("ypos");
        float xSize    = 30; //BAR WIDTH INCREASE FACTOR, MORE VALUE IS MORE SIZE
        float ySize    = 2; //BAR HEIGHT INCREASE FACTOR, MORE VALUE IS MORE SIZE
        float xDif    = 0; //BAR POSITION IN X AXIS, USE THIS TO MOVE ALL BARS TOGETHER
        float yDif    = 0; //BAR POSITION IN Y AXIS, USE THIS TO MOVE ALL BARS TOGETHER // DEFAULT 5
        void type        = getentityproperty(self, "type");
       
        if(mp >= 0){ //ENTITY IS ALIVE??
            if(type == openborconstant("TYPE_PLAYER") || type == openborconstant("TYPE_NPC")){
                mp         = (mp*xSize)/(maxmp); //CALCULATE REMAINING mp BAR SIZE
                maxmp        = (maxmp*xSize)/(maxmp); //CALCULATE MAX mp BAR SIZE
                x             = x-xPos-(maxmp/2)+xDif; //CALCULATE X POSITION TO BIND BAR IN THE ENTITY, OFFSET IS ALWAYS THE CENTER
                y             = z-yPos-y+yDif; //CALCULATE Y POSITION TO BIND BAR IN THE ENTITY
                drawbox(x, y, mp, ySize, z+3, rgbcolor(0x00,0xFF,0xFF), 0); //CYAN BAR, MP REMAINING
                drawbox(x, y, maxmp, ySize, z+1, rgbcolor(0x00,0x00,0xFF), 0); //BLUE BAR, MP LOST
                drawbox(x, y-1, maxmp, ySize*2, z, rgbcolor(0xFF,0xFF,0xFF), 0); //WHITE BORDER (UP/DOWN)
                drawbox(x-1, y, maxmp+2, ySize, z, rgbcolor(0xFF,0xFF,0xFF), 0); //WHITE BORDER (LEFT/RIGHT)
            }
        }
    }  
}
I'd like to know if it is possble to have the backfill without color like that one of the player.
Thank you in advance.
I saw your PM but for some reason it's blocked for replies. In case you want to add transparency to the bars, just fill the alpha parameter in the drawbox lines.

1731888292397.png

In case you want gray tones (no colors, I believe is what you meant), just fill the 3 RGB color parameters with the exact same value.

Code:
rgbcolor(64,64,64)
 
I saw your PM but for some reason it's blocked for replies. In case you want to add transparency to the bars, just fill the alpha parameter in the drawbox lines.
Hi my friend, I had deleted the PM. I did as you wrote but I don't have the same effect like marked.
The Punisher and Nick Fury 2.0 final (OpenBOR) - 0001.png
 
Last edited:
Strange, I use it all the time and works fine. I would like to see your latest code.
C:
void main()
{//Draw mp bar in the screen for NPCs

    if(openborvariant("in_level")){ //IN ANY LEVEL??
        void self    = getlocalvar("self");
        void type    = getentityproperty(self, "type");
        //void sType    = getentityproperty(self, "subtype");

        if(type == openborconstant("TYPE_PLAYER")){ //&& sType == openborconstant("SUBTYPE_FOLLOW")){
            int maxMp        = getentityproperty(self, "maxmp");
            int mp            = getentityproperty(self, "mp");
            int x            = 201; //X POSITION
            int y            = 19; //Y POSITION
            int z            = 1001; //LAYER
            int alpha         = 2;
            int colorBlue    = rgbcolor(0,0,255);
            int colorBlack    = rgbcolor(0,0,0);
            int colorWhite    = rgbcolor(255,255,255);
            int colorCyan    =  rgbcolor(0,255,255);
            float xSize        = 100; //BAR WIDTH INCREASE FACTOR, MORE VALUE IS MORE SIZE
            float ySize        = 3; //BAR HEIGHT INCREASE FACTOR, MORE VALUE IS MORE SIZE
            
            //DRAW MP BAR
            mp            = (mp*xSize)/maxMp; //CALCULATE REMAINING MP BAR SIZE
            maxMp        = (maxMp*xSize)/maxMp; //CALCULATE MAX MP BAR SIZE
            drawbox(x, y, mp, ySize, z+3, colorCyan, 0); //DRAW MP REMAINING
            drawbox(x, y, maxMp, ySize, z+1, colorBlue, alpha); //DRAW BACKFILL default Blue
            drawbox(x-1, y-1, maxMp+2, ySize+2, z, colorWhite, 0); //DRAW WHITE BORDER
        }
    }
}
 
C:
void main()
{//Draw mp bar in the screen for NPCs

    if(openborvariant("in_level")){ //IN ANY LEVEL??
        void self    = getlocalvar("self");
        void type    = getentityproperty(self, "type");
        //void sType    = getentityproperty(self, "subtype");

        if(type == openborconstant("TYPE_PLAYER")){ //&& sType == openborconstant("SUBTYPE_FOLLOW")){
            int maxMp        = getentityproperty(self, "maxmp");
            int mp            = getentityproperty(self, "mp");
            int x            = 201; //X POSITION
            int y            = 19; //Y POSITION
            int z            = 1001; //LAYER
            int alpha         = 2;
            int colorBlue    = rgbcolor(0,0,255);
            int colorBlack    = rgbcolor(0,0,0);
            int colorWhite    = rgbcolor(255,255,255);
            int colorCyan    =  rgbcolor(0,255,255);
            float xSize        = 100; //BAR WIDTH INCREASE FACTOR, MORE VALUE IS MORE SIZE
            float ySize        = 3; //BAR HEIGHT INCREASE FACTOR, MORE VALUE IS MORE SIZE
           
            //DRAW MP BAR
            mp            = (mp*xSize)/maxMp; //CALCULATE REMAINING MP BAR SIZE
            maxMp        = (maxMp*xSize)/maxMp; //CALCULATE MAX MP BAR SIZE
            drawbox(x, y, mp, ySize, z+3, colorCyan, 0); //DRAW MP REMAINING
            drawbox(x, y, maxMp, ySize, z+1, colorBlue, alpha); //DRAW BACKFILL default Blue
            drawbox(x-1, y-1, maxMp+2, ySize+2, z, colorWhite, 0); //DRAW WHITE BORDER
        }
    }
}
Now I understand the problem, in my original code I'm using a white box a bit bigger than the life bar in order to work as a border instead of drawing each line individually.


In this case you need to use the script this way, here's the new code:
Code:
void main()
{//Draw mp bar in the screen for NPCs

    if(openborvariant("in_level")){ //IN ANY LEVEL??
        void self    = getlocalvar("self");
        void type    = getentityproperty(self, "type");
        //void sType    = getentityproperty(self, "subtype");

        if(type == openborconstant("TYPE_PLAYER")){ //&& sType == openborconstant("SUBTYPE_FOLLOW")){
            int maxMp        = getentityproperty(self, "maxmp");
            int mp            = getentityproperty(self, "mp");
            int x            = 201; //X POSITION
            int y            = 19; //Y POSITION
            int z            = 1001; //LAYER
            int alpha         = 6;
            int colorBlue    = rgbcolor(0,0,255);
            int colorBlack    = rgbcolor(0,0,0);
            int colorWhite    = rgbcolor(255,255,255);
            int colorCyan    =  rgbcolor(0,255,255);
            float xSize        = 100; //BAR WIDTH INCREASE FACTOR, MORE VALUE IS MORE SIZE
            float ySize        = 3; //BAR HEIGHT INCREASE FACTOR, MORE VALUE IS MORE SIZE
            
            //DRAW MP BAR
            mp            = (mp*xSize)/maxMp; //CALCULATE REMAINING MP BAR SIZE
            maxMp        = (maxMp*xSize)/maxMp; //CALCULATE MAX MP BAR SIZE
           drawbox(x, y, maxMp, ySize, z+1, colorBlue, alpha); //DRAW BACKFILL default Blue

           drawbox(x-1, y-1, maxMp+2, 1, z, colorWhite, 0); //UPPER WHITE BORDER
           drawbox(x-1, y+ySize, maxMp+2, 1, z, colorWhite, 0); //LOWER WHITE BORDER
           drawbox(x-1, y, 1, ySize, z, colorWhite, 0); //LEFT WHITE BORDER
           drawbox(x+maxMp, y, 1, ySize, z, colorWhite, 0); //RIGHT WHITE BORDER

           drawbox(x, y, mp, ySize, z+3, colorCyan, 0); //DRAW MP REMAINING
        }
    }
}

 
Now I understand the problem, in my original code I'm using a white box a bit bigger than the life bar in order to work as a border instead of drawing each line individually.


In this case you need to use the script this way, here's the new code:
Code:
void main()
{//Draw mp bar in the screen for NPCs

    if(openborvariant("in_level")){ //IN ANY LEVEL??
        void self    = getlocalvar("self");
        void type    = getentityproperty(self, "type");
        //void sType    = getentityproperty(self, "subtype");

        if(type == openborconstant("TYPE_PLAYER")){ //&& sType == openborconstant("SUBTYPE_FOLLOW")){
            int maxMp        = getentityproperty(self, "maxmp");
            int mp            = getentityproperty(self, "mp");
            int x            = 201; //X POSITION
            int y            = 19; //Y POSITION
            int z            = 1001; //LAYER
            int alpha         = 6;
            int colorBlue    = rgbcolor(0,0,255);
            int colorBlack    = rgbcolor(0,0,0);
            int colorWhite    = rgbcolor(255,255,255);
            int colorCyan    =  rgbcolor(0,255,255);
            float xSize        = 100; //BAR WIDTH INCREASE FACTOR, MORE VALUE IS MORE SIZE
            float ySize        = 3; //BAR HEIGHT INCREASE FACTOR, MORE VALUE IS MORE SIZE
       
            //DRAW MP BAR
            mp            = (mp*xSize)/maxMp; //CALCULATE REMAINING MP BAR SIZE
            maxMp        = (maxMp*xSize)/maxMp; //CALCULATE MAX MP BAR SIZE
           drawbox(x, y, maxMp, ySize, z+1, colorBlue, alpha); //DRAW BACKFILL default Blue

           drawbox(x-1, y-1, maxMp+2, 1, z, colorWhite, 0); //UPPER WHITE BORDER
           drawbox(x-1, y+ySize, maxMp+2, 1, z, colorWhite, 0); //LOWER WHITE BORDER
           drawbox(x-1, y, 1, ySize, z, colorWhite, 0); //LEFT WHITE BORDER
           drawbox(x+maxMp, y, 1, ySize, z, colorWhite, 0); //RIGHT WHITE BORDER

           drawbox(x, y, mp, ySize, z+3, colorCyan, 0); //DRAW MP REMAINING
        }
    }
}

Thank you! To get the effect desired I disabled the line drawbox(x, y, maxMp, ySize, z+1, colorBlue, alpha); //DRAW BACKFILL default Blue so I have no color about backfill like the player.
I'd like to have the same thing for that rpg style one with this graphic.
The Punisher and Nick Fury 2.0 final (OpenBOR) - 0001.png
After several attempts, I obtained the bar as shown in the screenshot above. At the upper and lower border, I put x instead of x-1 and maxmp instead of maxmp+2.
 
Last edited:
Back
Top Bottom