Difference between revisions of "Manual:Zone Manual/The Reset Section/Special reset functions"

From DikuMUD Wiki
Jump to navigation Jump to search
(checked against the current code (wiki review 2026-11-15))
 
Line 1: Line 1:
 
=== Special reset functions ===
 
=== Special reset functions ===
  
−
Now that we have gone over the basic load and equip commands we
+
Besides <code>load</code> and <code>equip</code> the reset section has a few more commands and one more option: <code>complete</code> keeps a unit only if everything in its block worked, <code>follow</code> loads a group, <code>purge</code> and <code>remove</code> clear things away, and <code>random</code> loads things only some of the time.
−
have some special commands that you can add to them to make them do more
+
 
−
interesting things. Sometimes when doing resets you don't always want
+
==== Success and failure ====
−
items or NPCs to load or sometimes you want them to load but only if a
+
 
−
certain amount of other things correctly load. There are also times you
+
Every reset command either succeeds or fails, and that decides what happens next:
−
want to clear the rooms or reload an entire object after removing the
+
* A command's block runs only if the command succeeded.
−
old one. All these things and more can be accomplished with the reset
+
* <code>complete</code> (below) looks at whether the commands in its block succeeded.
−
section.
+
 
−
==== The complete directive. ====
+
{| class="wikitable"
 +
! Command !! Succeeds when
 +
|-
 +
| <code>load</code>, <code>equip</code>, <code>follow</code> || the unit was loaded. They fail when a limit stops them, when the NPC already wears something in that position (<code>equip</code>), or on an error (logged).
 +
|-
 +
| <code>random</code> || the dice roll was under the percentage.
 +
|-
 +
| <code>nop</code> || always.
 +
|-
 +
| <code>door</code>, <code>purge</code>, <code>remove</code> || never: they do their work but count as failed, so a block after them never runs.
 +
|}
 +
 
 +
==== The complete option ====
 +
 
 +
<code>complete</code> can be added to <code>load</code>, <code>equip</code> and <code>follow</code>. The unit is loaded and its block runs as usual; then, if any command directly in the block failed, the unit is removed again, with everything it carries.
 +
 
 +
<pre>
 +
load captain into jail_room complete
 +
{
 +
  equip magic_sword position WEAR_WIELD max 1
 +
  load bag
 +
  {
 +
      load ruby_ring max 1
 +
  }
 +
}
 +
</pre>
 +
 
 +
The captain stays only if he got the magic sword and the bag. Only the commands directly in his block count: if the ruby ring isn't loaded (because one exists already), the bag was still loaded, so the captain stays, with an empty bag. To make a missing ring remove the captain too, give the bag <code>complete</code> as well: then the bag is removed when the ring fails, the bag counts as failed, and so does the captain.
 +
 
 +
Because <code>door</code>, <code>purge</code> and <code>remove</code> always count as failed, don't put them in a <code>complete</code> block. The same goes for a <code>load</code> that is often stopped by its limit: an object with no limit gets <code>local 1</code>, which counts what is already inside the unit.
 +
 
 +
The unit is removed after it was loaded, so the room still sees an NPC that is removed this way arrive.
  
−
The 'load' and 'equip' commands have one more argument that can be
 
−
placed at the end of them to make them act a bit different.the complete
 
−
directive. In the case where this directive is placed at the end
 
−
of a 'load or 'equip' command, the unit is only loaded in case all immediate commands inside
 
−
its nesting are executed successfully.  For example:
 
−
<nowiki>
 
−
load captain into jail_room complete
 
−
{
 
−
  equip magic_sword position WEAR_WIELD max 1
 
−
  load bag
 
−
  {
 
−
      load ruby_ring max 1
 
−
  }
 
−
}</nowiki>
 
−
In this case the captain is only loaded if the objects magic_sword
 
−
and bag are successfully loaded. if the ruby_ring is not loaded,
 
−
it will have no effect on the complete directive. To make the ruby_ring
 
−
affect to captains complete directive, the bag must also have specified a
 
−
complete directive (because the bag would then not be complete, and thus the
 
−
captain would not be complete).
 
 
==== The follow command ====
 
==== The follow command ====
  
−
Once you load a NPC you may want that NPC to follow another NPC.
+
<pre>
−
  That is what the 'follow' command is for.  The following is the format
+
follow <NPC> [max <n>] [zonemax <n>] [local <n>] [complete] [{ <more commands> }]
−
  of the 'follow' command
