Post-Apocalyptic RPG forums

Development => Programming => Topic started by: zenbitz on November 30, 2009, 07:54:23 AM



Title: Inventory system
Post by: zenbitz on November 30, 2009, 07:54:23 AM
As in, we need one.  If you need some "game physics" advice on it.  PM me or look me up in IRC or send a smoke signal or tweet or something.

I think we should start with some place holder graphics to represent objects, that would be fine.   I think the inventory GUI badly needs tool tips.

I think our inventory as planned looks a lot like avernum 6.  Although they don't seem to have weight in your "pack" count at all... but whatever, it's just a phat loot / level grind game.


Title: Re: Inventory system
Post by: mvBarracuda on November 30, 2009, 01:13:10 PM
I'm just trying to imagine how we could tackle this step by step. Saritor has been working on refactoring the GUI code and AFAICT the inventory code pretty much relies on it. I haven't seen Saritor for a week so he's prolly rather busy with his job/school. Should I send him an email, asking about the status of the refactoring? Or can we go ahead with implementing the inventory pretty much independent of the ongoing GUI code refactoring?


Title: Re: Inventory system
Post by: amo-ej1 on November 30, 2009, 01:32:17 PM
I had a talk with b0rland about this too, I believe he was also working on this part. (not the gui part of it though)


Title: Re: Inventory system
Post by: shevegen on November 30, 2009, 02:50:48 PM
How about a simple placeholder for it? No inventory system means that quests can't be done because the actor can not carry objects.


Title: Re: Inventory system
Post by: b0rland on December 01, 2009, 11:35:41 PM
Class for inventory is already in place and in svn. If you have any suggestions/additions, let me know or feel free make your own patch. Class name is quite predictably Inventory.


Title: Re: Inventory system
Post by: Kaydeth on December 02, 2009, 12:31:44 AM
We could use the console commands to display the Inventory in text format until we can get a GUI up a running. But that still requires someone to put the Inventory plumbing together in the gamestate class as well as the dialouge engine.


Title: Re: Inventory system
Post by: zenbitz on December 02, 2009, 08:48:18 PM
I poked in the code a bit.
I think what is missing is attaching Inventory classes to PC & NPCs. 

Also, some one should make a test for picking up stuff on the ground


Title: Re: Inventory system
Post by: b0rland on December 03, 2009, 11:50:21 AM
I've commited the new inventory GUI today and replaced all the old-style references to inventory that I could find. PC now has an attached inventory object with several slots. Drag and drop inside the inventory and between inventory and container works fine. Objects don't multiply anymore.
There still are things that need testing and some long-time todos
* Dialog/Quest system may have suffered, especially things related to beer :). I'd like to ask someone who worked closely with it lately to check if things are fine
* Regardless of whether it's already broken, we'll end up having problems with it sooner or later. It's no longer possible to refer to object as if it were a text string. The best way of object identification seems to be the ID field that every GameObject has. I'd like a word of feedback from the guys who work(ed) on quest/dialog engine about whether it's a good idea and how much changes it will require. At the very least we'll probably need a helper class to keep track of occupied IDs and corresponding objects and that will allow for easy conversion ID <-> Object and new ids generation.
* Picking up stuff directly from the map isn't implemented yet.
* The objects database is still missing and I don't think anyone started it. For now the visible effect of this is that beer looks like a dagger. Because, well, everything looks like a dagger. Even a rudimentary implementation of the db with properly designed interface would be nice at this point. And some graphics for the objects we plan to have in techdemo.
* Some parts weren't yet tested properly. I suspect evil things will happen if one would try to drag-and-drop to a widget that is not intended for that. I also suspect that "ready" slots in hud and inventory may be out of sync. Please let me know if such things happen. I intend to polish that part during the nearest days.
* I very much dislike the idea of referencing the View tier from the Model tier as we do of lately in Containers:
Code:
self.containergui = engine.view.hud.createBoxGUI(self.name, self, self.events)
...
def showContainer (self):
    if self.containergui:
        self.containergui.showContainer()
