Loot Tables
Loot Tables associate distributions with Data Table rows. They can be defined in the editor using templates and sampled from at runtime. Notably, Loot Tables can point to any type of data within a data table, meaning they can be used for many applications: ARPG Loot Generation, Spawning Random Actors, and many more!
Overview
Loot Tables are the runtime objects which can be sampled from. They are instantiated or composed from Loot Table Templates.
At their core, Loot Tables point at rows from Data Tables and assign an item from a distribution to that row. For example, suppose we have the data table:
Source Data Table
Array A (Data Table Row Handles) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Index | Data Table | Row Name | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
0 | DT_Fruits | Apple | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 | DT_Fruits | Banana | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2 | DT_Fruits | Orange |
Array A represents an array of Data Table Row Handles. It is not a data table.
Distribution B (Unlimited) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Index | Weight | Probability | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
0 | 100 | 10% | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1 | 400 | 40% | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
2 | 500 | 50% |
If we construct a loot table out of Array A and Distribution B, we would get:
Loot Table C (Unlimited) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Data Table | Row Name | Weight | Probability | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
DT_Fruits | Apple | 100 | 10% | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
DT_Fruits | Banana | 400 | 40% | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
DT_Fruits | Orange | 500 | 50% |
Each time we sample from loot table C, we receive one of the data table row handles: Apple, Banana, or Orange.
Usage
Construction
To construct a Loot Table object at runtime, use one of three methods:
Instantiate Table
Instantiation creates a loot table from a template as-is. It's the fastest and simplest method to use, but it doesn't allow editing at runtime.
- Invoke InstantiateTable on a Loot Table Template.
Compose Table
Composition creates a new loot table based on one or more templates. Additionally, you can filter out rows or modify weights/counts of composed templates.
- See composition.
Manual
You can manually create a loot table based on source data table rows and a discrete distribution.
- Spawn a STLootTable object using the SpawnObject blueprint node.
- Invoke InitializeLootTable on the object with the distribution and source rows. Note: Size of the Distribution and Source Rows array must be equivalent.
Sampling
Loot Tables implement the functions listed in samples, except they output DataTableRowHandles instead of indices. To obtain the data from the sampled row(s), use the blueprint function GetDataTableRow.