BioWare Forums: View Post For Code Display


Vous examinez un unique message. Merci de ne pas l'extraire de son contexte.
Lisez la totalité du fil de discussion: 1.68 is now available

Auteur 1.68 is now available
John Bye Posted: vendredi, 01 septembre 2006 07:13
Quote: tiamiat - "OOOO looking forward to it. Been pointing lots of peeps interested in setting up tailors to craft cloaks to your post on the Beta 3 threads "
Ok, the new version of Good vs Evil II with cloak customisation support is available here now.

As noted before, it works around the CopyItemAndModify bug in v1.68 by spawning an entirely new cloak with the appropriate model number and then copying all the colours and item enchantments from the old cloak to the new one, along with its name. Unfortunately you do lose the cloak's description in the process, but everything else should be intact hopefully.

The relevant code is -

NWScript:
object MatchItem(object oItem, object oDonor, int nType, int nIndex)
{
    int nValue = GetItemAppearance(oDonor,nType,nIndex);
    object oNew = CopyItemAndModify(oItem,nType,nIndex,nValue);
    DestroyObject(oItem);
    return oNew;
}

object ModifyCloakModel(object oItem, int nNewValue)
{
    // Bodge for CopyItemAndModify not working on cloak appearance in NWN v1.68
    // Create a new cloak with the correct model
    object oNewItem = CreateItemOnObject("g_ar_accbodge" + IntToString(nNewValue),GetPCSpeaker());
    // Copy across all the colours for it
    oNewItem = MatchItem(oNewItem,oItem,ITEM_APPR_TYPE_ARMOR_COLOR,ITEM_APPR_ARMOR_COLOR_CLOTH1);
    oNewItem = MatchItem(oNewItem,oItem,ITEM_APPR_TYPE_ARMOR_COLOR,ITEM_APPR_ARMOR_COLOR_CLOTH2);
    oNewItem = MatchItem(oNewItem,oItem,ITEM_APPR_TYPE_ARMOR_COLOR,ITEM_APPR_ARMOR_COLOR_LEATHER1);
    oNewItem = MatchItem(oNewItem,oItem,ITEM_APPR_TYPE_ARMOR_COLOR,ITEM_APPR_ARMOR_COLOR_LEATHER2);
    oNewItem = MatchItem(oNewItem,oItem,ITEM_APPR_TYPE_ARMOR_COLOR,ITEM_APPR_ARMOR_COLOR_METAL1);
    oNewItem = MatchItem(oNewItem,oItem,ITEM_APPR_TYPE_ARMOR_COLOR,ITEM_APPR_ARMOR_COLOR_METAL2);
    itemproperty iProp = GetFirstItemProperty(oItem);
    while (GetIsItemPropertyValid(iProp))
        {
        if (GetItemPropertyDurationType(iProp) == DURATION_TYPE_PERMANENT)
            {
            AddItemProperty(DURATION_TYPE_PERMANENT,iProp,oNewItem);
            iProp = GetNextItemProperty(oItem);
            }
        }
    SetName(oNewItem,GetName(oItem));
    return oNewItem;
}


All you need to do is export the blueprints for the cloaks (which are all in the custom armour -> clothing palette) and import them into your module, then copy and paste the code above into the top of your script and call ModifyCloakModel, passing in oItem (the old cloak) and nNewValue (the model number you want the new cloak to have). It should return a spangly new cloak with the model number you specified and all the colours and enchantments from the old cloak.

If your script isn't triggered from a conversation you'll need to change that GetPCSpeaker() to whatever's appropriate for your script.

Any other problems, let me know.
_________________
John "Gestalt" Bye
Good vs Evil - lead an army in an epic battle between good and evil

This post taken from the BioWare Forums
Powered by BioBoards Version 3.00.0 10.1.12.22
Please read our Copyright and Trademark Information