+
</pre>
−
<nowiki>
+
 
−
  follow &lt;symbol&gt; &lt;load amount #&gt; &lt;complete&gt;</nowiki>
+
<code>follow</code> goes in an NPC's block. It loads another NPC into the same room and makes it follow the NPC of the block, so the two move about as a group. The follower's own block works on the follower, so you can dress it there.
−
;symbol
+
 
−
: The first argument to the follow command is the symbolic name of the NPC to follow the NPC of the outer grouping.
+
The limits are those of <code>load</code> (see [[Manual:Zone Manual/The Reset Section/Loading objects and NPCs|Loading objects and NPCs]]), and as with <code>load</code> an NPC without a limit gets <code>max 1</code>. <code>local</code> is no use here: it counts what the leader carries, not the NPCs in the room.
−
;load amount
 
−
: the second argument is an optional argument that tells the reset how many of the NPC followers of this type  are allowed in the world, zone, or locally. The possible values for this field are as follows:
 
  
−
;max &lt;num&gt;
+
A captain with two guards:
−
: This  command  is  always  part  of  another reset command (load,
 
−
equip, etc.).  At reset time the entire world 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.
 
−
;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.
 
  
−
;complete
+
<pre>
−
: This only makes the NPC follow if all the other things in the grouping finishes completely. For a better description of how this directive works see (Link to resetcomplete).
+
load captain into jail
 +
{
 +
  follow guard max 4
 +
  {
 +
      equip guard_helmet position WEAR_HEAD
 +
      equip guard_plate position WEAR_BODY
 +
      equip guard_legs position WEAR_LEGS
 +
      equip guard_boots position WEAR_FEET
 +
  }
 +
  follow guard max 4
 +
  {
 +
      equip guard_helmet position WEAR_HEAD
 +
      equip guard_plate position WEAR_BODY
 +
      equip guard_legs position WEAR_LEGS
 +
      equip guard_boots position WEAR_FEET
 +
  }
 +
}
 +
</pre>
 +
 
 +
Each <code>follow</code> line loads one guard, so two lines give two guards, as long as there are fewer than four in the game. The guards are only loaded together with a new captain: while the captain lives, his block doesn't run.
  
−
The follow command is always used nested inside a loaded
 
−
NPC to force the NPC &lt;symbol&gt; to follow the NPC of the outer
 
−
grouping.  The following would be a correct use of the follow
 
−
command.
 
−
<nowiki>
 
−
load captain into jail
 
−
  {
 
−
  follow guard max 4
 
−
    {
 
−
equip guard_helmet WEAR_HEAD
 
−
equip guard_plate WEAR_BODY
 
−
equip guard_legs WEAR_LEGS
 
−
equip guard_boots WEAR_FEET
 
−
}
 
−
  follow guard max 4
 
−
    {
 
−
equip guard_helmet WEAR_HEAD
 
−
equip guard_plate WEAR_BODY
 
−
equip guard_legs WEAR_LEGS
 
−
equip guard_boots WEAR_FEET
 
−
}
 
−
  }</nowiki>
 
−
This example would load two guards that are fully dressed and
 
−
they would start following the captain which is also loaded.
 
 
==== The purge command ====
 
==== The purge command ====
  
−
There are times when you want to clean up a room.  This can be
+
<pre>
−
done very easy by using the '''purge'''. The following is
+
purge <room>
−
the format of the purge command.
+
</pre>
−
<nowiki>
+
 
−
purge &lt;symbol&gt;</nowiki>
+
Removes every NPC and object from the room. Players stay, and so do rooms inside the room. To empty the jail at every reset:
−
This command doesn't take much description.  The symbol is the
+
 
−
room you want to empty of all objects and NPCs. If you wanted to get
+
<pre>
−
rid of all objects and NPCs from a room with the symbolic name of jail
+
purge jail
−
it would look like this.
+
</pre>
−
<nowiki>
+
 
−
purge jail</nowiki>
+
==== The remove command ====
 +
 
 +
<pre>
 +
remove <unit> in <room>
 +
</pre>
 +
 
 +
Removes every copy of the unit that lies in the room (not copies that someone carries or that are in a container).
 +
 
 +
An NPC that is still alive at a reset is not loaded again, and neither is its block: a guard whose sword was stolen stays without one, and a chest that players emptied stays empty. <code>remove</code> lets you start such a unit afresh. A cabinet that holds a knife and a bag of sugar after every reset:
 +
 
 +
