Author Topic: NPC Floaty Names  (Read 319 times)

Legacy_Jenna WSI

  • Hero Member
  • *****
  • Posts: 1837
  • Karma: +0/-0
NPC Floaty Names
« on: October 27, 2011, 10:23:17 pm »


               Is there a way to make them a different color?
               
               

               
            

Legacy_Xardex

  • Sr. Member
  • ****
  • Posts: 414
  • Karma: +0/-0
NPC Floaty Names
« Reply #1 on: October 27, 2011, 10:36:31 pm »


               This is the script im using for colored text, and im pretty happy with it.

const string COLORTOKEN = "                  ##################$%&'()*+,-./0123456789:;;==?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[[]^_`abcdefghijklmnopqrstuvwxyz{|}~~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ¡¡¢£¤¥¦§¨©ª«¬¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþþ";

// returns a properly color-coded sText string based on specified RGB values
// ends color mode after sText if iEnd = 1
string ColorString(string sText, int nRed=255, int nGreen=255, int nBlue=255, int iEnd = 0);
string ColorString(string sText, int nRed=255, int nGreen=255, int nBlue=255, int iEnd = 0)
{
    string sEnd = "";
    if (iEnd == 1) {sEnd = "</c>";}
    return "<c" + GetSubString(COLORTOKEN, nRed, 1) + GetSubString(COLORTOKEN, nGreen, 1) + GetSubString(COLORTOKEN, nBlue, 1) + ">" + sText + sEnd;
}



void SetColors();
void SetColors()
{
    int r=0,g=0,b=0, in;
    while (1)
    {
        SetCustomToken(6000 + r*100 + g*10 + b*1, ColorString("", r*28+3, g*28+3, b*28+3));
             if ((r == 9) && (g == 9) && (b == 9)) {break;}
        else if (            (g == 9) && (b == 9)) {r++; g=0; b=0;}
        else if (                        (b == 9)) {     g++; b=0;}
        else                                       {          b++;}
        in++;
    }
    DelayCommand(3.0, FloatingTextStringOnCreature(IntToString(in), GetFirstPC()));
    SetCustomToken(7000, "</c>");
}


It might seem complicated but you don't really have to know how it works. Anyhow, make sure you have this script included on your OnModuleLoad and call for SetColors(). After that you can use custom tokens from 6000 to 7000 to create colored text.

Think of it as 6RGB; (google RGB incase you dont know what it means)
6900 = bright red
6005 = dark blue
6963 = orange
etc...
7000 is used to stop colored text. (normal text coloring kicks in)

Incase you don't know what custom tokens are... Well, its really simple. Basically you write <CUSTOM#> where # is a number, and the whole thing will be replaced by something.

EDIT
This forum's colored text fails so hard..........

Anyhow, for example, if you want half of the name to be green and the other half cyan, just type this in the creatures name field. Just play around with it, its really simple.

<CUSTOM6090>Crea<CUSTOM6099>ture<CUSTOM7000>

The 7000 isn't needed in creature names, but you might have use for it in places like journal and item descriptions.
               
               

               


                     Modifié par Xardex, 27 octobre 2011 - 09:47 .
                     
                  


            

Legacy_Jenna WSI

  • Hero Member
  • *****
  • Posts: 1837
  • Karma: +0/-0
NPC Floaty Names
« Reply #2 on: October 27, 2011, 11:19:52 pm »


               Awesome! We have some colored tokens in already so I'll try this out.
               
               

               
            

Legacy_Xardex

  • Sr. Member
  • ****
  • Posts: 414
  • Karma: +0/-0
NPC Floaty Names
« Reply #3 on: October 28, 2011, 10:27:26 am »


               I didn't notice it earlier but the following stuff are there just for debugging:

int r=0,g=0,b=0[u], in[/u];
...
in++;
...
DelayCommand(3.0, FloatingTextStringOnCreature(IntToString(in), GetFirstPC()));