Author Topic: Appearance changing script  (Read 336 times)

Legacy_Necroscope

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
Appearance changing script
« on: April 28, 2013, 01:43:26 pm »


               I want make a simple next/previous armor/clothing color changing script (through dialogue, of course).

Here's how it works; let's say I want so dye "leather1" layer of my armor:
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
(change color/armor)

void main()
{
  object oPC = GetPCSpeaker();
  SetLocalInt(oPC, "ItemToDye", INVENTORY_SLOT_CHEST);
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
(change color/armor/leather1)

void main()
{
    object oPC = GetPCSpeaker();

    SetLocalInt(oPC, "MaterialToDye", ITEM_APPR_ARMOR_COLOR_LEATHER1);
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
(change color/armor/leather1/next)

#include "nekr_lu_include"

void main()
{
  object oPC = GetPCSpeaker();
  Color(oPC,0);
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
(change color/armor/leather1/previous)

#include "nekr_lu_include"

void main()
{
  object oPC = GetPCSpeaker();
  Color(oPC,1);
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include "nekr_lu_include"

void Color(object oPC, int nMode)
{
  int nSlot = GetLocalInt(oPC, "ItemToDye");
  object oItem = GetItemInSlot(nSlot, oPC);
  int nMatDye = GetLocalInt(oPC, "MaterialToDye");
  int nCurrColor = GetItemAppearance(oItem, ITEM_APPR_TYPE_ARMOR_COLOR, nMatDye);
  object oNew;

  int nBaseType = GetBaseItemType(oItem);
  int nMin = 0;
  int nMax = 175;

  do
  {
    if(nMode == 0) nCurrColor++;
    else nCurrColor--;
    if(nCurrColor > nMax) nCurrColor = nMin;
    if(nCurrColor < nMin) nCurrColor = nMax;

    oNew = CopyItemAndModify(oItem, ITEM_APPR_TYPE_ARMOR_COLOR, nMatDye, nCurrColor, TRUE);
  }
  while(!GetIsObjectValid(oNew));

  if(GetIsObjectValid(oNew))
  {
    SetCommandable(TRUE, oPC);
    DestroyObject(oItem);
    AssignCommand(oPC, ClearAllActions(TRUE));
    AssignCommand(oPC, ActionEquipItem(oNew, nSlot));
  }
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Now the problem is: while it works for "leather1", "leather2", "metal1", "metal2", for some reason it doesn't work for "cloth1" and "cloth 2".
               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Appearance changing script
« Reply #1 on: April 28, 2013, 04:35:39 pm »


               While I cannot immediately detect any problems in the above script, your issue is with cloth not leather.

First possibility is that cloth works perfectly well, but does not visibly show on the given armor (so adjusting the appearance does nothing as far as you can see).

Second possibility is that you have a scripted confirmation that is out of synchronization with the implementation (e.g. you change cloth 1 but check cloth 2 to see if a change is made).

Third possibility is that the function does not support cloth changes.  Though I am pretty sure that this is not the case as I have used standard cloth dyes effectively.
               
               

               
            

Legacy_Necroscope

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
Appearance changing script
« Reply #2 on: April 28, 2013, 05:07:31 pm »


               

WhiZard wrote...
First possibility is that cloth works perfectly well, but does not visibly show on the given armor (so adjusting the appearance does nothing as far as you can see).

These are some changes I've made using the script: http://i.imgur.com/lUPk8Lk.jpg
The pitch black layers are "cloth1"/cloth2" .

WhiZard wrote...
Third possibility is that the function does not support cloth changes.

I'm sure it does as I've seen in practive a very similar script to the one I'm trying to make.

WhiZard wrote...
Second possibility is that you have a scripted confirmation that is out
of synchronization with the implementation (e.g. you change cloth 1 but
check cloth 2 to see if a change is made).

I've checked everything several dozen of times with pen and paper and I'm clueless.


But now something totally FUBAR; I deleted the whole "void Color" leaving it blank:
void ColorItem
{
}

And the exact same thing happens - leather and metal layers do work, cloth layers do not.':blink:'
               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Appearance changing script
« Reply #3 on: April 28, 2013, 06:01:57 pm »


               

Necroscope wrote...

But now something totally FUBAR; I deleted the whole "void Color" leaving it blank:
void ColorItem
{
}

And the exact same thing happens - leather and metal layers do work, cloth layers do not.':blink:'


Add
void main(){}

to the include, compile it then remove the void main(){} and recompile it and all scripts that include it.  Includes do not report all compilation problems, and it is likely the script being executed is different from the one you are modifying even though the name is the same.
               
               

               


                     Modifié par WhiZard, 28 avril 2013 - 05:03 .
                     
                  


            

Legacy_Necroscope

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
Appearance changing script
« Reply #4 on: April 28, 2013, 06:46:01 pm »


               I recompiled all the scripts and it works! Looks like some old code stored somewhere on the lower Layers of the Abyss was the culprit.

Anyway, thx man!

Btw, how to get a cloak appearance (I know it's possible since 1.68)? For armor parts it's:

iType: ITEM_APPR_TYPE_ARMOR_MODEL
iIndex: ITEM_APPR_ARMOR_MODEL_*
               
               

               
            

Legacy_Necroscope

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-0
Appearance changing script
« Reply #5 on: April 29, 2013, 03:19:31 pm »


               Ok, the last problem (got everything else working):

void RemakeShield(object oPC, int nMode)
{
 int nSlot = INVENTORY_SLOT_LEFTHAND;
 object oItem = GetItemInSlot(nSlot, oPC);
 int nCurrApp = GetItemAppearance(oItem, ITEM_APPR_TYPE_SIMPLE_MODEL, 0);
 object oNew;

 int nBaseType = GetBaseItemType(oItem);
 int nMin = StringToInt(Get2DAString("baseitems", "MinRange", nBaseType));
 int nMax = StringToInt(Get2DAString("baseitems", "MaxRange", nBaseType));

 do
 {
   if(nMode == 0) nCurrApp++;
   else nCurrApp--;
   if(nCurrApp > nMax) nCurrApp = nMin;
   if(nCurrApp < nMin) nCurrApp = nMax;

   oNew = CopyItemAndModify(oItem, ITEM_APPR_TYPE_SIMPLE_MODEL, 0, nCurrApp, TRUE);
 }

The script cycles through all the "_SIMPLE_MODEL" appearances:
http://i.imgur.com/W2GAsKC.jpg

How to restrict it to the base item type appearances?
               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Appearance changing script
« Reply #6 on: April 29, 2013, 07:39:02 pm »


               

Necroscope wrote...

Ok, the last problem (got everything else working):

How to restrict it to the base item type appearances?


There is no specific resource devoted to this.  What BioWare did for the armor torso (so as to keep the armor from changing to one of a different base AC) was to construct des_crft_appear.2da so as to loop through the torsos by index.  Depending on how much out of order the shield models are, you may wish to create such a 2da for shields. 
               
               

               


                     Modifié par WhiZard, 29 avril 2013 - 06:41 .
                     
                  


            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Appearance changing script
« Reply #7 on: April 29, 2013, 11:45:48 pm »


               I have looped through shield appearances and each shield type only uses the set of appearances designated for it.  This is somewhat misleading as WCoC introduced many circular large shields that look similar to small shields.  Small shields cannot have the WCoC appearance though.  There are, however gaps between different shield models and if an invalid model is selected the item will still be produced with the corresponding null appearance.

Here are the appearance numbers for shields

Small Shields
11-13, 21-23, 31-33, 41-43
Tower Shields
11-13, 21-23, 31-33, 41-43
51-54 (WCoC tower)

Large shields
11-13, 21-23, 31-33, 41-43
51-56, 61-65 (round large shields)
66-75 (other WCoC shields)