<pre>
 +
remove cabinet in kitchen
 +
load cabinet into kitchen
 +
{
 +
  load sugarbag
 +
  load knife
 +
}
 +
</pre>
 +
 
 +
The old cabinet goes, with whatever is in it, and a new one is loaded and filled.
 +
 
 
==== The random command ====
 
==== The random command ====
  
−
If you ever want to load something only some of the time.  There
+
<pre>
−
is a built in '''random''' command that allows you to pick
+
random <percent>
−
the percentage of the time that the item will load.  The random command
+
{
−
has the following format.
+
  <more commands>
−
<nowiki>
+
}
−
random &lt;num&gt;
+
</pre>
−
  {group or single set of resets}</nowiki>
+
 
−
It is important to point out this is done by a random percentage
+
Runs its block with the given chance: <code>random 80</code> runs it 80% of the time, <code>random 100</code> always, <code>random 0</code> never.
−
chance where as 1% of the time would be almost not at all and 100% of
+
 
−
the time would be all the time. If we wanted to load a group of things
+
The block of <code>random</code> has no unit of its own to work on. Every <code>load</code> in it needs <code>into</code> a room, and <code>equip</code> and <code>follow</code> can't be used directly in it. To load something at random into an NPC, put the <code>random</code> around the NPC's <code>load</code>, and the rest in the NPC's block:
−
only 80% of the time it would look like this.
+
 
−
<nowiki>
+
<pre>
−
random 80
+
random 80
−
  {
+
{
−
  load captain into jail_room complete
+
  load captain into jail_room complete
−
    {
+
  {
−
    equip magic_sword position WEAR_WIELD max 1
+
      equip magic_sword position WEAR_WIELD max 1
−
    load bag
+
      load bag
−
      {
+
      {
−
      load ruby_ring max 1
+
        load ruby_ring max 1
−
      }
+
      }
−
    }
+
  }
−
}</nowiki>
+
}
−
==== The remove command ====
+
</pre>
 +
 
 +
Now the captain, if there is none yet, is loaded at 80% of the resets.
 +
 
 +
==== The nop command ====
 +
 
 +
<code>nop</code> does nothing and always succeeds, so a block after it always runs. It is a way to group commands; as with <code>random</code>, give every <code>load</code> in its block an <code>into</code>, and don't put <code>equip</code> or <code>follow</code> directly in it.
  
−
Many times players take items out of containers like chests or
+
<pre>
−
steal items from your NPCs and leave them naked.  If the NPC is not dead
+
nop
−
the resets don't reload them therefore your NPCs will stand there empty
+
{
−
and so will your chests.  This is fine if that is what you want but
+
  load guard into hall local 1
−
sometimes you want them to get dressed or refilled again at reset time.  that is
+
  load bone into hall
−
what the '''remove''' command is for.  The following is the
+
}
−
format of the remove command.
+
</pre>
−
<nowiki>
 
−
remove &lt;symbol1&gt; in &lt;symbol2&gt;</nowiki>
 
−
Again the remove command is a simple command and it only has two
 
−
arguments, the item and where it is to remove it from.  If you
 
−
wanted to have a cabinet that at every reset it would have a knife and a
 
−
bag of sugar in it would look like this.
 
−
<nowiki>
 
−
remove cabinet in kitchen
 
−
load cabinet into kitchen
 
−
{
 
−
load sugarbag
 
−
load knife
 
−
}</nowiki>
 
  
 
<div style='padding-top: 30px; padding-bottom: 20px; text-align: left;float:left;width:50%;'>[[Manual:Zone_Manual/The_Reset_Section/Loading_objects_and_NPCs|Previous: Loading objects and NPCs]]</div>
 
<div style='padding-top: 30px; padding-bottom: 20px; text-align: left;float:left;width:50%;'>[[Manual:Zone_Manual/The_Reset_Section/Loading_objects_and_NPCs|Previous: Loading objects and NPCs]]</div>
 
<div style='padding-top: 30px; padding-bottom: 20px; text-align: right;float:right;width:50%;'>[[Manual:Zone_Manual/The_Reset_Section/Reset_walk_through|Next: Reset walk through]]</div>
 
