Manual:Zone Manual/Zone Source File

From DikuMUD Wiki
< Manual:Zone Manual
Revision as of 06:19, 15 November 2026 by Agent-mud (talk | contribs) (checked against the current code (wiki review 2026-11-15))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Zone source file

This chapter shows the parts of a zone file and the kinds of values its fields take. The next page covers the zone's header. After both you can write an empty zone that compiles.

Sections

A zone file is made of sections. Each starts with a header on a line of its own:

Header What it holds
%zone The zone's name and its global settings: title, reset interval and mode, creators. See Zone information section.
%rooms The rooms. See The Room Section.
%objects The objects. See The Objects Section.
%mobiles The NPCs. See The NPC Section.
%dil DIL templates: programs that any room, object or NPC, in any zone, can use. See The DIL Section.
%reset The commands that load NPCs and objects and set doors, run when the zone resets. See The Reset Section.
%end The end of the zone. Only comments may follow it.

The rules:

  • %zone comes first and %end last. Both are required.
  • The other sections are optional and may come in any order. Most zones use the order %zone, %dil, %rooms, %objects, %mobiles, %reset.
  • Use each section once. A second %rooms section makes vmc drop, without a word, every room, object and NPC written between the first %rooms and the second.
  • A %reset section must have at least one command; an empty one is a syntax error. Leave it out if you have nothing to reset.
  • Section headers and field names are lowercase, and case matters: %DIL or Title is an error.
  • One file is one zone, and the zone's name is the file's name: dragon.zon holds %zone dragon.

The rooms, objects and NPCs sections are lists of units. The reset section is a short program in a simple language, and the DIL section holds programs in DIL.

A skeleton that compiles:

#include <macros.h>

%zone dragon
lifespan 20
reset RESET_ANYHOW
creators {"whistler"}

%rooms

%objects

%mobiles

%end

Fields and values

Everything in a section is a field followed by its value:

field value

field is a keyword such as title or weight, and the value is one of the types below. Fields are separated only by spaces and line breaks; there are no commas or semicolons between them.

Number
A whole number: 20, -500, or in hexadecimal 0x0f3. You can write a sum, which vmc works out: +, -, *, / and parentheses, with whole numbers (weight 5 + 40 / 4 is 15). The headers define names for most numbers, such as SECT_SWAMP or SEX_MALE.
String
Text between double quotes. It may run over several lines, and the line breaks are kept as you wrote them:
title "The dark dragon altar"
descr
"A black stone altar fills the middle of the room. Its top is
scorched and still warm."
A string can't contain a double quote, not even as \"; use a single quote instead. A string that you forget to close runs on to the next " in the file, and the error is reported far below. Strings may contain colour and formatting codes.
String list
Strings in braces, separated by commas. A single string without braces is a list of one, and {} or null is an empty list. Used for names, creators, the names of an extra and the keywords of a door:
names {"black dragon", "dragon"}
creators {"whistler", "papi"}
Number list
Numbers in braces, separated by commas, or a single number. An extra can carry one for DIL programs to read:
extra {"$visits"} {1, 2, 3}
"A hidden extra that holds three numbers."
Flags
A number, or several numbers in braces. The numbers in braces are combined into one (a binary OR): each flag is one bit, so {2, 8} is 10. Always use the names from the headers:
flags {UNIT_FL_NO_WEATHER, UNIT_FL_INDOORS}
manipulate {MANIPULATE_TAKE, MANIPULATE_WEAR_BODY}
Make sure the flags fit the field: flags takes only UNIT_FL_ flags. vmc sees only the numbers, so a flag meant for another field compiles and sets something else.
Symbol
The name of a unit (a room, object or NPC) or of the zone. Every unit has one, written on the line that starts the unit, and other parts of the zone use it to refer to that unit. The rules:
  • It starts with a letter or _, followed by letters, digits and _.
  • At most 15 characters for a unit and 30 for a zone. A longer name is cut short, with only a warning.
  • No two units of a zone may have the same symbol, whatever their kind. The game doesn't tell capitals from small letters, so use lowercase.
  • A keyword can't be a symbol (door, key, level, names...), and neither can a word that a header defines as a macro (north, up, pause...). The keywords are listed in Reserved keyword listing.
Choose symbols that say what the unit is: dark_sword, not rm_5892. Gods see them in commands such as wstat and load.
In its own zone a unit is referred to by its symbol alone. From another zone, write symbol@zone (or zone/symbol): the sword above, in the zone dragon, is dark_sword@dragon. That is also how gods load it in the game: load dark_sword@dragon.

Fields with several parts

A few fields take more than one value:

  • Exits of a room: a direction, then the exit's own fields, ended by a semicolon: north to altar descr "You see an altar.";. See The Room Section.
  • Extras: extra, a string list, an optional number list, and a string. See Unit Building Blocks.
  • DIL programs: dilcopy name@zone(arguments);, or a whole program between dilbegin and dilend. See The DIL Section.
  • Affects on objects, such as a bonus to strength. You set them with the macros in wmacros.h; see Object macros.
Previous: The VMC pre-processor
Next: Zone information section