Difference between revisions of "Manual:Zone Manual/The Objects Section/Building your first object"

From DikuMUD Wiki
Jump to navigation Jump to search
(checked against the current code (wiki review 2026-11-15))
 
Line 1: Line 1:
−
=== Building your first object ===
+
== Building your first object ==
  
−
Now that you have learned how to make rooms and NPCs its time to
+
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.
−
make the objects for your little world.
 
−
In the last couple of sections you have looked
 
−
through the fields.  In this section we are going to make a nice easy
 
−
object.  There is really not that much new from what you have learned
 
−
with rooms and NPCs so this should be a real quick section. As always
 
−
we will start with something I like which as you remember is dragons.
 
−
So the first object we will make is a dragon head. I didn't say I liked
 
−
them alive now did I?  Anyway this will be a nice simple object that
 
−
your player can pick up and carry around.
 
  
−
When making objects you create the zone source file first as shown
+
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.
−
in (Link to ch-02). If you only have objects you do not need the
 
−
%reset, %mobiles, and %rooms fields. For the examples in this chapter we
 
−
will use the zone we created in (Link to ch-04) and add the
 
−
%objects section where we will put all the object definitions.  At the end
 
−
of this chapter, in (Link to roomnpcobjzone), we will bring it
 
−
all together with the rooms and NPCs we have defined already.
 
  
−
The first part of all object definitions is the symbolic name it is good
+
=== The symbolic name ===
−
to always pick a name that will match the name of the object so it
 
−
will be easy to load the object.
 
−
The reason the symbolic and name should match is when you use the
 
−
command '''wstat''' it will only show you a
 
−
list of the objects by symbolic name for example if you type '''
 
−
wstat zone dragon objects''' You will get the following:
 
−
<nowiki>
 
−
List of objects in zone Dragon:
 
−
claw info_board dragon_head</nowiki>
 
−
If you didn't make it clear what the object was by the symbolic name
 
−
it might look like this:
 
−
<nowiki>
 
−
List of objects in zone Dragon:
 
−
obj1 a_obj2 o3</nowiki>
 
−
While this might be great when you first start imagine trying to
 
−
remember each object if you have over 30 of them.
 
  
−
Now lets get started with our dragon head. As with the rooms and
+
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:
−
npcs all that is required to make an object is the symbolic and end fields.
 
−
That of course will make a NPC with all defaults.
 
−
<nowiki>
 
−
dragon_head
 
−
end</nowiki>
 
−
Thats it for that dragon head right?  Nope not quite, like before
 
−
with NPCs, that makes an object with all defaults.  That means this will probably be
 
−
a very blank spot on the screen with no names and no way your players
 
−
can interact with it.
 
−
Now lets start putting the
 
−
Dragon heads other more interesting fields on.
 
  
−
Like with rooms and NPCs, the first three things we need are the
+
<pre>
−
dragon heads title, description and names.  The description should be what you
+
List of objects in zone dragon:
−
see when you do a 'look' in the room.  The title should be what you see
+
claw info_board dragon_head
−
when the object is in your inventory or you are whacking someone over the
+
</pre>
−
head with it.  Since we are not making a weapon though the title is what
 
−
will be shown when you are picking up or dropping the object.
 
−
Finally the names should cover everything
 
−
in the title and description fields so if your player wants to pick
 
−
the object up or wear it will be easy to figure out what the names
 
−
are.
 
−
<nowiki>
 
−
dragon_head
 
  
−
title "a gold dragon head"
+
Names like <code>obj1</code> and <code>o3</code> may be easy while you write them, but not once the zone has thirty objects.
  
−
descr "A large golden dragon head is laying here looking sad."
+
An object needs only its symbolic name and <code>end</code>:
  
−
names {"large golden dragon head","large gold dragon head",
+
<pre>
−
      "golden dragon head","large dragon head","gold dragon head",
+
dragon_head
−
      "dragon head","large head", "sad head","head"}
+
end
−
...
+
</pre>
−
end</nowiki>
 
−
The names, title and description shouldn't be to hard so I don't
 
−
think its necessary to go into any more description on the subject.
 
−
Lets move on.  Now we have to take care of what a player sees when he or
 
−
she looks at an object.  to make the main description of an NPC you place an
 
−
extra on the NPC with no names in the list.  The blank extra is a
 
−
special extra that will be shown every time you look at anything in the
 
−
names list of the object.  So a description of an object would look something
 
−
like this.
 
−
<nowiki>
 
−
extra {}
 
−
"The head is large and beautiful, at least as beautiful as a dead
 
−
dragon head can be.  There is an extreme look of sorrow on the dragons
 
−
face and it seems to be for much more than its own death."</nowiki>
 
−
Now that you have a main description for the object you need to make
 
−
any smaller descriptions that you want the player to be able to look at.
 
−
In this case it may be good to give some secret information if the
 
−
player looks at the face of the head directly.
 
−
<nowiki>
 
−
extra {"gold dragon head face","dragon head face","head face","face"}
 
−
"Looking into the dragons face your eyes are drawn to the eyes of the
 
−
dead dragon.  Could there be something there?"
 
  
−
extra {"eyes","eye"}
+
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.
−
"A world of blue skies and no storms is visible through the eyes and it
 
−
seems to be moving as if you were watching the world from space."</nowiki>
 
−
Now that we have the object all described we only need to give the
 
−
    object the manipulate flags it needs, weight, height, and maybe
 
−
    some extras that will make some cool acts when a player picks it up
 
−
    or drops it.
 
  
