Zone Config Loot Tables - torilmud/docs GitHub Wiki

Loot Tables

Loots tables are for rewarding players when killing an NPC. They can be used to distribute loot to each player who assisted in killing a mob, or to load a single set of gear. They can be used to load randomized sets of gear chosen from the loot table, or a static set, or a combination of the two.

Getting Started

Loot tables are defined in the zone config file. These tables are then referred to in template files. Multiple mobs can use the same loot table. Note that the loot tables are tied to mob loads, not individual mobs. In other words, you can load multiple instances of the same mob vnum with different loot tables.

Example

"lootTables": [
    {
      "name": "entropis-test",
      "items": [
        {
          "type": "table",
          "name": "entropis-items",
          "weight": 500
        },
        {
          "type": "nothing",
          "weight": 500
        }
      ]
    },
    {
      "name": "entropis-items",
      "items": [
        {
          "type": "item",
          "name": "cincture",
          "vnum": 24244,
          "weight": 100
        },
        {
          "type": "item",
          "name": "scale",
          "vnum": 24245,
          "weight": 100
        },
        {
          "type": "item",
          "name": "volance",
          "vnum": 24246,
          "weight": 100
        }
      ]
    },
    {
      "name": "general-consolation",
      "items": [
        {
          "type": "item",
          "name": "hair tonic",
          "vnum": 98300,
          "weight": 100
        },
        {
          "type": "item",
          "name": "a handful of acorns",
          "vnum": 89439,
          "weight": 200
        }
      ]
    }
  ]

The lootTables field inside of the zone config contains a list of all of the zone's loot tables. A loot table consists of a name and a list of items. Despite the name, the items correspond to any type of reward, not just an object. An item can be a roll on a loot table, a game object, coins, or nothing at all.

The example above shows three loot tables:

  1. entropis-test: This contains just two options, a roll on another loot table and nothing.
  2. entropis-items: This contains three reward options, all vnums of gear objects.
  3. general-consolation: This is another standard loot table that just rewards two items.

Note the weight field in the items. This field controls the likelihood that that option will load. If the weight is -1, the item will always load. Otherwise, it will be thrown into a pool of items that will be selected randomly based on the relative weight of the item.

Given that, entropis-test is set up as a 50% chance to get a chance at rolling on the entropis-items loot table, since the weight between the loot table and the 'nothing' option are equal.

Within entropis-items, we have an equal chance to get one of the three items in the list. In this example then, the player has a 50% to get an item. If they succeed, they then have a 33% chance to get one of the three items in the table.

Loot Table Fields

  • name: The name of the loot table. This must be unique within the zone. It's ok if this name is used in another zone.
  • items: An array containing the rewards for this loot table.

Loot Table Item Fields

  • type: One of: item, coins, table, or nothing.
  • name: This field is not used by the game but is helpful for readability. Think of it as a comment.
  • vnum: If type is item, this is the vnum of that item.
  • weight: The relative weight of this item in the loot table. -1 will always load. See below for more details.
  • quantity: If type is coins, this is the number of platinum to reward.

Zone Command: lootTables

To add a loot table to a mob load, add a lootTables field to the load npc zone command:

{
      "comment": "Lord Entropis",
      "command": "load npc",
      "vnum": 98300,
      "room": 98389,
      "lootTables": [
        {
          "name": "entropis-test",
          "mode": "each",
          "rolls": 2,
          "unique": true,
          "consolationTable": "general-consolation",
          "consolationRolls": 3
        }
      ]
    }

The above example defines a loot table load for this mob that says "When the mobs dies, each player will get 2 rolls for unique rewards on the entropis-test loot table. If they don't win anything, they will get 3 rolls on the consolation prize table."

Zone Command: lootTables Fields

  • chance: The chance that the loot table will be rolled on. Defaults to 100%.
  • mode: One of single or each. single will load one instance of the reward. each will roll for each player and place it in their inventory.
  • roomVnum: If using the single mode, put a room vnum here to load the reward on the ground in that room.
  • name: The name of the loot table to roll on. Must match a loot table defined in this zone.
  • rolls: The number of times to roll on the loot table. Multiple rolls equals multiple chances to win rewards.
  • oneShot: Boolean. This loot table should only reward once per boot. Successive times will reward nothing. Defaults to false
  • unique: Boolean. If set, do not reward more than 1 copy of the same item to any recipience. Defaults to false.
  • consolationTable: Optional name of a "consolation" loot table. If nothing is rewarded from the main loot table, this one will be rolled on.
  • consolationRolls: The number of rolls on the consolation table.

Weights

Weights are used to control the probability of a specific reward being selected to load from the loot table.

-1 weights will always load. You can have as many of these as desired in a loot table. You can combine them with randomly chosen items to have a loot table that has guaranteed rewards in addition to random ones.

If the item shouldn't load every time, give it a positive number in the weight field to indicate how likely it is. The exact number you use isn't important. The key piece is the total weight of the entire loot table. For example:

  • Three weight: 1 items equals a total weight of 3. Each item has therefore has a 33% chance to load.
  • Three weight: 1000 items equals a total weight of 3000. Since each item has an equal 1000 weight, they also have a 33% chance to load.
  • One weight: 700 item paired with two weight: 150 items would give a 70% chance to the first item, with a 15% chance each for the second two items.

Loot Table Reward Rules

The current rules (subject to change) for receiving personal loot via the each mode are:

  • The player must have caused threat to the NPC within the past 15 minutes.

As long as the criteria above is met, the player will receive the items in their inventory wherever they are in the world.