Skip to content

LootTable ​

Inherits: DatabaseResource < Resource

A shareable resource for randomizing loot drops Can be used by entities, containers, chests, etc.

Description ​

The table says WHAT drops. WHEN it drops and at what item level is said by the loot rule of the holder (LootRule, LootLevelSource); a table can also pin its own level source. Entries are items, amounts of a currency, or other tables. See docs/systems/ability-ranks-and-item-generation.md, section 8.

Properties ​

intmin_items1
intmax_items3
Array[LootEntry]loot_entries[]
Array[LootEntry]guaranteed_entries[]
intnothing_weight0
intmin_quality_tier0
LootLevelSourcelevel_source

Methods ​

Dictionarygenerate_loot( looter: Variant = null )
Dictionaryroll_drops( context: Dictionary = {} )
voidadd_loot_entry( item_id: int, weight: int = 10, min_qty: int = 1, max_qty: int = 1, can_dup: bool = false )
voidadd_guaranteed_entry( item_id: int, min_qty: int = 1, max_qty: int = 1 )
voidadd_guaranteed_currency( currency_id: int, min_amount: int, max_amount: int = -1 )
intget_total_weight()
booluses_item_level()
Arrayvalidate()

Constants ​

  • int MAX_DEPTH = 6 - The most tables that can be inside each other (a table that points back at itself does not run for ever)

Property descriptions ​

int min_items = 1 ​

Minimum number of items to roll from the loot_entries array

int max_items = 3 ​

Maximum number of items to roll from the loot_entries array

Array[LootEntry] loot_entries = [] ​

Array of possible loot entries with weights and quantities - rolled randomly up to min/max_items

Array[LootEntry] guaranteed_entries = [] ​

Array of guaranteed loot entries - these always drop and don't count toward min/max_items

int nothing_weight = 0 ​

The weight of "nothing": a roll can come up empty. With the entries at a total weight of 30 and a nothing weight of 10, a roll in four gives nothing (0 = never)

int min_quality_tier = 0 ​

Generated items from this table never roll a quality under this tier (a boss never drops Common). 0 = any

LootLevelSource level_source ​

Where the item level of the drops comes from. A table that sets one (not Inherit) overrules the loot rule of the holder

Method descriptions ​

Dictionary generate_loot( looter: Variant = null ) ​

Generate loot based on the table configuration. looter (the entity that gets it, usually the killer) can change it through two gain channels: loot_quantity (the size of every stack; a fraction is a chance of one more) and loot_rarity (magic find: a percentage that raises the weight of the entries that are rarer than the table's average). The answer is item id -> quantity: items only, at item level 1. Use roll_drops for currency, nested tables and item levels

Dictionary roll_drops( context: Dictionary = {} ) ​

The drops of one roll: {"items": [{"item_id", "quantity", "item_level", "min_quality_tier", "magic_find"}], "currency": {currency id: amount}}. Context (all optional): looter (an entity), item_level (the level of the items, 1 when missing), rng (a RandomNumberGenerator), level_resolver (a Callable that gets the LootLevelSource of a nested table and the level it inherits, and returns its level), depth

void add_loot_entry( item_id: int, weight: int = 10, min_qty: int = 1, max_qty: int = 1, can_dup: bool = false ) ​

Helper function to add a loot entry

void add_guaranteed_entry( item_id: int, min_qty: int = 1, max_qty: int = 1 ) ​

Helper function to add a guaranteed entry

void add_guaranteed_currency( currency_id: int, min_amount: int, max_amount: int = -1 ) ​

Helper function to add a guaranteed amount of a currency

int get_total_weight() ​

Get total weight

bool uses_item_level() ​

Does anything in the table (or the tables inside it) need an item level: a generated item, or an entry with a level band?

Array validate() ​

Validate the loot table configuration