Inventory systems in GM suck.

Posted by Astryl on April 18, 2011, 9:47 a.m.

I was locked away for several nights, delving into the arcane workings of a dynamic inventory. And I succeeded. In C++ it would've been a lot easier (Polymorphism, better primitive data-structures, speed).

This is what I managed to do:

It's fully functional, and any item I create that is a child of obj_baseitem can be picked up/examined/used/eaten/drunken/dropped/thrown.

As for the key-layout, I'm using an approximation of Roguelike controls, and relying as little as possible on the mouse (I hate using the mouse for an RPG myself, though I give exception to Morrowind.)

Coming soon: Player status Window.

GM8.1 stuff

I got GM 8.1 Lite. Don't want to get Standard. Can't afford it :P

Anyway, it's got it's good points, and I love the zoom feature for rooms, but… it's not quite enough to change me over permanently.

GM 8 Pro is still fine for my needs.

Also, my internet connection will be intermittent at best, so expect progress updates anytime between now and next month :P

QUICK UPDATE

I did a few things, like sticking the information-boxes at the top-left of the screen (Don't worry, the font is temporary.), and I changed the UI color.

Also, as mentioned in my latest comment, I added more keyboard commands.

Comments

Scott_AW 13 years, 5 months ago

Looking good.

F1ak3r 13 years, 5 months ago
Castypher 13 years, 5 months ago

Inventory systems aren't TOO bad. They're a pain at first, but also one of those things that make you feel great when you get them finished.

I just use a 1D array for the inventory slots, a 2D array for item data (name, item type, cost, etc), and a ds_map to check if the item is currently in the inventory so it can be stacked.

The game looks great so far.

Moikle 13 years, 5 months ago

i have gm7 so i cant upgrade :(

Mush 13 years, 5 months ago

sexy screenshot

Scott_AW 13 years, 5 months ago

Can we make him a blocky model?

Undeadragons 13 years, 5 months ago

This looks really epic.

How did you implement the inventory system (aka MOAR TECH SPECS!)?

Astryl 13 years, 5 months ago

MOAR TECH SPECS? YOU ASKED FOR IT…

Nah, just kidding; not that bad.

I used an array that's part of the game-control object called vInvSlots, which has 20 elements. (I use the letters v, my, and f for variables in GM. Helps me to spot them later.).

Each one of these slots contains either the integer value 0, or an instance ID (Fetched when an inventory item is created). I have a script to handle adding and removing inventory items (Checks for available ID, etc, returns ID to 0 if removed, etc).

The inventory system expects some variables to be in the item, so I use inheritance for that.

Scott_AW: No. Not in GM. Unless I find myself with lots of time and a heap of graphing paper, or the patience to make a simple geometry editor.

Tooltips were blocking the view of the HUD, so I made them all display at the top-left of the screen now.

Also, I just finished the item-use keys.

The keys are u (Use), q (Quaff/Drink), e (Eat) and D (Drop). The stats are also finished, and they also use a simple array (With 9 elements. Contains the Level and XP of the player as well).

death 13 years, 5 months ago

lol i dont think GM is all that bad with Inventories. it's just how the programmer codes. i made 3 different inventory systems fairly easily. i think that type of system is too common for me to use. i go with a traditional CAN ONLY HOLD 10 ITEMS PER PERSON deal lol (at least that's what i'm working with atm) i also take weight into account cause i love realism mixed with pointless fantasy!

still pretty neat. are you gonna be able to hold # of items in a slot? other wise it might be a little difficult =P

Astryl 13 years, 5 months ago

Nope. Only ONE ITEM PER SLOT. Not for any particular reason besides the fact that the Roguelikes I play do that. :P