Manual:Zone Manual/The Reset Section/Special reset functions
Contents
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
}