This leads to some weird special effects which I had to hack around just to make things work. I think this can be improved, although obviously not high priority.
* In far future I think we should make a joint Container-Inventory GUI (similar to Arcanum et al). Current gui's usability sucks.
For most of the above I'll try to create tickets. Comments are welcome as usual.


Title: Re: Inventory system
Post by: shevegen on December 03, 2009, 12:25:41 PM
Quote
The best way of object identification seems to be the ID field that every GameObject has.

Reminds me of what MUDs using http://en.wikipedia.org/wiki/LPC_%28programming_language%29 (http://en.wikipedia.org/wiki/LPC_%28programming_language%29)LPC used decades ago - a unique ID for every object. :>


Quote
For now the visible effect of this is that beer looks like a dagger. Because, well, everything looks like a dagger.

Bug! BUUUUG!!!! lol

I should collect quotes.

December 2009: "Hmm, something is strange... every object looks like a dagger."


Title: Re: Inventory system
Post by: Beliar on December 03, 2009, 01:23:11 PM
[...]
* I very much dislike the idea of referencing the View tier from the Model tier as we do of lately in Containers:
Code:
self.containergui = engine.view.hud.createBoxGUI(self.name, self, self.events)
...
def showContainer (self):
    if self.containergui:
        self.containergui.showContainer()
This leads to some weird special effects which I had to hack around just to make things work. I think this can be improved, although obviously not high priority.
[...]

Well, i put that in so that every container has unique contents. It also has the benefit that it is now possible to wait for the open animation to finish before showing the gui and doing the close animation when the close button is pressed.

But i agree that its probably not good to reference them there but i saw no better way then.


Title: Re: Inventory system
Post by: zenbitz on December 03, 2009, 09:17:42 PM
b0land -

I will go through the quest/dialogue stuff and refactor it to fit the new system.   I realized when I posted yesterday that the dialog references to inventory had to be replaced (they were just placeholders anyway).

I also think we should rename 'take stuff' to give stuff.  Then we have give_stuff and get_stuff as dialog functions that access inventory.  The other (duh) thing we need is to be able to check if PC/NPC "has" the thing we are looking for in his/her inventory.  I think this is implemented though.

It would be somewhat awesome if someone could change the colors on the "dagger" image so that it's not exactly the same as the "bag".  Actually the bag icon (repsententing generic container?) I find really annoying.


Title: Re: Inventory system
Post by: zenbitz on December 04, 2009, 03:29:00 AM
There is a trac ticket for this:
http://parpg-trac.cvsdude.com/parpg/ticket/229

Other things I noticed:  Need a input file format for PC and NPCs inventory.  Currently PCs starting stuff is hardcoded.
Also, I think we are going to need a "findItemByName" function instead of by ID.  Since we will basically never know the ID.

Basically - questEngine needs to search PC/NPC inventory for a specific object or type of object and transfer/use/drop/destroy it.


Title: Re: Inventory system
Post by: b0rland on December 06, 2009, 12:58:39 AM
Another note. I think we need to have two cases in mind. Sometimes we'll only care about whether a user possesses any object of a certain kind (grain from this field or that field, we don't really care as long as beer can be brewed from it). Other times we'll need to check for a certain specific object which e.g. belonged to some NPC ("go steal that big bandit's glasses and bring them to me", not some random glasses, but the ones with specific ID (?)). Possibly both cases can be solved by findItemByName if we start giving those quest items (bandit's glasses) unique names which don't collide with anything else anywhere in the game. Or maybe it's better to refer to items by ID when we have a specific item in mind.

I'll create findItemById anyway since it comes virtually for free. But it's still useful to decide on a preferred strategy to use in quest/dialog engine.


Title: Re: Inventory system
Post by: amo-ej1 on December 06, 2009, 07:04:38 PM
I played around with the inventory systems and  I ran into a couple oddities/exceptions. See ticket 231 and 226.