−
First thing to do though is pick the manipulate flags you
+
=== Names, title and description ===
−
want on the object.  This is not a weapon or armour so all the
 
−
player really needs to be able to do with it is pick it up and maybe
 
−
hold it if you want and I do.  The flags would then be as follows:
 
−
<nowiki>
 
−
manipulate {MANIPULATE_TAKE,MANIPULATE_HOLD}</nowiki>
 
−
If you were feeling a little weird you could even make the
 
−
person be able to wear the dragon head on his head but that would
 
−
just be strange.  of course its always good to know you have
 
−
options.
 
  
−
Now lets set the height and weight. Remember you set the height
+
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.
−
in centimeters and the weight in pounds. In the future the VME will
 
−
standardize to one or the other but for now we have to play the
 
−
conversion game.
 
−
<nowiki>
 
−
//20 feet  (1 inch = 2.54 cm
 
−
height 33
 
  
−
//566 KG (1 lb. = .45359 kg)
+
<pre>
−
weight 50</nowiki>
+
dragon_head
−
The final touch to our little dragon head is some cute acts
+
names {"large golden dragon head", "large gold dragon head",
−
when the player picks it up or drops it.  If you remember from the extra
+
      "golden dragon head", "gold dragon head", "large dragon head",
−
fields in (Link to objfielddescr), there are some special extras
+
      "dragon head", "large head", "sad head", "head"}
−
that are made just for this purpose.
+
title "a gold dragon head"
−
<nowiki>
+
descr "A large golden dragon head is lying here, looking sad."
−
extra {"$get_s"}
+
...
−
"You suddenly feel very sad for a world that you don't even know."
+
end
 +
</pre>
  
−
extra {"$get_o"}
+
=== What players see when they look ===
−
"A strange look of sadness crosses $1ns face."
 
  
−
extra {"$drop_s"}
+
When a player looks at the head, they see the extra with no names in its list:
−
"You feel much happier but you remember a feeling of great sorrow."
 
  
−
extra {"drop_o"}
+
<pre>
−
"$1n seems to cheer up a bit."</nowiki>
+
extra {}
−
There are other things we could add to this item but I want to
+
"The head is large and beautiful, at least as beautiful as a dead dragon
−
keep this first object simple. The finished head would then look like
+
head can be. There is a look of deep sorrow on the dragon's face, and it
−
this:
+
seems to be about much more than its own death."
−
<nowiki>
+
</pre>
−
dragon_head
 
  
−
title "a gold dragon head"
+
Extras with names describe the parts a player might look at next. Here they hide a hint in the dragon's face:
  
−
descr "A large golden dragon head is laying here looking sad."
+
<pre>
 +
extra {"dragon face", "face"}
 +
"Looking into the dragon's face, your eyes are drawn to its eyes. Could
 +
there be something there?"
  
−
names {"large golden dragon head","large gold dragon head",
+
extra {"eyes", "eye"}
−
      "golden dragon head","large dragon head","gold dragon head",
+
"A world of blue skies and no storms is visible through the eyes, and it
−
      "dragon head","large head", "sad head","head"}
+
seems to move, as if you were watching the world from space."
 +
</pre>
  
−
  extra {}
+
Line breaks in descriptions are shown as you write them, so keep lines shorter than about 72 characters.
−
"The head is large and beautiful, at least as beautiful as a dead
 
−
dragon head can be.  There is an extreme look of sorrow on the dragons
 
−
face and it seems to be for much more than its own death."
 
  
−
extra {"gold dragon head face","dragon head face","head face","face"}
+
=== What can be done with it ===
−
"Looking into the dragons face your eyes are drawn to the eyes of the
 
−
dead dragon.  Could there be something there?"
 
  
−
extra {"eyes","eye"}
+
The head is no weapon or armour. Players should be able to pick it up, and to hold it if they like:
−
"A world of blue skies and no storms is visible through the eyes and it
 
−
seems to be moving as if you were watching the world from space."
 
  
−
manipulate {MANIPULATE_TAKE,MANIPULATE_HOLD}
+
<pre>
 +
manipulate {MANIPULATE_TAKE, MANIPULATE_HOLD}
 +
</pre>
  
−
height 33
+
If you were feeling strange you could let them wear it on their head instead, with <code>MANIPULATE_WEAR_HEAD</code>.
−
weight 50
 
  
−
extra {"$get_s"}
+
=== Weight, size and price ===
−
"You suddenly feel very sad for a world that you don't even know."
 
  
−
extra {"$get_o"}
+
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:
−
"A strange look of sadness crosses $1ns face."
 
  
−
extra {"$drop_s"}
+
<pre>
−
"You feel much happier but you remember a feeling of great sorrow."
+
weight 60
 +
height 90
 +
cost 2 GOLD_PIECE
 +
MATERIAL_ORGANIC("Dragon scales and bone")
 +
</pre>
  
−
extra {"drop_o"}
+
=== Messages when it is picked up and dropped ===
−
"$1n seems to cheer up a bit."
 
  
−
end</nowiki>
+
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".
−
Thats all there is to making regular items. The rest is just
 
−
adding functionality to what you already know.  We will get much deeper
 
−
into what you can do with items in (Link to objcomplex) but first
 
−
we will go over a debugging example and then all the special DIL functions made
 
−
for objects.
 
  
−
<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>
+
<pre>
−
<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>
+
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 &lt;macros.h&gt;
 +
 
 +
%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

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.

Previous: Object macros
Next: Compiling and Debugging your first object