Difference between revisions of "Manual:Zone Manual/The Reset Section/Loading objects and NPCs"

From DikuMUD Wiki
Jump to navigation Jump to search
(checked against the current code (wiki review 2026-11-15))
 
Line 1: Line 1:
 
=== Loading objects and NPCs ===
 
=== Loading objects and NPCs ===
  
−
Time to start loading your zone with its life and all the other
+
Two commands put the NPCs and objects you have built into the game: <code>load</code> and <code>equip</code>. <code>load</code> puts a unit in a room, in a container or in an NPC's inventory; <code>equip</code> puts an object on an NPC, as if the NPC had worn or wielded it.
−
strange things you have built.  There is two commands that do all the
 
−
loading and equipping of objects. Oddly enough the commands are called
 
−
'load' and 'equip'.  The format of the commands are almost the same
 
−
but equip must be used inside a NPC grouping.  With that in mind lets
 
−
start with simple loads and work our way up.
 
  
−
The command to load an object or an NPC into a room is as
+
==== The load command ====
−
follows:
 
−
<nowiki>
 
−
load &lt;object or NPC&gt; [into] [&lt;room&lt;] [&lt;load amount&gt;]
 
−
  [{Other loads and equip commands}]</nowiki>
 
−
;object or NPC
 
−
: The first argument to the load command is the object or NPC symbolic name that you want to load.  The first argument is the only one that must be included in all load commands.
 
−
;into
 
−
: This is just a symbol that tells the reset that we are loading the object or NPC into some other unit.
 
−
;object, NPC, and room
 
−
: The third argument is the symbolic name of the place where you are loading the object and the NPC.
 
−
;load amount
 
−
: the fourth argument is an optional argument that tells the reset how many of the objects are allowed in the world, zone, or locally.  The possible values for this field are as follows:
 
  
−
;max &lt;num&gt;
+
<pre>
−
: This  command  is  always  part  of  another reset command (load,
+
load <unit> [into <room>] [max <n>] [zonemax <n>] [local <n>] [complete] [{ <more commands> }]
−
equip, etc.).  At reset time the entire world is scanned for occurences
+
</pre>
−
of the loaded unit - only if the currently existing number is less than
 
−
&lt;num&gt; will the command be executed.
 
−
;local &lt;num&gt;
 
−
: This command is always  part  of  another  reset  command  (load,
 
−
equip, etc.).  At reset time the location of which the unit is to
 
−
be loaded into is scanned for occurences of the loaded unit only  if  the currently
 
−
existing number is less than &lt;num&gt; will the
 
−
command be executed.
 
−
;zonemax &lt;num&gt;
 
−
: This command is always  part  of  another  reset  command  (load,
 
−
equip,  etc.).  At  reset  time  the  entire zone being reset is
 
−
scanned for occurences of the loaded unit - only if the currently
 
−
existing number is less than &lt;num&gt; will the command be
 
−
executed.
 
  
−
;Optional grouping
+
Everything after the unit is optional, and the options can come in any order.
−
: Any reset command may be followed by a pair of curly brackets {}
 
−
containing  more reset commands. The commands inside the brackets
 
−
will only be executed in case the associated command was successful.
 
  
−
Don't be alarmed if this sounds a bit hard. It all gets much
+
;unit
−
more clear as some examples are explained. Lets take a look at the
+
:The symbolic name of the NPC or object to load. A unit from another zone takes its zone name: <code>fido_dog@midgaard</code>. Only NPCs and objects can be loaded; a room in this place is logged as an error.
−
following example and see if we can't make this much more clear.
+
;into &lt;room&gt;
−
<nowiki>
+
:The room to load the unit into. It must be a room (anything else is ignored). Without <code>into</code> 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 <code>load</code> that is not in a block needs <code>into</code>; without it the server logs <code>Reset Error: Don't know where to put ...</code>.
−
load udgaard/fido into midgaard/temple max 1</nowiki>
+
;max, zonemax, local
−
This example is pretty simple it says load the fido into the
+
:Limits on how many copies may exist, described below.
−
temple only if there isn't already 1 in the world. Now lets get a bit
+
;complete
−
more complicated.
+
:Takes the unit away again if not all commands in its block succeeded. See [[Manual:Zone Manual/The Reset Section/Special reset functions|Special reset functions]].
−
<nowiki>
+
;block
−
load udgaard/fido into midgaard/temple max 1
+
:More reset commands in braces. They run only if this unit was loaded, and they work on it.
−
{
 
−
  load bone
 
−
  load excrement into midgaard/temple
 
−
}</nowiki>
 