<div style='padding-top: 30px; padding-bottom: 20px; text-align: right;float:right;width:50%;'>[[Manual:Zone_Manual/The_Reset_Section/Reset_walk_through|Next: Reset walk through]]</div>

Latest revision as of 06:23, 15 November 2026

Special reset functions

Besides load and equip the reset section has a few more commands and one more option: complete keeps a unit only if everything in its block worked, follow loads a group, purge and remove clear things away, and random loads things only some of the time.

Success and failure

Every reset command either succeeds or fails, and that decides what happens next:

  • A command's block runs only if the command succeeded.
  • complete (below) looks at whether the commands in its block succeeded.
Command Succeeds when
load, equip, follow the unit was loaded. They fail when a limit stops them, when the NPC already wears something in that position (equip), or on an error (logged).
random the dice roll was under the percentage.
nop always.
door, purge, remove never: they do their work but count as failed, so a block after them never runs.

The complete option

complete can be added to load, equip and follow. The unit is loaded and its block runs as usual; then, if any command directly in the block failed, the unit is removed again, with everything it carries.

load captain into jail_room complete
{
   equip magic_sword position WEAR_WIELD max 1
   load bag
   {
      load ruby_ring max 1
   }
}

The captain stays only if he got the magic sword and the bag. Only the commands directly in his block count: if the ruby ring isn't loaded (because one exists already), the bag was still loaded, so the captain stays, with an empty bag. To make a missing ring remove the captain too, give the bag complete as well: then the bag is removed when the ring fails, the bag counts as failed, and so does the captain.

Because door, purge and remove always count as failed, don't put them in a complete block. The same goes for a load that is often stopped by its limit: an object with no limit gets local 1, which counts what is already inside the unit.

The unit is removed after it was loaded, so the room still sees an NPC that is removed this way arrive.

The follow command

follow <NPC> [max <n>] [zonemax <n>] [local <n>] [complete] [{ <more commands> }]

follow goes in an NPC's block. It loads another NPC into the same room and makes it follow the NPC of the block, so the two move about as a group. The follower's own block works on the follower, so you can dress it there.

The limits are those of load (see Loading objects and NPCs), and as with load an NPC without a limit gets max 1. local is no use here: it counts what the leader carries, not the NPCs in the room.

A captain with two guards:

load captain into jail
{
   follow guard max 4
   {
      equip guard_helmet position WEAR_HEAD
      equip guard_plate position WEAR_BODY
      equip guard_legs position WEAR_LEGS
      equip guard_boots position WEAR_FEET
   }
   follow guard max 4
   {
      equip guard_helmet position WEAR_HEAD
      equip guard_plate position WEAR_BODY
      equip guard_legs position WEAR_LEGS
      equip guard_boots position WEAR_FEET
   }
}

Each follow line loads one guard, so two lines give two guards, as long as there are fewer than four in the game. The guards are only loaded together with a new captain: while the captain lives, his block doesn't run.

The purge command

purge <room>

Removes every NPC and object from the room. Players stay, and so do rooms inside the room. To empty the jail at every reset:

purge jail

The remove command

remove <unit> in <room>

Removes every copy of the unit that lies in the room (not copies that someone carries or that are in a container).

An NPC that is still alive at a reset is not loaded again, and neither is its block: a guard whose sword was stolen stays without one, and a chest that players emptied stays empty. remove lets you start such a unit afresh. A cabinet that holds a knife and a bag of sugar after every reset:

remove cabinet in kitchen
load cabinet into kitchen
{
   load sugarbag
   load knife
}

The old cabinet goes, with whatever is in it, and a new one is loaded and filled.

The random command

random <percent>
{
   <more commands>
}

Runs its block with the given chance: random 80 runs it 80% of the time, random 100 always, random 0 never.

The block of random has no unit of its own to work on. Every load in it needs into a room, and equip and follow can't be used directly in it. To load something at random into an NPC, put the random around the NPC's load, and the rest in the NPC's block:

random 80
{
   load captain into jail_room complete
   {
      equip magic_sword position WEAR_WIELD max 1
      load bag
      {
         load ruby_ring max 1
      }
   }
}

Now the captain, if there is none yet, is loaded at 80% of the resets.

The nop command

nop does nothing and always succeeds, so a block after it always runs. It is a way to group commands; as with random, give every load in its block an into, and don't put equip or follow directly in it.

nop
{
   load guard into hall local 1
   load bone into hall
}
Previous: Loading objects and NPCs
Next: Reset walk through