Solved Boss Font name?

Question that is answered or resolved.

ZVitor

Active member
My Mod - 0008.png
It's probably something very simple, but I didn't find it in the manual or around here, how do I change the name font for a boss?
 
Do you want its name font to be aligned at the center of the entity's lifebar box next to its small portrait like this?

My Mod - 0923.png
My Mod - 0924.png

If so, you will need to center the text with script first in the very screen. Then align/move the text by giving a plus and value. This one is simply done with ondrawscript (which I just made for you), and you should use settextobj for this. I just renamed it to bossname.c which you'd declare it as ondrawscript. However, I'm not sure about findtarget(self), but it's what I'm using for my own. Dunno if it works for you.

Code:
ondrawscript data/scripts/bossname.c

bossname.c:
C-like:
void main(){
    void self = getlocalvar("self");
    void Name = getentityproperty(self, "name");
    int hRes = openborvariant("hresolution");
 
    if(findtarget(self)){
        settextobj(37, (hRes-strwidth(Name,0))/2 + 73, 11, 0, 8000, Name); //settextobj(index, x, y, font, z, text)
    }
}

This is not the best I have, but this is what I find useful.

EDIT: To me, I spaced out both that plus and the value for a reason, but it doesn't matter if you don't space them out since they're evaulated in X coord/parameter.

In case you're wondering what strwidth is like, here it is.

strwidth(string)

  • it returns the string width in pixels depending by the font.
  • if the width of the character is 6 pixels and the string is "HELLO"
  • strwidth("HELLO") will returns 6x5 = 30 (30 pixels)
  • useful to align a string in the screen specially if you use multi-byte strings.
EXAMPLE: strwidth("HELLO");

settextobj:
Code:
// settextobj(int index, int x, int y, int font, int z, char text, int time {optional})

EDIT 2:

I was wrong about using settextobj after testing and I forgot that drawstring still works. Use drawstring instead.

C:
void main(){
    void self = getlocalvar("self");
    void Name = getentityproperty(self, "name");
    int hRes = openborvariant("hresolution");

    drawstring((hRes-strwidth(Name,0))/2 + 73, 11, 0, Name);
}
 
Last edited:
This one is simply done with ondrawscript (which I just made for you), and you should use settextobj for this.
I see a problem here. If you are using ondrawscript, why are you using settextobj? This will constantly create a text obj, over and over, for the same text.
I think drawstring would be better in this case.

I hadn't seen this topic, but I talked to him via discord a few days ago and made this code

C-like:
void main(){
void self = getlocalvar("self"); // get self
void bossName = getentityproperty(self, "name");    // get boss name

//drawstring(int x, int y, int font#, text, layer)
drawstring( 140, 30,0,bossName);
}

But I liked your solution with strwidth so it could be easily placed.
 
I see a problem here. If you are using ondrawscript, why are you using settextobj? This will constantly create a text obj, over and over, for the same text.
I think drawstring would be better in this case.

I hadn't seen this topic, but I talked to him via discord a few days ago and made this code

C-like:
void main(){
void self = getlocalvar("self"); // get self
void bossName = getentityproperty(self, "name");    // get boss name

//drawstring(int x, int y, int font#, text, layer)
drawstring( 140, 30,0,bossName);
}

But I liked your solution with strwidth so it could be easily placed.
You are right about the use of drawstring which works well, and I kept on not noticing on mine (without a second thought). I didn't check carefully that drawstring still works, and it does. The reason I did put settextobj was because of the crash every time I used it. I got mixed up on using ondrawscript with animationscript in regard to using strings, or I forgot. Using drawstring doesn't work in animationscript, so that's when I use settextobj. I realized I was wrong.

@ZVitor I apologize to you for pointing out incorrectly on the use of settextobj. It should be drawstring that works fine in an update script (such as ondrawscript, update.c, etc.).

Correct version:

C:
void main(){
    void self = getlocalvar("self");
    int hres = openborvariant("hresolution");
    void name = getentityproperty(self, "name");
   
    drawstring((hres-strwidth(name, 0))/2+73, 11, 0, name);
}
 
Last edited:
Back
Top Bottom