I’m working on combat. It’s kind of slow going, because it’s the most involved part of the game, and it needs a lot of other structures and objects to be in place first. Not least of which are monsters. Thanks to an audience suggestion, I’ve started with skeletons, a classic 1 hit dice monster.
For that, I needed a way of creating new monsters, keeping each unique copy of them persistent in the database, and managing them. I also wanted a way of making sure that combat could occur between players-and-monsters, monsters-and-monsters, and players-and-players. I big part of the BONES of the LOST GOD setting is battling in the magical arena at Rooksfoot, so I need to support all those types of combat.
The easiest way to go about that is to make sure that both Monsters and Characters are interchangeable; Monsters should implement the same interface as Characters. Looking through the game ruleset I’m using, with a bit of fudging and the invention of some creative items (monsters will have to invisibly equip items like “dragon’s hide”, “dragon claws” and “scroll of dragon’s breath” to set their AC, damage output, etc.) I don’t see why that shouldn’t be possible. So after a bit of work and some refactoring, I now have some new factory and blueprint objects.
When I want to create a new type of monster, I just have to crack open my trusty Monster Manual, and create a corresponding new Blueprint. This defines the monster’s name, appearance, attributes and statistics, equipment, and so on. I can create permutations of the same monster by defining some methods in there to return different values each time.
Then when it’s time to spawn a monster into the world, I take the Blueprint and give it to the Factory object, which creates a new Character and applies the settings from the Blueprint, resulting in a brand-new character/monster saved to the database. In fact, it’s so nice and flexible that I named them NPC Factory/Blueprints; and I’ll be using them to generate townsfolk, quest givers and the like, as well as monsters. It’s also pleasing to me that everything that’s alive and active in the game world is stored away in the same place in the database. There’s some enumerated flags in there so I can tell PCs and NPCs apart at a glance, and it seems to work quite nicely.
(In theory, all this means monsters and NPCs could be recruitable as player characters, further down the line. It also means it’s trivial to turn or clone player characters into NPCs; which is how I intend to do asynchronous PvP combat — it’s almost like I had a plan for this all worked out!)
Last but not least, I’m changing the way Characters are attached to Users; instead of tying them directly to the user’s account as I’m doing currently, I’ll be introducing the concept of a Party; a container for a list of Characters. Having this intermediary step means I can write combat as an event that happens between two or more parties, without having to consider who owns the party; all the UI will have to do is allow the player a way to assign actions to their Characters instead of AI and combat will progress non-the-wiser. Actually writing the monster’s AI, though, is a task for another day.