Search Unity

Inventory Looting based on Forum Code

Discussion in 'Immediate Mode GUI (IMGUI)' started by Adam-Buckner, May 17, 2010.

  1. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Afalk: Not quite sure I understand... Are you asking how easy would it be to have an in-game merchant 'selling' things to the character using the inventory item system?

    A merchant should be relatively easy as it's all item based. All you'd need is a front end that displays items and when selected, deducts money from the player. A simple check against funds to activate a slot for purchase... and maybe a quick "are you sure you want to buy this?" y/n button.

    Currently there is a "lootable base" that extends to a "lootable item" (one thing) and a "lootable object" (group of things: chest, dead body). These all look up items in an item dictionary containing all the items in the game. Adding or extending a class for a merchant could be easily do-able.

    This system also hooks into a related quest system which uses these items to complete quests, so it's relatively extendible.
     
  2. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    I was asked about this system in the "What are you working on" thread (http://forum.unity3d.com/threads/70252), which is worth a peek every now and then.

    To answer some of the questions here as well as there:

    All updates will be free. I'm following the paradigm (like Brady at A&BSoft with EZGui and SpriteManager) that only serious re-builds (a true new release) will be chargeable. I don't see that any time soon. I plan on supporting this system and polishing it with user feedback. I found with MessageManager that no amount of prediction could match the needs of real-world users!

    The package will also come with the chest model and textures (animated and non-animated - I find the non-animated chests are good stand-ins when lightmapping and make good props...), 25 or 30 icons with borders and as clean 64x textures, and I have also included some of Bluee Eyess (free) weapon Models, along with a link for more. There will be other stuff as well (like the potion model and textures...), everything you see in the videos.

    For an idea of how the editor works with this system, I've made this video this morning:


    (I know I should have been working on the OnGUI issue, but I was up until 3 am trying hunt down a machine issue, that might be a failing power supply, so I was a bit slow this morning...)

    The system is fully converted into an Event driven system, with full drag drop and swapping and multiple bags and other bells and whistles...
     
  3. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Working on the final polish. I'm hung up on getting the last details done. Currently, before I release, I want to make sure that tiny issues like moving bags around, and their content, work properly.

    The inventory as a system is done. It's primarily icon manipulation (clicking outside of a window prompts a "Do you want to destroy this? Y/N" window, and bags can be moved and swapped in their slots correctly.
     
  4. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    First real Beta is up on the site:
    http://theantranch.com/InventoryManager.html

    I'm trying to put it thru it's paces and I have one or two more polish things to do... but if you can break it let me know.

    Things I know about:
    - You can put full bags back into the inventory causing issues... oops
    - Scroll bar sensing is off-line
    - You can consume potions without any Y/N warning

    Things you can do:
    - Drag Drop Icons pretty much anywhere
    - Item slots are type sensitive
    - Clicking in the Game World prompts a "Destroy?" query
    - Clicking items without dragging either equips or uses depending on type (eg: will consume potion, will equip clothing, will add bag)
    - Swap full bags to a new location
    - Equipped Items add to summarized bonus
    - More
     
    Last edited: Apr 13, 2011
  5. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Final(?) Beta is available!
    http://theantranch.com/InventoryManager.html


    Things I know about:
    - The drag-delta seems a bit finicky and fragile. I need to make this more robust.

    Things you can do:
    Left Clicking will cause primary functionality:
    Click a Lootable Item (Chest) to loot it.
    Click an item in the loot window to loot the item.
    Click an item in the inventory window to equip or use the item.
    Click an item in the character window to un-equip the item.

    Right Clicking will cause general destruction/cancel functionality:
    When dragging, Rt Clicks will cancel the drag.
    When not dragging, Rt Clicks will prompt a removal query

    Dragging will pick up icons:
    Depending upon the drop-target an item will be accepted or rejected by the drop-target.
    Dropping on another icon, if compatible, will swap it.
    Dropping on an empty and invalid drop zone (eg: the world) will prompt a removal query.

    In General:
    Bags are movable and swappable
    Bags can be unequipped or destroyed if they are empty..
    Removed items, if set up to do so (Potions, Swords, Dagger), will be re-instantiated in the game.

    Things to come in an update (which will be free):
    Stores/Vendors, Better Searching within the Inventory Item Editor, Stacking, Rt-clicking an Inventory Object on a bag will simply put it in the first available slot, option for Individual Windows for each Bag and more.
     
    Last edited: Apr 14, 2011
  6. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Just to be ABSOLUTELY clear:

    This system's Look and Feel are fully customizable using either GUISkins from Unity or the Developer's own artwork.

    The demo of Inventory Manager uses the Default Unity GUISkin, Default Unity Font and Sample Icons (included).

    The current demo is deliberately left as neutral as possible so that it only displays functionality, not in-game style, which I've kept free for you to do.
     
    Last edited: Apr 15, 2011
  7. MaliceA4Thought

    MaliceA4Thought

    Joined:
    Feb 25, 2011
    Posts:
    406
    bookmarking this so I know when its available :)

    Regards

    Graham
     
  8. Afrokid001

    Afrokid001

    Joined:
    Jun 3, 2010
    Posts:
    89
    awesome, i cannot wait to get my hands on this work of art!
    Keep up with the awesome work.
     
  9. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
  10. Afrokid001

    Afrokid001

    Joined:
    Jun 3, 2010
    Posts:
    89
    very nice, i cant wait!

    btw, what were the changes between the last version and the release?
     
  11. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Some very fine polish fixes and one bug fix.

    I changed the way drag is calculated and the way that the icons are "tapped" when the mouse comes down. There were times that the way icons were "tapped" or "targeted" you could, if the circumstances were correct, duplicate the item - or more correctly - duplicate a bag. It was related to how icons were tapped dragged and how the inventory changed size when new bags were added.
     
  12. Afrokid001

    Afrokid001

    Joined:
    Jun 3, 2010
    Posts:
    89
    ah, glad that got fixed then, duplicating would of ruined my game haha
     
  13. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Beta 4 is up. One more rare occurrence of aberrant behaviour fixed!
    http://theantranch.com/InventoryManager.html

    I was possible under some circumstances if one swapped an item in the character window and then used rt click to cancel the drag to destroy the item rather than return it to the inventory: Fixed!
     
  14. Afrokid001

    Afrokid001

    Joined:
    Jun 3, 2010
    Posts:
    89
    awesome, Quick question, will it come with a // commented code or a small tutorial on how it functions and such (im still learning the coding phase of game making)
     
  15. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    afrokid:

    In a nut shell: Yes. It will.

    The original code (see the top of this thread) is much more extensively commented than this one is as I'm pushing to get it out. There will be a very basic tutorial guide to start with, but ultimately you will have a full set of documents (.pdf/video or both), but this can take more than a week to get ready, so I will probably release the code before I release the detailed documents, so people can just muck in and get dirty with it.

    If you are curious about what my videos are like, check out the ones I've done for MessageManager:
    http://theantranch.com/forum/viewtopic.php?f=23&t=1158

    Ultimately, if you want to look at code and see how it works, and you want to understand how THIS code works, you should download the original, simple, (and free) version of Inventory and read the comments. Understanding how the basic system works will help understand the advanced version.

    Note that, whereas the original base version was meant for forum entertainment and education, this current version is not. It is writen in C#, uses linq (http://en.wikipedia.org/wiki/Linq), generics, events and other more advanced topics.

    All that being said, if you want to dissect some code just to see how it works, look at my "skrollin" example (http://www.theantranch.com/Unity/). I tried to thoroughly explain how it works, both in the code and in the comments.
     
  16. Afrokid001

    Afrokid001

    Joined:
    Jun 3, 2010
    Posts:
    89
    awesome, i cant wait.
     
  17. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Ok, I have the release candidate up:
    http://theantranch.com/InventoryManager.html

    Let me know what you think. I've completely redesigned the behaviour based on user feedback and play-testing. Read the instructions below the player for the new mouse moves.

    In general it is more "familiar" in its feel. Rt Clicks for Equipping, Drag and Drop on all slots, Bags can be swapped or "replaced" where a new bag can be placed in a slot with an old bag and all of the contents are carried into the new bag if there is enough space in the new bag, allowing for easy upgrading of inventory slots - no emptying a bag to delete it so a new bag can take its place.

    If no one finds any problems, I'll put the code up on the store asap.

    The order of release will be C# (which the RC is built in), then I'll get the JS version up and finally I will do the detailed documentation and videos. This may seem a bit backwards, docs last, but they can take longer than expected and I want to get the code out there...

    Now, just so I'm clear and everyone is aware, I'm planning on selling the C# and the JS packages separately, so if you need JS, you will need to wait a few days longer for me to propagate the changes from the current working C# version into the (now seriously stale) JS version.
     
  18. kheng

    kheng

    Joined:
    Oct 22, 2008
    Posts:
    126
    Hey looking good, the only think that would be nice that I notice right away is if your have your character panel open and you want to equip something in your inventory you can't just double click in it if you have a slot open. It would be nice just to have the option to just double click on the object to equip it. And for the store feature later do you plan on adding a sell option? Also it'll be nice to have these items be stored in a database. But its looking good so far, how much do you plan on selling it for?
     
  19. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    kheng: Ultimately, I want to make the system completely generic, so, without coding, the developer can associate a key stroke with an action, but that is something for the future.

    If you want to equip something from the Inventory into the Character window (open or not), the keystroke is Rt Click, if you don't want to drag and drop. This comes from play-testing and user feedback. TBH is this a more familiar feel, the Rt. Click to equip, as many high profile RPG's use this keystroke. This means that (Left) Click is free to "use" or "activate" an item either in the inventory or equipped on the character.

    When the store is enabled, the players will be able to both buy and sell items to and from the store.

    When you say "stored in a database", do you mean an external one? (like FileMaker Pro) or and internal one? Currently all of the items are stored in an array within Unity which is zipped up into a dictionary when the game starts. This gives a balance between ease of use at edit time and efficiency at run time. The system also has an inventory item editor for ease of creating items in the editor:


    This script can be edited to fit the needs of the developer and includes context sensitive details.

    Starting (introductory) sales price will be $19.99 USD, but I plan on raising the price as additional functionality is added (store, etc.). These updates will be free to original users, but new users will have to pay the new price.
     
    Last edited: Apr 25, 2011
  20. afalk

    afalk

    Joined:
    Jun 21, 2010
    Posts:
    164
    Sounds fantastic -- will most definitely be picking this up as soon as its available! :)
     
  21. kheng

    kheng

    Joined:
    Oct 22, 2008
    Posts:
    126
    Awesome! RT click works for me, also is there an easy way to add more bonus category?

    I will definitely be picking this up too!
     
  22. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Yes, you can add categories for bonuses.

    The intent of this package is that it is a core system that must be customized by the developer. The demo-scene in the package will do exactly what you see in the web player. Any customization needs to be added on top.

    Currently, for additional bonuses, the developer will have to edit the code. I have clearly labeled where and how to do this in the script. It must be editable by the developer, as I can in no way predict how many bonuses or of what type they are nor how they hook into the developer's game. I intend to make it completely editor driven, where the developer can set these parameters on the components in the inspector, rather than in the code, but that will be a thing for the future, and the package will be more than $19.99 by then.

    For look customization, the system can accept custom GUISkins for all the elements, the windows are all based on settings in the inspector, and the system has hooks and automation for graphic backgrounds (Texture2D) for all of the windows.



    -

    Just one more bug to stomp. The playtesting over the Easter weekend revealed on more very odd rare anomaly where Rt Clicking Dragging in the Character window after destroying an object could recover the item from destruction.
     
    Last edited: Apr 26, 2011
  23. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Last edited: Apr 27, 2011
  24. ralfkaka

    ralfkaka

    Joined:
    Jun 23, 2010
    Posts:
    4
    It looks very cool!
     
  25. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    ralfkaka: This version is still available as a base to start your own code. It doesn't have drag and drop nor a number of the other enhancements that IM2.0 has. If this looks good, take a peek at IM2.0 and see if it suits you!
     
  26. taragon

    taragon

    Joined:
    Jan 23, 2010
    Posts:
    119
    I downloaded your Inventory js files, and while creating an empty object and connecting the inventory.js and loottable.js scripts worked, I'm getting the following error:


    Assets/Inventory/Scripts/LootableObject.js(23,38): BCE0022: Cannot convert 'UnityEngine.Object' to 'LootTable'.

    I'm not sure why..
     
  27. taragon

    taragon

    Joined:
    Jan 23, 2010
    Posts:
    119
    Assets/Inventory/Scripts/LootableObject.js(23,37): BCE0022: Cannot convert 'UnityEngine.Object' to 'LootTable'.

    This is the error I'm getting and don't know how to fix.
     
  28. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Taragon: I'm on my iPhone right now, so I'll try to get to this when I'm back at my desk. This is the first report of this. I'll load up the scripts in an empty project and see what I get. Is there any other information you can give me to help me recreate this?
     
  29. taragon

    taragon

    Joined:
    Jan 23, 2010
    Posts:
    119
    Hey LittleA --

    I basically downloaded the package and removed the two prefabs since it couldn't be converted from .blend to .fbx. Upon doing this, I did what you said to do on your website which was to create a new empty game object, and add the 2 scripts you suggest. I then attached lootobject to a piece that would be picked up, however I keep getting that error. I've referenced scripts before and haven't had this issue come up either. Does it have to do with removing the 2 prefabs you had in there?
     
  30. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Maybe. What that looks like is a type casting issue, where Unity cannot understand the intended type of an variable, so Unity is assuming it's simply an "object", rather than a "loot table".
     
  31. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    And JS has gone thru a number of revisions since this was written.

    (^_^) The expanded version is up to date!
    http://forum.unity3d.com/threads/87228

    I'll try to get to this when I get home.

    Say... Does the full demo of this package work for you? It's on the front page somewhere... models aside, if you run it, does it work?
     
  32. taragon

    taragon

    Joined:
    Jan 23, 2010
    Posts:
    119
    Will purchase once I have a working demo.. this is just the concept stage, however, I like your stuff, and when this gets to be a full-fledged game, I'll revisit.
     
  33. taragon

    taragon

    Joined:
    Jan 23, 2010
    Posts:
    119
    Actually, I deleted the scene, "Inventory"...
     
  34. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    What you are looking at here is a very stale, but free version that I have since expanded as "Inventory Manager" or "Inventory 2.0", which is the thread I pointed to. I have not touched this project in over a year, and it's primarily - depending on who you are - proof of concept or a good place to start your own code, rather than a working inventory system.
     
  35. taragon

    taragon

    Joined:
    Jan 23, 2010
    Posts:
    119
    your right, i should just buy it. it looks really great.. i'd need it in js though
     
  36. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
  37. taragon

    taragon

    Joined:
    Jan 23, 2010
    Posts:
    119
    We have to spend another $20 to get upgrades??
     
  38. taragon

    taragon

    Joined:
    Jan 23, 2010
    Posts:
    119
    Question though -- how would i transfer inventory to other characters in the game??
     
  39. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    The base system is $19.99. Point upgrades will always be free. One license per developer, not per game or instance.

    Currently there is no support for trades between player characters, as this would require networking hooks.

    If you are working on a multiplayer networked game, we should move into PM or eMail and work it out, as each networking choice could require a different solution to this problem. I'm happy to include networking hooks, which I will propagate thru to a point free point upgrade, but I'd need to know your requirements. (See my network comparison thread in my .sig)

    If you are talking about NPC, I have a beta version with stores/vendors, gold, etc., but it's not ready for release yet.
     
  40. taragon

    taragon

    Joined:
    Jan 23, 2010
    Posts:
    119
    Well, this would only be moving inventory to another character which is the computer essentially. Once giving to the robot in the game (the computer) there's no getting this back. So it's not a networking game yet, however can this work?
     
  41. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Currently, as it stands, Inventory 2.0 only supports a single character who can take, use and drop items.

    Giving the item to an Computer Controlled "Non Player Character" (NPC) is not supported in the release version of Inventory 2.0, but I do have a version of this working in my internal version - in my case as a "vendor" or "shopkeeper". The robot could be a "vendor" with no items to sell back and who takes any items given to it and returns no gold. I also have working in the internal version of a quest system that integrates with the inventory, which does something similar but different, in terms of giving items to an NPC and removing it from the Inventory List.

    May I ask *why* you are allowing your players to give something away to the computer? This may give more insight.

    I hesitate to give an accurate time line to release for this point upgrade, as Inventory is not paying my mortgage just yet, and I need to keep other balls in the air.
     
    Last edited: Aug 14, 2011
  42. taragon

    taragon

    Joined:
    Jan 23, 2010
    Posts:
    119
    Why is your GUI not available on the asset store? I hate giving credit card info to individuals...
     
  43. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    NP. I find the asset store submission to be irritating (tho' not that bad) and slow to update. I do have MessageManager up on the AssetStore.

    If this is a deal breaker, I can submit it to the Asset Store tomorrow, and then it will be the typical wait until processed.
     
  44. taragon

    taragon

    Joined:
    Jan 23, 2010
    Posts:
    119
    Great, I'll download as soon as it's up. Can you make an announcement when it's available on the asset store?

    I will need to modify to incorporate the NPC. I hope your code is flexible enough to do this. Thanks!
     
  45. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Taragon: It should be. I'm working thru some of these issues internally, but I'm willing to take what you and other people need into account. When I get beta code available, I'll let you have a sniff. TBH, when it comes to beta cycles, however, it's easier for developers who use eSellerate, as I can much more easily track authorization codes and updates are same day turn-around. The asset store is just "that much slower". I'll have to find out from Caitlyn and the folks at UT how best for the provider (me) to check authorized developers...
     
  46. taragon

    taragon

    Joined:
    Jan 23, 2010
    Posts:
    119
    OK, well, if you can put it up today, I'll work with what you have and we can talk about the rest later. Will you be able to get it up on the asset store? I would rather not give my info to an individual is all.
     
  47. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    I'll submit to the asset store tomorrow. Then it's up to UT (like the Apple™ App Store) to run it's approval process, which can be a bit of a crap shoot! I'll put up an announcement here and on the Inventory 2.0 thread.
     
  48. taragon

    taragon

    Joined:
    Jan 23, 2010
    Posts:
    119
    Great, thanks!
     
  49. taragon

    taragon

    Joined:
    Jan 23, 2010
    Posts:
    119
    Hello LittleA,

    Is this submitted to Unity yet?
     
  50. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Sorry, Yes, It is.

    We are resting upon our laurels waiting for the wise old owls to have their parliament and give us their approval.