Steven1985
Active member
Hi, to draw mpbar of npc(s) I use two types of mpbar, the classic one or rpg style.
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.
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)
}
}
}
}
Thank you in advance.