Starbound

Starbound

Not enough ratings
Modding: Loot Tables Guide
By Ceterai
Want to define loot dropped from your monster/object/crop, contents of a reward bag or a chest? Well look no further!
WEBSITE[ceterai.github.io] | SUPPORT ME[buymeacoffee.com]
   
Award
Favorite
Favorited
Unfavorite
Introduction
This guide covers loot tables (drop pools), their syntax, where they are located and how to integrate them to be used as loot, drops, rewards, etc.
The guide assumes you know modding basics (how to unpack files and how to work with JSON).
Loot Table Syntax
This section goes over where loot tables are defined, and how to define them.
Location
Loot tables are defines in bulk in ".treasurepools" JSON files, usually located in the "treasure" folder:
/treasure/ Missions/ apexmission1.treasurepools ... biome.treasurepools bugs.treasurepools ...
You can add your own or you can patch an already existing file if you feel like it.
If you don't know how to patch files, check out the last section of the guide.
Syntax
The full syntax of a loot table looks something like this:
"fishinguncommon" : [ // the ID of your loot table. Should be unique. [ 0, // a minimal level at which the following configuration will be active, in this case 0 { "fill" : [ // contents that will always be present alongside a random pool { "item" : "rawfish" }, // "item" lets you specify an ID of and item/object to spawn (x1) { "item" : ["rawfish", 2, {...}] }, // instead of a string, you can pass a list in following format: [<itemName/objectName>, <count>, <parameters>] { "item" : ["rawfish", 2] }, // this also works { "pool" : "fishingUpgrade" } // "pool" lets you specify an ID of another loot table instead of an item or an object ], "pool" : [ // items, objects and loot tables for the game to choose from { "weight" : 0.12, "item" : ["money", 16, {...}] }, // "weight" defines how likely this is to be picked over the other entries, relatively { "weight" : 0.97, "item" : "apex1legs" }, { "weight" : 1.03, "pool" : "fishingUpgrade" } ], "poolRounds" : [ // defines how many entries to pull from the pool above [0.7, 0], // syntax is [<weight>, <count>] [2, 1], [0.6, 2] ], "allowDuplication" : true // whether the same "pool" entry can be picked multiple times, default is "false". } ], [ 0.5, // this will be chosen on planet danger/at level of 1 and up { "fill" : [...], "pool" : [...] } ], [ 3.5, // this will be chosen on planet danger/at level of 4 and up { "pool" : [...], "poolRounds" : [[0.7, 0],[0.3, 1]], "allowDuplication" : true } ] ],
Weights in "pool"/"poolRounds" don't have to add up to a 1, but it's convenient.
There's a loot table called "empty". As the name suggests, it returns no items.
This is a single loot table, which is usually a part of a dictionary of loot tables contained within a single ".treasurepools" file, like so:
{ "fishingUpgrade" : [ [0, { "pool" : [ {"weight" : 1.0, "item" : "fishingreelstrong"}, {"weight" : 1.0, "item" : "fishingreellong"}, {"weight" : 1.0, "item" : "fishingreelfast"} ] }] ], "fishingcommon" : [ [0, { "fill" : [{"item" : "rawfish"}], "pool" : [{"weight" : 1.0, "pool" : "fishingUpgrade"}], "poolRounds" : [[0.7, 0],[0.3, 1]], "allowDuplication" : true }] ] }
Using Loot Tables
Now you need to get your loot table in action! Where can you use it and how?
  • Other Loot Tables
  • Monster Drop
  • Object Drop
  • NPC Drop
  • Chest Loot
  • Dungeon Chest Loot
  • Crop Harvest Loot
  • Reward Bags
  • Tenant Gift
  • Inside Lua Logic
  • Spawn With Commands
Other Loot Tables
To make your loot table part of another loot table, refer to the syntax section of this guide.
Monster Drop
Monsters have a "dropPools" parameter to set loot tables and what weapon they drop from:
"dropPools" : [{ "default" : [b]<loot table ID>[/b], "bow" : "<loot table ID>", "bugnet" : ... etc }],
Use "empty" to specify an empty drop. Minimal setup:
"dropPools" : [{ "default" : "empty" }],
Object Drop
If you want the object to drop other stuff instead of itself, you can either specify "breakDropOptions"/"smashDropOptions" to list possible items, or you can specify "breakDropPool"/"smashDropPool" to refence your loot table:
"smashable" : true, "smashDropPool" : <loot table ID>, "breakDropPool" : <loot table ID>
NPC Drop
Like monsters, NPCs have a "dropPools" parameter to set loot tables, but this time it's a simple list of loot tables:
"dropPools" : [<loot table ID>],
Chest Loot
If you want chests that randomly spawn in the world (not in dungeons) to use your loot table, add a "treasure chest" definition to a ".treasurechests" file, then reference it in your biome file.
Dungeon Chest Loot
To set your loot table to be inside of any dungeon container, open the dungeon in Tiled and create the following property for it:
Name
"parameters"
Type
"string"
Value
{ "treasurePools" : [<loot table ID>] }
Crop Harvest Loot
To make it so your crop drops your loot table when harvested (not broken, refer to "Object Drop" for that), alter the last stage's "harvestPool" with your loot table ID:
"stages" : [ { "duration" : [280, 320] }, { "duration" : [280, 320] }, { "alts" : 5, "duration" : [1170, 1230] }, { "alts" : 5, "resetToStage" : 2, "harvestPool" : <loot table ID> } ],
Reward Bags
If you have an item based on the logic of the default reward bag, you can specify its loot by setting "treasure" : { "pool" : "ct_alta_pod_loot" } to your loot table ID:
"treasure" : { "pool" : <loot table ID>, ... },
Tenant Gift
If you want a tenant to use your table for their gifts, you can set the "rent.pool" value in the ".tenant" file of your tenant:
"rent" : { "pool" : <loot table ID>, ... },
Inside Lua Logic
If you need to spawn your loot table in the middle of the script, use the following SB Lua function:
root.createTreasure(<loot table ID>, <level>)
Full documentation on this function: Starbounder Wiki: Modding: Lua: Root[starbounder.org]
Spawn With Commands
Use the following command to spawn your loot at the cursor (<level> is optional, default is 1):
/spawntreasure <loot table ID>, <level>
Full documentation on this function: Starbounder Wiki: Commands: Admin[starbounder.org]
From Trees
You can't, unfortunately. I think. You can spawn individual items but not through loot tables.
From Projectiles
Same as with trees - not loot tables but individual items:
"actionOnReap" : [{ "action" : "item", "name" : "money" }],
Conclusion
This is all I have to share on this topic. Let me know if there's anything I'm missing! ^^
Helpful Resources
The guide mentions patching in one section. If you're not familiar with it, here's a helpful guide:
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=2124444255
More about loot tables:
https://starbounder.org/Treasure