−
Now we have said again load the fido into the temple if there is
 
−
not already one in the world. Then if fido loads fill his inventory
 
−
with a bone and load excrement into the temple as well.
 
  
−
We can get even more complicated but still just using the load
+
When an NPC is loaded, the room sees "''NPC'' has arrived.", and its size varies a little from the height in its definition.
−
commands by doing the following
+
 
−
<nowiki>
+
==== Limits ====
−
load udgaard/fido into midgaard/temple max 1
+
 
−
{
+
Every time the zone resets, every <code>load</code> runs again. The limits keep that from filling the game with copies:
−
  load bone
 
−
  load excrement into midgaard/temple
 
−
      load bag
 
−
  {
 
−
      load apple max 1
 
−
  }
 
−
}</nowiki>
 
−
now we still have the fido loading if there isn't one already in
 
−
the world then the bone and the excrement and finally we load a bag.
 
−
If there isn't an apple already in the world we load the bag with a
 
−
apple in it other wise the bag will be empty.
 
  
−
Well that should be enough load examples for now but we will get
 
−
right back to them in a bit.  Now we should introduce another reset
 
−
command called the 'equip' command that we have already mentioned.  The
 
−
'equip' command works a lot like load but has much simpler arguments.
 
−
The 'equip' command is as follows.
 
−
<nowiki>
 
−
equip &lt;symbol&gt; position [load amount &lt;num&gt;]</nowiki>
 
−
;symbol
 
−
: The first argument is just the symbolic name of the item being worn by the NPC.
 
−
;position
 
−
: The position is any of the positions available in the
 
−
''vme.h''.  The following are all the positions along
 
