Sunday, September 16, 2007

Inventory, NPC merchant, buildings blueprints

Those were big systems needed to easily build worlds. The blueprint system was surely the most difficult to build but it's now the one I'm the most proud of.

A building (house,tavern,...) is really just a zone that you can access by walking toward a door. The walls are just props I created with various size to be able to do collision. For the prototype interface, I used the set found on Lost Garden.

So to manually create a building, all I had to do was to use the /createprop command I already had. While it do offer the possibility to create whatever setting you have in mind, it is a lot of work to have everything at the right place. To ease the process a bit, I could just do some work on the interface to allow a drag and drop feature where I could pick walls sections and put them next to each other. However, if I'd want 50 buildings, it would still be too much work.

So instead of creating walls, I figured it would be much easier to use a blueprint that would create all zones and walls related to a type of building. The blueprint system works like the SWG system. You drag the blueprint from your inventory and drop it somewhere on the screen to create the appropriate type of building. In 10 seconds you obtain what would take about 30 minutes to build.

To create the world of my first game, I'll just set a NPC merchant that will sell blueprints. Since I'm planning to allow some part of the world to be built by beta players, everyone will become autonomous to build the world without having to deal with strange commands. This system is the first step toward players' owned buildings.

So since I needed a way to put blueprints in my inventory, I needed to create the NPC merchant. This NPC will sell both "infinite" type of props (meaning he the quantity available never goes down) and props bought from players (currently the NPC only sell stuff, buying from PC will come later). When a prop is bought from a NPC, inventory space is checked, money taken from PC and a prop is then put inside the PC inventory.

The inventory has been functional for some time already but it's just this week that I added the graphical interface that make it a bit easier to deal with it. The screenshot below show the inventory as well as the content of the chest near Dak. Props can be put inside the chest and/or inventory by drag and drop. Both windows can be dragged around and there's even transparency (and all of this is created with just 1 line of code thanks to!).

Click to zoom

I haven't put a video of this since the interface is not as functional as I want it to be. I just thrown some code together to have something that works but it's not worth showing yet.

Here's how "Type 1 House" create with a blueprint looks like (I've put in the bottom left how it looks from the outside). Even if this is just a prototype, it's beginning to look a bit more like a real world.

Click to zoom