Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Modding:Treasure Tables

From bg3.wiki
Revision as of 18:43, 14 August 2024 by ArousalMax (talk | contribs)

One of the many types of text files crucial to a mod maker's toolkit are Treasure Tables. Treasure Tables define all inventories in the game- what is in them, and what could be. All chests, traders, and corpses use treasure tables to define their loot. For mods adding items, the main way for them to appear in game is to add them to one treasure table or another. Most commonly, mods that add items just for the sake of it add their items to the tutorial chest, a cartilaginous chest found on the Nautiloid. This page goes over the basics of treasure tables.

Let's look at an excerpt from one of the TreasureTable.txt files in the game:


new treasuretable "Gold_Pocket_Wealthy"

new subtable "10,1;11,1;12,1;13,1"

object category "Gold",1,0,0,0,0,0,0,0


The first line, in a rather self explanatory manner, creates a new treasure table named "Gold_Pocket_Wealthy"

The second line looks much more confusing, but isn't. Every item within a table needs a subtable. If you want 1 potion of healing that's guaranteed to be in the treasure table, it would still need its own subtable. So, with that in mind, a subtable is created. The numbers within the quotation marks denote the weights for how many times the table will be rolled- As an example, the weights for this table start with "10,1", so, with a weight of 1 (equal to everything else in the table), this table could be rolled 10 times. That means we would get 10 of whatever is listed in the table below. Each subsequent numbered pair denotes another quantity & weight pair- "11,1" means there is a weight of 1 that the table will be rolled 11 times, and so on.

The final line, much like the first, is pretty self explanatory. the "object category" that it begins with is necessary for all items within a subtable- it doesn't mean much to us, since it always stays the same, but it means a lot to the code. "Gold" quite obviously means Gold, the game's currency. The 1 is the number of items- so, if it were a 10 instead, each time the table was rolled, it would give 10 gold. Therefore, if the table was decided to be rolled 11 times in the previous step, you would get 110 gold. In this case, you would only get 11. The 1 is followed by 7 zeros. Every example I can find always has these zeros- they just seem to be necessary for the code to work and don't seem to mean much.