On Friday I decided to make a small change to the treasure table format. I got a bit carried away and ended up spending a bunch of time over the weekend to clean up, organize, and rebuild ALL of our .treasurepools files, which I finally finished. It was a lot of work but the results make treasure much easier to work with and a much better system in general, so I’m very happy to have completed it.
For a bit of technical detail: our treasure pools are specified as weighted lists of items. The weight associated with an item determines how likely it is to be randomly selected, relative to other items in the table (not an absolute percentage chance). This means that adding new items to a table changes the likelihood of each of the other items in the table being selected. As you can imagine, this makes it very hard to edit and balance the tables! The engine change I made was to allow treasure tables to reference other treasure tables. With that functionality implemented, I rebuilt our tables by splitting loot into categories. For example, here’s the new table for a single general treasure item, such as you might find in a plain surface chest:
{“weight” : 0.4, “pool” : “money”},
{“weight” : 0.1, “pool” : “ore”},
{“weight” : 0.1, “pool” : “food”},
{“weight” : 0.1, “pool” : “healingItem”},
{“weight” : 0.1, “pool” : “fuel”},
{“weight” : 0.05, “pool” : “thrownWeapon”},
{“weight” : 0.05, “pool” : “weapon”},
{“weight” : 0.03, “pool” : “tool”},
{“weight” : 0.03, “pool” : “seed”},
{“weight” : 0.02, “pool” : “shield”},
{“weight” : 0.01, “pool” : “costume”},
{“weight” : 0.01, “pool” : “instrument”}
As you can see, the probabilities are now specified for general categories of items, each of which has its own separate treasure pool. Now, when we add (for example) a new weapon, the probability of getting SOME weapon will stay the same, as will the probabilities of other categories within this file. I’ve also split several of these categories up into sub tables, divided them based on threat level, and massively reorganized things to make them easier to work with. The end result is that we can now move ahead with our work on biomes and progression (more on that later in the week!) without creating huge amounts of redundant configuration files and future work in the process.