Stackable Potions / Items

Posts 1–8 of 8 · Page 1 of 1
Stackable Potions / Items
Is anyone in the possestion the code for stackable stuff? (like Prods MOTMG tokens)
Or is there a source released with it?
Would appreciate any hints or actual code.

Thanks
make 10 items, all with the number on top right corner xD
write function in playeruseitem and make it so when you have a token in inv and another token in inv, to stack them, when one is consumed they both disappear and Token with 2 in the top right corner is given to u, now when the Token with 2 in top right corner is in inv and regular single Token is in inv and consumed, they both disappear and Token with 3 in top right corner is given to u, and so on and so on and so on
then once player does that all the way until you have Token 9 and single Token in inv and consume single Token to turn the Token 9 into Token 10, the Token 10 can be consumed for whatever i guess

i dont really play prod so idk what happens when u get 10 xD all i know is that they stack
Quote Originally Posted by cxydsaewq View Post
Is anyone in the possestion the code for stackable stuff? (like Prods MOTMG tokens)
Or is there a source released with it?
Would appreciate any hints or actual code.

Thanks
take the xmls change them them make invswap merge items and ur done (u can do so by checking the item types and then change to another type)
U know the greater hp pot's those stack look at those.
Quote Originally Posted by SeXZeFPS View Post
U know the greater hp pot's those stack look at those.
Nope. Atleast not in my source.
They're just getting less, not actually stackable
i had no other idea so i started doing this lol

im using the <Doses> xml tag for the number in corner, might as well use that since its already there its pretty much the same thing

im gonna make an interactive frame where u can place 2 Single Tokens and click "Stack" and it will put a 2x Token in your inv and delete the 2 single tokens, then if u want to stack it to 3 u will have to put the 2x Token in one of the frames slots and a Single Token in the other frames slot and click Stack to be given the 3x Token, and then when the 3x Token is consumed, you are rewarded with whatever depending on which one it is
these vault ones for example is gonna give you a Vault Chest Unlocker consumable.

posted this because imo its a cooler way to do it rather than just completely copying how prod does it, might as well remake prods features but make it your own a little bit as well this way your server can be different

Quote Originally Posted by cxydsaewq View Post
Is anyone in the possestion the code for stackable stuff? (like Prods MOTMG tokens)
Or is there a source released with it?
Would appreciate any hints or actual code.

Thanks
Darza's does this by making all items a struct:

 
Item Struct

Code:
struct Item
{
    ushort Type;
    byte Count;
    bool Soulbound;
}


The actual count of the item is Item.Count + 1. Aka a count of 0 = 1 item. All items can be stored and sent as an Int32 by sending 2 bytes for the type, 1 byte for the count, and 1 byte for soulbound. The client should then add the text in the corner if the count is greater than 0. The text displays Item.Count + 1 for viewing purposes.

In the XMLs you should define a <MaxStack> element, then change the Swap handler to have something like this:

 
Swap Handler

Code:
Item Item1; // The item from the first slot
Item Item2; // The item from the second slot

byte MaxStack = Item2.Data.MaxStack;
if (Item1.Type == Item2.Type && Item2.Count < MaxStack)
{
    Item2.Count += (byte)(Item1.Count + 1); // Add the two counts together
    if (Item2.Count > MaxStack) // If the counts exceed the MaxStack then fill one slot, and put the extra in the other slot
    {
        Item1.Count = (byte)(Item2.Count - MaxStack - 1);
        Item2.Count = MaxStack;
    }
    else
    {
        Item1 = Item.Blank; // Item.Blank means no item, or an empty slot
    }

    Item _Temp = Item1;
    Item1 = Item2;
    Item1 = _Temp;
}


This does have some limits. The count can only go up to 255. You can change the count to an Int16/short if you want, and remove the soulbound data to have a larger count ceiling.

This code will not plug and play into your source though. You'll need to take the concept from it and apply it accordingly to yours.
Quote Originally Posted by Juix View Post
Darza's does this by making all items a struct:

 
Item Struct

Code:
struct Item
{
    ushort Type;
    byte Count;
    bool Soulbound;
}


The actual count of the item is Item.Count + 1. Aka a count of 0 = 1 item. All items can be stored and sent as an Int32 by sending 2 bytes for the type, 1 byte for the count, and 1 byte for soulbound. The client should then add the text in the corner if the count is greater than 0. The text displays Item.Count + 1 for viewing purposes.

In the XMLs you should define a <MaxStack> element, then change the Swap handler to have something like this:

 
Swap Handler

Code:
Item Item1; // The item from the first slot
Item Item2; // The item from the second slot

byte MaxStack = Item2.Data.MaxStack;
if (Item1.Type == Item2.Type && Item2.Count < MaxStack)
{
    Item2.Count += (byte)(Item1.Count + 1); // Add the two counts together
    if (Item2.Count > MaxStack) // If the counts exceed the MaxStack then fill one slot, and put the extra in the other slot
    {
        Item1.Count = (byte)(Item2.Count - MaxStack - 1);
        Item2.Count = MaxStack;
    }
    else
    {
        Item1 = Item.Blank; // Item.Blank means no item, or an empty slot
    }

    Item _Temp = Item1;
    Item1 = Item2;
    Item1 = _Temp;
}


This does have some limits. The count can only go up to 255. You can change the count to an Int16/short if you want, and remove the soulbound data to have a larger count ceiling.

This code will not plug and play into your source though. You'll need to take the concept from it and apply it accordingly to yours.
Thanks!
Reading your post reminded me that SD has itemdata, I'll just try to add it that way.
Also, the way you explain things really is extraordinary, very good
Posts 1–8 of 8 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?