Difference between revisions of "Manual:Zone Manual/The Reset Section/Loading objects and NPCs"
(checked against the current code (wiki review 2026-11-15)) |
|||
| Line 1: | Line 1: | ||
=== Loading objects and NPCs === | === Loading objects and NPCs === | ||
| − | + | 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. | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | + | ==== The load command ==== | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | + | <pre> | |
| − | + | load <unit> [into <room>] [max <n>] [zonemax <n>] [local <n>] [complete] [{ <more commands> }] | |
| − | + | </pre> | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | + | 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: <code>fido_dog@midgaard</code>. 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 <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>. | |
| − | + | ;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 [[Manual:Zone Manual/The Reset Section/Special reset functions|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 <code>load</code> runs again. The limits keep that from filling the game with copies: | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
{| class="wikitable" | {| class="wikitable" | ||
| − | + | ! Limit !! The unit is loaded only if there are fewer than ''n'' | |
|- | |- | ||
| − | + | | <code>max <n></code> || copies in the whole game, wherever they are (on players too). | |
| − | |||
|- | |- | ||
| − | | | + | | <code>zonemax <n></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. |
| − | | | ||
|- | |- | ||
| − | | | + | | <code>local <n></code> || 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 <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. | |
| − | | | + | |
| − | + | 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 | ||
|- | |- | ||
| − | | | + | | <code>WEAR_FINGER_R</code> || 2 || <code>WEAR_WAIST</code> || 14 |
| − | | | ||
|- | |- | ||
| − | | | + | | <code>WEAR_FINGER_L</code> || 3 || <code>WEAR_WRIST_R</code> || 15 |
| − | | | ||
|- | |- | ||
| − | | | + | | <code>WEAR_NECK_1</code> || 4 || <code>WEAR_WRIST_L</code> || 16 |
| − | | | ||
|- | |- | ||
| − | | | + | | <code>WEAR_NECK_2</code> || 5 || <code>WEAR_WIELD</code> || 17 |
| − | | | ||
|- | |- | ||
| − | | | + | | <code>WEAR_BODY</code> || 6 || <code>WEAR_HOLD</code> || 18 |
| − | |WEAR_HOLD | ||
|- | |- | ||
| − | | | + | | <code>WEAR_HEAD</code> || 7 || <code>WEAR_CHEST</code> || 19 |
| − | | | ||
|- | |- | ||
| − | | | + | | <code>WEAR_LEGS</code> || 8 || <code>WEAR_BACK</code> || 20 |
| − | | | ||
|- | |- | ||
| − | | | + | | <code>WEAR_FEET</code> || 9 || <code>WEAR_EAR_L</code> || 21 |
| − | | | ||
|- | |- | ||
| − | | | + | | <code>WEAR_HANDS</code> || 10 || <code>WEAR_EAR_R</code> || 22 |
| − | | | ||
|- | |- | ||
| − | | | + | | <code>WEAR_ARMS</code> || 11 || <code>WEAR_ANKLE_L</code> || 23 |
| − | | | ||
|- | |- | ||
| − | | | + | | <code>WEAR_SHIELD</code> || 12 || <code>WEAR_ANKLE_R</code> || 24 |
| − | | | ||
|- | |- | ||
| − | | | + | | <code>WEAR_ABOUT</code> || 13 || || |
| − | | | ||
| − | | | ||
| − | | | ||
| − | | | ||
| − | | | ||
| − | | | ||
| − | |||
|} | |} | ||
| − | |||
| − | |||
| − | ;max < | + | :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. |
| − | : | + | ;max <n> |
| − | + | :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>. | |
| − | + | ||
| − | + | 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. | |
| − | + | ||
| − | : | + | Dressing a guard with objects from the same zone, so no zone names are needed: |
| − | + | ||
| − | + | <pre> | |
| − | + | 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 | |
| − | + | } | |
| + | </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> | ||
| − | + | 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. | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | + | The dragon station's resets, with all of this together, are in [[Manual:Zone Manual/The Reset Section/Reset walk through|Reset walk through]]. | |
| − | |||
| − | |||
<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
Contents
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
intothe 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. Aloadthat is not in a block needsinto; without it the server logsReset 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. Twoload guard into ...lines load one guard, not two. To have several, give a limit, e.g.zonemax 2on each line, orlocal 1to 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'sMANIPULATE_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.
equiptakes nozonemaxorlocal.
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.