Difference between revisions of "Manual:Zone Manual/The Objects Section/More complex objects"

From DikuMUD Wiki
Jump to navigation Jump to search
(checked against the current code (wiki review 2026-11-15))
 
Line 1: Line 1:
 
=== More complex objects ===
 
=== More complex objects ===
  
−
In the last sections you learned all the fields and how to make a
+
The earlier pages showed the object fields and how to build a basic object. This page uses them,
−
basic object. In this section we will use the information from the last
+
with the macros from [[Manual:Zone Manual/The Objects Section/Object macros|Object macros]] and the
−
sections to create some more unique objects for our dragon station zone
+
DIL functions from [[Manual:Zone Manual/The Objects Section/DIL functions for objects|DIL functions for objects]],
−
There is not a lot of new information here we will be using the DIL functions,
+
to make the objects of the dragon station zone: a board, a locker with its key, a drink, some food,
−
fields, and flags to make objects we have only mentioned before.
+
a weapon, a piece of armour and a ring.
−
==== Making a communication board ====
 
  
−
In (Link to objdilboard) you learned all there you need to
+
Every finished object on this page is part of the zone on the next page,
−
know about the boards DIL to create a board. In this small section we
+
[[Manual:Zone Manual/The Objects Section/Dragon station with rooms NPCs and objects|Dragon station with rooms, NPCs and objects]],
−
are going to show you the rest of a board and what a finished one looks
+
and compiles there. Two rules to keep in mind while reading them:
−
like.
+
* A type macro (<code>WEAPON_DEF</code>, <code>ARMOUR_DEF</code>, <code>LIQ_WINE</code>...) sets <code>type</code>, <code>value[]</code> and sometimes <code>weight</code>. These fields keep the last value written, so put the macro first and change things after it. <code>manipulate</code>, <code>flags</code> and <code>open</code> add up instead, so a <code>manipulate</code> line after the macro adds to what the macro set.
 +
* Give every object a material with one of the <code>MATERIAL_*</code> macros from wmacros.h. The text appears when a player identifies the item, and DIL can test the material (for example <code>"$mat_metal" in item.extra</code>).
  
−
As with all objects the first step is to fully describe and name
+
==== Making a communication board ====
−
your board.  We will stick with the space station theme since our goal
 
−
is to have a complete example zone for you.  The boards symbolic, names, title,
 
−
description and extra turned out like this.
 
−
<nowiki>
 
−
info_board
 
−
 
 
−
title "a merchant information board"
 