I found some other errors too but those were mainly gui-ish things I believe.  But I also created tickets for those.


Title: Re: Inventory system
Post by: shihonage on December 07, 2009, 10:16:10 PM
Having gone through very similar decisionmaking process, I have to suggest - use FindItemByName (and FindItemOnThisPersonByName). With unique names.

Do NOT refer to anything by fixed index numbers. It will become incomprehensible very fast.

Unique names are fine, especially considering that you can CreateItem("glasses") and then change the name of THAT SPECIFIC ITEM to "Ivan's broken glasses". Just make sure that the name of each item is stored with it, and NOT JUST in the global "all possible items" index.

In other words... really DO create the item, including the name... don't just make a pointer to template it was created from.

Sorry if much of this is redundant, and carry on.


Title: Re: Inventory system
Post by: zenbitz on December 07, 2009, 10:49:50 PM

Thanks Shihonage... but yes... you cannot make the writers/level designers etc. refer to objects by ID#.
Maybe the the way to do it is to have a "double" naming system; each object has a (unique) class name "beer", "12 ga. shotgun" and then an optional "specific" name "billy's shotgun", "beer made by the gods".

I wonder if will want to refer to items by "superclass" like   if npc.hasItem("weapon") would return True if the PC has any item that falls under the class "weapon".



Title: Re: Inventory system
Post by: b0rland on December 08, 2009, 09:23:00 AM
I added the findItem function. It currently supports name parameter to look up by name and kind parameter to look up by one of our base types like "weapon", "openable", "container", etc.


Title: Re: Inventory system
Post by: b0rland on December 08, 2009, 10:19:48 AM
The bugs mentioned above are fixed.

However I'm still not quite sure about the best way to act when one object is being put on top of the other. There are two obvious strategies and maybe more not-so-obvious ones.
Stategy 1:  When a new object is being put in a slot occupied by an old object, we replace the old one with the new one and drop the old one to backpack. This is what I do now. I think it makes sense for objects already being worn or wielded, but it looks a bit awkward when done in backpack. I welcome everyone to play around with the two daggers that PC currently has to see what I'm talking about. I suspect it may cause some confusion among players.
Strategy 2: When an object is being dropped into an occupied slot, deny that and return the dropped object to its original place.

I know that Arcanum follows strategy 2. Can someone post an info on some other RPG games? Does anyone do strategy 1 and if so, which game exactly? Also, I'd gladly hear your thoughts about whether or not the current behavior is confusing.


Title: Re: Inventory system
Post by: shevegen on December 08, 2009, 04:36:37 PM
Quote
When a new object is being put in a slot occupied by an old object, we replace the old one with the new one and drop the old one to backpack.

In the old text MUDs you usually had containers and the "inventory". The inventory was a simplification of saying "your character carries these things with his hands" or somehow attached to himself, but without specifically putting it into a container (like into a backpack, or a simple bag)

In Ultima VII and VIII you could quite easily stuff bag into bag into bag into backpack. Was a bit annoying to search through your belongings, because you had to click with your mouse. But in principle it was fun.

Quote
I think it makes sense for objects already being worn or wielded, but it looks a bit awkward when done in backpack.

Not sure what you mean "in backpack". You mean an object replacing another object in the backpack? Or, that if you wear a new hat, the old hat would then appear in the backpack?

Quote
When an object is being dropped into an occupied slot, deny that and return the dropped object to its original place.

Quote
I know that Arcanum follows strategy 2. Can someone post an info on some other RPG games? Does anyone do strategy 1 and if so, which game exactly?

Personally I think this behaviour in #2 is a bit annoying. It forces you to first "remove" a worn object before you can wear a new object right?
Actually, the text MUDs I used to play require you to do the same. If you wanted to wear a second trouser, it gave you an error message:
"Something is in the way."
Which meant that some other armour layer was occupying that slot already.
You would first have to "remove" this layer.

