Skip to content

How do I make custom colours take priority over different equipment selection? [NPC Mod Question]

IcecreamtubIcecreamtub Member Posts: 547
edited June 2017 in General Modding
Just wondering how/if this is achieved so that I don't have to make custom starter armors that are only good for 2 seconds upon arrival to the party.



Old photo, I've fixed a lot of the weird colours in the obvious places since here. Just showcasing what I mean.

Comments

  • chimericchimeric Member Posts: 1,163
    edited June 2017
    I'm not quite sure what you mean, but colors are set with the Set Color (7) opcode in the properties of items. They override characters' own colors when they are donned. However, for non-party NPC (enemies, monsters, commoners...) you can go to the CRE files and include an Effect that applies custom coloring where you want it and overrides items' colors in turn. This will normally be the same opcode 7 again, targeted at Self, non-magical and with Timing mode 9.

    In short, effects apply in this order:

    Regular creature colors (from Major, Minor etc. in the CRE file)
    Item colors
    Effects in the CRE file

    I suppose you could also edit party NPC files to the same end, but party NPC are more complicated, so I'm not sure. Also everything I'm writing here may not suit your purposes, if it's a party mod that you have in mind. The reason? Party members are directly under control of the player, their inventories are accessible and they are going to take off and put on armors all the time. Whatever overriding the Effect in the CRE file does is probably going to be overridden in turn when they take off the old armor and put on something else - or even that same piece. What you would want is some kind of effect that triggers automatically every time a character reequips and empties a bucket of paint on him, but I doubt that's possible.

    Otherwise, for those other NPC who won't get to strip and will appear in the same suit from the moment they are spawned to the time they die, the above works. But sometimes there are problems with opcode 7 applied directly from within a CRE, so if you want to apply several color changes really instantly you need to create a spell, an SPL, instead, with no name (-1), and put a Cast Spell Effect in the CRE file - again Self-targeted, timing mode 9 etc. Casting speed here must be "Cast instantly." Then you stack the color changes you desire - and any other changes, like stat adjustments, avatar swaps, custom glows etc. - in that spell. The spawning creature will appear already under the effects... Only keep in mind that recolors inside a CRE are pure cosmetics, they don't change the actual item colors (because those are properties of the ITM file on the hard drive). So if you turn a sword blade black this way and a curious player kills the creature to check out that cool sword, picks it up and equips it, he's not going to see a black blade.

    P.S. A while ago I made a prototype mod that diversified some creatures' colors this way, cosmetically. I wanted to give standard monsters and commoners a more varied appearance. That's set aside for now, but later I made another file to diversify actual armor colors instead of these effects on top. I wanted several different shades for the standard leather armor, for instance, that so many creatures wear. It isn't realistic and it's boring to have the same color of hide and metal, unless they are cloning whatever creatures are being skinned for them. But how to change actual ITMs, when you can't do anything to the files from inside the engine?

    Let me describe to you what I did, in case you find it useful for your purposes. I edited the standard file for leather, LEAT01, to cast a spell (use EFF) on the wearer if he is NOTGOOD (that's one of the EA values) when that armor is equipped. Since all party members and friendlies are GOODCUTOFF, the effect doesn't apply to them. Everyone else - non-party NPC, enemies... - is subject to a custom spell, which instantly - "Cast instantly," the player won't even know - replaces this leather with another suit from a random list. That list has several positions with the Create Item In Slot (opcode 143), pointing to different resources - leathers of custom but realistic hues. This way the original, LEAT01, became only a placeholder for leather armor. Whenever a non-party creature spawned wearing leathers, the placeholder would get phased out for a random suit. The suits had all the same stats as the original except for colors.

    But that's not all I had to do. I wanted the party to get these nice random leathers as well, but I couldn't use Create Item In Slot with a creature with an inventory, because when an item put on the paperdoll attempts to replace itself right there, before the player's eyes, the game crashes. That's why I had to take a detour through NOTGOOD and restrict that effect to non-party NPC. For the party I had to find another solution, and I came up with an addition to baldur.bcs, which read:

    IF

    HasItem("LEAT01",Player1)

    THEN

    (TakeItemReplace with a suit from the list, random Response chances)

    This was repeated for Players 2 to 6. The idea was that any time a party member got hold of the placeholder armor, got it in his inventory, the engine would quietly whisk it away and substitute a custom armor looking exactly the same, with the same icon, but with different properties. And here is the sweet bit modders will appreciate: I realized that there is NO WAY the party can obtain an item except by first passing it through the inventory. Do you get it? Even if they loot a body, they have to click on the leather armor on the corpse to pick it up, then walk away or close the window, then go to the inventory screen. But the engine is always faster. No matter how quickly the player goes about those tasks, the engine is going to take away and replace the armor before he looks in the backpack next. And in actuality the party would never have found the game-crashing placeholder suit, LEAT01, on a body, because the monster would have tried to wear it - so only a custom suit would end up as loot. All I had to do was put that script bit in baldur.bcs to take care of LEAT01 bought from stores or found in chests or given as a reward.

    I made a working demo and I would have gone on to repeat this for chain mail, plate and so on... in principle you could even do it for things like wands, so they would end up in the inventory with a random number of charges once bought... but I got distracted by other ideas. Still, you might be able to use this technique for your armors to conjure exactly the suits you need.
  •  TheArtisan TheArtisan Member Posts: 3,277
    You can do it two ways, using NearInfinity/DLTCEP or whatever program best suits you: the first is flat out preventing any color overrides via a Protection from Opcode effect.




    The downside is that this affects all colors, including weapons and helmets.

    The second is manually overriding individual colours using the Set Character colours by Palette opcode:




    Here you can see Khalid wearing black metallic armor but his weapon and helmet retain their normal look.
  • IcecreamtubIcecreamtub Member Posts: 547
    Thank you for your uhh... Incredibly confusing essay of very thorough explanation x_x @chimeric

    Thanks @Artemius_I ! This is exactly what I was looking for <3
  • chimericchimeric Member Posts: 1,163
    If you're going with the NI method and protection from Set Color, you'll want to extend this protection to all party NPC, including custom NPC, not just the official throng. Instead of editing files in NI, you should make a custom nameless instantly-cast spell that gives this immunity, call it something, then extend baldur.bcs with the following code:

    IF

    Global("MAIN_RECOLORED","GLOBAL",0)

    THEN

    RESPONSE #100

    ApplySpellRES("custom",Player1)
    SG("MAIN_RECOLORED",1)
    Wait(1)
    Continue()
    END

    IF
    Joins(Player2)

    THEN

    ApplySpellRES("custom",Player2)
    Wait(1)
    Continue()
    END

    (repeat for Players3 to 6)

    This way any joining NPC will be immune to the color changes.
  • IcecreamtubIcecreamtub Member Posts: 547
    I understand your desire to help but, outside of your original explanations, I don't understand any of those text lines. I haven't started fiddling with oppcodes yet and I have only just (finally) started my beginner's adventure through WeiDu.
Sign In or Register to comment.