Results 1 to 8 of 8
  1. #1
    cxydsaewq's Avatar
    Join Date
    Jan 2014
    Gender
    male
    Posts
    954
    Reputation
    25
    Thanks
    1,341
    My Mood
    Amazed

    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

  2. #2
    Riigged's Avatar
    Join Date
    Jan 2013
    Gender
    male
    Location
    no
    Posts
    3,846
    Reputation
    401
    Thanks
    10,254
    My Mood
    Devilish
    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

     








  3. #3
    Slendergo's Avatar
    Join Date
    Nov 2014
    Gender
    male
    Posts
    382
    Reputation
    17
    Thanks
    250
    My Mood
    Inspired
    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)

  4. #4
    SeXZeFPS's Avatar
    Join Date
    Jan 2015
    Gender
    male
    Location
    In your wardrobe
    Posts
    598
    Reputation
    10
    Thanks
    637
    My Mood
    Asleep
    U know the greater hp pot's those stack look at those.

  5. #5
    Riigged's Avatar
    Join Date
    Jan 2013
    Gender
    male
    Location
    no
    Posts
    3,846
    Reputation
    401
    Thanks
    10,254
    My Mood
    Devilish
    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


     








  6. #6

  7. #7
    Juix's Avatar
    Join Date
    Oct 2012
    Gender
    male
    Posts
    249
    Reputation
    59
    Thanks
    3,196
    My Mood
    Tired
    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:

     

    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:

     

    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.
    Last edited by Juix; 09-23-2017 at 02:14 AM.

  8. The Following User Says Thank You to Juix For This Useful Post:

    MiniguyBrendan (09-27-2017)

  9. #8
    cxydsaewq's Avatar
    Join Date
    Jan 2014
    Gender
    male
    Posts
    954
    Reputation
    25
    Thanks
    1,341
    My Mood
    Amazed
    Quote Originally Posted by Juix View Post
    Darza's does this by making all items a 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:

     

    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

Similar Threads

  1. [WTB] [Shop Owner][Donator][50+ Vouches] Buying RoTMG Potions/Items (PayPal/Skrill/BTC)
    By King Tijn 2 in forum Realm of the Mad God Selling / Trading / Buying
    Replies: 183
    Last Post: 06-19-2017, 01:03 AM
  2. [WTS] RealmShop - Cheap - Potions - Items
    By nathan_hh in forum Realm of the Mad God Selling / Trading / Buying
    Replies: 10
    Last Post: 04-02-2015, 01:05 PM
  3. [WTS] [SKINS] [POTIONS] [ITEMS] Alde's Shop
    By Alde. in forum Realm of the Mad God Selling / Trading / Buying
    Replies: 16
    Last Post: 01-31-2015, 02:09 PM
  4. Buying RoTMG Potions/Items [PayPal/UGC]
    By AdrianPvP in forum Realm of the Mad God Selling / Trading / Buying
    Replies: 0
    Last Post: 04-04-2014, 01:39 PM
  5. Looking For Potion/Item Supplier
    By Pegboard Nerds in forum Realm of the Mad God Selling / Trading / Buying
    Replies: 5
    Last Post: 03-12-2014, 05:51 PM