(FIXED) Cloak Exchanger

For in-game support requests, and bug reports.
User avatar
Li'l Rose
Posts: 142
Joined: Thu Apr 09, 2015 8:19 pm

(FIXED) Cloak Exchanger

Post by Li'l Rose » Tue Dec 01, 2015 2:53 am

The cloak exchanger seems to be bugged. It takes my equipped cloak, and puts a new cloak in my inventory. The new cloak is the same design as the old clock. Not sure if this was intended, but since it is in Signe's dressing room, I imagine it is supposed to change the cloak design. However it is not doing that.

User avatar
Li'l Rose
Posts: 142
Joined: Thu Apr 09, 2015 8:19 pm

Re: Cloak Exchanger

Post by Li'l Rose » Tue Dec 01, 2015 3:11 am

Also is it possible you could slide the carpet a little so that the models stand on the floor? The carpet makes it hard to see the options for shoes.

Thank you Tara.

User avatar
tarashon
Posts: 857
Joined: Sun Jan 11, 2015 6:27 pm

Re: Cloak Exchanger

Post by tarashon » Tue Dec 01, 2015 10:02 am

Howdy Rose :)

I have completely removed the cloak exchanger. It was an import we hoped would work but it didn't and it being there has no purpose except risking people loosing magical cloaks...

As for the carpet I double checked but alas...

The thing is the tileset makes the natural floor sand and if i lower the marblefloor placeable even 0.01 the sand starts to shine through. And similarly if I lower the carpet even 0.01 the marble shines through... sorry !


/tara

User avatar
Li'l Rose
Posts: 142
Joined: Thu Apr 09, 2015 8:19 pm

Re: Cloak Exchanger

Post by Li'l Rose » Tue Dec 01, 2015 11:05 am

What I had meant for the carpet was to just slide it away from the models, not to lower it.

For the cloak exchanger. On the advanced tab of the placeable, set the starting position to deactivated, then try this script in the on used slot.

Code: Select all

#include "x2_inc_itemprop"

void _CopyProps(object oOld, object oNew)
{
    if (GetIsObjectValid(oOld) && GetIsObjectValid(oNew))
    {
        itemproperty ip = GetFirstItemProperty(oOld);
        while (GetIsItemPropertyValid(ip))
        {
            AddItemProperty(DURATION_TYPE_PERMANENT,ip,oNew);

            ip = GetNextItemProperty(oOld);
        }
    }
}

object MyDyeArmor(object oItem, int nColorType, int nColor)
{
    object oRet = CopyItemAndModify(oItem,ITEM_APPR_TYPE_ARMOR_COLOR,nColorType,nColor,TRUE);
    if (GetIsObjectValid(oRet))
        DestroyObject(oItem);   // remove old item
    else
        oRet = oItem;           // failed, just return the original

    return oRet; //return new item
}

