EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Development::Bots (https://www.eqemulator.org/forums/forumdisplay.php?f=676)
-   -   Bot armor color + texture (https://www.eqemulator.org/forums/showthread.php?t=33864)

Criimson 07-18-2011 07:40 PM

After more color tests - the colors are fine the way they are. Unsure why but they do work on a ### ### ### style format. It takes time to get a feel for the color shifts because as far as I can tell it isnt an exact 0-255 for each set of ### but it seems it is close.

So for instance it going R### G### B###:
000 000 050 (just type 50 for color) is a blue 000 000 000 is a deep black....way darker then sony ever allowed. Easiest to get a sense of where ya want to be by picking a number like 50 then adding a digit 500, 5000, 5000 etc and youll see the colors change and will give you a place to start.

Don't think coloring weaps and shields is possible at this time so removing sql from submission for now

lerxst2112 07-18-2011 08:35 PM

You don't need an int64 to hold a color, they are 24 bits and fit just fine in an int.

Try something like this. I didn't compile it, but you should be able to get the idea from it.
Code:

        if(!strcasecmp(sep->arg[1], "armorcolor")) {
                if(c->GetTarget() && c->GetTarget()->IsBot() && (c->GetTarget()->CastToBot()->GetBotOwner() == c)) {
                        if(sep->argnum < 6) {
                                c->Message(0, "Usage: #bot armorcolor [slot] [red] [green] [blue] - use #bot help armorcolor for info");
                                return;
                        }

                        int setslot = atoi(sep->arg[2]);
                        uint8 red = atoi(sep->arg[3];
                        uint8 green = atoi(sep->arg[4];
                        uint8 blue = atoi(sep->arg[5];
                        uint32 setcolor = (red << 16) | (green << 8) || blue;
                        //You may not need this, but I believe if a color is set that the top bits must be 0xff
                        if(setcolor) {
                                setcolor &= (0xff << 24);
                        }
                }

A few of other things...

1) Change Bot::GetID to be const, don't make a new function that does exactly the same thing.

2) You don't need to use Bot::GetEquipmentColor() to call your function, just GetEquipmetColor() will call it.

3) You don't need Bot::SendWearChange at all. It's just a copy of Mob::SendWearChange.

Criimson 07-18-2011 09:04 PM

Quote:

Originally Posted by lerxst2112 (Post 201552)
You don't need an int64 to hold a color, they are 24 bits and fit just fine in an int.

Try something like this. I didn't compile it, but you should be able to get the idea from it.
Code:

        if(!strcasecmp(sep->arg[1], "armorcolor")) {
                if(c->GetTarget() && c->GetTarget()->IsBot() && (c->GetTarget()->CastToBot()->GetBotOwner() == c)) {
                        if(sep->argnum < 6) {
                                c->Message(0, "Usage: #bot armorcolor [slot] [red] [green] [blue] - use #bot help armorcolor for info");
                                return;
                        }

                        int setslot = atoi(sep->arg[2]);
                        uint8 red = atoi(sep->arg[3];
                        uint8 green = atoi(sep->arg[4];
                        uint8 blue = atoi(sep->arg[5];
                        uint32 setcolor = (red << 16) | (green << 8) || blue;
                        //You may not need this, but I believe if a color is set that the top bits must be 0xff
                        if(setcolor) {
                                setcolor &= (0xff << 24);
                        }
                }

A few of other things...

1) Change Bot::GetID to be const, don't make a new function that does exactly the same thing.

2) You don't need to use Bot::GetEquipmentColor() to call your function, just GetEquipmetColor() will call it.

3) You don't need Bot::SendWearChange at all. It's just a copy of Mob::SendWearChange.

Thank you for the tips.

Running tests right now.

Criimson

lerxst2112 07-18-2011 10:03 PM

Sorry, I made a typo in the original code.

Here are the two corrected bits.

Code:

uint32 setcolor = (red << 16) | (green << 8) | blue;

and

if(setcolor) {
    setcolor |= (0xff << 24);
}


Criimson 07-18-2011 10:20 PM

Well the code as written doesn't work. It returns 1 no matter what is entered.

Will keep testing and trying to figure it out

Being able to enter RGB would be nice. AFter looking at a couple of websites on color in code I was wondering does EQ use RGB or ARGB?

EDIT: didnt see your reply will look into it

Good sites:

http://www.codeproject.com/KB/graphics/color.aspx

http://developer.android.com/referen...ics/Color.html

lerxst2112 07-18-2011 10:32 PM

Yeah, sorry about the errors. Editing in the reply window is a pain. :(

The colors themselves are just RGB. I'm not sure what the high byte is actually used for, but if you look at Mob::SetSlotTint it seems like the client either expects a 0 for no color, or 0xff for any color. I don't know if any other value might work there. I'd guess the current value was found through either trial and error or packet collects to make the client happy.

Criimson 07-18-2011 10:49 PM

I have to say: lerxst2112 you are great

I really appreciate all of the help while I learn. I am too stubborn to say I can't do it or learn it and its nice to have someone help when stuck.

Your code works great. I had to remove the
Code:

if(setcolor) {
    setcolor |= (0xff << 24);
}

For some reason with it in it would always return a negative number. But the code works exactly without it. 255 0 0 is red 0 0 255 is blue. Thats exactly how it should work.

Criimson

EDIT: yea using this RGB system is nice. I sat there for like 5 minutes just testing it on my enchanter, watching her rob change

lerxst2112 07-18-2011 11:23 PM

Yes, when examined as an integer that will be a negative number, but the reality is that the colors are 4 separate bytes, so displaying it as one int doesn't make sense.

If it works without that then I guess it's fine, but the other code that manipulates colors does do it that way. If you need to display the color you could extract the values again and display that.

Something like this assuming the color variable is named color.

Code:

uint8 red = (color >> 16) & 0xff;
uint8 green = (color >> 8) & 0xff;
uint8 blue = color & 0xff;

I saw you commented out the check for the proper number of parameters. You should probably check that since trying to extract the values if the player doesn't type the line correctly could cause a crash or some very unpredictable behaviour.

I'm glad it works, and I hope you enjoy your colorful bots. :)

Criimson 07-18-2011 11:54 PM

The check was already there but written differently. For some reason when I compiled with your check it would hang on that and not except any input. So I just went with my original check.

And yea its nice to be able to say I want my druid in green and not have to hunt through tons of almost random numbers to find a shade close. Now its "I want this color" and wham

Capheus 07-23-2011 05:32 AM

Hey wow you guys took it and ran with it. I am hoping I get some time soon to check this stuff out too. Great job guys.

Congdar 07-24-2011 02:32 PM

Quote:

Originally Posted by Capheus (Post 201728)
Hey wow you guys took it and ran with it. I am hoping I get some time soon to check this stuff out too. Great job guys.

Thought i would post in this thread that this is committed. svn 1982 or newer.


All times are GMT -4. The time now is 11:51 PM.

Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.