Skip to main content

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)
IndexData TableRow Name
0DT_FruitsApple
1DT_FruitsBanana
2DT_FruitsOrange
note

Array A represents an array of Data Table Row Handles. It is not a data table.

Distribution B (Unlimited)
IndexWeightProbability
010010%
140040%
250050%

If we construct a loot table out of Array A and Distribution B, we would get:

Loot Table C (Unlimited)
Data TableRow NameWeightProbability
DT_FruitsApple10010%
DT_FruitsBanana40040%
DT_FruitsOrange50050%

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.

  1. 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.

  1. See composition.

Manual

You can manually create a loot table based on source data table rows and a discrete distribution.

  1. Spawn a STLootTable object using the SpawnObject blueprint node.
  2. 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.