−
side there defines as found in the ''vme.h''.
 
 
{| class="wikitable"
 
{| class="wikitable"
−
|+Wear positions
+
! Limit !! The unit is loaded only if there are fewer than ''n''
 
|-
 
|-
−
!Position
+
| <code>max &lt;n&gt;</code> || copies in the whole game, wherever they are (on players too).
−
!Define(s)
 
 
|-
 
|-
−
|head
+
| <code>zonemax &lt;n&gt;</code> || 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.
−
|WEAR_HEAD
 
 
|-
 
|-
−
|hands
+
| <code>local &lt;n&gt;</code> || copies directly in the place it is loaded into: the room, or the NPC or container of the enclosing block.
−
|WEAR_HANDS
+
|}
−
|-
+
 
−
|arms
+
You can give more than one; all must be met. If you give none:
−
|WEAR_ARMS
+
* an NPC gets <code>max 1</code>: only one in the whole game. Two <code>load guard into ...</code> lines load one guard, not two. To have several, give a limit, e.g. <code>zonemax 2</code> on each line, or <code>local 1</code> to have one in each room.
−
|-
+
* an object gets <code>local 1</code>: one in the room or container it is loaded into.
−
|body
+
 
−
|WEAR_BODY
+
A <code>load</code> 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:
 +
 
 +
<pre>
 +
load guard into jail max 1
 +
</pre>
 +
 
 +
loads the guard into the jail if there is no guard anywhere in the game. With a block:
 +
 
 +
<pre>
 +
load guard into jail max 1
 +
{
 +
  load bone
 +
  load bread into jail
 +
}
 +
</pre>
 +
 
 +
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:
 +
 
 +
<pre>
 +
load guard into jail max 1
 +
{
 +
  load bone
 +
  load bread into jail
 +
  load bag
 +
  {
 +
      load apple max 1
 +
  }
 +
}
 +
</pre>
 +
 
 +
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 <code>MANIPULATE_ENTER</code> and room for the apple (see [[Manual:Zone Manual/The Objects Section/Object macros|Object macros]]).
 +
 
 +
==== The equip command ====
 +
 
 +
<pre>
 +
equip <object> [position] <WEAR_position> [max <n>] [complete] [{ <more commands> }]
 +
</pre>
 +
 
 +
<code>equip</code> loads an object and puts it on the NPC of the enclosing block, so it must be inside an NPC's block. The word <code>position</code> is optional: <code>equip helmet position WEAR_HEAD</code> and <code>equip helmet WEAR_HEAD</code> are the same.
 +
 
 +
;object
 +
:The symbolic name of the object.
 +
;WEAR_position
 +
:Where the NPC wears it; the constants are in ''vme.h'':
 +
 
 +
{| class="wikitable"
 +
! Position !! Value !! Position !! Value
 
|-
 
|-
−
|legs
+
| <code>WEAR_FINGER_R</code> || 2 || <code>WEAR_WAIST</code> || 14
−
|WEAR_LEGS
 
 
|-
 
|-
−
|feet
+
| <code>WEAR_FINGER_L</code> || 3 || <code>WEAR_WRIST_R</code> || 15
−
|WEAR_FEET
 
 
|-
 
|-
−
|cloak
+
| <code>WEAR_NECK_1</code> || 4 || <code>WEAR_WRIST_L</code> || 16
−
|WEAR_ABOUT
 
 
|-
 
|-
−
|shield
+
| <code>WEAR_NECK_2</code> || 5 || <code>WEAR_WIELD</code> || 17
−
|WEAR_SHIELD
 
 
|-
 
|-
−
|hold
+
| <code>WEAR_BODY</code> || 6 || <code>WEAR_HOLD</code> || 18
−
|WEAR_HOLD
 
 
|-
 
|-
−
|wield
+
| <code>WEAR_HEAD</code> || 7 || <code>WEAR_CHEST</code> || 19
−
|WEAR_WIELD
 
 
|-
 
|-
−
|ear
+
| <code>WEAR_LEGS</code> || 8 || <code>WEAR_BACK</code> || 20
−
|WEAR_EAR_R and WEAR_EAR_L
 
 
|-
 
|-
−
|neck
+
| <code>WEAR_FEET</code> || 9 || <code>WEAR_EAR_L</code> || 21
−
|WEAR_NECK_1 and WEAR_NECK_2
 
 
|-
 
|-
−
|wrist
+
| <code>WEAR_HANDS</code> || 10 || <code>WEAR_EAR_R</code> || 22
−
|WEAR_WRIST_R and WEAR_WRIST_L
 
 
|-
 
|-
−
|finger
+
| <code>WEAR_ARMS</code> || 11 || <code>WEAR_ANKLE_L</code> || 23
−
|WEAR_FINGER_R and WEAR_FINGER_L
 
 
|-
 
|-
−
|chest
+
| <code>WEAR_SHIELD</code> || 12 || <code>WEAR_ANKLE_R</code> || 24
−
|MANIPULATE_WEAR_CHEST
 
 
|-
 
|-
−
|back
+
| <code>WEAR_ABOUT</code> || 13 || ||
−
|MANIPULATE_WEAR_BACK
 
−
|-
 
−
|waist
 
−
|MANIPULATE_WEAR_WAIST
 
−
|-
 
−
|ankle
 
−
|WEAR_ANKLE_R and WEAR_ANKLE_L
 
 
|}
 
|}
−
;load amount
 
−
: the fourth argument is an optional argument that tells the reset how many of the objects are allowed in the world, zone, or locally.  The possible values for this field are as follows:
 
  
−
;max &lt;num&gt;
+
:Use the <code>WEAR_</code> constants here, not the object's <code>MANIPULATE_WEAR_</code> flags. Without a position the server logs that the object "doesn't have a legal equip position" and loads nothing.
−
: This  command  is  always  part  of  another reset command (load,
+
;max &lt;n&gt;
−
equip, etc.).  At reset time the entire world is scanned for occurences
+
:Load it only if there are fewer than ''n'' copies in the whole game. <code>equip</code> takes no <code>zonemax</code> or <code>local</code>.
−
of the loaded unit - only if the currently existing number is less than
+
 
