Aller au contenu

Photo

Appearance changing script


  • Veuillez vous connecter pour répondre
7 réponses à ce sujet

#1
Necroscope

Necroscope
  • Members
  • 494 messages
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".

#2
WhiZard

WhiZard
  • Members
  • 1 204 messages
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.

#3
Necroscope

Necroscope
  • Members
  • 494 messages

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:

#4
WhiZard

WhiZard
  • Members
  • 1 204 messages

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 .


#5
Necroscope

Necroscope
  • Members
  • 494 messages
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_*

#6
Necroscope

Necroscope
  • Members
  • 494 messages
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?

#7
WhiZard

WhiZard
  • Members
  • 1 204 messages

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 .


#8
WhiZard

WhiZard
  • Members
  • 1 204 messages
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)