−
descr "A merchant information Board is mounted on a wall here."
 
  
−
names {"merchant information board","information board","merchant
+
A board is an object with the <code>board@boards</code> DIL function on it. The function and its
−
board","board"}
+
arguments are explained in [[Manual:Zone Manual/The Objects Section/DIL functions for objects|DIL functions for objects]].
 +
As with every object, first name and describe it:
 +
<pre>
 +
info_board
 +
names {"merchant information board", "information board", "merchant board",
 +
      "board"}
 +
title "a merchant information board"
 +
descr "A merchant information board is mounted on a wall here."
 +
extra {}
 +
"A large flashy black steel board."
 +
MATERIAL_METAL("A very fine quality black steel")
 +
</pre>
  
−
extra {} "A large flashy black steal board."</nowiki>
+
Then the board itself: the type and the DIL function. Here everyone may read and post, but only
−
Just incase the VME server we have has a spell that can damage
+
administrators may remove other people's posts (<code>rem_res@boards</code>), and the board holds
−
inanimate objects we will give this board a material type.
+
up to 100 posts. It has no <code>MANIPULATE_TAKE</code>, so nobody can walk off with it.
−
<nowiki>
+
<pre>
−
MATERIAL_METAL("A very fine quality black steel")</nowiki>
+
type ITEM_BOARD
−
Now for the special stuff for the board.  We need to give the
+
dilcopy board@boards("info", "", "rem_res@boards", "", 100);
−
board a type and copy the board DIL to it.
+
</pre>
−
<nowiki>
 
−
type ITEM_BOARD
 
−
dilcopy board@boards("info","","rem_res@boards","",100);</nowiki>
 
−
There you go nothing to it you have just created your first board.
 
−
Now lets bring it all together and tag on an end symbol and we are all
 
−
finished.
 
−
<nowiki>
 
−
info_board
 
−
title "a merchant information board"
 
−
descr "A merchant information Board is mounted on a wall here."
 
−
names {"merchant information board","information board","merchant
 
−
board","board"}
 
  
−
extra {}
+
The finished board:
−
"A large flashy black steal board."
+
<pre>
 +
info_board
 +
names {"merchant information board", "information board", "merchant board",
 +
      "board"}
 +
title "a merchant information board"
 +
descr "A merchant information board is mounted on a wall here."
 +
extra {}
 +
"A large flashy black steel board."
 +
MATERIAL_METAL("A very fine quality black steel")
 +
type ITEM_BOARD
 +
dilcopy board@boards("info", "", "rem_res@boards", "", 100);
 +
end
 +
</pre>
  
−
MATERIAL_METAL("A very fine quality black steel")
+
The first argument, <code>"info"</code>, names the files the posts are kept in. Every board with the
−
type ITEM_BOARD
+
same name shows the same posts, so give a board of your own a name no other board uses.
−
dilcopy board@boards("info","","rem_res@boards","",100);
 
  
−
end</nowiki>
 
 
==== Making a container ====
 
==== Making a container ====
  
−
I thought it would be cool to have a small weapons locker on the
+
The station gets a small weapons locker. It hangs on the wall, so it can't be taken; it can be
−
space station not to mention event hough we went over the container
+
opened, closed and locked, and a black key opens it. The description comes first, as always:
−
macro in (Link to objmacrocontainer), we didn't cover everything
+
<pre>
−
you need in fact the macro eaves a few things out because you may or may
+
wpn_locker
−
not want to set them.
+
names {"weapons locker", "weapon locker", "locker"}
 +
title "a weapons locker"
 +
descr "A small weapons locker hangs on the wall here."
 +
extra {}
 +
"It is an ordinary weapons locker that looks like it holds any illegal
 +
weapons that are taken on the station."
 +
MATERIAL_METAL("A very fine quality steel")
 +
</pre>
  
−
As with all objects we start right off by describing the item.
+
Then what makes it a container:
−
There is nothing new here so we will just show it to you and go
+
<pre>
−
on.
+
CONTAINER_DEF(50)
−
<nowiki>
+
manipulate {MANIPULATE_ENTER}
−
wpn_locker
+
open {EX_OPEN_CLOSE, EX_CLOSED, EX_LOCKED}
 +
key black_key
 +
weight 400
 +
</pre>
  
−
title "a weapons locker"
+
* <code>CONTAINER_DEF(50)</code> sets the type and the capacity, here 50 pounds. It sets nothing else.
−
names {"weapons locker","weapon locker","locker"}
+
* <code>MANIPULATE_ENTER</code> is what lets players put things in; without it nothing can be put in the locker. A player can also <code>enter</code> an open object with this flag if he and all he carries fit in its capacity, so keep the capacity of a small container small.
 +
* There is no <code>MANIPULATE_TAKE</code>, so the locker stays on the wall. The high weight is only a second guard against that.
 +
* <code>open</code> takes the same <code>EX_*</code> flags as a door: <code>EX_OPEN_CLOSE</code> makes it something you can open and close, <code>EX_CLOSED</code> and <code>EX_LOCKED</code> say how it is when it is loaded.
 +
* <code>key</code> is the symbolic name of the key object. To unlock, a player must carry an object with that symbolic name. vmc doesn't check that the key exists; if it doesn't, only the pick lock skill opens the locker.
  
−
descr "a small weapons locker hangs on the wall here."
+
So the key has to be made too. A key has no macro: it is <code>type ITEM_KEY</code> and something you
 +
can take and hold.
 +
<pre>
 +
black_key
 +
names {"small black key", "black key", "key"}
 +
title "a small black key"
 +
descr "A small black key has been dropped here."
 +
extra {}
 +
"It is a plain key of black steel. It looks like it fits a locker."
 +
MATERIAL_METAL("Black steel")
 +
type ITEM_KEY
 +
manipulate {MANIPULATE_TAKE, MANIPULATE_HOLD}
 +
weight 1
 +
end
 +
</pre>
  
−
extra {}
+
The finished locker:
−
"It is an ordinary weapons locker that looks like it holds any illegal
+
<pre>
−
weapons that are taken on the station."</nowiki>
+
wpn_locker
−
Now we need to put in all the information that makes this item a
+
names {"weapons locker", "weapon locker", "locker"}
−
container that can't be taken but it can be opened and it is
+
title "a weapons locker"
−
locked.
+
descr "A small weapons locker hangs on the wall here."
−
<nowiki>
+
extra {}
−
manipulate {MANIPULATE_ENTER}
+
"It is an ordinary weapons locker that looks like it holds any illegal
−
CONTAINER_DEF(500)
+
weapons that are taken on the station."
−
open {EX_OPEN_CLOSE, EX_CLOSED,EX_LOCKED}
+
MATERIAL_METAL("A very fine quality steel")
−
key black_key</nowiki>
+
CONTAINER_DEF(50)
−
Notice we didn't make the item 'MANIPULATE_TAKE' because
+
manipulate {MANIPULATE_ENTER}
−
we don't want people to be able to walk off with our weapons locker.
+
open {EX_OPEN_CLOSE, EX_CLOSED, EX_LOCKED}
−
One final touch and we are all finished with the weapons locker.  It is
+
key black_key
−
always nice to put a material type on your items so a spell or a skill
+
weight 400
−
can tell if you can do anything with them.  So with our material added
+
end
−
in the full locker would look like this.
+
</pre>
−
<nowiki>
 
−
wpn_locker
 
  
−
title "a weapons locker"
+
Loading things into the locker, and keeping the key somewhere a player can find it, is done in the
−
names {"weapons locker","weapon locker","locker"}
+
reset section (see [[Manual:Zone Manual/The Reset Section/Loading objects and NPCs|Loading objects and NPCs]]).
−
descr "a small weapons locker hangs on the wall here."
 
  
−
extra {}
 
−
"It is an ordinary weapons locker that looks like it holds any illegal
 
−
weapons that are taken on the station."
 
−
 
−
MATERIAL_METAL("A very fine quality steel")
 
−
 
−
manipulate {MANIPULATE_ENTER}
 
−
CONTAINER_DEF(500)
 
−
open {EX_OPEN_CLOSE, EX_CLOSED,EX_LOCKED}
 
−
key black_key
 
−
 
−
end</nowiki>
 
 
==== Creating drinks ====
 
==== Creating drinks ====
  
−
In (Link to objmacroliqcont), we covered how to set the size and weight of the container and its content but now we need to talk about some other special things about a drink container verses other objects.
+
A drink container has a few rules of its own for the title, descriptions and names, because the
 +
liquid in it can change: a player can drink it empty and fill it with something else.
  
−
The drink container is one of the few objects that has rules on
+
The title and descriptions must not mention the liquid. A bag full of wine is "a red bag", not "a
−
how you set the title, description and names fields.  The title and
+
bag of wine": once a player has drunk the wine and filled the bag with water, a title saying wine
−
description fields should ot have anything to do with the liquid inside
+
would be wrong.
−
the container. This means if you have a barrel full of water you do not
+
<pre>
−
put the word water in the title or the description.  In our case we have
+
liq_ration
−
a bag full of wine so we do not put wine in either the title or
+
title "a red bag"
−
description.  The reason for this is if the player drinks the bag empty
+
descr "A red bag has been gently placed here."
−
and then fills it with water and we had put wine in the title or
+
</pre>
−
description it would still be there but the bag would now be full of
 
−
water..  Our symbolic, title, and description would then look like
 
−
this.
 
−
<nowiki>
 
−
liq_ration
 
  
−
title "a red bag"
+
The name of the liquid must be the '''last''' name in the names list. When the container is
−
descr "A red bag has been gently placed here."</nowiki>
+
emptied, the game removes the last name; when it is filled, the name of the new liquid is added at
−
The names on the other hand MUST have the drink name as the last
+
the end.
−
name in the name list. The reason it must be the last one is when a
+
<pre>
−
player drinks or pours out the liquid the name is removed.  If a player
+
names {"red bag", "bag", "wine"}
−
then refills the container the name of the new liquid is added to the
+
</pre>
−
last name. The bag we are making is full of wine so our names list would
 
−
look like this.
 
−
<nowiki>
 
−
names {"red bag", "bag", "wine"}</nowiki>
 
−
Now we add the liquid define for wine
 
−
<nowiki>
 
−
LIQ_WINE(1,2,2,0)</nowiki>
 
−
Finally we add the material type for the bag, the cost to buy the
 
−
container, an extra players can look at, and finally an identify extra so
 
−
if a player casts either the identify or improved identify spell on the
 
−
bag they will se it.  with all that added The finished drink container
 
−
looks like this.
 
−
<nowiki>
 
−
liq_ration
 
−
names {"red bag", "bag", "wine"}
 
−
title "a red bag"
 
−
descr "A red bag has been gently placed here."
 
  
−
extra {}
+
The liquid comes from a macro in liquid.h (included by macros.h). The four arguments are the weight
−
"A small label reads Tassel Grove's finest. Year 321"
+
of the empty container, its capacity, how much is in it, and how poisonous the liquid is (0: not
 +
at all). The macro also sets the weight, to the container plus its contents.
 +
<pre>
 +
LIQ_WINE(1, 2, 2, 0)
 +
</pre>
  
−
MATERIAL_ORGANIC("a soft plastic")
+
To finish it, add a material, <code>MANIPULATE_TAKE</code> so it can be picked up, a price, and an
−
manipulate {MANIPULATE_TAKE}
+
<code>$identify</code> extra. A player who casts identify on the bag sees the text of
−
LIQ_WINE(1,2,2,0)
+
<code>$identify</code>; improved identify shows <code>$improved identify</code> as well. The finished
−
cost 2 IRON_PIECE
+
drink container:
 +
<pre>
 +
liq_ration
 +
names {"red bag", "bag", "wine"}
 +
title "a red bag"
 +
descr "A red bag has been gently placed here."
 +
extra {}
 +
"A small label reads: Tassel Grove's finest. Year 321."
 +
MATERIAL_ORGANIC("a soft plastic")
 +
LIQ_WINE(1, 2, 2, 0)
 +
manipulate {MANIPULATE_TAKE}
 +
cost 2 IRON_PIECE
  
−
extra {"$identify"}
+
extra {"$identify"}
−
"Its the special wine from Tassel grove a small halfling village on the
+
"It's the special wine from Tassel Grove, a small halfling village on the
−
planet Valhalla. It seems like a great vintage wine."
+
planet Valhalla. It seems like a great vintage."
 +
end
 +
</pre>
  
−
end</nowiki>
 
 
==== Creating food ====
 
==== Creating food ====
  
−
The food is very simple to make its just a regular item with the
+
Food is a plain object with <code>FOOD_DEF(amount, poison)</code>: how filling it is, and how
−
macros you learned in (Link to objmacrofood).  In fact making
+
poisonous (0: not at all). Here is a stick of dried beef that might be lying around a space station:
−
food is so simple we almost left it out.  I am only adding this to show
+
<pre>
−
how simple it is to change a regular item like the dragon head we showed
+
beef_stick
−
you in (Link to objbasic) into a food item. Now only a sick
+
names {"tough leathery stick", "tough leather stick", "leathery stick",
−
person would make a dragon head into food but if you wanted to you just
+
      "leather stick", "tough stick", "stick"}
−
add the 'FOOD_DEF(...)' and your all set.  here is a basic food that you
+
title "a tough leathery stick"
−
might find laying around a space station.
+
descr "A tough leathery looking stick is lying here."
−
<nowiki>
+
extra {}
−
beef_stick
+
"This has the word BEEF burnt into it."
−
 
+
MATERIAL_ORGANIC("tough beef")
−
title "a tough leathery stick"
+
FOOD_DEF(5, 0)
−
descr "A tough leathery looking stick is laying here."
+
manipulate {MANIPULATE_TAKE}
−
names {"tough leathery stick","tough leather stick","leathery stick",
+
weight 1
−
"leather stick","tough stick","stick"}
+
cost 1 COPPER_PIECE
−
 
+
end
−
extra {}
+
</pre>
−
"This has the word BEEF burnt into it."
 
−
 
 
−
manipulate {MANIPULATE_TAKE}
 
−
FOOD_DEF(5,0)
 
−
weight 1
 
−
cost 1 COPPER_PIECE
 
−
MATERIAL_ORGANIC("tough beef")
 
  
−
end</nowiki>
 
 
==== Making a weapon ====
 
==== Making a weapon ====
  
−
Whats a game with out some kind of weapon to chop or bash things
+
This stiletto uses the weapon macro, a skill bonus while it is wielded, and a restriction: only
−
into little pieces.  We examined how to set the weapon fields in (Link to objmacroweapon), the object transfers in (Link to objmacrotransfers), and the restriction DIL functions in (Link to objdilrestrict).  Now we will pull all we have learned together
+
players with enough dexterity can wield it. First the description and the material:
−
and make a pretty nifty little stiletto.
+
<pre>
−
 
+
w_stiletto
−
The first part as with all our example objects is to set up the
+
names {"deadly looking stiletto", "deadly stiletto", "stiletto", "dagger"}
−
symbolic, names, title, description, object extra, and material type.  this is no
+
title "a stiletto"
−
different from any other object so here is what we ended up with
+
descr "A deadly looking stiletto has been left here."
−
<nowiki>
+
extra {}
−
w_stiletto
+
"This looks like a thief's dream come true."
−
title "a stiletto"
+
MATERIAL_METAL("A very fine quality steel")
−
names {"stiletto", "dagger"}
+
</pre>
−
descr
 
−
"A deadly looking stiletto has been left here."
 
  
−
extra{}
+
Then what makes it a special weapon:
−
"This looks like a thieves dream come true. "
+
<pre>
 +
WEAPON_DEF(WPN_DAGGER, BONUS_AVERAGE_PLUS, BONUS_GOOD)
 +
SKILL_TRANSFER(SKI_BACKSTAB, 2)
 +
dilcopy abi_restrict@function(ABIL_DEX, 10, 0, 25, "");
 +
</pre>
  
−
MATERIAL_METAL("A very fine quality steel")</nowiki>
+
* <code>WEAPON_DEF(weapon, craftsmanship, magic bonus)</code> makes it a dagger with a craftsmanship of +1 (<code>BONUS_AVERAGE_PLUS</code>) and a magic bonus of +2 (<code>BONUS_GOOD</code>). Both bonuses go from -7 to +7, named <code>BONUS_JUNK</code> to <code>BONUS_ARTIFACT</code> in values.h; vmc refuses anything outside. The macro also sets <code>MANIPULATE_TAKE</code> and <code>MANIPULATE_WIELD</code>.
−
Now lets add the defines and DIL functions that make this a special weapon
+
* <code>SKILL_TRANSFER(SKI_BACKSTAB, 2)</code> raises the backstab skill by 2 while the stiletto is wielded.
−
along with the manipulate flags that makes it able to be wielded.  We will give
+
* <code>abi_restrict@function</code> makes a player with a dexterity below 10 drop it again.
−
it a bonus in magic and good craftsmanship along with a plus in
 
−
backstab for all those assassins on the game.
 
−
<nowiki>
 
−
manipulate {MANIPULATE_TAKE, MANIPULATE_WIELD}
 
−
WEAPON_DEF(WPN_DAGGER, 1, 2)
 
−
SKILL_TRANSFER(SKI_BACKSTAB, 2)
 
−
dilcopy abi_restrict@function (ABIL_DEX,10,0,25,"");</nowiki>
 
−
to finish it off we will give the weapon a cost, rent, and finally
 
−
two identifies for the two identify spells. Now that we have it all
 
−
defined we pull it together and it looks like this.
 
−
<nowiki>
 
−
w_stiletto
 
−
title "a stiletto"
 
−
names {"deadly looking stiletto","deadly stiletto","stiletto", "dagger"}
 
−
descr
 
−
"A deadly looking stiletto has been left here."
 
  
−
extra{}
+
To finish it, a weight, a price, the rent, and the two identify extras. The finished weapon:
−
"This looks like a thieves dream come true. "
+
<pre>
 +
w_stiletto
 +
names {"deadly looking stiletto", "deadly stiletto", "stiletto", "dagger"}
 +
title "a stiletto"
 +
descr "A deadly looking stiletto has been left here."
 +
extra {}
 +
"This looks like a thief's dream come true."
 +
MATERIAL_METAL("A very fine quality steel")
 +
WEAPON_DEF(WPN_DAGGER, BONUS_AVERAGE_PLUS, BONUS_GOOD)
 +
SKILL_TRANSFER(SKI_BACKSTAB, 2)
 +
dilcopy abi_restrict@function(ABIL_DEX, 10, 0, 25, "");
 +
weight 2
 +
cost 2 GOLD_PIECE
 +
rent 1 COPPER_PIECE
  
−
MATERIAL_METAL("A very fine quality steel")
+
extra {"$identify"}
 +
"The stiletto looks magical in nature and seems really sharp. You can
 +
tell that if you wield it you would be able to backstab someone really
 +
easily."
  
−
manipulate {MANIPULATE_TAKE, MANIPULATE_WIELD}
+
extra {"$improved identify"}
−
WEAPON_DEF(WPN_DAGGER, 1, 2)
+
"The stiletto has a magic bonus of +2 and a craftsmanship of +1. It
−
SKILL_TRANSFER(SKI_BACKSTAB, 2)
+
also raises your backstab skill by 2. You need a dexterity of at least
−
dilcopy abi_restrict@function (ABIL_DEX,10,0,25,"");
+
10 to wield it."
−
weight 2
+
end
−
cost 2 GOLD_PIECE
+
</pre>
−
rent 1 COPPER_PIECE
 
  
−
extra {"$identify"}
+
<code>rent</code> is what a player pays per real day for keeping the item while logged off. It is
−
"The stiletto looks magical in nature and seems really sharp. You can
+
multiplied by the <code>rent</code> percentage in the server's server.cfg, which is 0 (no rent at all) in
−
tell if you wield it you would be able to backstab someone really easy."
+
the configuration that comes with the code.
  
−
extra{"$improved identify"}
 
−
"The stiletto gives you a magical bonus of +1 and has a quality of +2.
 
−
It also raises your back stabbing skill  by 2%.  You have to have at
 
−
least 10% in dex before you can wield this magical weapon."
 
−
 
−
end</nowiki>
 
 
==== Making armour ====
 
==== Making armour ====
  
−
In (Link to objmacroarmour) we explained how to set the
+
When a character is hit in melee, the game picks the part of the body that was hit, and only armour
−
          armour fields now we will finish off by adding some more
+
(<code>type ITEM_ARMOR</code>) worn on that part protects. There are six such parts:
−
          important information about armour in general.
 
  
−
  The most important thing to realize is that not all wear
 
−
          positions on the VME server are armour positions.  In fact
 
−
          only seven of the wear positions count as armour the rest are
 
−
          non-armour positions which we will cover next in (Link to objnon-armour).  The following are the armour
 
−
          positions and their defines.
 
 
{| class="wikitable"
 
{| class="wikitable"
−
|+Armour positions
+
|+ Armour positions
 +
! Position !! Manipulate flag !! Chance to be hit
 
|-
 
|-
−
!Position
+
| body || <code>MANIPULATE_WEAR_BODY</code> || 34%
−
!Define
 
 
|-
 
|-
−
|head
+
| legs || <code>MANIPULATE_WEAR_LEGS</code> || 28%
−
|MANIPULATE_WEAR_HEAD
 
 
|-
 
|-
−
|hands
+
| arms || <code>MANIPULATE_WEAR_ARMS</code> || 23%
−
|MANIPULATE_WEAR_HANDS
 
 
|-
 
|-
−
|arms
+
| head || <code>MANIPULATE_WEAR_HEAD</code> || 5%
−
|MANIPULATE_WEAR_ARMS
 
 
|-
 
|-
−
|body
+
| hands || <code>MANIPULATE_WEAR_HANDS</code> || 5%
−
|MANIPULATE_WEAR_BODY
 
 
|-
 
|-
−
|legs
+
| feet || <code>MANIPULATE_WEAR_FEET</code> || 5%
−
|MANIPULATE_WEAR_LEGS
 
−
|-
 
−
|feet
 
−
|MANIPULATE_WEAR_FEET
 
−
|-
 
−
|cloak
 
−
|MANIPULATE_WEAR_ABOUT
 
 
|}
 
|}
−
<blockquote style="background-color: #E8E8E8; font-style: italic; ">There is one more field that works as armour, 'MANIPULATE_WEAR_SHIELD' but since that uses another define it is not shown here.  We will leave that for an exercise for you to do later.</blockquote>
 
  
−
First we do the same as we have for every other item, pick the
+
A cloak (<code>MANIPULATE_WEAR_ABOUT</code>) is not one of them. A shield is made with
−
symbolic, title, description, extra description, and material type for the plate.
+
<code>SHIELD_DEF</code> and worn with <code>MANIPULATE_WEAR_SHIELD</code>; it blocks blows in its own way.
−
<nowiki>
 
−
pol_plate
 
−
names {"polished breast plate","polished plate","breast plate","plate"}
 
−
title "a polished breast plate"
 
−
descr "A polished breast plate has been left here."
 
−
MATERIAL_METAL("A high luster silver colored metal")</nowiki>
 
−
Now we pick the armour type in this case I want it to be made like
 
−
plate mail and I want it to have a magical bonus and a high
 
−
craftsmanship. Obviously since this is a plate we will pick the body
 
−
position.
 
−
<nowiki>
 
−
manipulate {MANIPULATE_TAKE, MANIPULATE_WEAR_BODY}
 
−
ARMOUR_DEF(ARM_PLATE,5,9)</nowiki>
 
−
All that is left is to add the cost, rent, the identify extras,
 
−
and I felt like putting a 40% strength restriction on the armour.  With
 
−
all that added together we finish up with the following piece of
 
−
armour.
 
−
<nowiki>
 
−
pol_plate
 
−
names {"polished breast plate","polished plate","breast plate","plate"}
 
−
title "a polished breast plate"
 
−
descr "A polished breast plate has been left here."
 
  
−
extra{}
+
We will make a breast plate. First the name, descriptions and material:
−
"This is one shiny plate it seems to be made out of one perfect piece of
+
<pre>
−
metal. There doesn't even seem to be any markings of owner ship."
+
pol_plate
 +
names {"polished breast plate", "polished plate", "breast plate", "plate"}
 +
title "a polished breast plate"
 +
descr "A polished breast plate has been left here."
 +
extra {}
 +
"This is one shiny plate. It seems to be made out of one perfect piece
 +
of metal. There don't even seem to be any marks of ownership."
 +
MATERIAL_METAL("A high lustre silver coloured metal")
 +
</pre>
  
−
MATERIAL_METAL("A high luster silver colored metal")
+
Then the armour: plate, with a craftsmanship of +4 (<code>BONUS_EXCELLENT</code>) and a magic bonus
 +
of +3 (<code>BONUS_GOOD_PLUS</code>). The armour macros only set <code>MANIPULATE_TAKE</code>; the
 +
position where it is worn has to be added, here the body.
 +
<pre>
 +
ARMOUR_DEF(ARM_PLATE, BONUS_EXCELLENT, BONUS_GOOD_PLUS)
 +
manipulate {MANIPULATE_WEAR_BODY}
 +
</pre>
  
−
manipulate {MANIPULATE_TAKE, MANIPULATE_WEAR_BODY}
+
All that is left is a strength restriction, the weight, cost, rent and the identify extras. The
−
ARMOUR_DEF(ARM_PLATE,5,9)
+
finished armour:
 +
<pre>
 +
pol_plate
 +
names {"polished breast plate", "polished plate", "breast plate", "plate"}
 +
title "a polished breast plate"
 +
descr "A polished breast plate has been left here."
 +
extra {}
 +
"This is one shiny plate. It seems to be made out of one perfect piece
 +
of metal. There don't even seem to be any marks of ownership."
 +
MATERIAL_METAL("A high lustre silver coloured metal")
 +
ARMOUR_DEF(ARM_PLATE, BONUS_EXCELLENT, BONUS_GOOD_PLUS)
 +
manipulate {MANIPULATE_WEAR_BODY}
 +
dilcopy abi_restrict@function(ABIL_STR, 40, 0, 25, "");
 +
weight 25
 +
cost 2 GOLD_PIECE
 +
rent 3 COPPER_PIECE
  
−
dilcopy abi_restrict@function (ABIL_STR,40,0,25,"");
+
extra {"$identify"}
−
cost 2 GOLD_PIECE
+
"This is a high quality plate with a magical feeling."
−
rent 3 COPPER_PIECE weight 25
 
  
−
extra{"$identify"}
+
extra {"$improved identify"}
−
"This is a high quality plate with a magical feeling."
+
"The plate has a magic bonus of +3 and a craftsmanship of +4. You need
 +
a strength of at least 40 to wear it."
 +
end
 +
</pre>
  
−
extra{"$improved identify"}
 
−
"The plate has a magical bonus to your defence of a +5 and a quality of
 
−
+9.  You need 40% in strength to be able to wear it."
 
−
end</nowiki>
 
 
==== Making non-armour worn objects ====
 
==== Making non-armour worn objects ====
  
−
In the previous section we defined armour that actually protects
+
Clothing and jewellery don't protect in a fight, but they can carry bonuses that help in the long
−
the char in combat.  Here we will learn how to make the clothing and
+
run. These are the other places an object can be worn:
−
jewelery that may not do anything directly to combat but it can give
+
 
−
your characters bonuses that help in combat in the long run. We will
 
−
start by listing all the non-armour worn positions and their manipulate
 
−
defines and then we will give a simple ring object.
 
 
{| class="wikitable"
 
{| class="wikitable"
−
|+Non-armour positions
+
|+ Other worn positions
 +
! Position !! Manipulate flag !! How many
 
|-
 
|-
−
!Position
+
| finger || <code>MANIPULATE_WEAR_FINGER</code> || 2
−
!define
 
 
|-
 
|-
−
|ear
+
| neck || <code>MANIPULATE_WEAR_NECK</code> || 2
−
|MANIPULATE_WEAR_EAR
 
 
|-
 
|-
−
|neck
+
| wrist || <code>MANIPULATE_WEAR_WRIST</code> || 2
−
|MANIPULATE_WEAR_NECK
 
 
|-
 
|-
−
|wrist
+
| ear || <code>MANIPULATE_WEAR_EAR</code> || 2
−
|MANIPULATE_WEAR_WRIST
 
 
|-
 
|-
−
|finger
+
| ankle || <code>MANIPULATE_WEAR_ANKLE</code> || 2
−
|MANIPULATE_WEAR_FINGER
 
 
|-
 
|-
−
|chest
+
| about the body (cloak) || <code>MANIPULATE_WEAR_ABOUT</code> || 1
−
|MANIPULATE_WEAR_CHEST
 
 
|-
 
|-
−
|back
+
| waist || <code>MANIPULATE_WEAR_WAIST</code> || 1
−
|MANIPULATE_WEAR_BACK
 
 
|-
 
|-
−
|waist
+
| chest || <code>MANIPULATE_WEAR_CHEST</code> || 1
−
|MANIPULATE_WEAR_WAIST
 
 
|-
 
|-
−
|ankle
+
| back || <code>MANIPULATE_WEAR_BACK</code> || 1
−
|MANIPULATE_WEAR_ANKLE
 
 
|}
 
|}
−
<blockquote style="background-color: #E8E8E8; font-style: italic; ">When giving ability, skill, weapon, or spell bonuses make sure you realize that positions like ear, neck, wrist, and ankle can all have two on a player.  This means any bonuses you give can be doubled if the player gets two of them</blockquote>
 
  
−
I don't want to beat a dead horse so since I have already
+
A player can wear two rings, two necklaces, two bracelets, two earrings and two anklets. Any
−
explained armour in (Link to objarmour) the only difference here
+
bonus you put on such an item can be doubled when a player gets two of them.
−
is there is no 'ARMOUR_DEF' everything else is the same.  The following
 
−
was one of the first items my wife made as a new builder and I have
 
−
always liked it. I know, I am a lush but this way I don't have to write
 
−
an example.
 
−
<nowiki>
 
−
  maskwa
 
  
−
names {"maskwa platinum ring", "platinum ring","maskwa ring","maskwa","ring"}
+
A worn object is made like armour, with two differences: there is no <code>ARMOUR_DEF</code>, and
−
title "a Maskwa ring"
+
its type is <code>ITEM_WORN</code>. This ring adds 1 to the wearer's strength:
−
descr "A Maskwa platinum ring is laying here."
+
<pre>
−
MATERIAL_METAL("Platinum, and other precious metals")
+
maskwa
−
extra {}
+
names {"maskwa platinum ring", "platinum ring", "maskwa ring", "maskwa",
−
"The ring has a large bear head. Could this be the legendary head of
+
      "ring"}
−
Maskwa? Any thing formed with its head on it is said to strengthen the
+
title "a Maskwa ring"
−
wearer."
+
descr "A Maskwa platinum ring is lying here."
−
type ITEM_WORN
+
extra {}
−
manipulate {MANIPULATE_TAKE, MANIPULATE_HOLD, MANIPULATE_WEAR_FINGER}
+
"The ring has a large bear head. Could this be the legendary head of
−
cost 100 COPPER_PIECE
+
Maskwa? Anything formed with its head on it is said to strengthen the
−
rent 50 IRON_PIECE
+
wearer."
−
weight 1
+
MATERIAL_METAL("Platinum, and other precious metals")
−
STR_TRANSFER(+1)
+
type ITEM_WORN
−
end</nowiki>
+
manipulate {MANIPULATE_TAKE, MANIPULATE_WEAR_FINGER}
−
<blockquote style="background-color: #E8E8E8; font-style: italic; ">One last thing I forgot to mention.  The item type also changes but then that is not hard to understand since this is not armour it should be some other thing.  In the case of non-armour worn items the item type is 'ITEM_WORN'.</blockquote>
+
STR_TRANSFER(+1)
 +
weight 1
 +
cost 100 COPPER_PIECE
 +
rent 50 IRON_PIECE
 +
end
 +
</pre>
  
−
<div style='padding-top: 30px; padding-bottom: 20px; text-align: left;float:left;width:50%;'>[[Manual:Zone_Manual/The_Objects_Section/DIL_functions_for_objects|Previous: DIL functions for objects]]</div>
+
<div style='padding-top: 30px; padding-bottom: 20px; text-align: left;float:left;width:50%;'>[[Manual:Zone Manual/The Objects Section/DIL functions for objects|Previous: DIL functions for objects]]</div>
−
<div style='padding-top: 30px; padding-bottom: 20px; text-align: right;float:right;width:50%;'>[[Manual:Zone_Manual/The_Objects_Section/Dragon_station_with_rooms_NPCs_and_objects|Next: Dragon station with rooms, NPCs, and objects]]</div>
+
<div style='padding-top: 30px; padding-bottom: 20px; text-align: right;float:right;width:50%;'>[[Manual:Zone Manual/The Objects Section/Dragon station with rooms NPCs and objects|Next: Dragon station with rooms, NPCs and objects]]</div>

Latest revision as of 06:14, 15 November 2026

More complex objects

The earlier pages showed the object fields and how to build a basic object. This page uses them, with the macros from Object macros and the DIL functions from DIL functions for objects, to make the objects of the dragon station zone: a board, a locker with its key, a drink, some food, a weapon, a piece of armour and a ring.

Every finished object on this page is part of the zone on the next page, Dragon station with rooms, NPCs and objects, and compiles there. Two rules to keep in mind while reading them:

  • A type macro (WEAPON_DEF, ARMOUR_DEF, LIQ_WINE...) sets type, value[] and sometimes weight. These fields keep the last value written, so put the macro first and change things after it. manipulate, flags and open add up instead, so a manipulate line after the macro adds to what the macro set.
  • Give every object a material with one of the MATERIAL_* macros from wmacros.h. The text appears when a player identifies the item, and DIL can test the material (for example "$mat_metal" in item.extra).

Making a communication board

A board is an object with the board@boards DIL function on it. The function and its arguments are explained in DIL functions for objects. As with every object, first name and describe it:

info_board
names {"merchant information board", "information board", "merchant board",
       "board"}
title "a merchant information board"
descr "A merchant information board is mounted on a wall here."
extra {}
"A large flashy black steel board."
MATERIAL_METAL("A very fine quality black steel")

Then the board itself: the type and the DIL function. Here everyone may read and post, but only administrators may remove other people's posts (rem_res@boards), and the board holds up to 100 posts. It has no MANIPULATE_TAKE, so nobody can walk off with it.

type ITEM_BOARD
dilcopy board@boards("info", "", "rem_res@boards", "", 100);

The finished board:

info_board
names {"merchant information board", "information board", "merchant board",
       "board"}
title "a merchant information board"
descr "A merchant information board is mounted on a wall here."
extra {}
"A large flashy black steel board."
MATERIAL_METAL("A very fine quality black steel")
type ITEM_BOARD
dilcopy board@boards("info", "", "rem_res@boards", "", 100);
end

The first argument, "info", names the files the posts are kept in. Every board with the same name shows the same posts, so give a board of your own a name no other board uses.

Making a container

The station gets a small weapons locker. It hangs on the wall, so it can't be taken; it can be opened, closed and locked, and a black key opens it. The description comes first, as always:

wpn_locker
names {"weapons locker", "weapon locker", "locker"}
title "a weapons locker"
descr "A small weapons locker hangs on the wall here."
extra {}
"It is an ordinary weapons locker that looks like it holds any illegal
weapons that are taken on the station."
MATERIAL_METAL("A very fine quality steel")

Then what makes it a container:

CONTAINER_DEF(50)
manipulate {MANIPULATE_ENTER}
open {EX_OPEN_CLOSE, EX_CLOSED, EX_LOCKED}
key black_key
weight 400
  • CONTAINER_DEF(50) sets the type and the capacity, here 50 pounds. It sets nothing else.
  • MANIPULATE_ENTER is what lets players put things in; without it nothing can be put in the locker. A player can also enter an open object with this flag if he and all he carries fit in its capacity, so keep the capacity of a small container small.
  • There is no MANIPULATE_TAKE, so the locker stays on the wall. The high weight is only a second guard against that.
  • open takes the same EX_* flags as a door: EX_OPEN_CLOSE makes it something you can open and close, EX_CLOSED and EX_LOCKED say how it is when it is loaded.
  • key is the symbolic name of the key object. To unlock, a player must carry an object with that symbolic name. vmc doesn't check that the key exists; if it doesn't, only the pick lock skill opens the locker.

So the key has to be made too. A key has no macro: it is type ITEM_KEY and something you can take and hold.

black_key
names {"small black key", "black key", "key"}
title "a small black key"
descr "A small black key has been dropped here."
extra {}
"It is a plain key of black steel. It looks like it fits a locker."
MATERIAL_METAL("Black steel")
type ITEM_KEY
manipulate {MANIPULATE_TAKE, MANIPULATE_HOLD}
weight 1
end

The finished locker:

wpn_locker
names {"weapons locker", "weapon locker", "locker"}
title "a weapons locker"
descr "A small weapons locker hangs on the wall here."
extra {}
"It is an ordinary weapons locker that looks like it holds any illegal
weapons that are taken on the station."
MATERIAL_METAL("A very fine quality steel")
CONTAINER_DEF(50)
manipulate {MANIPULATE_ENTER}
open {EX_OPEN_CLOSE, EX_CLOSED, EX_LOCKED}
key black_key
weight 400
end

Loading things into the locker, and keeping the key somewhere a player can find it, is done in the reset section (see Loading objects and NPCs).

Creating drinks

A drink container has a few rules of its own for the title, descriptions and names, because the liquid in it can change: a player can drink it empty and fill it with something else.

The title and descriptions must not mention the liquid. A bag full of wine is "a red bag", not "a bag of wine": once a player has drunk the wine and filled the bag with water, a title saying wine would be wrong.

liq_ration
title "a red bag"
descr "A red bag has been gently placed here."

The name of the liquid must be the last name in the names list. When the container is emptied, the game removes the last name; when it is filled, the name of the new liquid is added at the end.

names {"red bag", "bag", "wine"}

The liquid comes from a macro in liquid.h (included by macros.h). The four arguments are the weight of the empty container, its capacity, how much is in it, and how poisonous the liquid is (0: not at all). The macro also sets the weight, to the container plus its contents.

LIQ_WINE(1, 2, 2, 0)

To finish it, add a material, MANIPULATE_TAKE so it can be picked up, a price, and an $identify extra. A player who casts identify on the bag sees the text of $identify; improved identify shows $improved identify as well. The finished drink container:

liq_ration
names {"red bag", "bag", "wine"}
title "a red bag"
descr "A red bag has been gently placed here."
extra {}
"A small label reads: Tassel Grove's finest. Year 321."
MATERIAL_ORGANIC("a soft plastic")
LIQ_WINE(1, 2, 2, 0)
manipulate {MANIPULATE_TAKE}
cost 2 IRON_PIECE

extra {"$identify"}
"It's the special wine from Tassel Grove, a small halfling village on the
planet Valhalla. It seems like a great vintage."
end

Creating food

Food is a plain object with FOOD_DEF(amount, poison): how filling it is, and how poisonous (0: not at all). Here is a stick of dried beef that might be lying around a space station:

beef_stick
names {"tough leathery stick", "tough leather stick", "leathery stick",
       "leather stick", "tough stick", "stick"}
title "a tough leathery stick"
descr "A tough leathery looking stick is lying here."
extra {}
"This has the word BEEF burnt into it."
MATERIAL_ORGANIC("tough beef")
FOOD_DEF(5, 0)
manipulate {MANIPULATE_TAKE}
weight 1
cost 1 COPPER_PIECE
end

Making a weapon

This stiletto uses the weapon macro, a skill bonus while it is wielded, and a restriction: only players with enough dexterity can wield it. First the description and the material:

w_stiletto
names {"deadly looking stiletto", "deadly stiletto", "stiletto", "dagger"}
title "a stiletto"
descr "A deadly looking stiletto has been left here."
extra {}
"This looks like a thief's dream come true."
MATERIAL_METAL("A very fine quality steel")

Then what makes it a special weapon:

WEAPON_DEF(WPN_DAGGER, BONUS_AVERAGE_PLUS, BONUS_GOOD)
SKILL_TRANSFER(SKI_BACKSTAB, 2)
dilcopy abi_restrict@function(ABIL_DEX, 10, 0, 25, "");
  • WEAPON_DEF(weapon, craftsmanship, magic bonus) makes it a dagger with a craftsmanship of +1 (BONUS_AVERAGE_PLUS) and a magic bonus of +2 (BONUS_GOOD). Both bonuses go from -7 to +7, named BONUS_JUNK to BONUS_ARTIFACT in values.h; vmc refuses anything outside. The macro also sets MANIPULATE_TAKE and MANIPULATE_WIELD.
  • SKILL_TRANSFER(SKI_BACKSTAB, 2) raises the backstab skill by 2 while the stiletto is wielded.
  • abi_restrict@function makes a player with a dexterity below 10 drop it again.

To finish it, a weight, a price, the rent, and the two identify extras. The finished weapon:

w_stiletto
names {"deadly looking stiletto", "deadly stiletto", "stiletto", "dagger"}
title "a stiletto"
descr "A deadly looking stiletto has been left here."
extra {}
"This looks like a thief's dream come true."
MATERIAL_METAL("A very fine quality steel")
WEAPON_DEF(WPN_DAGGER, BONUS_AVERAGE_PLUS, BONUS_GOOD)
SKILL_TRANSFER(SKI_BACKSTAB, 2)
dilcopy abi_restrict@function(ABIL_DEX, 10, 0, 25, "");
weight 2
cost 2 GOLD_PIECE
rent 1 COPPER_PIECE

extra {"$identify"}
"The stiletto looks magical in nature and seems really sharp. You can
tell that if you wield it you would be able to backstab someone really
easily."

extra {"$improved identify"}
"The stiletto has a magic bonus of +2 and a craftsmanship of +1. It
also raises your backstab skill by 2. You need a dexterity of at least
10 to wield it."
end

rent is what a player pays per real day for keeping the item while logged off. It is multiplied by the rent percentage in the server's server.cfg, which is 0 (no rent at all) in the configuration that comes with the code.

Making armour

When a character is hit in melee, the game picks the part of the body that was hit, and only armour (type ITEM_ARMOR) worn on that part protects. There are six such parts:

Armour positions
Position Manipulate flag Chance to be hit
body MANIPULATE_WEAR_BODY 34%
legs MANIPULATE_WEAR_LEGS 28%
arms MANIPULATE_WEAR_ARMS 23%
head MANIPULATE_WEAR_HEAD 5%
hands MANIPULATE_WEAR_HANDS 5%
feet MANIPULATE_WEAR_FEET 5%

A cloak (MANIPULATE_WEAR_ABOUT) is not one of them. A shield is made with SHIELD_DEF and worn with MANIPULATE_WEAR_SHIELD; it blocks blows in its own way.

We will make a breast plate. First the name, descriptions and material:

pol_plate
names {"polished breast plate", "polished plate", "breast plate", "plate"}
title "a polished breast plate"
descr "A polished breast plate has been left here."
extra {}
"This is one shiny plate. It seems to be made out of one perfect piece
of metal. There don't even seem to be any marks of ownership."
MATERIAL_METAL("A high lustre silver coloured metal")

Then the armour: plate, with a craftsmanship of +4 (BONUS_EXCELLENT) and a magic bonus of +3 (BONUS_GOOD_PLUS). The armour macros only set MANIPULATE_TAKE; the position where it is worn has to be added, here the body.

ARMOUR_DEF(ARM_PLATE, BONUS_EXCELLENT, BONUS_GOOD_PLUS)
manipulate {MANIPULATE_WEAR_BODY}

All that is left is a strength restriction, the weight, cost, rent and the identify extras. The finished armour:

pol_plate
names {"polished breast plate", "polished plate", "breast plate", "plate"}
title "a polished breast plate"
descr "A polished breast plate has been left here."
extra {}
"This is one shiny plate. It seems to be made out of one perfect piece
of metal. There don't even seem to be any marks of ownership."
MATERIAL_METAL("A high lustre silver coloured metal")
ARMOUR_DEF(ARM_PLATE, BONUS_EXCELLENT, BONUS_GOOD_PLUS)
manipulate {MANIPULATE_WEAR_BODY}
dilcopy abi_restrict@function(ABIL_STR, 40, 0, 25, "");
weight 25
cost 2 GOLD_PIECE
rent 3 COPPER_PIECE

extra {"$identify"}
"This is a high quality plate with a magical feeling."

extra {"$improved identify"}
"The plate has a magic bonus of +3 and a craftsmanship of +4. You need
a strength of at least 40 to wear it."
end

Making non-armour worn objects

Clothing and jewellery don't protect in a fight, but they can carry bonuses that help in the long run. These are the other places an object can be worn:

Other worn positions
Position Manipulate flag How many
finger MANIPULATE_WEAR_FINGER 2
neck MANIPULATE_WEAR_NECK 2
wrist MANIPULATE_WEAR_WRIST 2
ear MANIPULATE_WEAR_EAR 2
ankle MANIPULATE_WEAR_ANKLE 2
about the body (cloak) MANIPULATE_WEAR_ABOUT 1
waist MANIPULATE_WEAR_WAIST 1
chest MANIPULATE_WEAR_CHEST 1
back MANIPULATE_WEAR_BACK 1

A player can wear two rings, two necklaces, two bracelets, two earrings and two anklets. Any bonus you put on such an item can be doubled when a player gets two of them.

A worn object is made like armour, with two differences: there is no ARMOUR_DEF, and its type is ITEM_WORN. This ring adds 1 to the wearer's strength:

maskwa
names {"maskwa platinum ring", "platinum ring", "maskwa ring", "maskwa",
       "ring"}
title "a Maskwa ring"
descr "A Maskwa platinum ring is lying here."
extra {}
"The ring has a large bear head. Could this be the legendary head of
Maskwa? Anything formed with its head on it is said to strengthen the
wearer."
MATERIAL_METAL("Platinum, and other precious metals")
type ITEM_WORN
manipulate {MANIPULATE_TAKE, MANIPULATE_WEAR_FINGER}
STR_TRANSFER(+1)
weight 1
cost 100 COPPER_PIECE
rent 50 IRON_PIECE
end
Previous: DIL functions for objects
Next: Dragon station with rooms, NPCs and objects