[6] Items And Inventory

10/06/2019, 10:19pm

This week I worked on adding items and the inventory to the game. It's not perfect, so I'll probably spend a bit more time tweaking it while I figure out what the next feature is going to be. You can pickup, drop, and examine items. There's no way to trade with other players yet, but one player can drop items for others to pick up. As with the rest of the player data, inventories are stored in the database, and getting that working was one of the most interesting challenges so far. Of all the state in the game, the inventory has the most complex, so it really tested the database and network syncing code. So far it seems to be holding up, but I am getting a lot of insight as to how I plan on designing the codebase for the next multiplayer game I work on. With this update, there are now 24 packets in the game protocol.

In adddition, NPCs drop items when they die now (just some coins). I plan on adding a more robust item drop system this week. I'll probably write a very tiny DSL to make it easy to define interesting drop tables. Like entities, items are defined in .toml files like so:

id = 2 [item] name = "Raw Rat Meat" description = "I should cook this." type = "ingredient" model_id = 0 is_stackable = false

The inventory UI on the client needs some more work, as I threw it together quickly just to get moving. Ideally, I'd like players to be able to drag items to rearrange them, as well as drop items in quantities greater than one at a time. There's also no item icons, because I don't have any. When I find some time to pry myself away from the code, I'll do some minor touch ups and add new art. I already got sick of looking out into space and put some rock walls up.

I did some more tweaking for combat formulas as well. This is totally new territory for me, so I'm not sure how balanced it will feel as time goes on. I've been using a nifty spreadsheet to work on this stuff, and it isn't too hard to try out new values.

That's all this week. September is over now, so check out This Month in Rust GameDev #2! I'm moving quickly to try and get an official server hosted and a demo out so people can check out the game.