 |
 |
 |
 |
|
 |
 |
|
 |
 |
|
 |
 |
|
 |
 |
|
 |
 |
|
 |
 |
|
 |
 |
|
 |
 |
|
 |
 |
|
 |
 |
|
 |
 |
| Author |
Message |
Marilla
Joined: 02 Feb 2006 Posts: 329
|
Posted: Wed Oct 18, 2006 7:28 pm Post subject: |
|
|
Hmm... not sure what's confusing about this... maybe another wording by way of explanation?
First: Random names are generated based on the graphic of the NPC, by all scripts I have seen. In fact, as a totally separate issue, I think it's best to do it by objtype. I might explain that below... but the fact is, that's not how it's done.
The reason for the constants defined inside RandomNameUtil.inc is as a list of the graphics that random names are needed for. Why is it in a separate file from the code that does the random names? I don't know. (I don't use that code, myself). Why, also, does it not just use constants from client.inc? Perhaps simply so as not to have to include client.inc. Then again, the naming convention of OBJ_* suggests the writer of that include MEANT for it to be used along with client.inc. (at any rate, I -never- duplicate global variable or constant names, nor function names, anywhere in my files, so as to prevent problems with include changes).
But the code that does the actual selecting of the random names, from RandomName.inc, clearly uses the mob.graphic property. It chooses an 'index' of types of names based on what the graphic is, and then chooses a random name from among the names that have that index in the names configuration file.
So, to add a new graphic to an existing list, you just need to find the code that selects the 'index' based on the graphic, and be sure to include a constant value for the new graphic you are using, that needs a name.
As for the objtype member. I can't even guess why this is so, but the reason it exists and is separate from the graphic property is answered by a look at the POL Object Reference: Both mobiles and items inherit from UOBject, which defines both objtype and graphic members. It's that simple. Further, definitions for both items and mobiles follow a similar pattern: You -must- define an objtype for the item, but the graphic is optional. If you do not define the graphic, it takes the same value as objtype.
This makes graphic and objtype members related, much of the time. However, 'related' does not at all mean 'the same'. items have a separate requirement, in that each objtype must be uniquely defined. mobiles do NOT have that requirement (you can define as many NPCs of objtype 0x1 (the first ogre graphic) as you like, and you can give them each whatever graphic you like. On the other hand, you can only have one item with objtype 0x1, though you can have any number of items with graphic 0x1.
Because both item and mobile inherit both graphic and objtype from UObject, they also treat the properties the same in most other ways; You can change the graphic all you want on an existing instance of the object, and the objtype always remains the same. The objtype also is read-only; you can't change it if you wanted to.
I think most scripters know how to use this fact for items - you can always check an item's objtype to be 100% sure that an item is of a certain type, no matter what might have been done to the graphic, name or CProps. Well, what many don't seem to realize is the objtype member of mobiles serves exactly the same purpose, basically (because it is read-only), but because objtype's can be duplicated among mobiles, there's an extra thing that it can be used for: For 'classing' or 'grouping' NPCs.
That is; You could make all your Daemons have the same objtype of, say, 0x9... but then give them each their own graphic. So each daemon will have the appearance you wish for it, and will generate the appropriate corpse, etc... but now, you have an easy-to-use way to tell monster 'classes', without having to package your NPCs and read the package name from the npctemplate. (though I still do recommend packaging classes of NPCs anyway - this just offers a better way, IMO, of discerning which monster is in which 'class', as it seems to me testing for equality among integer values is certainly better performing than testing a portion of a variable length string for a certain variable length string:
| Code: |
if (npc.objtype == 0x9)...
if (npc.npctemplate["daemon"])...
|
Anyway... umm... so ends my ramble! |
|
 |
|
|
 |
 |
|