Fallout was sort of much simpler. You only had slots for 2 weapons and one armour piece. Most other RPGs allow you to wear multiple stuff. In Realms of Arcania, you could replace an object with another object by just dragging that object onto the slot of the new one, and I think this is good.

Image showing this:
(http://blog.hexagonstar.com/wp-content/uploads/roa3.png)

The general aim, IMHO, should be to allow things to work easily for the player. (Come to think about it, Fallout was really quite limited here. Even if we dont have magical rings, why not allow the actor to wear a ring? At the worst, it could be a gold ring, and the actor could trade it for something lateron, or a NPC might notice that ring and exchange it for some special item, because that NPC always wanted to have such a ring or something ...)


Title: Re: Inventory system
Post by: zenbitz on December 08, 2009, 06:08:08 PM
The Aventum (VI) inventory GUI is actually pretty nice.  I guess it's not out for PC yet.

What I would do is have the 'backpack' (bulk storage) slots all act the same, so if you drop an object ANYWHERE in the "backpack" it just goes to the first empty space.  Although I guess that will hurt people who actually want to _organize_ their backpacks.  You could just have it drop to "nearest open space" so it would land where you would expect it to.

I would have to review the inventory mechanics specs, but my recollection is that we only limited the total weight and maximum size of any object in the "pack".

Remember, the generic design goal is NOT the standard RPG "Oh, lets' fill my pack with everything I find" (In Aventum 16 I was walking around with 17 bags of mushroom meal, and 2 extra suits of chainmail), but rather to make the player decide what he needs (there wlll be a mechanism to "cache" things somewhere, although it's not immune to theft or spoilage).

Speaking of which, it came up in this (or another) thread recently about why quest items (that are otherwise useless) have zero weight/bulk - the answer is that so you won't get punished by leaving somewhere far away, then have to go back and get it to finish a quest.  (unless of, course, part of the quest is that you have to figure out how to transport some bulky or heavy item long distances)


Title: Re: Inventory system
Post by: b0rland on December 08, 2009, 06:31:06 PM
Not sure what you mean "in backpack". You mean an object replacing another object in the backpack? Or, that if you wear a new hat, the old hat would then appear in the backpack?
First, to make things absolutely clear, backpack is the area where all the objects that are not currently worn or wielded reside. The area 4x5 slots at the bottom of inventory dialog. So, I'm referring to the case when I try to place an object into one of those slots and the slot is already occupied. What happens is the object currently occupying the slot is replaced by a new one and is transferred into the first vacant slot of the backpack. That is supposing backpack has infinite size. With limited backpack capacity it gets even uglier. Although in that case we can probably resort to option #2 (deny the operation and put the new object back where it was taken from).

Quote
I know that Arcanum follows strategy 2. Can someone post an info on some other RPG games? Does anyone do strategy 1 and if so, which game exactly?

Personally I think this behaviour in #2 is a bit annoying. It forces you to first "remove" a worn object before you can wear a new object right?
Actually, the text MUDs I used to play require you to do the same. If you wanted to wear a second trouser, it gave you an error message:
"Something is in the way."
Which meant that some other armour layer was occupying that slot already.
You would first have to "remove" this layer.
Yes, that's what I meant. And I do agree that it's more cumbersome, that's why I chose to implement the "replacing" strategy.

I'll try to dig for a copy of Realms of Arcania to see how it works there. Hope I can make it run in dosbox or elsewhere.


Title: Re: Inventory system
Post by: b0rland on December 12, 2009, 03:08:03 PM
I created a ticket http://parpg-trac.cvsdude.com/parpg/ticket/238 . It's about increasing the amount of items that can be displayed in backpack section and making it scrollable and improving visual appearance of inventory gui. Feel free to add more enhancements into that task.
Those who feel confident with pychan guis and have some experience with gui design and wish to do this ticket, raise your hands please. Or rather just assign to yourself and do it :).