Difference between revisions of "Manual:Zone Manual/The Objects Section/Building your first object"
(checked against the current code (wiki review 2026-11-15)) |
|||
| Line 1: | Line 1: | ||
| − | + | == Building your first object == | |
| − | + | Now that you can make rooms and NPCs, it is time for objects. There is not much new here, so this is a short section. We stay with the dragon theme of the earlier chapters: the first object is a dragon head. A dead one. It is a simple object that a player can pick up, carry around and hold. | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | + | Objects go in the <code>%objects</code> section of the zone file. A zone with only objects needs no <code>%rooms</code>, <code>%mobiles</code> or <code>%reset</code> section. In this chapter we add an <code>%objects</code> section to the dragon station zone from the earlier chapters; in [[Manual:Zone Manual/The Objects Section/Dragon station with rooms NPCs and objects|Dragon station with rooms NPCs and objects]] everything comes together. | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | + | === The symbolic name === | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | + | Every object starts with its symbolic name. Pick one that matches the object, because that is what you see when you list the objects of a zone, and what you type to load one. <code>wstat zone dragon objects</code> in the game lists them by symbolic name: | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | + | <pre> | |
| − | + | List of objects in zone dragon: | |
| − | + | claw info_board dragon_head | |
| − | + | </pre> | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | + | Names like <code>obj1</code> and <code>o3</code> may be easy while you write them, but not once the zone has thirty objects. | |
| − | + | An object needs only its symbolic name and <code>end</code>: | |
| − | + | <pre> | |
| − | + | dragon_head | |
| − | + | end | |
| − | + | </pre> | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | + | That compiles, but everything in it is a default: no names, no title, no description, and it can't even be picked up. Let's give it the fields that make it a dragon head. | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | + | === Names, title and description === | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | + | As with rooms and NPCs, the first fields are the names, the title and the description. The description is what players see when the head lies in the room. The title is what they see when they pick it up, drop it, or find it in their inventory. The names are what they type to do something with it, so every word of the title and description that a player might use should be there. Longer names go first: vmc refuses a list where a name starts with an earlier one. | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | + | <pre> | |
| − | + | dragon_head | |
| − | + | names {"large golden dragon head", "large gold dragon head", | |
| − | + | "golden dragon head", "gold dragon head", "large dragon head", | |
| − | + | "dragon head", "large head", "sad head", "head"} | |
| − | + | title "a gold dragon head" | |
| − | + | descr "A large golden dragon head is lying here, looking sad." | |
| − | + | ... | |
| − | + | end | |
| + | </pre> | ||
| − | + | === What players see when they look === | |
| − | |||
| − | + | When a player looks at the head, they see the extra with no names in its list: | |
| − | |||
| − | + | <pre> | |
| − | + | extra {} | |
| − | + | "The head is large and beautiful, at least as beautiful as a dead dragon | |
| − | + | head can be. There is a look of deep sorrow on the dragon's face, and it | |
| − | + | seems to be about much more than its own death." | |
| − | + | </pre> | |
| − | |||
| − | + | Extras with names describe the parts a player might look at next. Here they hide a hint in the dragon's face: | |
| − | + | <pre> | |
| + | extra {"dragon face", "face"} | ||
| + | "Looking into the dragon's face, your eyes are drawn to its eyes. Could | ||
| + | there be something there?" | ||
| − | + | extra {"eyes", "eye"} | |
| − | + | "A world of blue skies and no storms is visible through the eyes, and it | |
| − | + | seems to move, as if you were watching the world from space." | |
| + | </pre> | ||
| − | + | Line breaks in descriptions are shown as you write them, so keep lines shorter than about 72 characters. | |
| − | |||
| − | |||
| − | |||
| − | + | === What can be done with it === | |
| − | |||
| − | |||
| − | + | The head is no weapon or armour. Players should be able to pick it up, and to hold it if they like: | |
| − | |||
| − | |||
| − | + | <pre> | |
| + | manipulate {MANIPULATE_TAKE, MANIPULATE_HOLD} | ||
| + | </pre> | ||
| − | + | If you were feeling strange you could let them wear it on their head instead, with <code>MANIPULATE_WEAR_HEAD</code>. | |
| − | |||
| − | + | === Weight, size and price === | |
| − | |||
| − | + | Weight is in pounds and height in centimetres. A head 90 cm tall that weighs 60 pounds is a heavy thing to carry around, as it should be. Give it a price so the shops know what it is worth, and say what it is made of: | |
| − | |||
| − | + | <pre> | |
| − | + | weight 60 | |
| + | height 90 | ||
| + | cost 2 GOLD_PIECE | ||
| + | MATERIAL_ORGANIC("Dragon scales and bone") | ||
| + | </pre> | ||
| − | + | === Messages when it is picked up and dropped === | |
| − | |||
| − | + | The finishing touch: special extras that replace the standard messages when the head is picked up and dropped. <code>$get_s</code> and <code>$drop_s</code> go to the player who does it, <code>$get_o</code> and <code>$drop_o</code> to the others in the room; <code>$1n</code> is the player's name. The name must start with <code>$</code>; <code>extra {"drop_o"}</code> would just be a description of something called "drop_o". | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | <div style='padding-top: 30px; padding-bottom: 20px; text-align: left;float:left;width:50%;'>[[Manual: | + | <pre> |
| − | <div style='padding-top: 30px; padding-bottom: 20px; text-align: right;float:right;width:50%;'>[[Manual: | + | extra {"$get_s"} |
| + | "You suddenly feel very sad for a world that you don't even know." | ||
| + | |||
| + | extra {"$get_o"} | ||
| + | "A strange look of sadness crosses $1n's face." | ||
| + | |||
| + | extra {"$drop_s"} | ||
| + | "You feel much happier, but you remember a feeling of great sorrow." | ||
| + | |||
| + | extra {"$drop_o"} | ||
| + | "$1n seems to cheer up a bit." | ||
| + | </pre> | ||
| + | |||
| + | === The finished head === | ||
| + | |||
| + | Put together, in the dragon station zone: | ||
| + | |||
| + | <pre> | ||
| + | #include <macros.h> | ||
| + | |||
| + | %zone dragon | ||
| + | title "The Dragon Station" | ||
| + | lifespan 20 | ||
| + | reset RESET_ANYHOW | ||
| + | creators {"whistler"} | ||
| + | |||
| + | notes | ||
| + | "This is the dragon station." | ||
| + | |||
| + | %objects | ||
| + | |||
| + | dragon_head | ||
| + | names {"large golden dragon head", "large gold dragon head", | ||
| + | "golden dragon head", "gold dragon head", "large dragon head", | ||
| + | "dragon head", "large head", "sad head", "head"} | ||
| + | title "a gold dragon head" | ||
| + | descr "A large golden dragon head is lying here, looking sad." | ||
| + | |||
| + | extra {} | ||
| + | "The head is large and beautiful, at least as beautiful as a dead dragon | ||
| + | head can be. There is a look of deep sorrow on the dragon's face, and it | ||
| + | seems to be about much more than its own death." | ||
| + | |||
| + | extra {"dragon face", "face"} | ||
| + | "Looking into the dragon's face, your eyes are drawn to its eyes. Could | ||
| + | there be something there?" | ||
| + | |||
| + | extra {"eyes", "eye"} | ||
| + | "A world of blue skies and no storms is visible through the eyes, and it | ||
| + | seems to move, as if you were watching the world from space." | ||
| + | |||
| + | extra {"$get_s"} | ||
| + | "You suddenly feel very sad for a world that you don't even know." | ||
| + | |||
| + | extra {"$get_o"} | ||
| + | "A strange look of sadness crosses $1n's face." | ||
| + | |||
| + | extra {"$drop_s"} | ||
| + | "You feel much happier, but you remember a feeling of great sorrow." | ||
| + | |||
| + | extra {"$drop_o"} | ||
| + | "$1n seems to cheer up a bit." | ||
| + | |||
| + | manipulate {MANIPULATE_TAKE, MANIPULATE_HOLD} | ||
| + | weight 60 | ||
| + | height 90 | ||
| + | cost 2 GOLD_PIECE | ||
| + | MATERIAL_ORGANIC("Dragon scales and bone") | ||
| + | end | ||
| + | |||
| + | %end | ||
| + | </pre> | ||
| + | |||
| + | That is all there is to an ordinary object. The rest is adding what you already know: weapons, armour and the other kinds in [[Manual:Zone Manual/The Objects Section/Object macros|Object macros]], and scripts in [[Manual:Zone Manual/The Objects Section/More complex objects|More complex objects]]. First, compiling and debugging it. | ||
| + | |||
| + | <div style='padding-top: 30px; padding-bottom: 20px; text-align: left;float:left;width:50%;'>[[Manual:Zone Manual/The Objects Section/Object macros|Previous: Object macros]]</div> | ||
| + | <div style='padding-top: 30px; padding-bottom: 20px; text-align: right;float:right;width:50%;'>[[Manual:Zone Manual/The Objects Section/Compiling and Debugging your first object|Next: Compiling and Debugging your first object]]</div> | ||
Latest revision as of 06:18, 15 November 2026
Contents
Building your first object
Now that you can make rooms and NPCs, it is time for objects. There is not much new here, so this is a short section. We stay with the dragon theme of the earlier chapters: the first object is a dragon head. A dead one. It is a simple object that a player can pick up, carry around and hold.
Objects go in the %objects section of the zone file. A zone with only objects needs no %rooms, %mobiles or %reset section. In this chapter we add an %objects section to the dragon station zone from the earlier chapters; in Dragon station with rooms NPCs and objects everything comes together.
The symbolic name
Every object starts with its symbolic name. Pick one that matches the object, because that is what you see when you list the objects of a zone, and what you type to load one. wstat zone dragon objects in the game lists them by symbolic name:
List of objects in zone dragon: claw info_board dragon_head
Names like obj1 and o3 may be easy while you write them, but not once the zone has thirty objects.
An object needs only its symbolic name and end:
dragon_head end
That compiles, but everything in it is a default: no names, no title, no description, and it can't even be picked up. Let's give it the fields that make it a dragon head.
Names, title and description
As with rooms and NPCs, the first fields are the names, the title and the description. The description is what players see when the head lies in the room. The title is what they see when they pick it up, drop it, or find it in their inventory. The names are what they type to do something with it, so every word of the title and description that a player might use should be there. Longer names go first: vmc refuses a list where a name starts with an earlier one.
dragon_head
names {"large golden dragon head", "large gold dragon head",
"golden dragon head", "gold dragon head", "large dragon head",
"dragon head", "large head", "sad head", "head"}
title "a gold dragon head"
descr "A large golden dragon head is lying here, looking sad."
...
end
What players see when they look
When a player looks at the head, they see the extra with no names in its list:
extra {}
"The head is large and beautiful, at least as beautiful as a dead dragon
head can be. There is a look of deep sorrow on the dragon's face, and it
seems to be about much more than its own death."
Extras with names describe the parts a player might look at next. Here they hide a hint in the dragon's face:
extra {"dragon face", "face"}
"Looking into the dragon's face, your eyes are drawn to its eyes. Could
there be something there?"
extra {"eyes", "eye"}
"A world of blue skies and no storms is visible through the eyes, and it
seems to move, as if you were watching the world from space."
Line breaks in descriptions are shown as you write them, so keep lines shorter than about 72 characters.
What can be done with it
The head is no weapon or armour. Players should be able to pick it up, and to hold it if they like:
manipulate {MANIPULATE_TAKE, MANIPULATE_HOLD}
If you were feeling strange you could let them wear it on their head instead, with MANIPULATE_WEAR_HEAD.
Weight, size and price
Weight is in pounds and height in centimetres. A head 90 cm tall that weighs 60 pounds is a heavy thing to carry around, as it should be. Give it a price so the shops know what it is worth, and say what it is made of:
weight 60
height 90
cost 2 GOLD_PIECE
MATERIAL_ORGANIC("Dragon scales and bone")
Messages when it is picked up and dropped
The finishing touch: special extras that replace the standard messages when the head is picked up and dropped. $get_s and $drop_s go to the player who does it, $get_o and $drop_o to the others in the room; $1n is the player's name. The name must start with $; extra {"drop_o"} would just be a description of something called "drop_o".
extra {"$get_s"}
"You suddenly feel very sad for a world that you don't even know."
extra {"$get_o"}
"A strange look of sadness crosses $1n's face."
extra {"$drop_s"}
"You feel much happier, but you remember a feeling of great sorrow."
extra {"$drop_o"}
"$1n seems to cheer up a bit."
The finished head
Put together, in the dragon station zone:
#include <macros.h>
%zone dragon
title "The Dragon Station"
lifespan 20
reset RESET_ANYHOW
creators {"whistler"}
notes
"This is the dragon station."
%objects
dragon_head
names {"large golden dragon head", "large gold dragon head",
"golden dragon head", "gold dragon head", "large dragon head",
"dragon head", "large head", "sad head", "head"}
title "a gold dragon head"
descr "A large golden dragon head is lying here, looking sad."
extra {}
"The head is large and beautiful, at least as beautiful as a dead dragon
head can be. There is a look of deep sorrow on the dragon's face, and it
seems to be about much more than its own death."
extra {"dragon face", "face"}
"Looking into the dragon's face, your eyes are drawn to its eyes. Could
there be something there?"
extra {"eyes", "eye"}
"A world of blue skies and no storms is visible through the eyes, and it
seems to move, as if you were watching the world from space."
extra {"$get_s"}
"You suddenly feel very sad for a world that you don't even know."
extra {"$get_o"}
"A strange look of sadness crosses $1n's face."
extra {"$drop_s"}
"You feel much happier, but you remember a feeling of great sorrow."
extra {"$drop_o"}
"$1n seems to cheer up a bit."
manipulate {MANIPULATE_TAKE, MANIPULATE_HOLD}
weight 60
height 90
cost 2 GOLD_PIECE
MATERIAL_ORGANIC("Dragon scales and bone")
end
%end
That is all there is to an ordinary object. The rest is adding what you already know: weapons, armour and the other kinds in Object macros, and scripts in More complex objects. First, compiling and debugging it.