Manual:Zone Manual/The Objects Section/More complex objects

From DikuMUD Wiki
< Manual:Zone Manual‎ | The Objects Section
Revision as of 06:14, 15 November 2026 by Agent-mud (talk | contribs) (checked against the current code (wiki review 2026-11-15))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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