Aller au contenu

Photo

Remove quantity in inventory


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

#1
Jereniva

Jereniva
  • Members
  • 114 messages

I feel like I'm overthinking this...

How do you tell how many of an item is in the PC's inventory? 

 

I want to reduce the quantity the PC has by one, so if the item to be take is an arrow, and PC has a stack of 30, the PC loses one and now has stack of 29. PC could have 4 stacks of arrows, though.

 

What is simplest way to take an arrow from the PC?



#2
kevL

kevL
  • Members
  • 4 052 messages
in conversation? 'ga_destroy_item' should work okay ...

but from an event script it's a bit tricker because unfortunately the function in 'nw_i0_plot' TakeNumItems() doesn't work with stacks. I have a fix and if you need it (want to test it), just say.
  • Jereniva aime ceci

#3
Jereniva

Jereniva
  • Members
  • 114 messages

I found functions for SetItemStackSize and GetItemStackSize, I was going to look at these, but I will also look at your code if you don't mind. Thank you



#4
kevL

kevL
  • Members
  • 4 052 messages
// Shadooow, http://forum.bioware.com/topic/246962-community-patch-discussion-and-development-thread/?p=16428667
void TakeNumItems(object oTarget, string sItem, int nNumItems)
{
    int nCount = 0;

    object oItem = GetFirstItemInInventory(oTarget);
    while (GetIsObjectValid(oItem) && nNumItems > 0)
    {
        if (GetTag(oItem) == sItem)
        {
            nCount = GetItemStackSize(oItem);
            if (nCount > 1 && nCount > nNumItems) // 1.71: proper stacked items handling
            {
                SetItemStackSize(oItem, nCount - nNumItems);
                return;
            }
            else
            {
                ActionTakeItem(oItem, oTarget);
                nNumItems -= nCount;
            }
        }

        oItem = GetNextItemInInventory(oTarget);
    }
}


#5
Jereniva

Jereniva
  • Members
  • 114 messages

in conversation? 'ga_destroy_item' should work okay ...

but from an event script it's a bit tricker because unfortunately the function in 'nw_i0_plot' TakeNumItems() doesn't work with stacks. I have a fix and if you need it (want to test it), just say.

 

I tested with ga_destroy_item and either it doesn't work, or I used it wrong.

I put parameters of the tag, the quantity to be destroyed (I put 1) and a 1 for check the whole party. It took 49 of the stack of 50 and left me with 1 !

 

EDIT, my mistake, the Misc Small Item can only stack 1 high. Even though I put Quantity of 50 in the properties, and PC could pick up the stack of 50 and in to inventory as 50, this limitation of stack size of 1 must come in to place in that ga_destroy_item code.

The Max Stack size of a base item is not editable in item properties, so I chose Misc Stackable with a Max stack size of 10, with Quantity of 10 and this part worked correctly.



#6
kevL

kevL
  • Members
  • 4 052 messages
sounds a bit like the behavior i got when I reduced max_stacksize of arrows from 99 to 24.

So, sometimes i still receive bunches of arrows as 99, and have to manually mouse them down into multiple stacks with max 24. But I haven't tried running algorithms like these on illegal stacks - although i had my first stack overflow yesterday (hehe) - anyway, something to be wary of ....