Manual:Zone Manual/The Reset Section/Loading objects and NPCs

From DikuMUD Wiki
< Manual:Zone Manual‎ | The Reset Section
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

Loading objects and NPCs

Two commands put the NPCs and objects you have built into the game: load and equip. load puts a unit in a room, in a container or in an NPC's inventory; equip puts an object on an NPC, as if the NPC had worn or wielded it.

The load command

load <unit> [into <room>] [max <n>] [zonemax <n>] [local <n>] [complete] [{ <more commands> }]

Everything after the unit is optional, and the options can come in any order.

unit
The symbolic name of the NPC or object to load. A unit from another zone takes its zone name: fido_dog@midgaard. Only NPCs and objects can be loaded; a room in this place is logged as an error.
into <room>
The room to load the unit into. It must be a room (anything else is ignored). Without into the unit goes into the unit of the enclosing block: the inventory of the NPC, or the inside of the container, that the block belongs to. A load that is not in a block needs into; without it the server logs Reset Error: Don't know where to put ....
max, zonemax, local
Limits on how many copies may exist, described below.
complete
Takes the unit away again if not all commands in its block succeeded. See Special reset functions.
block
More reset commands in braces. They run only if this unit was loaded, and they work on it.

When an NPC is loaded, the room sees "NPC has arrived.", and its size varies a little from the height in its definition.

Limits

Every time the zone resets, every load runs again. The limits keep that from filling the game with copies:

Limit The unit is loaded only if there are fewer than n
max <n> copies in the whole game, wherever they are (on players too).
zonemax <n> copies anywhere in this zone, also ones carried by NPCs or players or lying in containers there. The limit only applies when the unit is loaded into this zone.
local <n> copies directly in the place it is loaded into: the room, or the NPC or container of the enclosing block.

You can give more than one; all must be met. If you give none:

  • an NPC gets max 1: only one in the whole game. Two load guard into ... lines load one guard, not two. To have several, give a limit, e.g. zonemax 2 on each line, or local 1 to have one in each room.
  • an object gets local 1: one in the room or container it is loaded into.

A load that is stopped by its limit counts as failed, and its block doesn't run.

Blocks

Any command may be followed by a block of more commands in braces. The block runs only if the command loaded something, and the commands in it work on that unit. A simple load:

load guard into jail max 1

loads the guard into the jail if there is no guard anywhere in the game. With a block:

load guard into jail max 1
{
   load bone
   load bread into jail
}

if the guard is loaded, a bone is loaded into his inventory and bread into the jail. The block only runs when the guard himself is loaded. At the next reset, if the guard is still alive, he is not loaded again, and neither is his block: a guard whose bone was taken stays without one until he is killed and loaded again.

A block can hold more blocks:

load guard into jail max 1
{
   load bone
   load bread into jail
   load bag
   {
      load apple max 1
   }
}

Now the guard also gets a bag. If there is no apple anywhere in the game, there is one in the bag; otherwise the bag is empty. For the bag to hold anything, its object needs MANIPULATE_ENTER and room for the apple (see Object macros).

The equip command

equip <object> [position] <WEAR_position> [max <n>] [complete] [{ <more commands> }]

equip loads an object and puts it on the NPC of the enclosing block, so it must be inside an NPC's block. The word position is optional: equip helmet position WEAR_HEAD and equip helmet WEAR_HEAD are the same.

object
The symbolic name of the object.
WEAR_position
Where the NPC wears it; the constants are in vme.h:
Position Value Position Value
WEAR_FINGER_R 2 WEAR_WAIST 14
WEAR_FINGER_L 3 WEAR_WRIST_R 15
WEAR_NECK_1 4 WEAR_WRIST_L 16
WEAR_NECK_2 5 WEAR_WIELD 17
WEAR_BODY 6 WEAR_HOLD 18
WEAR_HEAD 7 WEAR_CHEST 19
WEAR_LEGS 8 WEAR_BACK 20
WEAR_FEET 9 WEAR_EAR_L 21
WEAR_HANDS 10 WEAR_EAR_R 22
WEAR_ARMS 11 WEAR_ANKLE_L 23
WEAR_SHIELD 12 WEAR_ANKLE_R 24
WEAR_ABOUT 13
Use the WEAR_ constants here, not the object's MANIPULATE_WEAR_ flags. Without a position the server logs that the object "doesn't have a legal equip position" and loads nothing.
max <n>
Load it only if there are fewer than n copies in the whole game. equip takes no zonemax or local.

The object is equipped only if the NPC has nothing in that position yet. It is put there whether or not its manipulate flags allow wearing it there, and it is resized to fit the NPC.

Dressing a guard with objects from the same zone, so no zone names are needed:

load guard into jail
{
   equip helmet position WEAR_HEAD
   equip plate position WEAR_BODY
   equip pants position WEAR_LEGS
   equip specialsword position WEAR_WIELD max 1
   load brass_key
}

The guard gets a helmet, a plate and pants, and the special sword if there isn't one in the game already. The key goes into his inventory.

Blocks work after equip too. Here a pile of silver is loaded into the room only if a guard is loaded and gets the power sword:

load guard into safe_room zonemax 2
{
   equip plate position WEAR_BODY
   equip powersword position WEAR_WIELD max 1
   {
      load silver_pile into safe_room
   }
}
load guard into safe_room zonemax 2
{
   equip plate position WEAR_BODY
   equip powersword position WEAR_WIELD max 1
   {
      load silver_pile into safe_room
   }
}

At the first reset both guards are loaded, but only the first gets the sword (max 1), so there is one pile of silver. The silver is an object without a limit of its own, so it gets local 1: it won't be loaded while a pile is still in the room. One load line loads at most one copy, so two guards need two lines.

The dragon station's resets, with all of this together, are in Reset walk through.

Previous: The Reset Section
Next: Special reset functions