Loot Table Primer

About this primer

In this guide, we will go over how to set up loot for NPCs through the loot-table system.

SpawnDataTable

Once you have set up your NPC and want it to spawn some loot, you will need to create a table to go with it. In your mod-folder, you should set up two new files. Right-click in the content browser and select "Miscellaneous/Data Table" (see image on the right)

You will need one data-table based on the struct "LootTableRow". This data-table will be the main access-points. From here, you can assign multiple actual loot-tables and the percentage chance for each of those tables being accessed when the creature/npc dies.

The second data-table you need must be based on the struct "LootTableWeightedRow". This data-table is the actual contents of the loot. In here we will set up specific items to drop.

For the sake of clarity, we'll call the first (LootTableRow) table the "Main loot table" and the second table (LootTableWeightedRow) the "Weighted Table".

Now that these two tables are created, you should link the Main loot table to the NPC you created, and also, inside the Main loot table, link it to the Weighted Table. So let's go over that.

Main Loot Table

Before you do anything else, make sure that the new row names in this table are numbered and don't use any letters or symbols. Now - while it's possible to make items drop directly in this table, it gives you far less options than if you were to use a WeightedTable, as you will see when we go through what the different features in this table is below.

This may sound a bit complicated, but it's not really - there are examples after we go through the details of the Main Loot Table afterwards.

Use Table - this should be clicked if this entry links to a WeightedTable. If not, it will spawn items present in "ItemName" / "Item ID".

Table/Data Table - this is the link to the Weighted Table you want to use for this entry

Table/Row Name - if you want to spawn specific loot from a specific Weighted Table, you can use this, otherwise the result will be random between all the items listed in the Weighted Table.

Item Name - if you want to spawn items directly instead of going through a Weighted Table, you should put what is called the "plug" here. If you open the "ItemNameToTemplateID" table, you can see the name and plug for all items in the game. You don't have to use this, it's completely optional, but it may help when searching through long tables, instead of searching for numbers.

ItemID - this is the ItemTemplateID present in the ItemTable and the key to spawning the item

Min - this is the minimum amount of items to drop - OR - if you are using a table, the minimum amount of rolls that should be done on that table when dropping items from there.

Max - this is the maximum amount of items to drop - OR - if you are using a table, the maximum amount of rolls that should be done on that table when dropping items from there.

Percent Chance - this is the percentage chance of rolling on the table. 100% of course means that this table will always produce a result.

Min durability - if you drop an item directly, this is the minimum durability of that item. This really only affects armor and weapons - for anything else, you should leave this at 1.

Max durability - if you drop an item directly, this is the maximum durability of that item. Again, it really only affects armor and weapons - leave it at 1 if the item is something else.

Required Tags - This allows you to drop items that matches an item-tag query. You may, for example, set up a loot-table where you want to drop any weapon that is an iron weapon, or any healing item of tier 3. This query is very powerful and allows you to set up loot in such a way that any future game update, and even mod, can be included in the tables, as long as they follow the normal rules of gameplay tags.

More information on gameplay tags can be found in the Gameplay Tag Primer document.

Num Rolls - the number of times the loot table should be rolled on.

Int/Float Stat Modifier - this allows you to apply stat modifiers to items that are dropped. You may, for example, set up a modifier to apply a random multiplier between two values for damage, or armor to further increase the randomness between items.

Item.NoDrop Flag

The “Item.NoDrop” gameplay tag can be applied to items that you do not want drop from the loot-system in any way whatsoever. These items can still be spawned by using blueprint functions, but will never be dropped in chests or from worn equipment.

Examples

Example 1

In this example, we have a single Weighted Table, and when we kill a boss, we want the loot-system to drop between 2 to 10 items randomly from that table. Put "Min" to 2 and "Max" to 10, and link the DataTable to the Weighted Table. In addition, put the Percent Chance to 100. This will make it so that every time the boss dies, it will drop anywhere between 2 to 10 items from the Weighted Table.

Example 2

In this example, we have a boss that always drops a specific item, and also a random armor piece from a selection of 5. For the specific item, we don't need a weighted table, so put the ItemID of the item into the "ItemID" with a "Percent Chance" set to 100. "Min" and "Max" should both be 1. In additon, we need a new row in this table, where we link to the Weighted Table, and set "Min" to 1 and "Max" to 5. "Percentage chance" again should be set to 100.

Example 3

In this example, we have a boss that always drops a random piece of an armor-set, but also has a rare chance of dropping weapons. For the armor-set, we make a row, and link it to a Weighted Table. We set the "Min" and "Max" to 1 and "Percentage Chance" to 100. For the rare weapons (assuming we have multiple of them), we want another row, where it links to a second weighted table and where the "Percent Chance" is set to something like 10.

Tip: As a general rule - consider how many times you would be willing to kill a boss in order to get the reward yourself. If it's truly rare, 5-10 is pretty good, but 25-30 tends to be the target for most players.

Weighted Table

The Weighted Table is the more interesting part of the process and this is where the loot is housed. Note that you CAN use nested tables if you really wish to by using "Use Weight Table" or "Use Percent Table" but for the most part, one layer of complexity tends to be enough. Let's go over the rest of the details of this table.

Table/Data-Table - Use this for nested tables; this works in the same way that the Main Table does.

Table/Row Name - For nested tables you can also directly select which specific row to spawn for this result should you want to. Also functions in the exact same manner that the Main Table does.

Item Name - As mentioned in the Main Table section, you don't have to use this, it's completely optional, but it may help when searching through long tables, instead of searching for numbers.

ItemID - this is the ItemTemplateID present in the ItemTable and the key to spawning the item

Min - this is the minimum amount of items to drop - OR - if you are using a table, the minimum amount of rolls that should be done on that table when dropping items from there.

Max - this is the maximum amount of items to drop - OR - if you are using a table, the maximum amount of rolls that should be done on that table when dropping items from there.

Percent Chance - this is the percentage chance of rolling on the table. 100% of course means that this table will always produce a result.

Weight - This is the main reason why these tables are powerful. The higher the weight, the higher the chance of the item dropping.

Making NPCs automatically drop worn equipment

In the Spawn Data Table, you will find an entry for each NPC called “DropEquipmentPreset”. This preset determines how high chance an NPC has of dropping their worn equipment for all their various slots. Important to know is that this system only works for humans with actually worn equipment slots, and not for monsters.

In order to set up an automatic equipment drop, you will need to fill in this column with an entry that matches an entry in the “DropEquipmentTable”

As you can see - the DefaultHuman has a 25% chance of dropping their main hand weapon, and 15% chance of dropping each equipped other slot. Each equipment will drop with a current durability of 15% to 40% (0.15=15%).