Manual:Zone Manual/The Reset Section

From DikuMUD Wiki
< Manual:Zone Manual
Revision as of 06:23, 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

The reset section

Rooms exist as soon as the zone is loaded, but the NPCs and objects you have written are only templates: nothing of them is in the game until something loads it. The reset section does that. It is a list of commands that the server runs when the zone resets: it loads NPCs and objects into rooms, puts objects into containers and NPCs' inventories, dresses NPCs, makes NPCs follow each other, and closes, locks or hides doors that players have opened.

The section starts with %reset and is usually the last one, just before %end. It must hold at least one command: an empty %reset is a syntax error, so leave the header out if you have nothing to reset.

When the reset section runs

Two fields in the zone header decide when the commands run:

lifespan
Minutes between resets (default 60). The server adds a random delay of up to three minutes so that not all zones reset at the same moment. With lifespan 0 the zone is never reset, not even at boot.
reset
The reset mode, one of the constants from vme.h:
Mode Value The reset section runs
RESET_NOT 0 once, when the game boots. This is the default.
RESET_IFEMPTY 1 at boot, then every lifespan minutes if no player is in the zone; while one is, it tries again every minute.
RESET_ANYHOW 2 at boot, then every lifespan minutes, players or not.
RESET_NEVER 3 never, not even at boot.

A zone that should refill itself while the game runs needs RESET_IFEMPTY or RESET_ANYHOW; with the default, NPCs that are killed stay dead until the next reboot. An administrator can also reset a zone by hand with the reset command (reset dragonst), and wstat zone dragonst reset lists a zone's reset commands as the server read them.

How the commands run

The commands run from top to bottom, every time the zone resets. They are not a script that runs once: the same load runs again at the next reset, and only its limits (max, zonemax, local, see Loading objects and NPCs) stop it from loading a second copy.

Any command can be followed by a block in braces with more commands. The block runs only if its command succeeded, and the commands in it work on what that command loaded: a load in an NPC's block goes into the NPC's inventory, one in a container's block goes into the container. Blocks can be nested as deep as you like.

Command What it does Described in
door sets the flags of one side of a door below
load loads an NPC or object into a room, or into the unit of the enclosing block Loading objects and NPCs
equip loads an object and puts it on the NPC of the enclosing block Loading objects and NPCs
follow loads an NPC next to the NPC of the enclosing block and makes it follow Special reset functions
purge empties a room of everything but players Special reset functions
remove removes every copy of a unit from a room Special reset functions
random runs its block a given percentage of the time Special reset functions
nop does nothing and always succeeds; only useful with a block Special reset functions

The order of the commands is up to you. A common one is doors first, then objects in rooms, then NPCs with their equipment.

vmc does not check the names in reset commands. A misspelt unit compiles, and the server logs it when it boots (Slimed: Illegal ref.: ...) and loads a blob of green slime in its place. After adding resets, read the server log and wstat zone <zone> errors.

Door resets

A door is two exits, one in each room, and each side has its own flags. The flags in the room definition are what the door starts with when the zone is loaded. After that only the reset section changes them back: a door that a player opened stays open until a door command closes it. Here are two rooms from the dragon station joined by a door:

hallway
title "Module tunnel"
descr
"The hallway is about 50 metres long and around 100 metres from side to
side and top to bottom."
movement SECT_INSIDE
ALWAYS_LIGHT
flags {UNIT_FL_NO_WEATHER, UNIT_FL_INDOORS}

east to office descr
"You see what looks to be an office."
keyword {"air lock door","air lock","door"}
open {EX_OPEN_CLOSE, EX_CLOSED};
end

office
title "The station office"
descr
"Large paintings fill the walls of this part of the station."
movement SECT_INSIDE
ALWAYS_LIGHT
flags {UNIT_FL_NO_WEATHER, UNIT_FL_INDOORS}

west to hallway descr
"You see what looks to be a hallway."
keyword {"air lock door","air lock","door"}
open {EX_OPEN_CLOSE, EX_CLOSED};
end

The door command is:

door <room> <direction> <flags>
room
The symbolic name of the room the exit is in. A room in another zone takes its zone name: door myroom ... for a room in this zone, door out_room@frogwart ... for one in the zone frogwart.
direction
The exit, as a number. Use the direction macros from vme.h (included by macros.h):
Macro Value Macro Value
NORTH 0 DOWN 5
EAST 1 NORTHEAST 6
SOUTH 2 NORTHWEST 7
WEST 3 SOUTHEAST 8
UP 4 SOUTHWEST 9
If the room has no exit in that direction the server logs Zone Reset Error: No ... direction from room ... in door and does nothing. vmc does not check the number; only 0 to 9 are exits.
flags
The new flags of that exit, one flag or several in braces. They replace all the exit's flags, so list every flag the exit should have, also the ones that are not about the door's state (EX_CLIMB, EX_PICKPROOF, ...). The flags are those of the open field of an exit:
Flag Meaning
EX_OPEN_CLOSE The exit is a door, gate or the like that can be opened and closed.
EX_CLOSED The door is closed.
EX_LOCKED The door is locked. Without a key on the exit it can only be opened with the pick skill, the unlock spell or from DIL.
EX_PICKPROOF The lock can't be picked. (The unlock spell still opens it.)
EX_HIDDEN The exit can't be seen until someone finds it with search.
EX_CLIMB The exit must be climbed.
EX_FALL_THIS_WAY Things that fall in the room fall this way.

To close the door between the two rooms at every reset, reset both sides:

door hallway EAST {EX_OPEN_CLOSE, EX_CLOSED}
door office WEST {EX_OPEN_CLOSE, EX_CLOSED}

If you reset only one side, the other side stays open after a player opened it, and the door is closed from one room and open from the other.

The reset can also give the door a different state from the one in the room definition. This locks the door at every reset:

door hallway EAST {EX_OPEN_CLOSE, EX_CLOSED, EX_LOCKED}
door office WEST {EX_OPEN_CLOSE, EX_CLOSED, EX_LOCKED}

The two sides needn't have the same flags. The secret door in the dragon station is hidden only on the office side (see Reset walk through).

A door command never counts as a success, so a block after it never runs; give it none.

Previous: Suggested object exercises
Next: Loading objects and NPCs