void main()
{

  object oPC = GetLastUsedBy();
  object oCloak = GetItemInSlot(INVENTORY_SLOT_CLOAK,oPC);

  // if cloak in cloak slot
  if (GetIsObjectValid(oCloak) && GetIsObjectValid(oPC))
  {
    string sResRef = GetResRef(oCloak);
    string sName = GetName(oCloak);
    string sTag = GetTag(oCloak);       // So we can set the tag on the new cloak later (Foy 09/07)
    string sNewResRef;
    int iModelNum;         // 00=invisible, 1-14 no wings, 15-28 wings
    int iColor;
    int iWingType;
    int iMaxModelNum = 28;      // to support non-CEP module set this to 14
    int iMinModelNum = 0;       // to support non-CEP module set this to 1 (Foy 09/07)

    // If we have a resref.
    if (sResRef != "")
    {

        // Comment this section out if using an item instead of a placeable
        PlaySound("as_sw_lever1");
        ActionPlayAnimation (ANIMATION_PLACEABLE_ACTIVATE);
        ActionPlayAnimation (ANIMATION_PLACEABLE_DEACTIVATE);

        // First find out if the PC has wings
        if (GetCreatureWingType(oPC) == CREATURE_WING_TYPE_NONE)
            iMaxModelNum = 14;

        // Instance the invisible IP work container
        object oContainer = IPGetIPWorkContainer();

        // Build the new ResRef
        if (GetStringLeft(sResRef,9) != "basecloak")
            sNewResRef = "basecloak0" + IntToString(iMinModelNum);
        else
        {
            iModelNum = StringToInt(GetStringRight(sResRef,2)) + 1;
            if (iModelNum < iMinModelNum || iModelNum > iMaxModelNum)   
                iModelNum = iMinModelNum;                               
         
            if (iModelNum < 10)
                sNewResRef = "basecloak0" + IntToString(iModelNum);
            else
                sNewResRef = "basecloak" + IntToString(iModelNum);
        }

        // Create new cloak template in invisible container
        object oNew = CreateItemOnObject (sNewResRef,oContainer);

        if (GetIsObjectValid(oNew))
        {

            SendMessageToPC(oPC,"New Appearance will be " + GetName(oNew) + "");

            // remove all permanent item properties present on the template cloak
            // Base Cloaks don't have properties but just in case...
            IPRemoveAllItemProperties(oNew,DURATION_TYPE_PERMANENT);

            // instead, add the item properties from the current cloak
            _CopyProps(oCloak,oNew);

            // sync colors from old cloak
            iColor = GetItemAppearance(oCloak, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_COLOR_LEATHER1);
            oNew = MyDyeArmor(oNew, ITEM_APPR_ARMOR_COLOR_LEATHER1, iColor);
            iColor = GetItemAppearance(oCloak, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_COLOR_LEATHER2);
            oNew = MyDyeArmor(oNew, ITEM_APPR_ARMOR_COLOR_LEATHER2, iColor);
            iColor = GetItemAppearance(oCloak, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_COLOR_CLOTH1);
            oNew = MyDyeArmor(oNew, ITEM_APPR_ARMOR_COLOR_CLOTH1, iColor);
            iColor = GetItemAppearance(oCloak, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_COLOR_CLOTH2);
            oNew = MyDyeArmor(oNew, ITEM_APPR_ARMOR_COLOR_CLOTH2, iColor);
            iColor = GetItemAppearance(oCloak, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_COLOR_METAL1);
            oNew = MyDyeArmor(oNew, ITEM_APPR_ARMOR_COLOR_METAL1, iColor);
            iColor = GetItemAppearance(oCloak, ITEM_APPR_TYPE_ARMOR_COLOR, ITEM_APPR_ARMOR_COLOR_METAL2);
            oNew = MyDyeArmor(oNew, ITEM_APPR_ARMOR_COLOR_METAL2, iColor);

            // sync other properties
            SetName(oNew,sName);
            SetIdentified(oNew,GetIdentified(oCloak));
            SetPlotFlag(oNew,GetPlotFlag(oCloak));
            SetStolenFlag(oNew,GetStolenFlag(oCloak));
            SetItemCursedFlag(oNew,GetItemCursedFlag(oCloak));
            SetDroppableFlag(oNew,GetDroppableFlag(oCloak));
            SetItemCharges(oNew, GetItemCharges(oCloak));       

            // create a copy of the new cloak on the player
            // Change from CopyItem to copy object so we can set the tag at the same time
            // object oNewCloak = CopyItem(oNew, oPC, TRUE);
            object oNewCloak = CopyObject(oNew, GetLocation(oPC), oPC, sTag);

            // destroy the old cloak
            DestroyObject(oCloak);

            // destroy the copy template to prevent cluttingring up the item property container
            DestroyObject(oNew);

            // force player to equip new cloak.
            // Put in a pause in case the pc has wings
            // There seems to be some sort of bug where the wings disappear if you exchange too quickly
            AssignCommand(oPC,ClearAllActions(TRUE));
            DelayCommand(1.00,AssignCommand(oPC,ActionEquipItem(oNewCloak, INVENTORY_SLOT_CLOAK)));

        }
        else
        {
            SendMessageToPC(oPC,"Failed to create item with resref " + sResRef + "");
            return;
        }

    }
    else
    {
        // error message, we need a resref to update the cloak, if no resref exist, we can't do that.
        SendMessageToPC(oPC,"Could not convert " + GetName (oCloak) + ", this can only be done by the module author");
        return;
    }

  }
  else
  {
     // Inform player of no cloak present
     SendMessageToPC(oPC,"You need to equip the cloak you want to convert before running the script");
  }
}

