1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  4. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  5. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  6. The results are out! Check them out.
    Dismiss Notice
  7. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  8. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Hidden inventories with little code

Discussion in 'Miscellaneous Tutorials' started by Xonok, Jul 30, 2013.

  1. Xonok

    Xonok

    Joined:
    Mar 27, 2012
    Messages:
    3,040
    Resources:
    8
    Spells:
    3
    Tutorials:
    5
    Resources:
    8
    In my spellbook tutorial I only mentioned the trick and didn't provide a good way to use it.
    Also, I wrote this one before adding this information to the spellbook tutorial.
    Overall, the spellbook tutorial is meant to talk about absolutely everything related to spellbooks and their uses, while this one is for a specific technique and how it can be abused.
     
  2. Zwiebelchen

    Zwiebelchen

    Joined:
    Sep 17, 2009
    Messages:
    6,789
    Resources:
    12
    Models:
    5
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    JASS:
    4
    Resources:
    12
    Nice discovery.

    Let me present you of one awesome application you guys might not have thought about yet, that imho is much more valuable than just having a "secret" inventory that probably is more trouble than it's worth:

    You can use this method to implement a lightweight stacking system that doesn't require the usage of powerups.

    Currently, you can only do a stacking system by using powerups for items on the ground, as only powerups can be picked once the inventory is full. With this secret inventory bug, we now have a tool to allow picking up non-powerup items when the inventory is full, to allow incrementing the charges of existing items.

    So the secret inventory serves as a cache to collect items over the current inventory limit.
     
  3. Xonok

    Xonok

    Joined:
    Mar 27, 2012
    Messages:
    3,040
    Resources:
    8
    Spells:
    3
    Tutorials:
    5
    Resources:
    8
    That is actually quite a good idea. In this case it's definitely necessary to keep the secret part of the inventory full while the main is not, so that the main one can work properly. When the main is filled, an item should be deleted from the secret one and voila, you have a hidden free slot for stacking.

    Btw, back when I made the tutorial I didn't know about the moveitem orders. I'll test them to see if they can be used to shuffle items between inventories.
     
  4. A Void

    A Void

    Joined:
    Mar 29, 2011
    Messages:
    2,498
    Resources:
    10
    Models:
    2
    Spells:
    1
    Tutorials:
    7
    Resources:
    10
    I wonder is it possible to make the "hidden" inventory visible? In GUI?
     
  5. Bannar

    Bannar

    Joined:
    Mar 19, 2008
    Messages:
    3,087
    Resources:
    20
    Spells:
    5
    Tutorials:
    1
    JASS:
    14
    Resources:
    20
    Whats the problem? GUI is just a wrapper around jass functionality.
     
  6. Xonok

    Xonok

    Joined:
    Mar 27, 2012
    Messages:
    3,040
    Resources:
    8
    Spells:
    3
    Tutorials:
    5
    Resources:
    8
    The game only shows the last added inventory, so even though you can interact with the hidden one you can't make it visible.

    However, there are several workarounds.
    1. You can delete items from the hidden one and recreate them in the main one, in order to make it seem like they were moved.
    2. If moveitem orders work, then you can move items from hidden inventory to main one, but not the other way around(unless you drop the item and give it again).
     
  7. Zwiebelchen

    Zwiebelchen

    Joined:
    Sep 17, 2009
    Messages:
    6,789
    Resources:
    12
    Models:
    5
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    JASS:
    4
    Resources:
    12
    That was exactly what I was thinking. To the JASS section we go!
     
  8. Bannar

    Bannar

    Joined:
    Mar 19, 2008
    Messages:
    3,087
    Resources:
    20
    Spells:
    5
    Tutorials:
    1
    JASS:
    14
    Resources:
    20
  9. Xonok

    Xonok

    Joined:
    Mar 27, 2012
    Messages:
    3,040
    Resources:
    8
    Spells:
    3
    Tutorials:
    5
    Resources:
    8
    Yes it has, but Zwieb was talking about the situation where the unit's inventory is full. Dota has a system with powerups and so far it was the only known way.
     
  10. Bannar

    Bannar

    Joined:
    Mar 19, 2008
    Messages:
    3,087
    Resources:
    20
    Spells:
    5
    Tutorials:
    1
    JASS:
    14
    Resources:
    20
    I mean, his system also supports "max-inventory" case. He catches orders and prevents order if no slot is left.

    I don't deny anything from the idea. Meaby I'm just dumb, or could you explain the issue for me more closely?

    Edit: One problem tho, if hero (visible) inventory is full, even that the "hidden" ones are not, the "Full inventory" -warning is still applied. This can be caused by adding items by default in WE to unit (even in your map, add 6x crown of kings and see the difference).
    That idea in regard to leaving one empty slot from hidden inventory might not work. When you fill all the hidden inventories and the visible one, when items start to drop (because of your 15sec periodic trigger) you can not pick any items, unless you free slot from visible inventory.

    If I'm wrong, please help me get what/why/where.
     
    Last edited: Jul 22, 2014
  11. Xonok

    Xonok

    Joined:
    Mar 27, 2012
    Messages:
    3,040
    Resources:
    8
    Spells:
    3
    Tutorials:
    5
    Resources:
    8
    I've actually noted this bug that you described. The solution to this is removing one item from the main inventory(even if for a moment). This forces the game to refresh the inventory slots and thus will prevent the warning.
    Probably the best moment to do this is when you remove an item from the hidden inventory (which is the only time that this can bug really)
     
  12. Bannar

    Bannar

    Joined:
    Mar 19, 2008
    Messages:
    3,087
    Resources:
    20
    Spells:
    5
    Tutorials:
    1
    JASS:
    14
    Resources:
    20
    This is more than just "removing item for a moment". How to prevent message/sound from occuring in such case? Removing/adding item might as consequence alter hero' stats, even for that little while, what might be dangerous.

    Btw, I've just noticed that Witcher's system alters "full inventory" sound in interface constants.

    Power ups.. power ups.. will we ever get rid of em?

    Although the Witcher's idea might not be that bad, after all, we can play Inventory Full sound ourselves when there is no item to stack with in given inventory.
     
  13. Zwiebelchen

    Zwiebelchen

    Joined:
    Sep 17, 2009
    Messages:
    6,789
    Resources:
    12
    Models:
    5
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    JASS:
    4
    Resources:
    12
    So the inventory error still flashes when you try to pick up an item to a full inventory even if the hidden cache inventory is empty?

    Bummer. I was so hoping that this could be the perfect solution for a simple item stacking algorithm without powerups.
     
  14. Bannar

    Bannar

    Joined:
    Mar 19, 2008
    Messages:
    3,087
    Resources:
    20
    Spells:
    5
    Tutorials:
    1
    JASS:
    14
    Resources:
    20
    Exactly.

    This leads up to conclusion that approach used in Witcher's lib (altered sound + order "move") might be the best one if we want to avoid powerups.

    His system could be improved tho.
     
  15. Xonok

    Xonok

    Joined:
    Mar 27, 2012
    Messages:
    3,040
    Resources:
    8
    Spells:
    3
    Tutorials:
    5
    Resources:
    8
    If someone is willing to test the moveitem orders on items in hidden inventories, then that would be nice. I may get to it eventually, but atm I don't have much time.

    The idea is that you keep track of all items in hidden inventories. Then when you order one of the items to be moved, probably to the same slot as it is. This might refresh the thing that checks item slots without actually picking up new items.