−
&lt;num&gt; will the command be executed.
+
The object is equipped only if the NPC has nothing in that position yet. It is put there whether or not its <code>manipulate</code> flags allow wearing it there, and it is resized to fit the NPC.
−
;local &lt;num&gt;
+
 
−
: This command is always  part  of  another  reset  command  (load,
+
Dressing a guard with objects from the same zone, so no zone names are needed:
−
equip, etc.). At reset time the location of which the unit is to
+
 
−
be loaded into is scanned for occurences of the loaded unit - only if the currently
+
<pre>
−
existing number is less than &lt;num&gt; will the
+
load guard into jail
−
command be executed.
+
{
−
;zonemax &lt;num&gt;
+
  equip helmet position WEAR_HEAD
−
: This command is always  part  of  another  reset  command  (load,
+
  equip plate position WEAR_BODY
−
equip,  etc.).  At  reset  time  the  entire zone being reset is
+
  equip pants position WEAR_LEGS
−
scanned for occurences of the loaded unit - only if the currently
+
  equip specialsword position WEAR_WIELD max 1
−
existing number is less than &lt;num&gt; will the command be
+
  load brass_key
−
executed.
+
}
 +
</pre>
 +
 
 +
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 <code>equip</code> too. Here a pile of silver is loaded into the room only if a guard is loaded and gets the power sword:
 +
 
 +
<pre>
 +
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
 +
  }
 +
}
 +
</pre>
  
−
Now with the equipment command you can now get your NPCs dressed
+
At the first reset both guards are loaded, but only the first gets the sword (<code>max 1</code>), so there is one pile of silver. The silver is an object without a limit of its own, so it gets <code>local 1</code>: it won't be loaded while a pile is still in the room. One <code>load</code> line loads at most one copy, so two guards need two lines.
−
and ready for battle.  The 'load' and 'equip' commands are not the
 
−
easiest though so lets go through some simple examples.
 
−
<nowiki>
 
−
load guard into jail
 
−
  {
 
−
  equip helmet WEAR_HEAD
 
−
  equip plate WEAR_BODY
 
−
  equip pants WEAR_LEGS
 
−
  equip specialsword max 1
 
−
  load brass_key
 
−
  }</nowiki>
 
−
This is how you would equip a NPC with all items from the current
 
−
zone.  As you can see we didn't need full symbolics because the server
 
−
knows to grab the items from the zone the resets are in.
 
−
<nowiki>
 
−
load guard into safe_room max 2
 
−
{
 
−
equip plate WEAR_BODY
 
−
load powersword max1
 
−
  {
 
−
  load silver_pile into safe_room
 
−
  }
 
−
}</nowiki>
 
−
In this example we only load the silver pile if the guard loads
 
−
and if the power sword loads which may or may not happen since there is
 
−
only a max of one sword allowed while there is a max of 2 guards
 
−
allowed.  What will happen in this case is at the first reset there will
 
−
be one guard and one pile of silver.  The next reset there will still
 
−
only be one pile of silver but now there will be two guards.
 
  
−
Hopefully you have got the basic resets down.  If not don't worry
+
The dragon station's resets, with all of this together, are in [[Manual:Zone Manual/The Reset Section/Reset walk through|Reset walk through]].
−
there are plenty more examples to come and we still have to make the
 
−
resets for our dragon station zone.
 
  
 
<div style='padding-top: 30px; padding-bottom: 20px; text-align: left;float:left;width:50%;'>[[Manual:Zone_Manual/The_Reset_Section|Previous: The Reset Section]]</div>
 
<div style='padding-top: 30px; padding-bottom: 20px; text-align: left;float:left;width:50%;'>[[Manual:Zone_Manual/The_Reset_Section|Previous: The Reset Section]]</div>
 
<div style='padding-top: 30px; padding-bottom: 20px; text-align: right;float:right;width:50%;'>[[Manual:Zone_Manual/The_Reset_Section/Special_reset_functions|Next: Special reset functions]]</div>
 
<div style='padding-top: 30px; padding-bottom: 20px; text-align: right;float:right;width:50%;'>[[Manual:Zone_Manual/The_Reset_Section/Special_reset_functions|Next: Special reset functions]]</div>

Latest revision as of 06:23, 15 November 2026

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