Zone Templates - torilmud/docs GitHub Wiki
Zone templates are where zones come alive. A template is a collection of commands and triggers that handle loading NPCs and items throughout the zone. Templates, combined with config files, replace the old .zon
files. Zone template files can be organized into folders under your main area's folder. For example, if you have a lot of mob templates for various areas of your zone, you can put them in a folder called Mobs to keep them together from your doors, objects, etc template files. However, this currently only works one level deep meaning you can't organize like <zone_name>/Mobs/Level-1/<template_name>, <zone_name>/Mobs/Level-2/<template_name>, etc.
- No max load: Max loads are no longer needed. Each zone command keeps track of the entities it loads, and refreshes them as needed.
- Individual refresh timers: Each command can specify its own refresh time, or use the default zone refresh time.
- Instance flags: You can set flags on items and NPCs as you load them and it only applies to that instance. This means you don't need multiple copies of an NPC to have, for example, sentinel and non-sentinel versions.
- No distro rooms: Every command can take an optional room pattern argument that can specify a subset of rooms to randomly execute the command in. This removes the need for distro rooms by allowing you to specifically target loads towards sectors and subzones.
- Triggers: Triggers allow you to execute a list of commands based on events that happen in your zone. This can allow you to create truly dynamic events.
- Quantities: A single command can specify a quantity of items or NPCs to load, greatly reducing the number of commands needed to populate a zone.
- Randomized weapons: Easily load a random weapon on any NPC.
- name: The name of this template. This name will be used wherever this template is loaded.
- commands: A list of commands to execute when this template is applied and refreshed.
- triggers: A list of triggers to listen for.
A template file consists of a name, a list of commands, and a list of triggers.
{
"name": "example",
"commands": [
{
"command": "load npc",
"vnum": 98303,
"quantity": 10,
"resetTime": 15,
"equipment": [98310, 98309, 98311],
"weapons": [98335, 98336, 98337],
"room": 21
},
{
"command": "load item",
"vnum": 98329,
"room": 21,
"equipment": [33815],
"contentQuantity": 25
},
{
"command": "set exit",
"room": 21,
"exit": "south",
"flags": {
"exitFlags": ["closed"]
}
}
],
"triggers": [
{
"trigger": "NPC Death",
"npcVnum": 98301,
"resetTime": 40,
"commands": [
{
"command": "message",
"delay": 8,
"text": "{{crimson}}NPC DEATH{{/}} has been triggered"
}
]
}
]
}
Zone commands make up the bulk of template files. When listed in the commands
array, they will be executed when the template is
first loaded as well as when they refresh. When listed as part of a trigger, the commands will be executed when the specified conditions are triggered.
Each command uses a similar set of fields, but not all properties are available to each command. They can be used in any order. Check the command documentation to learn how to use each one.
The following fields are standard and can be used in any zone command:
-
resetTime: The amount of time in minutes until this command is executed again. By default, each command will use the zone's reset time, but you can override it by setting this field.
-
chance: The percentage chance from 1-100 that this command will be executed at each reset. If omitted, the default chance is 100%.
-
delay: The time in ticks (1/4 of a second) until the command is executed. You can use this to delay loading something until some time after a boot or a reset.
-
chain: If
true
, the current command will only execute if the previous command was successful. This is useful for chaining together multiple commands triggered by a single rare load.
The following expanded fields are used in multiple command types.
The items field is commonly used when loading NPCs or filling chests and the like with gear. Unlike the equipment
and weapons
fields, items loaded via this field do not repop by default. Generally, use this field for loading gear desirable by PCs, and the others for stock items intended for flavor.
All ARMOR
and WEAPON
type items given to an NPC via this option will attempt to be worn by the NPC unless flagged as SECRET
. NOSHOW
flagged items will still be worn to allow for hidden items giving NPCS extra stats/saves/powers/etc.
Shopkeepers will not attempt to wear anything unless the item has a cost of 0
or is flagged as NOSELL
. This keeps them from trying to wear the items they're supposed to be selling while still allowing you to equip them with flavor items if you'd like.
- name: No use in game, but helpful for commenting the file. Optional.
- vnum: The vnum of the item to load.
- chance: The percentage chance that it will load. Optional. Defaults to 100.
-
reload: Controls whether this item can reload after the first execution. Optional. Defaults to
false
. - quantity: Use this when loading a limited amount of items with a zone command whose quantity is greater than 1. The item will then only load x number of times regardless of how many NPCs are loaded from the command. If left blank, the item will load the same number of times specified in the command quantity. See the second example below.
-
items: Allows you to load items into a container on an NPC. This is useful for things like loading a quiver onto an NPC and loading arrows into that quiver. This option uses the
name
,vnum
,chance
, andquantity
options as above. This option is not recursive. You can't load containers into containers into containers, and so on.
Two examples are given below.
The first is the normal usage of the items
field to give an item to an NPC.
{
"comment": "Master Chef",
"command": "load npc",
"vnum": 98328,
"room": 98398,
"items": [
{
"name": "ladle",
"vnum": 98339
}
]
},
The second example shows loading a quiver onto an NPC, then loading arrows into that quiver.
{
"comment": "a bandit archer",
"command": "load npc",
"vnum": 49008,
"room": 49086,
"equipment": [ 49000, 49005, 49009 ],
"weapons": [ 49013 ],
"items": [
{
"name": "an elk skin quiver",
"vnum": 49019,
"reload": "true",
"items": [
{
"name": "a pine wood arrow",
"vnum": 49020,
"quantity": 75
}
]
}
]
}
In the next example, we load 8 burly sailors all over the zone. Only one of them has a shiny golden ring that loads at boot though, so by setting the quantity
on the item
field to 1, it will limit loading them on just the first sailor. If omitted, it would load 8 of them at boot.
{
"comment": "Burly Sailors",
"command": "load npc",
"vnum": 98301,
"weapons": [98336, 98335],
"loadRooms": [
{"distro": "Main Cavern", "quantity": 3},
{"distro": "Exterior Beach", "quantity": 2},
{"distro": "Smuggler Ship", "quantity": 1},
{"vnum": 98397, "quantity": 1},
{"vnum": 98383, "quantity": 1}
],
"items": [
{
"name": "shiny golden ring",
"vnum": 98328,
"quantity": 1
}
],
}
This field is used in most zone commands and triggers to define a subset of rooms in the zone. In some commands, like triggers, this is a single field definition. Most commonly, this is defined as an array in an NPC or item load command, where each row defines a quantity of things to load. See the second example for more detail.
- vnum: A specific room vnum.
- vnums: An array of room vnums. One will be chosen at random.
- vnumStart: Used with vnum_end to create a range of vnums to choose from at random.
- vnumEnd: Used with vnum_start to create a range of vnums to choose from at random.
- sector: A sector name to restrict the load to. Used with the vnum range fields. Room Sector List
- subzone: A subzone name to restrict the load to. Used with the vnum range fields.
- distro: The name of a distro to use for loading. Defined in the template config file.
"loadRooms": [
{"vnumStart": 98300},
{"vnumEnd": 98399},
{"sector": "desert"},
{"subzone": "desert"}
]
In the following example, we load 8 burly sailors from the same command, specifying where and how many to load in the loadRooms array:
{
"comment": "Burly Sailors",
"command": "load npc",
"vnum": 98301,
"weapons": [98336, 98335],
"loadRooms": [
{"distro": "Main Cavern", "quantity": 3},
{"distro": "Exterior Beach", "quantity": 2},
{"distro": "Smuggler Ship", "quantity": 1},
{"vnum": 98397, "quantity": 1},
{"vnum": 98383, "quantity": 1}
]
}
This field contains all of the flags used throughout the game.
- npc: A list of NPC ACT flags to apply. Mob Act Flags
- affects: A list of affect flags to apply. Affect Flags
- templates: A list of racial templates to apply. Race Templates
-
exitFlags: A list of exit flags to apply. Exit flag values are
nobits
,is door
,closed
,locked
,pickable
,secret
,blocked
,pickproof
,trapped
.
"flags": {
"npc": ["aggressive"],
"templates": ["undead"],
"affects": ["haste", "detect invisibility"]
}
The template load field contains a few standard fields used in template loading.
-
name: This is the name of the template to load. This should match the
name
field in the template file that you want to load. -
mode: When loading a template, you can choose whether it overlays the existing commands or replaces them. The options are
overlay
orreplace
. It will default tooverlay
. - chance: This is the 0-100% chance to load the template. Defaults to 100.
"template": {
"name": "NPCs",
"mode": "overlay"
}