Loot Tables¶
Loot Tables are probablility sheets that when executed, pick an option from its entries based on a weighted chance and send the chosen element (if any at all) to a Bag component.
To create one, right click on the Project Panel and select Create → Game Creator → Inventory → Loot Table.
To add a new loot entry, click on the Add Loot button. A new entry will appear with the following options:
- Rate: A number that represents the weight of the chance. The higher the value, the greater the chance.
- Loot: A dropdown that allows to pick an Item or a Currency.
- Amount: The amount picked if the entry is chosen. It can either be a constant value or a random one.
Weight vs Probability
It is important to note the distinction between a Rate (or weight) and a probability percentage.
The Rate depends on the total sum of all rates from all entries. For example, two entries with a Rate of 1 is equal to two entries with a Rate of 5. In both cases, the chance of picking them is 50%.
Optionally there is a No Drop Rate field that enables the Loot Table to pick nothing.
To execute a Loot Table it is as easy as using the Loot Table instruction and choosing both a Loot Table asset and the targeted Bag where the items/currency will be sent to.
Run multiple times
Note that each time a Loot Table is executed, it picks one entry from the table. A Loot Table can be used multiple times in sequence to fill, for example, a Chest with multiple items.
Chest with Random Loot
One easy way to randomize the loot of a level is to populate them with a Chest prefab that has an On Start Trigger. This Trigger then runs one or more times a Loot Table and sends its contents to the Chest's Bag component.
This allows to very easily populate all the Chests of a level with different content, while at the same time controlling the kind of content they contain.