User avatar
tarashon
Posts: 857
Joined: Sun Jan 11, 2015 6:27 pm

Re: Cloak Exchanger

Post by tarashon » Tue Dec 01, 2015 1:39 pm

Thx a bunch. really hope this works as it is so nice to be able to customize ones cloaks also :)

Both carpet moving and new script implemented !

/tara

User avatar
tarashon
Posts: 857
Joined: Sun Jan 11, 2015 6:27 pm

Re: Cloak Exchanger

Post by tarashon » Tue Dec 01, 2015 1:49 pm

Appearantly not working with the cloaks.

Get message like "failed to create item with resref CEP010" , or something similar.

*EDIT*

was wondering if this has something to do with the invisible chest in the script. maybe i need some item to spawn in, to be present in the toolset ?

If so maybe we can just alter the script so it uses another chest - like the one already place unreachable for players ?

/tara

BenevolentDevil
Posts: 360
Joined: Sun Oct 18, 2015 3:37 am

Re: Cloak Exchanger

Post by BenevolentDevil » Tue Dec 01, 2015 9:19 pm

Look in your list, and see if there is a clothing builder chest , I think thats what is needed.

User avatar
tarashon
Posts: 857
Joined: Sun Jan 11, 2015 6:27 pm

Re: Cloak Exchanger

Post by tarashon » Tue Dec 01, 2015 9:23 pm

Hmm i only got this script from the post benevolent, so as for me I have no items, and cant see any in the script here except the invisible thingi...

/tara

BenevolentDevil
Posts: 360
Joined: Sun Oct 18, 2015 3:37 am

Re: Cloak Exchanger

Post by BenevolentDevil » Tue Dec 01, 2015 9:44 pm

hmm, like I said, I might have linked you to the wrong ( outdated) version.

The bad part ...
the "new version" has been removed from the vault , I think because Project-Q folks made it, and between them and CEP folks, a good bit of ueful tools are being removed, because they are being merged into their hak systems. ( It's almost like , in oder to get the goodstuff , you MUST get the latest large haks anymore. , like even most of AmethystDragon's scripts , can only be gotten from the Aerilith haks now. < Funneling players left in NWN, to their PW, instead of letting everyone enjoy PWs elsewhere, ... almost. )


However, when I get free time, I bet I could figure out the cloak change scripts ... all one has to do, is point to the 2da appearance numbers of each "item" , and allow for dyes ... in theory, that shouldn't be that hard. The difficult part for me, would be to "copy" item properties to said changed cloak appearances.

Hopefully Rose will know more on that?

I'm not a great scripter by any means, and I never understood WHY bioware/aurora engine made doing things like changing appearances so complex and hard, or hidden ... , as it's only aesthetic appearance changes. ( like why do default NWN crafting, cost money to change a look? Seems a bit autistic in my opinion, lol.

User avatar
tarashon
Posts: 857
Joined: Sun Jan 11, 2015 6:27 pm

Re: Cloak Exchanger

Post by tarashon » Tue Dec 01, 2015 9:56 pm

Well look at the script Rose, added up this thread and see if you can figure out whats wrong with it :)

As for devellopers (maybe) trying to get players to their own PWs... who can blame them ??

/tara

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests