Chris Bissette

More work on the megadungeon bot

Today I've been doing more work on the Mörk Borg megadungeon bot. A core part of megadungeon play is in managing equipment. Since I want to do all character management inside the bot, I decided that I need an inventory management system that lets players move items around. The next logical step was to build a shop into the bot. As well as letting players spend their starting silver and equip themselves as they see fit, I also figured this would be a good way to let them sell items that they pull out of the dungeon and convert them into silver. I'm not sure how this interacts with scoring yet, but I'll cross that bridge when I come to it.

The result of today's development session is that players can now buy and sell items, the shop has a dynamic back room inventory system, and I've implemented consumables with limited uses, scroll parsing, and randomized starting equipment. I'll go over each of these in a little more detail below.

1. Complete Shop System

The shop system is now fully functional with a fairly complex inventory management system built on the back of a couple of different databases. There's a master catalogue of all available items at the start of the game, a shop inventory that functions as a sort of "back room" to track overall inventory for the shop, a shop stock database that keeps track of inventory on the "shop floor", and a config database that lets me adjust things like how much money the shop is holding, how many SKUs are on display on the shop floor at any given time, and the chances that items of different rarities will actually appear for sale.

I also have tracking for unique items that logs who first sold the item to the shop and who first bought it.

Here's a bullet point overview of some key features:

Player Commands:

Server Owner Commands:

2. Consumables System

Items can now have limited uses with automatic tracking. I feel like this is currently a little janky and might need some finessing, but it works and that's the important thing.

Features:

Example Items:

With most of these items I'm not actually implementing any mechanical effects of using them other than depleting the inventory, because that would be silly. Instead it just prints the effect, which is stored as flavour text, and players and GMs can apply the results as you would when running the game normally. Here's a quick example of use:

  1. Player uses /use slot:5 on Medicine Box
  2. Bot displays: "PlayerName used Medicine box! Effect: Stops bleeding/infection and +d6 HP. Medicine box has 3/4 uses remaining."
  3. Player rolls a d6 (just types roll 1d6)
  4. GM applies the effect manually using /heal
  5. When uses reach 0, item automatically removed from inventory

3. Smart Scroll System

Scrolls are in the game now. They don't appear in the shop by default but can be generated at character creation or when doing Getting Better with the /better command, and can be sold back into the shop.

During chargen the bot initially generates a result of either "Random Unclean Scroll" or "Random Sacred Scroll". Individual scrolls are defined as tuples (text, price, rarity), and automatic parsing extracts the scroll name and effect and inserts it into the player's inventory. These can then be used like any other item - expended, transferred to other players, or sold back into the shop.

The benefit of doing it this way is that I can always add new scrolls to the database during the game that will then organically filter through into the economy without me having to restart the bot.

These also tie into the...

4. Starting Items System

New characters now receive randomized starting equipment:

Structure:

Character Creation Flow:

  1. Character created with starting weapon in slot 1
  2. Random item from table 1 added to slot 2
  3. Random item from table 2 added to slot 3
  4. If scroll rolled, parsed and stored with proper name/effect
  5. Displayed in character creation message

5. Armour Swapping System

Players can now manage armour as inventory items, swapping pieces out and buying and selling it.

Commands:

Features:

6. Shield Mechanics

Shields in Mörk Borg allow you to sacrifice them in order to prevent all damage. They are a consumable item, functionally. I could probably have just made use of my existing item consumption system for them, or else just instruct players to unequip/drop shields when they're used, but I liked the idea of having a bespoke /block command. So I built one.

/block Command:

7. Misery Tracking

The /refresh command now tracks Miseries:

I might add something to my configuration commands to let me change the die size rolled for the Miseries, just to make the bot a little more functional.

New Commands:

8. Help Command

Role-based command documentation:

/help category:[all] Command:

Improvements

I implemented a few improvements to old systems while I was working on these new ones, too.

Current Command Count

I said on Bluesky that this bot currently has over 50 working commands but I was wrong. There are 39.

Total Commands: 39

Player Commands (15):

GM Commands (11):

Server Owner Commands (13):

Remaining Roadmap

Reporting Commands

These are a crucial part of the bot but I don't intend to implement them until everything else is working as intended.

Utility Commands

Dungeon Treasure System

This is a really big one. Since every GM is going to be running the same megadungeon and since we have a robust inventory system, it makes sense that GMs should be able to award treasure from the dungeon directly into player inventories. The original version (i.e. the /add_item command) will allow GMs to add items to a player's inventory but they have to type in values for each column of the item tracking CSV, and that's slow and tedious.

My idea for this is that, once I've written the dungeon, I'll implement a treasure database. Each room of the dungeon will be represented and will contain every lootable item. GMs will then be able to pull up the treasure for the room they're currently in with a slash command, and assign that treasure to players. If players have to drop items to make inventory space, those items will go into the dungeon room treasure table. This means that treasure locations will persist across delves and GMs won't need to worry about awarding duplicates etc.

Alongside this I probably need to build some procedures for dungeon restocking, although I guess I can just manually restock rooms as part of my upkeep while the game is ongoing. I should also implement a similar treasure distribution system for pocket treasures from wandering monsters, too.

The final thing that I should probably do is to split this into a GM bot and a player bot. Right now players can see all of the GM and server owner commands in Discord even though they can't use them, and aside from anything else that's just ugly. It also means that it can be hard to find the command you want to use. So at some point I may see about splitting it into two bots that talk to the same databases, which I think should be fairly straightforward.

At the time of writing this the bot is feature-complete for basic gameplay with economy, combat, inventory, and progression systems all functional. Future work focuses on polish, reporting, and some advanced features specific to Return Of The Troll King. At some point soon I'll probably drop it into the public Loot The Room discord server and run some test games just to see how it actually plays. I also find myself wondering how easily I could convert this into a bot for running A Dungeon Game and I think it should be fairly straightforward.

This is by far the largest Python project I've worked on but it's actually been fairly straightforward so far - certainly much easier than the hex map generator I was working on earlier this year. At its heart it's just a database application, but it's one that I'm really proud of.

#blog #dec25 #python #trollking