The loot_pool API can be used to easily build dynamic, composable, and reusable loot-granting systems that function across multiple experiences. The core loot_pool class takes in a context representing the relevant game state and returns an array of entities to the caller.
By using a common API, your loot pools become more transportable and interoperable across experiences. In addition, we also provide some basic implementation of a weighted loot pool, and access to some of Fortnite's underlying loot tables, designed to work cleanly with systems that follow these API standards.
Loot Pools
Found in module /UnrealEngine.com/LootPools.
The heart of the API are several core classes which define the contract that loot pools follow.
loot_context
Data passed to a loot_pool when loot is requested. The base members define the minimum amount of information a loot pool is expected to need to decide which items to return to the caller. Subclass it to pass extra data to your own pools and calculators for context-specific return values.
Member | Type | Description |
|
| The entity that loot is being selected for, for example the player who opened a chest. Defaults to |
|
| The |
loot_pool
Abstract base class of every loot source, defining the interface by which items are returned to the caller. An implementation of loot_pool must provide an implementation of SelectLoot[].
There are no guarantees about the size of the returned array. In many cases, an array of size zero is a valid output.
Member | Description |
| Returns the entities to be granted as loot. |
lootable_component
A component that can be attached to Scene Graph entities to return loot upon request. This is an abstract component which needs to implement SelectLoot, which returns the selected items to the caller.
loot_pool need not always be tied to a lootable_component, but this is a good way to signal to callers that there is available loot on a certain entity and define a public contract for searching for and retrieving it.
By default, a lootable_component doesn't do anything with the entities. The caller decides what to do with these new objects, like adding them to the Scene Graph, placing them in a player inventory, etc.
Member | Description |
| Returns the entities to be granted as loot. |
basic_lootable_component
This is a simple, concrete implementation of lootable_component which can be used out-of-the-box. This component holds a set of loot_pool classes, calls SelectLoot on each, and then passes the combined output as one array.
If a held loot_pool fails during a call to SelectLoot, this component will skip that result and continue checking the remaining loot pools. Other lootable_component implementations may handle failure differently.
Member | Description |
| Calls |
| The set of |
Example
This is a simple example of a custom loot_pool that returns a random entity from the options it holds, and a basic_lootable_component which holds more than one of these.
using { /UnrealEngine.com/LootPools }
using { /Verse.org/SceneGraph }
using { /Verse.org/Random }
using { /Verse.org/Simulation }
item_1 := class(entity){}
item_2 := class(entity){}
item_3 := class(entity){}
The equivalent visualization in the editor is:
Weighted Loot Pools
Found in module /UnrealEngine.com/LootPools.
This is an implementation of a loot_pool which provides out-of-the-box weighted loot pool behavior, in which a set of entries each have a weight and can be selected. Entries with a higher weight are selected more often relative to others with lower weights.
Each selected entry could be an entity that is directly selected, or the output of another, recursively called loot_pool class, easily allowing the construction of loot pool hierarchies.
weighted_loot_pool
A loot_pool containing a set of entries in Options, where entries with higher weight relative to others are selected more often.
Infinite weight entries are always returned first unless they exhaust their maximum selection count, if set.
A SelectLoot call will fail if Options is empty.
RollCalculator is a class used to define how many selections are made from Options in a single call to SelectLoot. You can use an existing simple option, or write your own which reads a loot_context subclass to determine how many rolls based on game state.
Note that the returned value from the RollCalculator is not guaranteed to be the size of the returned array. A roll can produce nothing, or call a nested loot_pool which returns an arbitrary-sized list of things.
A call to SelectLoot will keep track of how many times an entry has been selected for the lifetime of the function call for the purposes of checking against an entry's MaxSelectionCount. This will reset when the function call ends.
Member | Type | Description |
|
| The entries that can be selected. Each entry has its own weight and an optional selection limit. |
|
| How many independent selections from |
| Makes the selections and returns all the loot combined into one array. |
weighted_loot_entry
A base class for all entries held by a weighted_loot_pool, holding common metadata elements (such as WeightCalculator and MaxSelectionCount). The actual value, and way that value is instantiated, is defined in derived classes.
A new kind of entry can be added by subclassing this and overriding GetEntryValue, which is the function which instantiates and returns the []entity to the calling pool.
An entry with a weight of 0.0 or less is never selected. An entry with an Inf weight is always selected. If an entry with an Inf weight has no MaxSelectionCount, it is picked every time.
A common pattern is to set an entry to always be selected, or never be selected, based on runtime conditions. A custom loot_weight_calculator can use these rules to get that effect by returning Inf or 0.0 respectively based on values read in the loot_context object it gets passed.
If an entry's MaxSelectionCount is 0, the entry is never selected.
Member | Type | Description |
|
| How likely this entry is to be picked relative to the others. Defaults to a fixed weight of |
|
| The most times this entry can be picked in a single |
|
| Override in custom entry types to create the loot. Fails if no loot can be produced. |
|
| The function that gets called when this entry is selected that decrements the |
weighted_loot_entry_item
A subclass of weighted_loot_entry which returns a new instance of EntityType when selected.
Member | Type | Description |
|
| The type of entity to be default instantiated and returned when this object is selected. Defaults to the base |
weighted_loot_entry_pool
A subclass of weighted_loot_entry which calls SelectLoot on a stored loot_pool and returns the resulting array of entities as a component in the results of the calling weighted_loot_pool.
Member | Type | Description |
|
| The nested loot pool. When this entry is selected, the entry returns the value of this pool's call to |
loot_weight_calculator
This is an abstract class defining the interface by which we allow a context-based calculation of the weight value of a weighted_loot_entry.
Member | Type | Description |
|
| Abstract function that returns a float weight value for a particular weight entry which can be defined based on the context. |
loot_weight_calculator_fixed
An implementation of the loot_weight_calculator which returns a defined, fixed value every time independent of context.
Member | Type | Description |
|
| A defined, positive float value representing the likelihood of this item being returned relative to other entries. |
|
| Returns the value of |
loot_roll_calculator
This is an abstract class defining the interface by which we allow a context-based calculation of how many independent selections (rolls) to make from Options in a call to SelectLoot in a weighted_loot_pool.
Member | Type | Description |
|
| Abstract function which returns an integer representing how many rolls to make. |
loot_roll_calculator_fixed
An implementation of the loot_roll_calculator which returns a defined, fixed value every time independent of context.
Member | Type | Description |
|
| A defined, positive integer representing how many rolls to make, |
|
| Returns the value of |
Example
This is an example which includes a custom context that has a "Double Roll Perk" flag, which can be read by a custom roll calculator to give the player two rolls of loot if the flag is set in the context. There is also a weighted_loot_pool which contains a nested weighted_loot_pool that is selected 1/4 times.
using { /UnrealEngine.com/LootPools }
using { /Verse.org/SceneGraph }
using { /Verse.org/Simulation }
item_1 := class(entity){}
item_2 := class(entity){}
item_3 := class(entity){}
# Carries the "2x rolls" perk to the roll calculator.
The in-editor equivalent is:
Fortnite Loot Pools
Found in module /Fortnite.com/LootPools.
This set of classes allows direct Verse access to the loot pools that underpin a subset of Fortnite's containers, including chests, ammo boxes, and supply drops, among others.
These pools have no editable properties and ignore loot_context.
Note: This system accesses the current Fortnite loot pools, and the distribution and type of the returned loot is expected to change between game updates and seasons.
Currently available Fortnite loot pools include:
Class | Rolls the loot of… |
| A regular Fortnite chest. |
| A rare chest (the upgraded version a regular chest can spawn as). |
| An ammo box. |
| A rare ammo box. |
| A supply drop. |
| A food box. |