ID:151286
 
In most RPGs, the inventory system looks more like Baldur's Gate or Diablo and less like a vertical list. Since skins give us greater freedom in our interface style, I was wondering if anyone has attempted a less list looking inventory system. I was imagining that a beginining might be using a grid system where every item has an x and y position (maybe even a secondary map?) obtained based on where the item is drag and dropped in the inventory pane and the inventory displays based on that position as opposed to a list. It could be even be exapanded to allow for various item sizes so that an object con occupy more cels (say a large item).
I've never seen one done like Diablo. Try looking at the grid element and the proc :

MouseDrag proc (atom)

Format:
MouseDrag(over_object,src_location,over_location,src_control,over_control,params)
Args:
over_object: the object under the mouse pointer
src_location: the turf, stat panel, grid cell, etc. from where the src object was dragged
over_location: the turf, stat panel, grid cell, etc. containing the object under the mouse pointer
src_control: The id of the skin control the object was dragged from
over_control: The id of the skin control the object was dragged over
params: other parameters including mouse/keyboard flags, icon offsets, etc.; see mouse control
This is called while dragging this object by pressing and holding the left mouse button over the object and moving the mouse. The over_object may be null if dragging over a stat panel or over other empty space.

Don't define this unless you need it, because it generates extra communication that is otherwise avoided. Most operations can be done through Click(), DblClick(), and MouseDrop(). The other procedures are simply available for completeness.
In response to Kyle_ZX
Actually, I think MouseDrop is what you meant :-)

I haven't seen many games veer far outside a list style inventory and was wondering if anybody had tried it. I got a simple grid based inventory working and it looks alot nicer. I imagine there are other ways to do it, too.
One thing I've been wondering is, given this kind of system, is there an efficient sorting algorithm that allows you to pack the items in your inventory so that they take minimum space?
In response to Toadfish
Toadfish wrote:
One thing I've been wondering is, given this kind of system, is there an efficient sorting algorithm that allows you to pack the items in your inventory so that they take minimum space?

My hunch is that it's not that bad if you have restrictions on the shapes of the inventory and the items. If you have items that are rectangles fitting into a rectangular inventory it's probably easy enough, and you can probably develop a simple heuristic that does a good job. If you're looking to pack arbitrarily shaped items into an arbitrarily shaped container it's probably much harder.

To do this on a second map control I think you'd have to use screen objects, which means you might as well do it on a single map control. If BYOND had better mouse support I'd probably do this with screen objects, but the way it is now I'd probably do it in a browser control using JavaScript. That has some benefits you won't get from BYOND even with improved mouse support.
In response to Forum_account
Forum_account wrote:
Toadfish wrote:
One thing I've been wondering is, given this kind of system, is there an efficient sorting algorithm that allows you to pack the items in your inventory so that they take minimum space?

My hunch is that it's not that bad if you have restrictions on the shapes of the inventory and the items. If you have items that are rectangles fitting into a rectangular inventory it's probably easy enough, and you can probably develop a simple heuristic that does a good job. If you're looking to pack arbitrarily shaped items into an arbitrarily shaped container it's probably much harder.

Hmm, yeah, I think even with only rectangles this would be similar to the bin packing problem, so a heuristic is definitely the way to go. According to the article, one optimal heuristic for the bin packing problem is to sort the items from biggest to smallest, and place them in the first bin they fit. So extending this into a 2-dimensional inventory we can maybe partition the inventory space using something of an R-tree and place the sorted objects (height first width later rather than area, I'd say) in the first 'node' they fit.