View Single Post
  #10  
Old 02-09-2014, 08:05 PM
DrakePhoenix
Fire Beetle
 
Join Date: Jan 2014
Posts: 22
Default

[TL;DR] -- I finally got it working. It is imperfect, but it is good enough for my current purposes at this time. I will post details on how others can make this work at a later date. I'll try to post those details by the end of the week, but make no promises.


Now the long version...

OK, so there is a problem with trying to check for acceptable valid texture parameter values for the different races. While there is a finite set of textures that are valid for playable races, it seems that not all races have the same set of usable textures. The Vah Shir, for example, do not seem to be able to use robes textures, the client simply has no way to display them properly, because the display resources were never developed (Vah Shir on live always wear leather or better armor, never robes). Additionally, each non-standard race (a.k.a. monster race, a.k.a. non-playable race) has it's own limited set of acceptable texture values, and which values are acceptable changes from one race to the next and generally ranges somewhere between 0 and 7 (inclusive), with most capping out at 3 or 4, and many having only 0.

So unless I hard-code limits for each specific race (which is far more work than I'm willing to do), then there is no way to properly guarantee that the valid texture value check would be accurate all the time. Also, it seems to me, based on limited experimentation, that if an invalid texture value is provided, then the system will default to the baseline texture for the given race. That is, for playable races, it will display as though they are naked of equipment, and for non-standard races it will display them as though they used texture 0.

Based on all of that, I don't think that a check for valid texture parameter value is a workable idea, nor particularly necessary. So what I've done instead is to simply try to provide clear information and warning values in the help messages. I've also added processing for a new bot command, "#bot help spawn", that provides still further information, and warnings about the texture display limitations and how it might behave.


Anyway, I went ahead and re-coded to allow the #bot spawn command to accept optional parameters of texture and helmtexture. I then changed the Spawn function to accept those values as parameters for itself... rewrote the function declaration in bot.h, rewrote the function definition in bot.cpp, and rewrote all calls to the function to provide the new parameters.

I set the #bot spawn command to determine values for the textureparam and helmtextureparam values used by the revised Spawn function. If the command provides a value, then those values are used, if not, they default to 0 for non-standard races, and to 255 for standard races. Then the Spawn function itself now checks those values. For non-standard races it sets texture = textureparam, helmtexture = textureparam (helmtextureparam is ignored), gender = 2, and face = 0. For standard races it sets texture = textureparam, and helmtexture = helmtextureparam, no other changes.


I tested with that setup and found it still doesn't work. So I added in a SendIllusionPacket call at the end of the Spawn function, after the entity_list.AddBot function call. I set the illusion packet to use all of the values previously set for the Bot object (no changes).

I've also added command processing for #bot texture, #bot helmtexture, and #bot size commands to modify those values on a bot that has already been spawned. I also had to modify the SendIllusionPacket function to force it to use the texture, helmtexture, and size values provided, rather than defaulting them to 255 and race npc_type default size. Not sure why that wasn't addressed before, but now on my server illusion packets, such as that resulting from the #texture command, will not incorrectly reset texture, helmtexture, and size.

I didn't expect the addition of the SendIllusionPacket call to actually work, since it doesn't seem that it actually changes any values (I wrote the call to use all of the values already present on the Bot object), but I thought I'd try it anyway. I was quite pleasantly surprised to find that it actually does work this way.


So at this point I have a setup that allows players to spawn bots using any race they choose (though I could also limit this to specific races if I wanted), and they can specify the skin texture when they use the #bot spawn command. The resulting bot should successfully display the correct race model (if it's global, or has been made global), and if the texture parameter is provided and is valid for that specific race, then it should also display the correct skin texture.


Since there might be someone else who may at some point be interested in doing this for their own setup, I'll post the code changes themselves, but before I do that, I need to clean them up a bit. I need a break from staring at code though, so I'm not going to do that right away. I'll try to have them posted by the end of the week though.


Later,
Drake Phoenix
Reply With Quote