Author Topic: Customizing weapons with colors higher than 4, is this on the right track?  (Read 876 times)

Legacy_OldTimeRadio

  • Hero Member
  • *****
  • Posts: 2307
  • Karma: +0/-0


               Hey there, a question came up in the CC forum about customizing weapons with colors higher than 4 and I was hoping some of you might be able to help us with it.

I'm not actively working on a solution, but I wanted to know what the answer to the question was.  I did a little digging last night and it looks like with CEP, for instance, you can modify weapons like this.  Is that correct?  We're talking doing this via scripting, of course.  Looks like what they use was originally created by SartriX and then modified a bit from there.  This seems to be a slightly more updated version.

Anyway, for those of you with tailoring systems to change the appearance of weapons, is something like the system I link to above how you're getting around that 4 color limit?

Thanks.
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Customizing weapons with colors higher than 4, is this on the right track?
« Reply #1 on: November 15, 2012, 07:21:11 pm »


               Has anyone actually verified that this is indeed a problem? I didn't see any conclusive response in the first thread. While I haven't run into this yet, my plans for a custom crafting system could be stymied by it.
               
               

               
            

Legacy_OldTimeRadio

  • Hero Member
  • *****
  • Posts: 2307
  • Karma: +0/-0
Customizing weapons with colors higher than 4, is this on the right track?
« Reply #2 on: November 15, 2012, 08:46:40 pm »


               

henesua wrote...
Has anyone actually verified that this is indeed a problem?

It definitely appears that way, though I've never tried to implement such a system so I never ran into it personally.  You can pick up some hits searching for "CopyItemAndModify limit*" or "ITEM_APPR_TYPE_WEAPON_COLOR", for instance.

I didn't see any conclusive response in the first thread. While I haven't run into this yet, my plans for a custom crafting system could be stymied by it.

Bingo.  I'm in the same boat, more or less.  Meh, even if I don't get an answer I don't think it'll take too much digging to get to the bottom of the issue.  I'm just not too keen on throwing a few evening's worth of free time into it when (theoretically) there would be a number of regular readers here who would have some wisdom to share on the point.
               
               

               


                     Modifié par OldTimeRadio, 15 novembre 2012 - 08:47 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Customizing weapons with colors higher than 4, is this on the right track?
« Reply #3 on: November 15, 2012, 10:04:25 pm »


               

OldTimeRadio wrote...

  ...We're talking doing this via scripting, of course.  


I hope you do not mean by scripting alone, You will still need the models and icons for each color variant.     
 
But I am in the same boat as you two,   I have never played with the function myself with values past the 4 colors, since I have never had the models installed.   
 
My impression on the linked topic that brought up the question, was that they where reading to much into the limit placed in the comments on the CopyItemAndModify item for the ITEM_APPR_TYPE_WEAPON_COLOR parameter.   I feel that Bioware placed the 1-4 limit in the comments simply because that is how many variants the made for every item,   Since there where no other variants the range for the parameter was 1-4.     
               
               

               


                     Modifié par Lightfoot8, 15 novembre 2012 - 10:06 .
                     
                  


            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Customizing weapons with colors higher than 4, is this on the right track?
« Reply #4 on: November 15, 2012, 10:17:36 pm »


               This is piquing my curiosity. If I unearth anything I'll post the results.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Customizing weapons with colors higher than 4, is this on the right track?
« Reply #5 on: November 15, 2012, 10:30:44 pm »


               Here is some info from the file format to help your quest.  


Quote
From BioWare Aurora Engine Item Format...


4.1.3. Composite

Model = <Itemclass>_<position>_<number>.mdl

(eg., waxbt_b_011.mdl, waxbt_m_011.mdl, waxbt_t_011.mdl)

Icon = i<Model ResRef>.tga

(eg., iwaxbt_b_011.tga, iwaxbt_m_011.tga, iwaxbt_t_011.tga)

The <position> is one of the following letters: b (bottom), m (middle), or t (top), usually corresponding to the pommel, hilt, or blade of a weapon.

For weapons, the 3-digit <number> field is broken up into two parts. The first 2 digits map to a physical shape variant, and the last digit is a color variant. For example, parts 011, 021, and 031 all have the same color, but different shapes. Parts 011, 012, and 013 all have the same shape, but
different colors.


To determine what colors are available for each of the b, m, and t portions of a composite item, do the following steps.
Scan for icons, incrementing the <number> from the baseitems.2da MinRange to MaxRange, and find first icon file that exists. Check the color code in the icon's resref (the last digit). This is the minimum available color. Increment the <number> from there until another icon is found that has the same color. Recall what color the icon was before that. That color is the maximum available color.


