Search Unity

Inventory Looting based on Forum Code

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

  1. taragon

    taragon

    Joined:
    Jan 23, 2010
    Posts:
    119
    Funny.. If you had paypal and just a way to add my email address (no other personal info) I could do it that way too...

    If not, I'll wait for it to be in the Asset Store. Thanks!
     
  2. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    The site does accept paypal.


    Is the hold up the "required fields" for name address etc?

    I can't remember what I can see when I'm in paypal, but they also keep information that is made available to the other parties in the transaction... I know I've been able to see addresses, etc., of people who have paid me directly on paypal.

    I'm pretty sure eSellerate requires it to track taxes and tariffs.
     
  3. taragon

    taragon

    Joined:
    Jan 23, 2010
    Posts:
    119
    This and the software license concerns me. Is there a way to just use paypal and be done with it?
     
  4. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Oh! Didn't realize that anyone would dig deeply into that (the agreement). It's a basic/standard "don't rip me off" license agreement. It's very similar to what Brady at A&BSoft (EZGui, SpriteManager2, etc.) uses, and other agreements I have seen in the community. I thought it was the same on the Asset Store itself, as I thought we needed to include an agreement with UT, but I can't find it. I've asked UT to remind me what the agreement actually is...

    The single biggest problem with direct sales - eg: me giving you my paypal account address and when it clears, sending you a software package - is updates. Currently I now need to update two points - UT and eSellerate - every time I do an update, and then the systems handle making the updates available. If I were to send you a package directly, I would then have 3 points to update, and one more point per person I did this with. I rely on eSellerate and the Asset Store to do my distribution and updating. Since I have to pay them a (hefty) percentage, I'm not inclined to engineer a distribution system on top of that.

    If you have a specific problem with a part of the software agreement/license, let me know. I just re-read it, and - ya - it's full of legalese - but it essentially says: "I'm selling you a license for something I own and you can use. Please don't rip me off, and if it's not perfect, I'm sorry, but don't sue me."
     
  5. taragon

    taragon

    Joined:
    Jan 23, 2010
    Posts:
    119
    Specifically, #4 and #5 bother me. If we are buying this, this is very restrictive in the sense that it wouldn't allow for this GUI to be in another software product. Why not? If you're selling it, and I'm buying, what's the point of not being able to use it in another software product?
     
  6. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Ah...Ok. Fair enough.

    May Nots:
    The way I read #4 was, say, if you were developing a "software product" (not finished game), say - like an "RPG Builder", and you incorporated my code into that application, and other people were buying that application and could use this application and create RPG's with a built in Inventory and Looting system from this code, you would need a new license from me. This is actually something I've done. I've licensed MessageManager and InventoryManager to other people making tools for building RPGs, and we've negotiated a separate deal, as they are not the end user of the product. TBH, these products have yet to reach the market, but this is the principle.

    The way I read #5 was,say, if you were intending on putting an Inventory System up on the Asset Store or your own site or store, don't know how to do it, so buy and download this package to learn how to do it, copy the good bits and put up a modified version of your own - then you shouldn't do that. TBH, this particular line is the least prescient as all the code is exposed and in C# or JS, so there really isn't much decompiling, disassembling or reverse engineering to be done. If you are buying my product to find out how it works and want to make your own, fair enough. Feel free. If you were to then put that system up on the Asset Store afterwards would be a bit rude.

    I was looking at the software agreement that came with Vectrosity from Starscene Software, and it's very simple:
    I could try to come up with something as simple as this, but again, TBH, every time I stop to poke around with something on the business end - from licensing agreements to sales sites - it takes me away from developing, and it's a fine balance I need to strike between popularity and productivity. I think the eSellerate store looks like ass, IMHO, but I don't want to take a week (or more for me) to work out how to make my own site - tho' my domain host does have sales carts and things as pre-prepared scripts...

    You can feel comfortable I won't sue you if you just use the code in the spirit it was intended, which is make as many games as you can make. If you are a freelancer working on someone else's job, their company needs to buy a license if they are the distributor of the final game. Don't distribute or post my code without talking to me first and us agreeing it's ok. If you want to incorporate my code into another application which will in essence act as a distribution method for the code, drop me a line and we'll work out the details.
     
  7. taragon

    taragon

    Joined:
    Jan 23, 2010
    Posts:
    119
    Hey, thanks for clarifying. I'm just making a game and thought your code would be faster than reinventing the wheel. So it sounds like we're on the same page.
     
  8. taragon

    taragon

    Joined:
    Jan 23, 2010
    Posts:
    119
    Little A, did you say you had a working NPC thing attached?
     
  9. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    No, not yet. It's still an internal update. I have it working in one of my games, but I need to extract it and get it to work outside of the game itself.
     
  10. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Taragon: The Asset Store seems to have changed the format for the main graphic main graphic we need to supply for the asset store, so it was rejected. (>_<)! I even used the supplied template, but it displays incorrectly. I'll redo the graphics today and resubmit. /sigh
     
  11. taragon

    taragon

    Joined:
    Jan 23, 2010
    Posts:
    119
    LittleA,
    I bought and installed the software. For some reason though, the first bag is not showing up in the window (as this screen shot indicates). Therefore, any loot that is picked up by the player cannot be transferred over to the player. I do have all the bags included in the Item List section (I thought this might be the reason why it's not showing up. Also, as you can see, Orange Bag is the starting bag and open bags with inventory is checked. So I don't know why this wouldn't automatically show up.
     

    Attached Files:

    Last edited: Aug 23, 2011
  12. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    I would imaging that you have not yet set up your ItemList yet, or at least an item called "orange bag". If you see the screen shot below from the demo project, you will see the orange bag as part of the item list and the view of the same item in the item editor:



    Now, I could be more clever about the starting bag. Currently it's doing a string look-up, like the loot tables and other methods use as private values to keep track of and pass items around. As I cannot predict what a developer would want to use for a carrying system, it's hard to have a single default bag that is the starting bag. I'm leaving it up to the developer, right now, to create an item in the item editor and save it to the item list and then link this item via its name as a string in the public variable "Starting Bag". It's actually public string startingBag in C# or in JS it's var startingBag : String and the relevant code for setting the bag is:

    Code (csharp):
    1. //C#
    2. InventoryItem startingBagItem = itemList.item[startingBag] as InventoryItem;
    3.  
    4. // JS:
    5. var startingBagItem : InventoryItem = itemList.item[startingBag] as InventoryItem;
    6.  
    If you look into InventoryManager.(cs/js) you will find this variable commented as:
    public var startingBag : String; // The starting bag - this is a string to contain a valid name of an it set in the items list

    (oh dear - TYPO)

    And SHOULD say:

    public var startingBag : String; // The starting bag - this is a string to contain a valid name of an item set in the items list
     
  13. Adam-Buckner

    Adam-Buckner

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

    We should move this discussion to THIS THREAD.

    I've been linking to this discussion from the notification eMails, and this is really the (admittedly STALE) thread on the free version from last year. So others can find this discussion, we should be having it in the relevant thread.
     
  14. taragon

    taragon

    Joined:
    Jan 23, 2010
    Posts:
    119
    This is now moved to the link you provided above THIS THREAD.
     
  15. taragon

    taragon

    Joined:
    Jan 23, 2010
    Posts:
    119
    LittleA,
    Never hear from you on the other thread -- I do have the orange bag created, and therefore don't understand why it's not showing up (as my attachments showed earlier)
     
  16. _joseph

    _joseph

    Joined:
    Jun 14, 2011
    Posts:
    44
    @Little Angle
    If you wanted, could you conceptually "buy" these items over the internet? Are their tutorials on that?
     
  17. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Taragon: I can't see another response from you in either thread since I posted my proposed solution, so I presumed it was the correct solution and it had solved your problem. I am assuming you read the post on making sure you have an item created that has the same name as the variable for starting bag, and that this item is marked as a container. If you have an item in your inventory list that has the same name as the string for the starting bag and that item is marked as being a container, then I don't know why your bag is not showing up. Could you send me a cut down scene illustrating the problem and I'll take a look?
     
  18. taragon

    taragon

    Joined:
    Jan 23, 2010
    Posts:
    119
    LittleA --
    For some reason I wasn't notified you posted a response and am just checking the forums now! I have not resolved that issue of having a starting bag, and double checked against your screenshots. Do you want me to resend you the screenshots? I had posted them earlier...
     
  19. taragon

    taragon

    Joined:
    Jan 23, 2010
    Posts:
    119
    Little A, here are two screenshots that indicate the orange bag is supposed to be the starting bag along with it selected as a "container"
     

    Attached Files:

  20. taragon

    taragon

    Joined:
    Jan 23, 2010
    Posts:
    119
    Also, I was wondering when you transfer over an image from inventory to the character window, whether this is recorded anywhere in the code?
     
  21. taragon

    taragon

    Joined:
    Jan 23, 2010
    Posts:
    119
    LittleA --
    I believe this is what you wanted me to post earlier... I'm getting the following error:
    "object reference not set to an instance of an object"
    Code (csharp):
    1. function AddItem (item : InventoryItem) {
    2.     var currentBagLocation : int = bags.IndexOf(currentBag);
    3.     var currentStartIndex : int = GetBagsStartIndex (currentBagLocation);
    4.    
    5.     for (var i : int = 0; i < currentBag.bagSize; i++) {                            //  Go through each row OF THE CURRENT BAG
    6.         if (inventory[i + currentStartIndex] == null) {                     //  If the position is empty...
    7.             inventory[i + currentStartIndex] = item;                        //  ... add the new item....
    8.             return (true);                                                  //  ... and exit the function.
    9.         }
    10.     }
    Specifically, the error is occurring on the first for statement
     
  22. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    First: Can you tell me more about the "KeyNotFoundException" error? This may be a clue. On start, your inventory item list should be zipped up into a dictionary for quicker access.

    This could be saying that when you ask for "Orange Bag", it can't find the key named "Orange Bag" - if it's the starting bag that's throwing the error.

    Have you modified any of the code in any manner?

    Have you checked for a typo/name mismatch between the name of the item in the Item List and the value entered in the slot for "starting bag" in the Inventory Manager? They look the same, but could there be an invisible character issue? Trailing space? Try copy and pasting one of the string values into the other just to make sure they are identical if checking for a central double space or trailing space doesn't reveal anything.

    If I understand what you are asking, then yes, it should be stored in the "equipped" list.

    -

    The "Null Reference" error to the code you posted above would make sense if you are not getting an original bag... then it can't have a currentBagLocation as there is no currentBag!
     
    Last edited: Sep 4, 2011
  23. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Worst case scenario: Get a dropbox account and send me a link to your project and I'll take a look!
     
  24. taragon

    taragon

    Joined:
    Jan 23, 2010
    Posts:
    119
    I will do this.. do you want all files?
     
  25. taragon

    taragon

    Joined:
    Jan 23, 2010
    Posts:
    119
    Little A -- Dropbox is asking for an email address to share the contents of the folder with.. can you send me one? Otherwise, the public link will only get you access to the game at runtime I believe.
     
  26. taragon

    taragon

    Joined:
    Jan 23, 2010
    Posts:
    119
    ArgumentException: An element with the same key already exists in the dictionary.
    System.Collections.Generic.Dictionary`2[System.String,InventoryItem].Add (System.String key, .InventoryItem value)
    ItemList.Awake () (at /Users/melissalewis/Desktop/Games/Aug 27/Assets/Inventory-JS/ItemList.js:34)


    This is the error I get
     
  27. taragon

    taragon

    Joined:
    Jan 23, 2010
    Posts:
    119
    ArgumentException: An element with the same key already exists in the dictionary.
    System.Collections.Generic.Dictionary`2[System.String,InventoryItem].Add (System.String key, .InventoryItem value)
    ItemList.Awake () (at /Users/melissalewis/Desktop/Games/Aug 27/Assets/Inventory-JS/ItemList.js:34)

    This is the error I'm getting
    I don't know how to install as a zip.. I can try and reimport your zip as a zipped file and leave it as such.
     
  28. taragon

    taragon

    Joined:
    Jan 23, 2010
    Posts:
    119
    I re-imported, however keep getting the following errors, along with the key error I mentioned earlier. I double checked for consistency between the item list too, and didn't see the issue yet. Let me know your email address and I can let you have access to all the game files.

    NullReferenceException: Object reference not set to an instance of an object
    InventoryManager.AddItem (.InventoryItem item) (at /Users/melissalewis/Desktop/Games/Aug 27/Assets/Inventory-JS/InventoryManager.js:1050)
    InventoryManager.DrawLootWindow (UnityEngine.Event currentEvent) (at /Users/melissalewis/Desktop/Games/Aug 27/Assets/Inventory-JS/InventoryManager.js:906)
    InventoryManager.OnGUI () (at /Users/melissalewis/Desktop/Games/Aug 27/Assets/Inventory-JS/InventoryManager.js:297)
     
  29. taragon

    taragon

    Joined:
    Jan 23, 2010
    Posts:
    119
    Sorry to have so many messages, but specifically, the key error comes up again with the following issue in script "LootableObject", line 115:

    newItem = itemList.item[currentLootItem.name] as InventoryItem;
     
  30. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    I'll need a scene that includes on inventory manager and will run. Either zip the entire project or export a unity package including everything you need. Put this zip file or package in the public folder. Rt click (iirc) the file and copy the public link. PM that link to me.
     
  31. taragon

    taragon

    Joined:
    Jan 23, 2010
    Posts:
    119
    Hmm, I don't seem to see you on IRC.. I do have the file in dropbox, but easiest would be to add in your email
     
  32. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    Taragon: I have your project. Lots going on in there. The inventory complete scene worked fine:


    Is there another scene you want me to try? One that's implemented in a scene? I tried four or five of the scenes I could find at random, but none seemed to implement Inventory Manager.
     
  33. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    I think I may have found the error by reviewing your screen shots. I noticed this:


    You seem to have duplicated an item name. Actually, as that looks like the default setup from the demo, it seems that you have changed "Sword" to "Sword of Terror". The could cause an error when trying to create the dictionary at the start of the game, as the dictionary uses the item name as the unique key.

    -

    I have confirmed this!

    I just realized that the scene name was in your screen shot:


    So I loaded your scene and looked at the InventoryItemEditor:


    This is preventing the dictionary from being built successfully, and causing errors at start. When I open IM up for an update, I'll try to make this a more obvious error during edit time. This error will show in the Item Editor when you are creating or editing the item, but is less obvious when you are running the game.

    I couldn't get your scene to run, as there were other errors in the code preventing that scene from playing, but there shouldn't be any errors from Inventory Manager if you change one of the two "Swords of Terror" to a different name.
     
    Last edited: Sep 5, 2011
  34. taragon

    taragon

    Joined:
    Jan 23, 2010
    Posts:
    119
    Little A -- this absolutely worked! To think that a small error like adding in Sword of Terror twice would be the issue! Thank you!
     
  35. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    I'll try to trap that better so a warning goes off, even if it's at run time.

    Right now, the only place this is checked is on the "page" of the Inventory Manager itself.
     
  36. taragon

    taragon

    Joined:
    Jan 23, 2010
    Posts:
    119
    So what I need to do is to limit the items available for each loot able object. For instance, in the first treasure chest, maybe there's only 4 items available, whereas in the 2nd chest there are more, etc. I'll dig more into the code to figure out how to do this.

    Also, I'll have to find where the counter is (where is it keeping track of items that the player is adding on to inventory). For instance, when the player transfers inventory from the chest to the inventory window, where is the counter keeping track of all of this? I'll need to investigate and find this..
     
  37. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    taragon: Let me know what it is that you want to accomplish as your end goal, and perhaps I could help you achieve that. All of the issues you mention above are handled internally.

    Do you want a maximum carry? If so, limit the number of bags or size of bags. InventoryManager won't let the player carry more objects than the equipped bags will allow.

    For more detailed information of lootable object: Go to the main thread (http://forum.unity3d.com/threads/87228) and look on page 2 for more information about how to work with loot tables. Limiting the number of items is one of the options you can set.
     
  38. taragon

    taragon

    Joined:
    Jan 23, 2010
    Posts:
    119
    I will take a look at the info on the loot able object as you mentioned.

    What I'm trying to do is the following:

    1. Constraint each treasure chest to a set amount of pieces so that player can collect from more than one chest and not have inventory be full.
    2. When player clicks on the loot able object and drags into inventory slot, add onto a counter that keeps track of how many are added into inventory. This counter will basically trigger other features on player health for instance.
    3. If items are taken off of inventory into the Character slot, add onto a different counter that keeps track of how many are added onto character. This counter will trigger a decrease on player health (for instance).
     
  39. Adam-Buckner

    Adam-Buckner

    Joined:
    Jun 27, 2007
    Posts:
    5,664
    After I get my son to bed, I'll elaborate on each of those, but all is do-able in the current system.

    Let's try again to move this conversation to the appropriate thread:
    (http://forum.unity3d.com/threads/87228)

    I'll answer there.
     
    Last edited: Sep 5, 2011
  40. taragon

    taragon

    Joined:
    Jan 23, 2010
    Posts:
    119
    Shifted conversation to the appropriate thread.