To determine what shapes are available, scan for TGA icons from <number> = (MinRange + minimum color) to <number> = [i MaxRange[/i], incrementing by 10 each time. If an icon exists, then assume that all the MDL file exists as well, and also assume that the shape variant exists in all the other colors as well. For example, suppose that the minimum color found earlier was 2, the maximum color was 4,
MinRange
= 10, and MaxRange = 100. The icon scan would check for 012, 022, 032, ... 092. If 082 exists, for example, then assume that 083 and 084 also exist When drawing the Icon for a composite item, the 3 portions are painted one after the other in the order:
bottom, middle, top. The order is important because the icons overlap.
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Customizing weapons with colors higher than 4, is this on the right track?
« Reply #6 on: November 16, 2012, 03:05:02 am »


               Wow... that is asinine. It really does clamp the color value between 1 and 4. I have tried values 5, 6, 7 and -1 the result is that the item doesn't change.

This was on a dagger model with colors from 1-7


I made a tag based script and tested this out on some weapons:

void main()
{
     if (GetUserDefinedItemEventNumber() ==X2_ITEM_EVENT_ACTIVATE)
     {
          object oUser    = GetItemActivator();
          object oWeapon  = GetItemActivatedTarget();

          int nColorTop   = GetItemAppearance(oWeapon, ITEM_APPR_TYPE_WEAPON_COLOR, ITEM_APPR_WEAPON_COLOR_TOP);
          SendMessageToPC(oUser, "START Target("+GetName(oWeapon)+") Top("+IntToString(nColorTop) +")");

          object oCopy    = CopyItemAndModify(oWeapon,ITEM_APPR_TYPE_WEAPON_COLOR, ITEM_APPR_WEAPON_COLOR_TOP, ++nColorTop, TRUE);

  nColorTop   = GetItemAppearance(oCopy, ITEM_APPR_TYPE_WEAPON_COLOR, ITEM_APPR_WEAPON_COLOR_TOP);
  SendMessageToPC(oUser, "FINISH Target("+GetName(oCopy)+") Top("+IntToString(nColorTop)+")");
 }
}

               
               

               


                     Modifié par henesua, 16 novembre 2012 - 03:09 .
                     
                  


            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Customizing weapons with colors higher than 4, is this on the right track?
« Reply #7 on: November 16, 2012, 03:17:06 am »


               Well, I figured out what my solution will be: A store filled with items with special tags identifying model part numbers.

Let me know if you aren't sure how this would work.
               
               

               
            

Legacy_OldTimeRadio

  • Hero Member
  • *****
  • Posts: 2307
  • Karma: +0/-0
Customizing weapons with colors higher than 4, is this on the right track?
« Reply #8 on: November 17, 2012, 12:17:39 am »


               Thank you for the information, both of you!

@heneusa - I'd love a 25-cent rundown on how that would work.  I just wanted to be clear: That's not going to get you around the 4 color limit, is it?  Separate question: Do you recall if the dagger you tested had bottom, middle and top color 5's?  If it did have a color 5 for each of the models and it still didn't work...(makes sad face)

Lots more questions than answers now.  I guess the biggest one is where is that 4 coming from.

Putting that aside for a second, if this is Unchangeableâ„¢ (cringe), it looks like there's a path out using this NWNX plugin.  The idea being one dupes the weapon base item types to cover for the 4-color limit and is still able to tie the duped weapon base item types to feats appropriate to the original weapon base item type.  This would be an escape hatch if you wind up with more weapon appearances than you can account for with you weapon model * weapon color variations.

Back to the issue.  I did more searching around and I found that apparently CEP doesn't have a way around this, the 4 color limit, in thier crafting or any crafting pack I could find so far.  So it's gone from something I assumed everyone was doing (but just didn't know how to do myself) to something that hardly anyone/nobody knows how to do.  Would love to be wrong about that.

About the most hopeful thing I can offer up is the thin possibility that ITEM_APPR_WEAPON_COLOR isn't hardcoded, per se, but a derived value, the result of some logic in the program.  Both ITEM_APPR_TYPE_WEAPON_MODEL and ITEM_APPR_TYPE_ARMOR_MODEL appear to work like this.  Anyone who's attempted to add a new 3-part model from scratch knows the circuitous hoop-jumping you have to do to get them to show up in the toolset.  I guess, retreating to my Happy Place, I'd hope that the reason the weapon color (at least) has been so elusive is that modders haven't been meeting whatever requirements to cause the CopyObjectAndModify to behave differently.

I don't have much faith in that, though.  It looks like both ITEM_APPR_TYPE_WEAPON_COLOR and ITEM_APPR_TYPE_ARMOR_COLOR are similar in how their values are static and I haven't yet found an answer to how to change armor color either.

Where those values actually come from...I dunno.  LOL, I just wanna change a damned four to a nine!  '<img'>
               
               

               


                     Modifié par OldTimeRadio, 17 novembre 2012 - 12:19 .
                     
                  


            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Customizing weapons with colors higher than 4, is this on the right track?
« Reply #9 on: November 17, 2012, 02:54:45 am »


               This will get me around the four color limit in the crafting system I want to write. Whether it will benefit others, I don't know.

My thinking is that once a weapon is made, the model will not be modified further. So this will help crafters customize the look of a weapon that they make, but not players that want to adjust the look of a weapon they find. The later has never made any sense to me.

So for the above situation I will do the following:
(1) Create all the aesthetic variations of the various weapon types that I want players to be able to create.
(2) Each of these weapons will be put in a store and deleted from the palette.
(3) Most importantly each of these weapons will have a tag which identifies weapon type, and the model part numbers it uses.
(4) Create functions which enables the increment and decrement of a model part of a weapon. These functions generate a tag based on the specific change, and then get the weapon via tag from the store. Then it copies this weapon into the player's inventory, tags with something appropriate, and destroys the old weapon.
               
               

               
            

Legacy_OldTimeRadio

  • Hero Member
  • *****
  • Posts: 2307
  • Karma: +0/-0
Customizing weapons with colors higher than 4, is this on the right track?
« Reply #10 on: November 17, 2012, 02:58:48 am »


               Now I see what you mean- thanks for the explanation.
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Customizing weapons with colors higher than 4, is this on the right track?
« Reply #11 on: November 17, 2012, 03:01:43 am »


               Do you see why this doesn't work for existing weapons in the PCs posession?

The problem is that you can't copy all the item properties and data from an old weapon to a new using the method I describe. So it isn't a full featured solution. Essentially I'll be adding the properties relevant to the crafting being done, and allow players to customize the look of the weapon, but... am not able to allow modification of the appearance of an existing weapon.
               
               

               
            

Legacy_OldTimeRadio

  • Hero Member
  • *****
  • Posts: 2307
  • Karma: +0/-0
Customizing weapons with colors higher than 4, is this on the right track?
« Reply #12 on: November 17, 2012, 04:43:37 am »


               Your reasoning and the solution make sense, I'm just still hung up on the limitation.  With issues like this, I tend not to advance very far on the "Five Stages of Grieving" scale, heh heh!
               
               

               
            

Legacy_OldTimeRadio

  • Hero Member
  • *****
  • Posts: 2307
  • Karma: +0/-0
Customizing weapons with colors higher than 4, is this on the right track?
« Reply #13 on: November 17, 2012, 10:09:34 pm »


               

Lightfoot8 wrote...
My impression on the linked topic that brought up the question, was that they where reading to much into the limit placed in the comments on the CopyItemAndModify item for the ITEM_APPR_TYPE_WEAPON_COLOR parameter.   I feel that Bioware placed the 1-4 limit in the comments simply because that is how many variants the made for every item,   Since there where no other variants the range for the parameter was 1-4.

I wound up following in Heneusa's testing footsteps and also found there's definitely something going on though, honestly, something like what you were describing is what I was thinking too.  I uploaded a little test kit project so you can check out the behavior, here.

LOL, and I think asinine is the perfect way to describe the behavior, as well! 

See, one of the interesting quirks I came across is that if you have a 5th color (for each top, middle & bottom) and have those new fifth colors set on a model (I used a dagger, too), when you carry out a CopyItemAndModify function to change the Top of the weapon to 5, the model copies fine.  It's changing the Top part from 5 to 5, so that sort of makes sense. As in, no change, so it leaves it alone.

But the bottom and middle parts also remain changed.  Which shows there's some sort of "gate" that CopyItemAndModify is using and if the parts of the model are not being touched, they don't even have to pass through it.  But the setting you want to use does, and that's when it runs into trouble.

There are two other tests whcih might yield useful information: Creating the 5th part for each of the other shapes for the dagger (so every shape has a 5th part) and (maybe) IPGetModifiedWeapon and whether that can be used to circumvent this in some way.  Lexicon says it eventually calls CopyItemAndModify, so I'm guessing not.  Still...

I'm probably not going to attempt the first test any time soon because that requires something like 100+ icons and model parts to test- this would be to see if having the fifth color available to all shapes was what CopyItemAndModify needed in order to consider "5" a valid value to use.

OnEdit: Oh, there may be some impact on this situation from baseitem.2da, but it seems as though it would impact the shapes more than anything else.  I.e. Not the colors.  Tried a number of minrange and maxrange changes, found nothing particularly interesting or helpful.
               
               

               


                     Modifié par OldTimeRadio, 17 novembre 2012 - 10:15 .
                     
                  


            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Customizing weapons with colors higher than 4, is this on the right track?
« Reply #14 on: November 17, 2012, 11:35:31 pm »


               OTR, I believe you are over thinking this.

What you have is a function that you can't see inside, but will take some data.

We know that the function copies an item.
We also know that it can adjust a model/color part of the item.
These seem to work independently because of the following:

When you supply a color value outside the 1-4 range the color part of the model does not change yet at the same time it copies the model and gives it back to you. This occurs regardless of anything about the model, regardless of how many color parts it has, and regardless of what the value of its color part currently is.

I think it is a very safe assumption that the function simply checks to see if the color value supplied in the function call is within the 1-4 range, and if it is not, it ignores it.

Since we can't track down the function and modify it, nor can we find the code which sets a color or model part, we need a different kind of solution. If however we do find the code, then we are set. I would love to find a function which simply sets the color or model part of a weapon. That would be useful. I'm not going to hold my breath though.
               
               

               


                     Modifié par henesua, 17 novembre 2012 - 11:36 .