Difference between revisions of "Manual:Zone Manual/The Objects Section/Object macros"

From DikuMUD Wiki
Jump to navigation Jump to search
(checked against the current code (wiki review 2026-11-15))
 
Line 1: Line 1:
−
=== Object macros ===
+
== Object macros ==
  
−
  To make the creation of some objects easier we have provided a
+
Weapons, armour, drinks, lights and most other kinds of objects need a type and a few values that must fit together. The macros in <code>vme/include/wmacros.h</code> and <code>liquid.h</code> set them for you. Both are included by <code>#include &lt;macros.h&gt;</code>.
−
set of Macros. The macros range from general armour and weapons macros
+
 
−
to macros that help you create special affects on all items. We will
+
A macro sets fields such as <code>type</code>, <code>value[]</code> and <code>weight</code>, and those keep the last value given. Write the macro first and change things after it, or the macro overwrites what you wrote before it. <code>manipulate</code> and <code>flags</code> add up, so you can add to the flags a macro sets.
−
first cover what craftsmanship and magical modifiers are in (Link to objcraft) and (Link to objmag) respectively. After
+
 
−
which we will show the use of craftsmanship and magical modifiers in
+
The definitions below are copied from the headers. If you want to check one, the files are on GitHub: [https://github.com/Seifert69/DikuMUD3/blob/master/vme/include/wmacros.h wmacros.h], [https://github.com/Seifert69/DikuMUD3/blob/master/vme/include/liquid.h liquid.h].
−
(Link to objmacroweapon) and (Link to objmacroarmour).
+
 
−
==== Weapon and armour craftsmanship ====
+
=== The bonus scale ===
 +
 
 +
Weapons, armour and shields have two bonuses, craftsmanship and magic, and the transfer macros further down take an amount. All of them use the same scale from -7 to +7, with names in <code>values.h</code>:
  
−
The craftsmanship is a way of expressing the overall quality of  a
 
−
piece of armour or weapon.  The quality on the VME servers currently
 
−
means the amount of hit points given to an item.  The craftsmanship
 
−
ranges from 25 to -25 and the hit points range from 125 to 6000.  The craftsmanship can be looked at as how tough or good the armour
 
−
or weapon is.  The following table should help you in deciding how tough
 
−
your armour or weapon should be.
 
 
{| class="wikitable"
 
{| class="wikitable"
−
|+Approximate hit points verses craftsmanship
+
!Value
 +
!Name
 +
!Combat bonus
 +
!Hit points of the item
 
|-
 
|-
−
!Craftsmanship
+
|7
−
!Hit points
+
|<code>BONUS_ARTIFACT</code>
 +
|+20
 +
|2400
 
|-
 
|-
−
|25
+
|6
−
|6000
+
|<code>BONUS_SUPERIOR</code>
 +
|+17
 +
|2200
 +
|-
 +
|5
 +
|<code>BONUS_EXCELLENT_PLUS</code>
 +
|+14
 +
|2000
 
|-
 
|-
−
|20
+
|4
−
|5000
+
|<code>BONUS_EXCELLENT</code>
 +
|+11
 +
|1800
 
|-
 
|-
−
|15
+
|3
−
|4000
+
|<code>BONUS_GOOD_PLUS</code>
 +
|+8
 +
|1600
 
|-
 
|-
−
|10
+
|2
−
|3000
+
|<code>BONUS_GOOD</code>
 +
|+5
 +
|1400
 
|-
 
|-
−
|5
+
|1
−
|2000
+
|<code>BONUS_AVERAGE_PLUS</code>
 +
|+2
 +
|1200
 
|-
 
|-
 +
|0
 +
|<code>BONUS_AVERAGE</code>
 
|0
 
|0
 
|1000
 
|1000
 
|-
 
|-
−
|-5
+
| -1
−
|875
+
|<code>BONUS_AVERAGE_MINUS</code>
 +
| -2
 +
|965
 
|-
 
|-
−
|-10
+
| -2
−
|650
+
|<code>BONUS_BAD</code>
 +
| -5
 +
|930
 
|-
 
|-
−
|-15
+
| -3
−
|425
+
|<code>BONUS_BAD_MINUS</code>
 +
| -8
 +
|895
 
|-
 
|-
−
|-20
+
| -4
−
|300
+
|<code>BONUS_TERRIBLE</code>
 +
| -11
 +
|860
 
|-
 
|-
−
|-25
+
| -5
−
|125
+
|<code>BONUS_TERRIBLE_MINUS</code>
 +
| -14
 +
|825
 +
|-
 +
| -6
 +
|<code>BONUS_JUNK_ALMOST</code>
 +
| -17
 +
|790
 +
|-
 +
| -7
 +
|<code>BONUS_JUNK</code>
 +
| -20
 +
|755
 
|}
 
|}
−
It is suggested the higher the craftsmanship the higher the cost
 
−
of the weapon should be.  This is not a must but it goes with out saying
 
−
the quality of an item should be represented in the cost of it.  Of
 
−
corse there is the time you would want to sell your players poor quality
 
−
items at a high cost just to make them think they are getting something
 
−
cool.
 
−
==== Magical modifier ====
 
  
−
The magical modifier can be said to modify damage done to an
+
vmc refuses anything outside -7..+7 (the old manuals used ±25 and ±10; those numbers are wrong now). The comments in <code>wmacros.h</code> still mention the old ranges; ignore them.
−
opponent. In a combat the damage is calculated and then the magical
 
−
bonuses on armour or weapons is added in. This is best explained by an
 
−
example.
 
  
−
Lets say that you were about to give 25 hit points of damage to a
+
;Craftsmanship
−
person. Your sword has a plus 25% in magical bonus. The bonus is added to
+
:How well the item is made: the material and the smith. It decides the item's hit points (last column). Every hit with a weapon, and every hit taken on armour or a shield, wears the item down; at zero hit points it breaks, its title gets "(broken)" and it becomes worthless junk. A <code>hit</code> field on a weapon, armour or shield is ignored.
−
your damage to make it a total of 50 hit points of damage. The player
+
;Magic bonus
−
you are hitting however has a +25% magical bonus on his armour that you
+
:How much the item is enchanted. A higher magic bonus also makes the item wear down a little slower.
−
are about to hit him on.  That will reduce the damage back to its 25%
+
;Combat bonus
−
hit points originally done.  This is just a nice way to add a bit of
+
:When the game loads the item, both bonuses are turned into the combat bonus in the third column (a positive bonus sometimes comes out a little higher). A weapon's craftsmanship and magic bonus are added to its wielder's attack; armour's are added to the defence when that body part is hit, and a shield's to its chance to block. In a melee hit, +2 of combat bonus is worth as much as 1 more point of weapon skill.
−
damage for a special weapon.
 
  
−
The magical modifier ranges from 25 to -25.  It affects both the
+
Make better items cost more, and give a magic item <code>flags {UNIT_FL_MAGIC}</code> so that detect magic shows it.
−
damage being given to a player and the damage being given to a weapon or
 
−
a piece of armour.
 
  
−
It is suggested that you modify the costs of your objects to fit
+
=== Weapons ===
−
the amount of magical bonus along with adding the magical flag tot he
 
−
objects flag list so an identify spell can pick up that there is
 
−
magic about the object.  This is not a must but your players will love
 
−
you for it.
 
−
==== Setting weapon fields ====
 
  
−
  To create a weapon you only need three pieces of information.
+
<pre>
−
The weapons craftsmanship and magical modifiers defined in (Link to objcraft) and (Link to objmag) and the weapon type.
+
/* weapon_category: One of the WPN_XXX macros.       */
−
You have seen the weapon types before when defining a NPCs natural
+
/* craftsmanship:  [-25..25] Material used &amp; Smity */
−
attack type in (Link to npcmacroattarm).  The full list of weapon
+
/* magic_bonus:    [-25..25] Magic modification    */
−
types that are released with the VME 2.0 can be found in (Link to app-d). With craftsmanship, magical modifier and the weapon
+
#define WEAPON_DEF(weapon_category, craftsmanship, magic_bonus)  \
−
type all you need to do is pick from one of the following macros and
+
  manipulate {MANIPULATE_TAKE, MANIPULATE_WIELD} \
−
insert your numbers.
+
  type ITEM_WEAPON            \
−
<nowiki>
+
  value[0] weapon_category   \
−
#define WEAPONSZ_DEF(weapon_category, craftsmanship, magic_bonus, hgt)  \
+
  value[1] craftsmanship     \
−
  WEAPON_DEF(weapon_category, craftsmanship, magic_bonus)\
+
  value[2] magic_bonus       \
−
  height hgt
+
  value[3] RACE_DO_NOT_USE
  
−
#define SHIELD_DEF(shield_type, craftsmanship, magic_bonus)  \
+
#define WEAPONSZ_DEF(weapon_category, craftsmanship, magic_bonus, hgt)  \
−
  manipulate {MANIPULATE_TAKE, MANIPULATE_WEAR_SHIELD} \
+
  WEAPON_DEF(weapon_category, craftsmanship, magic_bonus)\
−
  type ITEM_SHIELD            \
+
  height hgt
−
  value[0] shield_type        \
+
</pre>
−
  value[1] craftsmanship      \
 
−
  value[2] magic_bonus</nowiki>
 
−
As you can see the first macro uses the second macro so the only
 
−
difference between them is the first one sets the height field.  Using
 
−
the first macro will force your weapon to be a certain size when loaded.
 
−
While not setting the height field by using the second macro would let
 
−
the VME server set the size of the weapon by what NPC it is loaded
 
−
on.
 
  
−
A  flail (two handed) of non-pure iron (-3%), a little better than
+
The weapon category is a weapon such as <code>WPN_DAGGER</code> or <code>WPN_BATTLE_AXE</code>, from <code>values.h</code> (see [[Manual:Zone Manual/Appendices/weapon definitions in values.h|weapon definitions in values.h]]). The groups <code>WPN_SWORD</code>, <code>WPN_AXE_HAM</code> and so on are for skills, not weapons: vmc refuses them here. How hard each weapon hits each kind of armour, whether it needs two hands, and the strength and level needed to wield it are in <code>vme/etc/weapons.def</code>.
−
average craftsmanship (5%) and no magic bonuses would have:
 
−
<nowiki>
 
−
    WEAPON_DEF(WPN_FLAIL, +2, 0)</nowiki>
 
−
A  rusty  (-5%) mean sacrificial dagger by a skilled smithy  (+5%)
 
−
and magically enchanted might be:
 
−
<nowiki>
 
−
    flags {UNIT_FL_MAGIC}
 
−
    WEAPON_DEF(WPN_DAGGER, 0, +5)</nowiki>
 
−
An old shaky wooden stick made for a 400 cm tall person could
 
−
    be:
 
−
<nowiki>
 
−
WEAPONSZ_DEF(WPN_CLUB, -5, 0,400)</nowiki>
 
−
A wooden bastard sword would have considerable less craftsmanship
 
−
than listed since wood prevents the slashing effect, also it would be
 
−
non-sense to apply better than average craftsmanship in this
 
−
case.
 
−
<nowiki>
 
−
    WEAPON_DEF(WPN_BROAD_SWORD, -15, 0)</nowiki>
 
−
==== Setting armour fields ====
 
  
−
When designing armour it is no more difficult then when designing
+
<code>WEAPONSZ_DEF</code> also sets the height. Without a height the weapon is made for a 180 cm character; when a reset equips an NPC with it, it is resized to fit that NPC anyway.
−
weapons.  There is five main armour types.  The types don't define the
 
−
material type for example if you wanted to create a wooden pair of
 
−
armour that protected like plate armour you could do this by defining
 
−
the armour type as plate and then adding the material as defined in
 
−
(Link to objmacromattype). The five armour types are as
 
−
follows:
 
−
* Clothes
 
−
* Leather
 
−
* Hard leather
 
−
* Chain
 
−
* Plate
 
−
The armours macros are almost the same as the weapons macro it looks
 
−
as follows.
 
−
<nowiki>
 
−
#define ARMOUR_DEF(atype, craftsmanship, magic_bonus) \
 
−
  manipulate {MANIPULATE_TAKE} \
 
−
  type ITEM_ARMOR              \
 
−
  value[0] atype
 
−
      value[1] craftsmanship      \
 
−
  value[2] magic_bonus
 
  
−
#define ARMOURSZ_DEF(atype, craftsmanship, magic_bonus, hgt)\
+
A two-handed iron flail, well made, not magic:
−
  ARMOUR_DEF(atype,craftsmanship, magic_bonus) \
+
<pre>
−
  height hgt</nowiki>
+
WEAPON_DEF(WPN_FLAIL, BONUS_GOOD, BONUS_AVERAGE)
−
The craftsmanship and magical modifier fields have already been
+
</pre>
−
explained so the only thing new that you need to pass into these macros
 
−
is the 'atype' which stands for armour type.  As we have mentioned there
 
−
are five different armour types.  The following are the defines for
 
−
each:
 
−
* ARMOUR_CLOTHES
 
−
* ARMOUR_LEATHER
 
−
* ARMOUR_HLEATHER
 
−
* ARMOUR_CHAIN
 
−
* ARMOUR_PLATE
 
−
The armour type defines how different weapons and spells are
 
−
defended against for example plate would be better against acid maybe
 
−
and worse against electricity.  You as a VME
 
−
administrator will have to decide which armours are better at what by
 
−
changing your ''weapons.def'' and
 
−
''spells.def''
 
  
−
This explains the entire armour define but there is some more to
+
A rusty sacrificial dagger with an enchantment:
−
it.  The rest will be covered in (Link to objarmour) For now an
+
<pre>
−
example use of the armour define would be as follows:
+
WEAPON_DEF(WPN_DAGGER, BONUS_BAD, BONUS_GOOD)
−
<nowiki>
+
flags {UNIT_FL_MAGIC}
−
flags {UNIT_FL_MAGIC}
+
</pre>
−
ARMOR_DEF(ARM_PLATE,+15,+5)</nowiki>
 
−
==== Setting shield fields ====
 
  
−
We have tried to keep the interface of making armours, weapons, and shields the same.  If you have already looked through the defines for weapons and armours you will find that there is very little difference here.  The following is the define for the macro that sets the shield values.
+
A huge wooden club made for a 400 cm giant:
−
<nowiki>
+
<pre>
−
#define SHIELD_DEF(shield_type, craftsmanship, magic_bonus) \
+
WEAPONSZ_DEF(WPN_CLUB, BONUS_BAD, BONUS_AVERAGE, 400)
−
  manipulate {MANIPULATE_TAKE, MANIPULATE_WEAR_SHIELD} \
+
</pre>
−
  type ITEM_SHIELD            \
 
−
  value[0] shield_type        \
 
−
  value[1] craftsmanship      \
 
−
  value[2] magic_bonus
 
  
−
#define SHIELDSZ_DEF(shield_type, craftsmanship, magic_bonus, hgt)  \
+
==== Slaying weapons ====
−
  SHIELD_DEF(shield_type, craftsmanship, magic_bonus)\
 
−
  height hgt</nowiki>
 
−
You have already seen the craftsmanship and magical modifiers
 
−
in (Link to objcraft) and (Link to objmag), so the only
 
−
thing different here is the shield type.  There are three shield
 
−
types available in the current combat system and they are categorized by
 
−
size.  the three sizes are small, medium, and large.  to set the type
 
−
you use the defines from ''vme.h'' which define the
 
−
following:
 
−
* SHIELD_SMALL
 
−
* SHIELD_MEDIUM
 
−
* SHIELD_LARGE
 
−
the larger the shield the better chance of blocking an attack.
 
−
You may want to remember to add weight as you add size to your shield so
 
−
players are weighted down and can not carry the best of everything
 
−
but that is up to the administrator of the VME server.
 
  
−
A small magical wooden shield could be assigned:
+
<pre>
−
<nowiki>
+
/* race : Match one of the RACE_XXX values. */
−
    flags {UNIT_FL_MAGIC}
+
#define WEAPON_SLAYER(race) \
−
    SHIELD_DEF(SHIELD_SMALL, 0, +5)</nowiki>
+
  flags {UNIT_FL_MAGIC} \
−
==== Setting material types ====
+
  value[3] race
  
−
Currently Material types are not used greatly in spells or skills
+
/* Will slay dragons */
−
but in the future we hope to add more functionality for materials.  For
+
#define WEAPON_SLAYER_DRAGONS \
−
example in the future if you are hit by an acid spell we want your
+
   flags {UNIT_FL_MAGIC} \
−
armour to be damaged depending on the material it is.  The material
+
   value[3] RACE_DRAGON_MIN \
−
doesn't have any affect on damage given or taken it is just a way you can
+
   extra {"$slayer"} {RACE_DRAGON_MIN, RACE_DRAGON_MAX} "dragon slayer"
−
check in DIL what the weapon is made out of.  The following is the list
+
</pre>
−
you would find in ''wmacros.h'' of in the VME 2.0
 
−
release.
 
−
<nowiki>
 
−
#define MATERIAL_WOOD(DESCR)    extra {"$material", "$mat_wood"} DESCR
 
−
#define MATERIAL_METAL(DESCR)  extra {"$material", "$mat_metal"} DESCR
 
−
#define MATERIAL_STONE(DESCR)  extra {"$material", "$mat_stone"} DESCR
 
−
#define MATERIAL_CLOTH(DESCR)   extra {"$material", "$mat_cloth"} DESCR
 
−
#define MATERIAL_LEATHER(DESCR) extra {"$material", "$mat_leather"} DESCR
 
−
#define MATERIAL_SKIN(DESCR) extra {"$material", "$mat_skin"} DESCR
 
−
#define MATERIAL_ORGANIC(DESCR) extra {"$material", "$mat_organic"} DESCR
 
−
#define MATERIAL_GLASS(DESCR)   extra {"$material", "$mat_glass"} DESCR
 
−
#define MATERIAL_FIRE(DESCR)    extra {"$material", "$mat_fire"} DESCR
 
−
#define MATERIAL_WATER(DESCR)   extra {"$material", "$mat_water"} DESCR
 
−
#define MATERIAL_EARTH(DESCR)  extra {"$material", "$mat_earth"} DESCR
 
−
#define MATERIAL_MAGIC(DESCR)  extra {"$material", "$mat_magic"} DESCR</nowiki>
 
−
Therefore if you had a wooden staff you could add the following to
 
−
your weapon so spells would know what it was made out of.
 
−
<nowiki>
 
−
MATERIAL_WOOD("a hard oak")</nowiki>
 
−
==== Drink container macros ====
 
  
−
There are two different kinds of macros for drink containers.  The
+
A slaying weapon gets +50 on its attacks against that race, and more against opponents above level 50. <code>WEAPON_SLAYER_DRAGONS</code> slays every dragon race. Put the slayer macro after <code>WEAPON_DEF</code>, which sets <code>value[3]</code> to <code>RACE_DO_NOT_USE</code> (no slaying):
−
one you use depends on the need at the time.  The harder macro is made
 
−
so you can create a drink of any kind.  If however you want normal
 
−
drinks like water, beer, or even lemonade there are more simple macros
 
−
already defined for you to use in ''liquid.h''. The
 
−
following is a couple of the macros from the
 
−
''liquid.h'' for a full listing see
 
−
(Link to app-e).
 
−
<nowiki>
 
−
#define LIQ_WATER(WEIGHT,CAPACITY,INSIDE,POISON) \
 
−
LIQ_DEF("clear", WEIGHT,CAPACITY,INSIDE,10,1,0,POISON)
 
−
#define LIQ_BEER(WEIGHT,CAPACITY,INSIDE,POISON) \
 
−
LIQ_DEF("brown", WEIGHT,CAPACITY,INSIDE,5,2,3,POISON)
 
−
#define LIQ_WINE(WEIGHT,CAPACITY,INSIDE,POISON) \
 
−
LIQ_DEF("red", WEIGHT,CAPACITY,INSIDE,5,2,5,POISON)
 
−
#define LIQ_COFFEE(WEIGHT,CAPACITY,INSIDE,POISON) \
 
−
LIQ_DEF("black", WEIGHT, CAPACITY, INSIDE, 6, 1, 0,POISON)</nowiki>
 
−
To use these macros the arguments are pretty simple.
 
  
−
;weight
+
<pre>
−
: The first argument just says how heavy your drink container is when empty.  Like a barrel might be 15 pounds and a glass might be 1 pound.
+
WEAPON_DEF(WPN_LONG_SWORD, BONUS_GOOD, BONUS_GOOD)
−
You may be thinking there is no way the glasses in your kitchen are one
+
WEAPON_SLAYER(RACE_ORC)
−
pound.  The truth is if we had less than a pound then we would set the
+
</pre>
−
glass to less but currently all units are measured in pounds so the
 
−
least we can make it is a pound.  In the future of the
 
−
VME we will be converting to smaller measurements
 
−
like grams or ounces.
 
−
; capacity
 
−
*
 
−
The second argument is what your container can carry weight wise.
 
−
So if your barrel is 15 pounds and your barrel can carry 35 pounds of a
 
−
liquid then the total weight when full would be 50 pounds, if my math
 
−
is working today.  To make a container with infinity liquid like a
 
−
fountain you just set capacity to '-1'.
 
−
<blockquote style="background-color: #E8E8E8; font-style: italic; ">Making capacities ridiculously large can cause weight bugs. If your going to allow ridiculous amounts you might just want to give them the infinite amount or really work on your drink and pour functions</blockquote>
 
−
; inside
 
−
*
 
−
  The third argument is how much liquid by weight your container
 
−
  has inside.  This value should not be greater than the capacity but if
 
−
  you mess up it will be fixed when the player tries to drink from it.
 
−
  The total weight of the drink container and the liquid it contains
 
−
  will be the weight added to this value.
 
−
; poison
 
−
*
 
−
the forth argument is the amount of poison in your drink.  There
 
−
is no limit on the amount of poison but understand that a value of ten
 
−
would be a very high poison value.
 
  
−
So if you wanted to make a simple small glass of water you would
+
=== Armour ===
−
use the water macro and it would look like this:
 
−
<nowiki>
 
−
LIQ_WATER(1,2,2,0)</nowiki>
 
−
You are probably wondering what it takes to fill a player from
 
−
empty.  The players thirst ranges from -24 which is dieing of
 
−
thirst all the way to positive 24 which is full.  So if you have a
 
−
barrel that can hold 24 capacity one full barrel can take a person from
 
−
zero thirst to full.
 
  
−
Now lets say you want to make something more exotic. All the
+
<pre>
−
                          normal drinks are made or at least a great
+
#define ARMOUR_DEF(atype,craftsmanship, magic_bonus) \
−
                          number of them are in the
+
manipulate {MANIPULATE_TAKE} \
−
                          ''liquid.h'' but what if
+
type ITEM_ARMOR              \
−
                          you had a race from outer space that drank
+
value[0] atype        \
−
                          nothing but silicone oil. This obviously is
+
value[1] craftsmanship      \
−
                          not covered in our liquid file so you would
+
value[2] magic_bonus
−
                          have to make one yourself or use the more
+
 
−
                          complex macro.
+
#define ARMOURSZ_DEF(atype, craftsmanship, magic_bonus, hgt)\
−
<nowiki>
+
ARMOUR_DEF(atype,craftsmanship, magic_bonus) \
−
#define LIQ_DEF(color, wgt, max_cap, inside,thirst,full,drunk,poison) \
+
height hgt
−
  type ITEM_DRINKCON          \
+
</pre>
−
  weight (wgt)+(inside) \
+
 
−
  capacity max_cap \
+
The armour type is one of five, from <code>vme.h</code>. Each has a shorter macro of its own, and a <code>SZ</code> version that also takes the height:
−
  value[0] inside        \
+
 
−
  value[3] poison \
+
{| class="wikitable"
−
  extra {"$drink_color"}color \
+
!Armour type
−
  extra {"$drink_thirst"} #thirst \
+
!Macro
−
  extra {"$drink_full"} #full \
+
!With height
−
  extra {"$drink_drunk"} #drunk</nowiki>
+
|-
−
As you can see this define has much more information you need to
+
|<code>ARM_CLOTHES</code>
−
pass it but it really is not that hard.  The following are the arguments
+
|<code>ARMOUR_CLOTHES(craftsmanship, magic_bonus)</code>
−
and what they do.
+
|<code>ARMOURSZ_CLOTHES(craftsmanship, magic_bonus, hgt)</code>
 +
|-
 +
|<code>ARM_LEATHER</code>
 +
|<code>ARMOUR_LEATHER(...)</code>
 +
|<code>ARMOURSZ_LEATHER(...)</code>
 +
|-
 +
|<code>ARM_HLEATHER</code> (hard leather)
 +
|<code>ARMOUR_HRD_LEATHER(...)</code>
 +
|<code>ARMOURSZ_HRD_LEATHER(...)</code>
 +
|-
 +
|<code>ARM_CHAIN</code>
 +
|<code>ARMOUR_CHAIN(...)</code>
 +
|<code>ARMOURSZ_CHAIN(...)</code>
 +
|-
 +
|<code>ARM_PLATE</code>
 +
|<code>ARMOUR_PLATE(...)</code>
 +
|<code>ARMOURSZ_PLATE(...)</code>
 +
|}
 +
 
 +
The type says how the armour is built, not what it is made of; a wooden breastplate built like plate is <code>ARM_PLATE</code>. Each weapon in <code>weapons.def</code> has its own damage against each armour type.
 +
 
 +
The armour macros only set <code>MANIPULATE_TAKE</code>. Add the body part, or the armour can't be worn:
 +
 
 +
<pre>
 +
ARMOUR_PLATE(BONUS_GOOD, BONUS_AVERAGE)
 +
manipulate {MANIPULATE_WEAR_BODY}
 +
</pre>
 +
 
 +
<pre>
 +
ARMOUR_DEF(ARM_CHAIN, BONUS_AVERAGE, BONUS_AVERAGE)
 +
manipulate {MANIPULATE_WEAR_HEAD}
 +
</pre>
 +
 
 +
Armour protects the body part it is worn on. More about armour in [[Manual:Zone Manual/The Objects Section/More complex objects|More complex objects]].
 +
 
 +
=== Shields ===
 +
 
 +
<pre>
 +
#define SHIELD_DEF(shield_type, craftsmanship, magic_bonus)  \
 +
  manipulate {MANIPULATE_TAKE, MANIPULATE_WEAR_SHIELD} \
 +
  type ITEM_SHIELD            \
 +
  value[0] shield_type        \
 +
  value[1] craftsmanship      \
 +
  value[2] magic_bonus
 +
 
 +
#define SHIELDSZ_DEF(shield_type, craftsmanship, magic_bonus, hgt)  \
 +
  SHIELD_DEF(shield_type, craftsmanship, magic_bonus)\
 +
  height hgt
 +
</pre>
 +
 
 +
The shield type is <code>SHIELD_SMALL</code>, <code>SHIELD_MEDIUM</code> or <code>SHIELD_LARGE</code>, from <code>vme.h</code>. A larger shield blocks more often: the base chance is 15%, 20% and 25%, plus the shield's bonuses. Whether a shield can block a weapon at all is set per weapon in <code>weapons.def</code>. <code>vme.h</code> also defines <code>SHIELD_TOWER</code>, but vmc refuses it.
 +
 
 +
A small enchanted wooden shield:
 +
<pre>
 +
SHIELD_DEF(SHIELD_SMALL, BONUS_AVERAGE, BONUS_GOOD_PLUS)
 +
flags {UNIT_FL_MAGIC}
 +
MATERIAL_WOOD("Oak planks bound with iron")
 +
</pre>
 +
 
 +
=== Materials ===
 +
 
 +
<pre>
 +
#define MATERIAL_WOOD(DESCR)    extra {"$material", MAT_WOOD_STR} DESCR
 +
#define MATERIAL_METAL(DESCR)  extra {"$material", MAT_METAL_STR} DESCR
 +
#define MATERIAL_STONE(DESCR)  extra {"$material", MAT_STONE_STR} DESCR
 +
#define MATERIAL_CLOTH(DESCR)  extra {"$material", MAT_CLOTH_STR} DESCR
 +
#define MATERIAL_LEATHER(DESCR) extra {"$material", MAT_LEATHER_STR} DESCR
 +
#define MATERIAL_SKIN(DESCR)    extra {"$material", "$mat_skin"} DESCR
 +
#define MATERIAL_ORGANIC(DESCR) extra {"$material", MAT_ORGANIC_STR} DESCR
 +
#define MATERIAL_GLASS(DESCR)  extra {"$material", MAT_GLASS_STR} DESCR
 +
#define MATERIAL_FIRE(DESCR)    extra {"$material", MAT_FIRE_STR} DESCR
 +
#define MATERIAL_WATER(DESCR)  extra {"$material", MAT_WATER_STR} DESCR
 +
#define MATERIAL_EARTH(DESCR)  extra {"$material", "$mat_earth"} DESCR
 +
#define MATERIAL_MAGIC(DESCR)  extra {"$material", MAT_MAGIC_STR} DESCR
 +
</pre>
 +
 
 +
A material macro adds a hidden extra that says what the object is made of, with a short description. The combat code doesn't use materials. They are there for DIL: a program can test <code>MAT_WOOD_STR in item.extra</code>, and in the public zones the engraver in Midgaard refuses items of cloth and fire. Give an object one macro per material it is made of:
 +
 
 +
<pre>
 +
MATERIAL_WOOD("A hard oak shaft")
 +
MATERIAL_METAL("A steel spike")
 +
</pre>
 +
 
 +
=== Drink containers ===
 +
 
 +
<pre>
 +
#define LIQ_DEF(color, wgt, max_cap, inside,thirst,full,drunk,poison) \
 +
  type ITEM_DRINKCON          \
 +
  weight (wgt)+(inside) \
 +
  capacity max_cap \
 +
  value[0] inside        \
 +
  value[3] poison \
 +
extra {"$drink_color"}color \
 +
extra {"$drink_thirst"} #thirst \
 +
extra {"$drink_full"} #full \
 +
extra {"$drink_drunk"} #drunk
 +
</pre>
  
 
;color
 
;color
−
: the first argument is the color of the liquid.  this color will be shown when you look at the liquid in the container.
+
:The colour of the liquid, shown when someone looks into the container.
 
;wgt
 
;wgt
−
: The second argument is the weight of the container as in the last macros.  It is what the container would weigh empty.
+
:The weight of the empty container in pounds.
 
;max_cap
 
;max_cap
−
: The third argument is the maximum capacity of the container.  If the value is set to 15 and the container is fulled it will contain 15 pounds of liquid which adds to the base weight to get the total weight of the container. If you want a container to have unlimited contents then you set the capacity to '-1' and the weight will be that of the
+
:How much liquid it holds, in pounds. -1 means it never runs out (a fountain).
−
'wgt' field.
 
 
;inside
 
;inside
−
: The forth argument is the amount of liquid the container starts with. This amount should not be greater than the 'max_cap' field, but if it is it will be corrected when the player takes a drink or acts on the container.
+
:How much liquid is in it when it loads. Each pound of liquid adds a pound to the weight.
−
;thirst
+
;thirst, full, drunk
−
: The fifth field is how much thirst this gives per pound of liquid consumed. For example if you have a glass of water and it only has a capacity of 1 with 1 inside.  this value will be added once to the players thirst field.
+
:What the liquid does to the drinker per sip. Each <code>drink</code> takes 3 to 10 pounds of liquid, and adds thirst × that / 4 to the drinker's thirst; fullness and drunkenness work the same way. All three stop at 24, and a player whose thirst is 24 can't drink more. Water has thirst 10; vodka has drunk 10. Blood has thirst -1, so it makes you thirstier.
 +
;poison
 +
:How poisonous the liquid is, 0 for none.
 +
 
 +
When the container is drunk empty, the game removes the last name in its <code>names</code>, so the last name must be the liquid: <code>names {"blue bottle", "bottle", "oil"}</code>. LIQ_DEF sets neither <code>manipulate</code> nor <code>names</code>; a bottle needs <code>MANIPULATE_TAKE</code>, a fountain doesn't.
 +
 
 +
A bottle of blue oil:
 +
<pre>
 +
names {"blue bottle", "bottle", "silicone oil", "oil"}
 +
manipulate {MANIPULATE_TAKE, MANIPULATE_HOLD}
 +
LIQ_DEF("blue", 1, 10, 10, 5, 1, 0, 0)
 +
</pre>
  
−
this can be a bit confusing so lets first explain that the thirst
+
<code>liquid.h</code> has ready-made liquids, all with the arguments <code>(WEIGHT, CAPACITY, INSIDE, POISON)</code>. This table is generated from it:
−
field can be anything from 0 to 10 or even greater but we suggest only 10
 
−
max. With that in mind know that we set water at 10 because it is one
 
−
of the best thirst quenchers known to man.  Therefore a glass with 1
 
−
capacity and 1 quantity inside will give a player +10 to his thirst so if
 
−
the player was down to zero thirst value one drink will give them 10.
 
−
remember that a players thirst ranges from -24 to +24 so with three
 
−
drinks of water a person could fill his thirst need entirely.
 
  
−
With that in mind when setting this field you have to think what
+
{| class="wikitable"
−
kind of thirst quencher is my drink.  If for example it is vodka it would
+
!Macro
−
have little to know thirst quenching power so you would set this field
+
!Colour
−
to 0 or 1.
+
!Thirst
−
;full
+
!Full
−
: The sixth field like the thirst field sets how the drink will affect the chars fullness. The chars fullness field is normally set when a player is eating but as you know drinking some drinks will also give you the feeling of being full.  One drink like this would be milk.
+
!Drunk
−
The chars fullness field ranges from -24 to 24 like the thirst field and
+
|-
−
the argument you are setting on this field should range from 0 to 10
+
|<code>LIQ_WATER</code>||clear||10||1||0
−
unless you have a pro teen drink that fills them like food. Milk might
+
|-
−
have a fullness of something like 5.
+
|<code>LIQ_BEER</code>||brown||5||2||3
−
;drunk
+
|-
−
: the seventh field like thirst and full deals with the Drunkenness of a character. A character can range from 0 (not drunk) all the way up to 24 (smashed). The drunk field on this macro sets how much drunk is added for each quantity of the liquid is consumed. Therefore something like vodka should have a value of 10 while something like water should be down at 0 unless you have some weird race that gets drunk from water.
+
|<code>LIQ_WINE</code>||clear||5||2||5
−
;poison
+
|-
−
: The eighth and final field is again like the last macro we looked at it sets the poison factor of a liquid. The value ranges from 0 (no poison) to whatever you want but understand that 10 is an extreme poison factor and a player drinking this will most likely die quickly.
+
|<code>LIQ_ALE</code>||brown||5||2||2
 +
|-
 +
|<code>LIQ_DARK_ALE</code>||dark brown||5||2||1
 +
|-
 +
|<code>LIQ_WHISKEY</code>||golden||4||1||6
 +
|-
 +
|<code>LIQ_LEMONADE</code>||red||8||1||0
 +
|-
 +
|<code>LIQ_FIREBRT</code>||green||0||0||10
 +
|-
 +
|<code>LIQ_LOCALSPC</code>||clear||3||3||3
 +
|-
 +
|<code>LIQ_SLIME</code>||light green||8||4||0
 +
|-
 +
|<code>LIQ_MILK</code>||white||6||3||0
 +
|-
 +
|<code>LIQ_TEA</code>||brown||6||1||0
 +
|-
 +
|<code>LIQ_COFFEE</code>||black||6||1||0
 +
|-
 +
|<code>LIQ_BLOOD</code>||red||-1||2||0
 +
|-
 +
|<code>LIQ_SALTWAT</code>||clear||2||1||0
 +
|-
 +
|<code>LIQ_COKE</code>||black||5||1||0
 +
|-
 +
|<code>LIQ_VODKA</code>||clear||0||0||10
 +
|-
 +
|<code>LIQ_BRANDY</code>||golden||4||1||6
 +
|}
 +
 
 +
A waterskin, and a fountain that never runs dry:
 +
<pre>
 +
names {"waterskin", "skin", "water"}
 +
manipulate {MANIPULATE_TAKE, MANIPULATE_HOLD}
 +
LIQ_WATER(1, 20, 20, 0)
 +
</pre>
 +
<pre>
 +
names {"stone fountain", "fountain", "water"}
 +
LIQ_WATER(100, -1, 50, 0)
 +
</pre>
 +
 
 +
If you use a liquid of your own often, define a macro for it like those in <code>liquid.h</code>:
 +
<pre>
 +
#define LIQ_SILICONE(WEIGHT,CAPACITY,INSIDE,POISON) \
 +
        LIQ_DEF("blue", WEIGHT,CAPACITY,INSIDE,5,1,0,POISON)
 +
</pre>
 +
 
 +
=== Food ===
 +
 
 +
<pre>
 +
#define FOOD_DEF(food_amount, poison_factor) \
 +
  type ITEM_FOOD        \
 +
  value[0] food_amount  \
 +
  value[3] poison_factor
 +
</pre>
 +
 
 +
<code>eat</code> adds the food amount to the eater's fullness and the food is gone. A player is full at 24, so <code>FOOD_DEF(24, 0)</code> fills an empty stomach in one go; most food in the public zones is between 2 and 12. The poison factor is 0 for wholesome food. Add <code>MANIPULATE_TAKE</code>:
 +
 
 +
<pre>
 +
manipulate {MANIPULATE_TAKE}
 +
FOOD_DEF(6, 0)
 +
</pre>
 +
 
 +
=== Light sources ===
 +
 
 +
<pre>
 +
/* Hours    : How many hours (mud time) that the item may burn for.       */
 +
/* How_bright: The amount of light sources that the item shines with.      */
 +
/*            small torch = 1, torch = 2, lantern = 3...                   */
 +
#define LIGHT_DEF(hours, how_bright)  \
 +
  type ITEM_LIGHT    \
 +
  value[0] hours      \
 +
  value[1] how_bright
 +
</pre>
 +
 
 +
The player lights the object with <code>light</code> and puts it out with <code>extinguish</code>. While lit it gives off <code>how_bright</code> light and burns one hour less each mud hour (5 real minutes); at 0 it goes out and can't be lit again. Add <code>MANIPULATE_HOLD</code>: a light lights up the room only when it is held, or when it lies on the floor.
 +
 
 +
<pre>
 +
manipulate {MANIPULATE_TAKE, MANIPULATE_HOLD}
 +
LIGHT_DEF(12, 2)
 +
</pre>
 +
 
 +
<code>vme.h</code> defines <code>INFINITE_BURNTIME</code> (-1) for a light that never burns out, but <code>light</code> refuses a light with 0 or fewer hours. For a light that is always on, don't use <code>LIGHT_DEF</code>; give the object <code>bright</code> instead:
 +
 
 +
<pre>
 +
manipulate {MANIPULATE_TAKE, MANIPULATE_HOLD}
 +
bright 2
 +
</pre>
 +
 
 +
=== Containers ===
 +
 
 +
<pre>
 +
#define CONTAINER_DEF(max_capacity)  \
 +
  type ITEM_CONTAINER              \
 +
  capacity max_capacity
 +
</pre>
 +
 
 +
The capacity is the weight of what fits inside, in pounds: a 230 pound corpse needs a capacity of 230. The macro sets no <code>manipulate</code> flags, and nothing can be put into an object without <code>MANIPULATE_ENTER</code>. A sack:
 +
 
 +
<pre>
 +
CONTAINER_DEF(50)
 +
manipulate {MANIPULATE_TAKE, MANIPULATE_ENTER}
 +
</pre>
 +
 
 +
A heavy chest that stays where it is, locked, with its key:
 +
 
 +
<pre>
 +
CONTAINER_DEF(300)
 +
manipulate {MANIPULATE_ENTER}
 +
open {EX_OPEN_CLOSE, EX_CLOSED, EX_LOCKED} difficulty 40
 +
key chest_key
 +
</pre>
 +
 
 +
There is no key macro. A key is any object; <code>type ITEM_KEY</code> and <code>manipulate {MANIPULATE_TAKE, MANIPULATE_HOLD}</code> are enough.
  
−
So with the definitions of each arguments in mind lets return to
+
=== Money ===
−
the example of making a silicone oil based liquid.  We will first
 
−
show what it would look like using the hard macro then what the new
 
−
easy macro that you could create would look like.
 
−
<nowiki>
 
−
LIQ_DEF("blue",5,10,10,5,1,0,0)</nowiki>
 
−
Now if you want to make this a liquid your going to use a lot
 
−
you would define your own easier macro like this.
 
−
<nowiki>
 
−
#define LIQ_SILICONE(WEIGHT,CAPACITY,INSIDE,POISON) \
 
−
LIQ_DEF("blue", WEIGHT,CAPACITY,INSIDE,5,1,0,POISON)</nowiki>
 
−
That covers the use of the macros but for more information on the
 
−
drink containers see (Link to objdrink).
 
−
==== The food macros ====
 
  
−
The food macro is much easier than that of the drink macro so if
+
<pre>
−
you have drink containers down you will have no problem making food to
+
/* This is ALL you need to define money, rest is inserted at runtime. */
−
go with your beverage.  The players fullness value ranges from -24 to 24
+
#define MONEY(coin_type, coins) \
−
as we have already learned when making drink containers and in the
+
  type ITEM_MONEY              \
−
current food system on the VME server we do not allow thirst to be
+
  manipulate MANIPULATE_TAKE    \
−
modified by food.  Therefore the only thing you have to set is the
+
   title coin_type              \
−
amount of fullness and the poison factor if there is any. The following
+
  value[0] coins
−
is what the define for food looks like.
+
</pre>
−
<nowiki>
 
−
#define FOOD_DEF(food_amount, poison_factor) \
 
−
  type ITEM_FOOD        \
 
−
  value[0] food_amount   \
 
−
  value[3] poison_factor</nowiki>
 
−
Therefore if you wanted to make sure that only one of your
 
−
foods that you were creating would fill a player entirely in one bite
 
−
you would set it like this:
 
−
<nowiki>
 
−
FOOD_DEF(50,0)</nowiki>
 
−
It is recommended that you only set the value between 1 and 10 so
 
−
that players have to eat a bit as if they were eating in the real
 
−
world.
 
−
==== Light object macro ====
 
  
−
The light macro is very simply to use it only has two values
+
The coin type is <code>IRON_PIECE</code>, <code>COPPER_PIECE</code>, <code>SILVER_PIECE</code>, <code>GOLD_PIECE</code> or <code>PLATINUM_PIECE</code>, and <code>coins</code> is how many (at least 1; 0 is logged as an error and made 1). The game gives the money its names, title, description and weight when it is loaded, so the symbolic name and the macro are all you write:
−
duration and brightness of light.  The macro is defined as
 
−
follows:
 
−
<nowiki>
 
−
#define LIGHT_DEF(hours, how_bright)  \
 
−
  type ITEM_LIGHT    \
 
−
  value[0] hours      \
 
−
  value[1] how_bright</nowiki>
 
−
The first argument is the duration in mud hours which is about 5
 
−
  minutes per mud hour. The second argument is how bright the object
 
−
  is 0 would be stupid cause it would give off no light but you never
 
−
  know maybe you want to do something like that.  One, two, and three
 
−
  would be small torch, large torch, and lantern respectively.  You
 
−
  could set a brightness greater than 3 but you should be carefull not
 
−
  to over light your characters or you may cause light bugs.
 
−
==== Container macro ====
 
  
−
The container macro is a simple macro that just sets two fields.
+
<pre>
−
The only information you have to give it is the capacity of the
+
silver_pile
−
container.  Remember that capacity of an item is in weight not size.
+
MONEY(SILVER_PIECE, 20)
−
Therefore if some ones corpse weighs 230 pounds you will need a container
+
end
−
that has a capacity of 230 to fit the corpse in it.  The following is
+
</pre>
−
the macros definition as found in ''wmacros.h'':
 
−
<nowiki>
 
−
#define CONTAINER_DEF(max_capacity) \
 
−
  type ITEM_CONTAINER              \
 
−
  capacity max_capacity</nowiki>
 
−
If you wanted to create a coffin that could carry any normal human
 
−
  corpse you could set it something like this:
 
−
<nowiki>
 
−
container_def(300)</nowiki>
 
−
==== Money macro ====
 
  
−
Money is one of the simplest objects you can make on the VME
+
The macro sets the <code>title</code> to the coin's abbreviation, so don't write a title of your own.
−
server.  With this macro all you need is the symbolic before the macro
 
−
and the end keyword after the macro and you have 1 piece of money or a whole pile.  The macro is defined in the ''wmacros.h'' and looks exactly as follows:
 
−
<nowiki>
 
−
#define MONEY(coin_type, coins) \
 
−
  type ITEM_MONEY \
 
−
  manipulate MANIPULATE_TAKE \
 
−
  title coin_type \
 
−
  value[0] coins</nowiki>
 
−
The arguments are simple the first argument is the type of money the five possible values are:
 
−
* IRON_PIECE
 
−
* COPPER_PIECE
 
−
* SILVER_PIECE
 
−
* GOLD_PIECE
 
−
* PLATINUM_PIECE
 
−
The second argument is the amount of coins.  If you set it to
 
−
zero then it will still make exactly 1 of the coins.  The following
 
−
would be what one platinum piece would be like in a zone file.
 
−
<nowiki>
 
−
platinum_piece
 
  
−
MONEY(PLATINUM_PIECE, 0)
+
=== Cursed objects ===
−
/* Rest of values are inserted at runtime */
 
  
−
end</nowiki>
+
<pre>
−
Now if you want to make a whole pile of money it would look like this:
+
/* To be used when a object is cursed so that it can't be unequipped */
−
  <nowiki>
+
#define CURSED_OBJECT \
−
platinum_pile
+
affect        \
 +
  id ID_CURSE \
 +
  duration -1 \
 +
  firstf TIF_NONE \
 +
  tickf TIF_NONE \
 +
  lastf  TIF_NONE \
 +
  applyf APF_MOD_OBJ_FLAGS \
 +
  data[0] OBJ_NO_UNEQUIP;
 +
</pre>
  
−
MONEY(PLATINUM_PIECE, 80)
+
Once worn, a cursed object can't be removed until the curse is lifted with the remove curse spell. Characters who detect curses see it. Just put the macro in the object:
−
/* Rest of values are inserted at runtime */
 
−
extra {}
 
−
"Holy cow thats a stash."
 
  
−
end</nowiki>
+
<pre>
−
==== Cursed objects macro ====
+
CURSED_OBJECT
 +
</pre>
  
−
Sometimes when making special objects you want to make an item
+
=== Potions, scrolls, wands and staffs ===
−
that a person can wear but can't remove.  With the cursed object macro
 
−
this is a simple thing.  The cursed object macro is defined in
 
−
''wmacros.h'' and looks as follows:
 
−
<nowiki>
 
−
#define CURSED_OBJECT \
 
−
affect \
 
−
  id ID_CURSE \
 
−
  duration -1 \
 
−
  firstf TIF_NONE \
 
−
  tickf  TIF_NONE \
 
−
  lastf  TIF_NONE \
 
−
  applyf APF_MOD_OBJ_FLAGS \
 
−
  data[0] OBJ_NO_UNEQUIP;</nowiki>
 
−
to use this macro it is simply a matter of putting the define
 
−
in your object like this:
 
−
<nowiki>
 
−
CURSED_OBJECT</nowiki>
 
−
When you set this macro on an object it adds an affect that can
 
−
only be removed by the 'set' command or by the 'remove curse
 
−
spell'.
 
−
==== Potion, wand, and staff macros ====
 
  
−
The macros for potions, scrolls, wands, and staffs are almost the
+
<pre>
−
same.  In fact there is only two differences. The first  is the potions and scrolls can cast three
+
#define POTION_DEF(power,spell1,spell2,spell3)  \
−
spells while wands can only cast two, The second is wands and staffs
+
  manipulate {MANIPULATE_TAKE, MANIPULATE_HOLD} \
−
have multiple charges possible while scrolls and potions only can be
+
  flags {UNIT_FL_MAGIC} \
−
used once.  The following are the macros
+
  spell power      \
−
for all four as found in ''wmacros.h''.
+
  type ITEM_POTION \
−
<nowiki>
+
  value[0] power  \
−
#define POTION_DEF(power,spell1,spell2,spell3)  \
+
  value[1] spell1  \
−
  manipulate {MANIPULATE_TAKE, MANIPULATE_HOLD} \
+
  value[2] spell2  \
−
  flags {UNIT_FL_MAGIC} \
+
  value[3] spell3
−
  spell power      \
 
−
  type ITEM_POTION \
 
−
  value[0] power  \
 
−
  value[1] spell1  \
 
−
  value[2] spell2  \
 
−
  value[3] spell3
 
  
−
#define SCROLL_DEF(power,spell1,spell2,spell3)  \
+
#define SCROLL_DEF(power,spell1,spell2,spell3)  \
−
  manipulate {MANIPULATE_TAKE, MANIPULATE_HOLD} \
+
  manipulate {MANIPULATE_TAKE, MANIPULATE_HOLD} \
−
  flags {UNIT_FL_MAGIC} \
+
  flags {UNIT_FL_MAGIC} \
−
  spell power      \
+
  spell power      \
−
  type ITEM_SCROLL \
+
  type ITEM_SCROLL \
−
  value[0] power  \
+
  value[0] power  \
−
  value[1] spell1  \
+
  value[1] spell1  \
−
  value[2] spell2  \
+
  value[2] spell2  \
−
  value[3] spell3
+
  value[3] spell3
  
−
#define WAND_DEF(power,charge,spell1,spell2)  \
+
#define WAND_DEF(power,charge,spell1,spell2)  \
−
  manipulate {MANIPULATE_TAKE, MANIPULATE_HOLD} \
+
  manipulate {MANIPULATE_TAKE, MANIPULATE_HOLD} \
−
  flags {UNIT_FL_MAGIC} \
+
  flags {UNIT_FL_MAGIC} \
−
  spell power      \
+
  spell power      \
−
  type ITEM_WAND \
+
  type ITEM_WAND \
−
  value[0] power  \
+
  value[0] power  \
−
  value[1] charge  \
+
  value[1] charge  \
−
  value[2] spell1  \
+
  value[2] spell1  \
−
  value[3] spell2  \
+
  value[3] spell2  \
−
  value[4] charge  /* The max charge */
+
  value[4] charge  /* The max charge */
  
−
#define STAFF_DEF(power,charge,spell1,spell2)  \
+
#define STAFF_DEF(power,charge,spell1,spell2)  \
−
  manipulate {MANIPULATE_TAKE, MANIPULATE_HOLD} \
+
  manipulate {MANIPULATE_TAKE, MANIPULATE_HOLD} \
−
  flags {UNIT_FL_MAGIC} \
+
  flags {UNIT_FL_MAGIC} \
−
  spell power      \
+
  spell power      \
−
  type ITEM_STAFF  \
+
  type ITEM_STAFF  \
−
  value[0] power  \
+
  value[0] power  \
−
  value[1] charge  \
+
  value[1] charge  \
−
  value[2] spell1  \
+
  value[2] spell1  \
−
  value[3] spell2  \
+
  value[3] spell2  \
−
  value[4] charge  /* The max charge */</nowiki>
+
  value[4] charge  /* The max charge */
−
The arguments are as follows for the macros.
+
</pre>
  
 
;power
 
;power
−
: The first argument on potions, scrolls, wands, and staff is the power the spell will be cast at.  You can have the power set in the range 1-200.  The spell power works the same as a player training in the spell. The higher the number the more powerfull the cast.
+
:How strongly the spells are cast, like a caster's skill in the spell. The public zones use 20 to 60.
 
;charge
 
;charge
−
: The second argument on the staffs and wands is how many charges it has.
+
:How many times a wand or staff can be used.
−
;spell#
+
;spell1, spell2, spell3
−
: On potions and scrolls you can set up to 2 spells you do not have to set them both the one you don't want set to 0. On staffs and wands you can set three spells.  Again if you want only one or two you can leave the one you do not want set to 0.
+
:Spells from <code>values.h</code>, such as <code>SPL_CURE_WOUNDS_1</code> (see [[Manual:Zone Manual/Appendices/Spell definitions in values.h|Spell definitions in values.h]]). Potions and scrolls hold three spells, wands and staffs two. Fill an unused place with <code>SPL_NONE</code>, not 0: 0 is a spell number too.
 +
 
 +
How they are used:
 +
* A potion is drunk with <code>quaff</code>: every spell in it is cast on the drinker, and the potion is gone.
 +
* A scroll is read with <code>recite</code>, which needs the scroll use skill; the scroll is gone afterwards.
 +
* A wand is held and pointed with <code>use wand &lt;target&gt;</code>. It needs the wand use skill, measured against the wand's power, and can't be used blind.
 +
* A staff is held and tapped on the ground with <code>use staff</code>. Its spells hit everyone in the room except the user and the user's group.
 +
* Each use of a wand or staff costs one charge; with none left it does nothing.
 +
 
 +
<pre>
 +
POTION_DEF(30, SPL_CURE_WOUNDS_1, SPL_NONE, SPL_NONE)
 +
</pre>
 +
<pre>
 +
WAND_DEF(40, 5, SPL_LIGHTNING_1, SPL_NONE)
 +
</pre>
 +
 
 +
=== Bows, arrows and traps ===
 +
 
 +
<pre>
 +
#define MISSILE_DEF(weapon_category, craftsmanship, magic_bonus, \
 +
                    race_sl, spel_type)  \
 +
  manipulate {MANIPULATE_WIELD, MANIPULATE_TAKE, MANIPULATE_HOLD} \
 +
  type ITEM_WEAPON            \
 +
  value[0] weapon_category    \
 +
  value[1] craftsmanship      \
 +
  value[2] magic_bonus        \
 +
  value[3] race_sl            \
 +
  value[4] spel_type
 +
 
 +
#define RANGED_DEF(spel_type, craftsmanship, magic_bonus, \
 +
                  race_sl, weapon_category, s_power) \
 +
  manipulate {MANIPULATE_TAKE, MANIPULATE_HOLD} \
 +
  type ITEM_FIREWEAPON        \
 +
  value[0] spel_type          \
 +
  value[1] craftsmanship      \
 +
  value[2] magic_bonus        \
 +
  value[3] race_sl            \
 +
  value[4] weapon_category    \
 +
  spell s_power              \
 +
  dilcopy ranged_need@skills();
 +
 
 +
#define TRAP_DEF(craftsmanship, magic_bonus) \
 +
  manipulate {MANIPULATE_TAKE} \
 +
  type ITEM_TRAP              \
 +
  value[1] craftsmanship      \
 +
  value[2] magic_bonus
 +
</pre>
 +
 
 +
<code>RANGED_DEF</code> makes a bow, crossbow or sling (<code>WPN_BOW</code>, <code>WPN_CROSSBOW</code>, <code>WPN_SLING</code>) for the <code>shoot</code> command. With <code>spel_type</code> 0 it shoots missiles; with a spell it shoots that spell instead and needs no missiles. <code>MISSILE_DEF</code> makes the arrows, bolts or stones; their weapon category must be the launcher's (<code>WPN_BOW</code> for arrows). <code>race_sl</code> is a slaying race, or <code>RACE_DO_NOT_USE</code>. <code>TRAP_DEF</code> makes a trap for the trap skill. The ranger items in <code>vme/zone/skills.zon</code> (a bow, an arrow and a man trap) show them in use.
 +
 
 +
<pre>
 +
RANGED_DEF(0, BONUS_GOOD, BONUS_AVERAGE, RACE_DO_NOT_USE, WPN_BOW, 0)
 +
</pre>
 +
<pre>
 +
MISSILE_DEF(WPN_BOW, BONUS_AVERAGE, BONUS_AVERAGE, RACE_DO_NOT_USE, 0)
 +
</pre>
 +
 
 +
=== Bonuses while the object is used ===
 +
 
 +
These macros give the character something for as long as the object is worn, wielded or held, and take it away again when it is removed. Each also sets <code>UNIT_FL_MAGIC</code>.
 +
 
 +
{| class="wikitable"
 +
!Macro
 +
!Gives
 +
|-
 +
|<code>STR_TRANSFER(amount)</code>, <code>DEX_TRANSFER</code>, <code>CON_TRANSFER</code>, <code>CHA_TRANSFER</code>, <code>BRA_TRANSFER</code>, <code>MAG_TRANSFER</code>, <code>DIV_TRANSFER</code>
 +
|More (or less) strength, dexterity, constitution, charisma, brain, magic or divine ability.
 +
|-
 +
|<code>HIT_TRANSFER(amount)</code>
 +
|More (or less) of the hit point ability, so more hit points.
 +
|-
 +
|<code>SKILL_TRANSFER(skill, amount)</code>
 +
|A better skill, <code>SKI_*</code>.
 +
|-
 +
|<code>WEAPON_TRANSFER(weapon, amount)</code>
 +
|A better weapon skill, a weapon or a group, <code>WPN_*</code>.
 +
|-
 +
|<code>SPELL_TRANSFER(spell, amount)</code>
 +
|A better spell skill, <code>SPL_*</code>.
 +
|-
 +
|<code>CHAR_FLAG_TRANSFER(flags)</code>
 +
|Character flags, such as <code>CHAR_DETECT_INVISIBLE</code>.
 +
|-
 +
|<code>SPEED_TRANSFER(delta_speed)</code>
 +
|Faster combat: a positive number lowers the combat speed (12 is normal, 4 the fastest).
 +
|-
 +
|<code>SLOW_TRANSFER(delta_speed)</code>
 +
|Slower combat. The number must be negative.
 +
|-
 +
|<code>PROTECTION_FROM_EVIL</code>, <code>PROTECTION_FROM_GOOD</code>
 +
|+20 defence in melee against evil (or good) attackers.
 +
|-
 +
|<code>CURSED_OBJECT</code>
 +
|See above.
 +
|}
 +
 
 +
The amount is on the bonus scale, -7 to +7. An ability, skill, weapon or spell goes up or down by about 10 points at ±7 (the table in <code>vme/src/common.cpp</code>: 1, 2, 4, 5, 6, 8, 10 for 1 to 7). vmc refuses an amount outside -7..+7. A speed change must be between -8 and 8; vmc doesn't check it, and the game ignores one outside that range.
  
−
==== Magical transfer macros ====
+
A belt that makes its wearer stronger but a worse mage:
 +
<pre>
 +
ARMOUR_LEATHER(BONUS_AVERAGE, BONUS_AVERAGE)
 +
manipulate {MANIPULATE_WEAR_WAIST}
 +
STR_TRANSFER(BONUS_GOOD)
 +
MAG_TRANSFER(BONUS_BAD)
 +
</pre>
  
−
There are times when you want to give a player a bonus in a
+
A ring of seeing:
−
ability, weapon, skill, and or weapon.  There is even times when you
+
<pre>
−
want to adjust a characters speed or add a flag to a player when they
+
manipulate {MANIPULATE_TAKE, MANIPULATE_WEAR_FINGER}
−
wear an item.  The following macros are what you would use to do any of
+
type ITEM_WORN
−
those when a person uses an item.
+
CHAR_FLAG_TRANSFER(CHAR_DETECT_INVISIBLE)
−
* CHAR_FLAG_TRANSFER(_MFLAGS)
+
SKILL_TRANSFER(SKI_SEARCH, BONUS_GOOD_PLUS)
−
* SKILL_TRANSFER(skill, amount)
+
</pre>
−
* WEAPON_TRANSFER(weapon, amount)
 
−
* SPELL_TRANSFER(spell, amount)
 
−
* STR_TRANSFER(amount)
 
−
* DEX_TRANSFER(amount)
 
−
* CON_TRANSFER(amount)
 
−
* CHA_TRANSFER(amount)
 
−
* BRA_TRANSFER(amount)
 
−
* MAG_TRANSFER(amount)
 
−
* DIV_TRANSFER(amount)
 
−
* HIT_TRANSFER(amount)
 
−
* SPEED_TRANSFER(newspeed)
 
−
* SLOW_TRANSFER(amount)
 
−
<blockquote style="background-color: #E8E8E8; font-style: italic; ">For the full definitions of the transfer macros see (Link to app-f) or the header file ''wmacros.h''.</blockquote>
 
  
−
The transfer macros can be broken down into three groups those
+
The full definitions are in <code>wmacros.h</code> and on [[Manual:Zone Manual/Appendices/Complete magical transfers macros listing|Complete magical transfers macros listing]].
−
which transfer percentage, flags, and speed. The skill, weapons,
 
−
spells, and ability macros transfer the amount of percentage you put.
 
−
If you give a negative percentage it will take that much away from the
 
−
player or NPC in that catagory.  The character flag transfer actually
 
−
adds the flag to the player while the player is using the item.  The
 
−
speed transfer macros add or subtract the amount of speed you give them.
 
−
The range for speed is from zero to twelve with twelve being the
 
−
slowest.
 
  
−
<div style='padding-top: 30px; padding-bottom: 20px; text-align: left;float:left;width:50%;'>[[Manual:Zone_Manual/The_Objects_Section|Previous: The Objects Section]]</div>
+
<div style='padding-top: 30px; padding-bottom: 20px; text-align: left;float:left;width:50%;'>[[Manual:Zone Manual/The Objects Section|Previous: The Objects Section]]</div>
−
<div style='padding-top: 30px; padding-bottom: 20px; text-align: right;float:right;width:50%;'>[[Manual:Zone_Manual/The_Objects_Section/Building_your_first_object|Next: Building your first object]]</div>
+
<div style='padding-top: 30px; padding-bottom: 20px; text-align: right;float:right;width:50%;'>[[Manual:Zone Manual/The Objects Section/Building your first object|Next: Building your first object]]</div>

Latest revision as of 06:18, 15 November 2026

Object macros

Weapons, armour, drinks, lights and most other kinds of objects need a type and a few values that must fit together. The macros in vme/include/wmacros.h and liquid.h set them for you. Both are included by #include <macros.h>.

A macro sets fields such as type, value[] and weight, and those keep the last value given. Write the macro first and change things after it, or the macro overwrites what you wrote before it. manipulate and flags add up, so you can add to the flags a macro sets.

The definitions below are copied from the headers. If you want to check one, the files are on GitHub: wmacros.h, liquid.h.

The bonus scale

Weapons, armour and shields have two bonuses, craftsmanship and magic, and the transfer macros further down take an amount. All of them use the same scale from -7 to +7, with names in values.h:

Value Name Combat bonus Hit points of the item
7 BONUS_ARTIFACT
20
2400
6 BONUS_SUPERIOR
17
2200
5 BONUS_EXCELLENT_PLUS
14
2000
4 BONUS_EXCELLENT
11
1800
3 BONUS_GOOD_PLUS
8
1600
2 BONUS_GOOD
5
1400
1 BONUS_AVERAGE_PLUS
2
1200
0 BONUS_AVERAGE 0 1000
-1 BONUS_AVERAGE_MINUS -2 965
-2 BONUS_BAD -5 930
-3 BONUS_BAD_MINUS -8 895
-4 BONUS_TERRIBLE -11 860
-5 BONUS_TERRIBLE_MINUS -14 825
-6 BONUS_JUNK_ALMOST -17 790
-7 BONUS_JUNK -20 755

vmc refuses anything outside -7..+7 (the old manuals used ±25 and ±10; those numbers are wrong now). The comments in wmacros.h still mention the old ranges; ignore them.

Craftsmanship
How well the item is made: the material and the smith. It decides the item's hit points (last column). Every hit with a weapon, and every hit taken on armour or a shield, wears the item down; at zero hit points it breaks, its title gets "(broken)" and it becomes worthless junk. A hit field on a weapon, armour or shield is ignored.
Magic bonus
How much the item is enchanted. A higher magic bonus also makes the item wear down a little slower.
Combat bonus
When the game loads the item, both bonuses are turned into the combat bonus in the third column (a positive bonus sometimes comes out a little higher). A weapon's craftsmanship and magic bonus are added to its wielder's attack; armour's are added to the defence when that body part is hit, and a shield's to its chance to block. In a melee hit, +2 of combat bonus is worth as much as 1 more point of weapon skill.

Make better items cost more, and give a magic item flags {UNIT_FL_MAGIC} so that detect magic shows it.

Weapons

/* weapon_category: One of the WPN_XXX macros.       */
/* craftsmanship:   [-25..25] Material used & Smity  */
/* magic_bonus:     [-25..25] Magic modification     */
#define WEAPON_DEF(weapon_category, craftsmanship, magic_bonus)  \
   manipulate {MANIPULATE_TAKE, MANIPULATE_WIELD} \
   type ITEM_WEAPON            \
   value[0] weapon_category    \
   value[1] craftsmanship      \
   value[2] magic_bonus        \
   value[3] RACE_DO_NOT_USE

#define WEAPONSZ_DEF(weapon_category, craftsmanship, magic_bonus, hgt)  \
   WEAPON_DEF(weapon_category, craftsmanship, magic_bonus)\
   height hgt

The weapon category is a weapon such as WPN_DAGGER or WPN_BATTLE_AXE, from values.h (see weapon definitions in values.h). The groups WPN_SWORD, WPN_AXE_HAM and so on are for skills, not weapons: vmc refuses them here. How hard each weapon hits each kind of armour, whether it needs two hands, and the strength and level needed to wield it are in vme/etc/weapons.def.

WEAPONSZ_DEF also sets the height. Without a height the weapon is made for a 180 cm character; when a reset equips an NPC with it, it is resized to fit that NPC anyway.

A two-handed iron flail, well made, not magic:

WEAPON_DEF(WPN_FLAIL, BONUS_GOOD, BONUS_AVERAGE)

A rusty sacrificial dagger with an enchantment:

WEAPON_DEF(WPN_DAGGER, BONUS_BAD, BONUS_GOOD)
flags {UNIT_FL_MAGIC}

A huge wooden club made for a 400 cm giant:

WEAPONSZ_DEF(WPN_CLUB, BONUS_BAD, BONUS_AVERAGE, 400)

Slaying weapons

/* race : Match one of the RACE_XXX values. */
#define WEAPON_SLAYER(race) \
  flags {UNIT_FL_MAGIC} \
  value[3] race

/* Will slay dragons */
#define WEAPON_SLAYER_DRAGONS \
  flags {UNIT_FL_MAGIC} \
  value[3] RACE_DRAGON_MIN \
  extra {"$slayer"} {RACE_DRAGON_MIN, RACE_DRAGON_MAX} "dragon slayer"

A slaying weapon gets +50 on its attacks against that race, and more against opponents above level 50. WEAPON_SLAYER_DRAGONS slays every dragon race. Put the slayer macro after WEAPON_DEF, which sets value[3] to RACE_DO_NOT_USE (no slaying):

WEAPON_DEF(WPN_LONG_SWORD, BONUS_GOOD, BONUS_GOOD)
WEAPON_SLAYER(RACE_ORC)

Armour

#define ARMOUR_DEF(atype,craftsmanship, magic_bonus) \
manipulate {MANIPULATE_TAKE} \
type ITEM_ARMOR              \
value[0] atype         \
value[1] craftsmanship       \
value[2] magic_bonus

#define ARMOURSZ_DEF(atype, craftsmanship, magic_bonus, hgt)\
ARMOUR_DEF(atype,craftsmanship, magic_bonus) \
height hgt

The armour type is one of five, from vme.h. Each has a shorter macro of its own, and a SZ version that also takes the height:

Armour type Macro With height
ARM_CLOTHES ARMOUR_CLOTHES(craftsmanship, magic_bonus) ARMOURSZ_CLOTHES(craftsmanship, magic_bonus, hgt)
ARM_LEATHER ARMOUR_LEATHER(...) ARMOURSZ_LEATHER(...)
ARM_HLEATHER (hard leather) ARMOUR_HRD_LEATHER(...) ARMOURSZ_HRD_LEATHER(...)
ARM_CHAIN ARMOUR_CHAIN(...) ARMOURSZ_CHAIN(...)
ARM_PLATE ARMOUR_PLATE(...) ARMOURSZ_PLATE(...)

The type says how the armour is built, not what it is made of; a wooden breastplate built like plate is ARM_PLATE. Each weapon in weapons.def has its own damage against each armour type.

The armour macros only set MANIPULATE_TAKE. Add the body part, or the armour can't be worn:

ARMOUR_PLATE(BONUS_GOOD, BONUS_AVERAGE)
manipulate {MANIPULATE_WEAR_BODY}
ARMOUR_DEF(ARM_CHAIN, BONUS_AVERAGE, BONUS_AVERAGE)
manipulate {MANIPULATE_WEAR_HEAD}

Armour protects the body part it is worn on. More about armour in More complex objects.

Shields

#define SHIELD_DEF(shield_type, craftsmanship, magic_bonus)  \
   manipulate {MANIPULATE_TAKE, MANIPULATE_WEAR_SHIELD} \
   type ITEM_SHIELD            \
   value[0] shield_type        \
   value[1] craftsmanship      \
   value[2] magic_bonus

#define SHIELDSZ_DEF(shield_type, craftsmanship, magic_bonus, hgt)  \
   SHIELD_DEF(shield_type, craftsmanship, magic_bonus)\
   height hgt

The shield type is SHIELD_SMALL, SHIELD_MEDIUM or SHIELD_LARGE, from vme.h. A larger shield blocks more often: the base chance is 15%, 20% and 25%, plus the shield's bonuses. Whether a shield can block a weapon at all is set per weapon in weapons.def. vme.h also defines SHIELD_TOWER, but vmc refuses it.

A small enchanted wooden shield:

SHIELD_DEF(SHIELD_SMALL, BONUS_AVERAGE, BONUS_GOOD_PLUS)
flags {UNIT_FL_MAGIC}
MATERIAL_WOOD("Oak planks bound with iron")

Materials

#define MATERIAL_WOOD(DESCR)    extra {"$material", MAT_WOOD_STR} DESCR
#define MATERIAL_METAL(DESCR)   extra {"$material", MAT_METAL_STR} DESCR
#define MATERIAL_STONE(DESCR)   extra {"$material", MAT_STONE_STR} DESCR
#define MATERIAL_CLOTH(DESCR)   extra {"$material", MAT_CLOTH_STR} DESCR
#define MATERIAL_LEATHER(DESCR) extra {"$material", MAT_LEATHER_STR} DESCR
#define MATERIAL_SKIN(DESCR)    extra {"$material", "$mat_skin"} DESCR
#define MATERIAL_ORGANIC(DESCR) extra {"$material", MAT_ORGANIC_STR} DESCR
#define MATERIAL_GLASS(DESCR)   extra {"$material", MAT_GLASS_STR} DESCR
#define MATERIAL_FIRE(DESCR)    extra {"$material", MAT_FIRE_STR} DESCR
#define MATERIAL_WATER(DESCR)   extra {"$material", MAT_WATER_STR} DESCR
#define MATERIAL_EARTH(DESCR)   extra {"$material", "$mat_earth"} DESCR
#define MATERIAL_MAGIC(DESCR)   extra {"$material", MAT_MAGIC_STR} DESCR

A material macro adds a hidden extra that says what the object is made of, with a short description. The combat code doesn't use materials. They are there for DIL: a program can test MAT_WOOD_STR in item.extra, and in the public zones the engraver in Midgaard refuses items of cloth and fire. Give an object one macro per material it is made of:

MATERIAL_WOOD("A hard oak shaft")
MATERIAL_METAL("A steel spike")

Drink containers

#define LIQ_DEF(color, wgt, max_cap, inside,thirst,full,drunk,poison) \
   type ITEM_DRINKCON           \
   weight (wgt)+(inside) \
   capacity max_cap \
   value[0] inside        \
   value[3] poison \
extra {"$drink_color"}color \
extra {"$drink_thirst"} #thirst \
extra {"$drink_full"} #full \
extra {"$drink_drunk"} #drunk
color
The colour of the liquid, shown when someone looks into the container.
wgt
The weight of the empty container in pounds.
max_cap
How much liquid it holds, in pounds. -1 means it never runs out (a fountain).
inside
How much liquid is in it when it loads. Each pound of liquid adds a pound to the weight.
thirst, full, drunk
What the liquid does to the drinker per sip. Each drink takes 3 to 10 pounds of liquid, and adds thirst × that / 4 to the drinker's thirst; fullness and drunkenness work the same way. All three stop at 24, and a player whose thirst is 24 can't drink more. Water has thirst 10; vodka has drunk 10. Blood has thirst -1, so it makes you thirstier.
poison
How poisonous the liquid is, 0 for none.

When the container is drunk empty, the game removes the last name in its names, so the last name must be the liquid: names {"blue bottle", "bottle", "oil"}. LIQ_DEF sets neither manipulate nor names; a bottle needs MANIPULATE_TAKE, a fountain doesn't.

A bottle of blue oil:

names {"blue bottle", "bottle", "silicone oil", "oil"}
manipulate {MANIPULATE_TAKE, MANIPULATE_HOLD}
LIQ_DEF("blue", 1, 10, 10, 5, 1, 0, 0)

liquid.h has ready-made liquids, all with the arguments (WEIGHT, CAPACITY, INSIDE, POISON). This table is generated from it:

Macro Colour Thirst Full Drunk
LIQ_WATER clear 10 1 0
LIQ_BEER brown 5 2 3
LIQ_WINE clear 5 2 5
LIQ_ALE brown 5 2 2
LIQ_DARK_ALE dark brown 5 2 1
LIQ_WHISKEY golden 4 1 6
LIQ_LEMONADE red 8 1 0
LIQ_FIREBRT green 0 0 10
LIQ_LOCALSPC clear 3 3 3
LIQ_SLIME light green 8 4 0
LIQ_MILK white 6 3 0
LIQ_TEA brown 6 1 0
LIQ_COFFEE black 6 1 0
LIQ_BLOOD red -1 2 0
LIQ_SALTWAT clear 2 1 0
LIQ_COKE black 5 1 0
LIQ_VODKA clear 0 0 10
LIQ_BRANDY golden 4 1 6

A waterskin, and a fountain that never runs dry:

names {"waterskin", "skin", "water"}
manipulate {MANIPULATE_TAKE, MANIPULATE_HOLD}
LIQ_WATER(1, 20, 20, 0)
names {"stone fountain", "fountain", "water"}
LIQ_WATER(100, -1, 50, 0)

If you use a liquid of your own often, define a macro for it like those in liquid.h:

#define LIQ_SILICONE(WEIGHT,CAPACITY,INSIDE,POISON) \
        LIQ_DEF("blue", WEIGHT,CAPACITY,INSIDE,5,1,0,POISON)

Food

#define FOOD_DEF(food_amount, poison_factor)  \
   type ITEM_FOOD         \
   value[0] food_amount   \
   value[3] poison_factor

eat adds the food amount to the eater's fullness and the food is gone. A player is full at 24, so FOOD_DEF(24, 0) fills an empty stomach in one go; most food in the public zones is between 2 and 12. The poison factor is 0 for wholesome food. Add MANIPULATE_TAKE:

manipulate {MANIPULATE_TAKE}
FOOD_DEF(6, 0)

Light sources

/* Hours     : How many hours (mud time) that the item may burn for.        */
/* How_bright: The amount of light sources that the item shines with.       */
/*             small torch = 1, torch = 2, lantern = 3...                   */
#define LIGHT_DEF(hours, how_bright)   \
   type ITEM_LIGHT     \
   value[0] hours      \
   value[1] how_bright

The player lights the object with light and puts it out with extinguish. While lit it gives off how_bright light and burns one hour less each mud hour (5 real minutes); at 0 it goes out and can't be lit again. Add MANIPULATE_HOLD: a light lights up the room only when it is held, or when it lies on the floor.

manipulate {MANIPULATE_TAKE, MANIPULATE_HOLD}
LIGHT_DEF(12, 2)

vme.h defines INFINITE_BURNTIME (-1) for a light that never burns out, but light refuses a light with 0 or fewer hours. For a light that is always on, don't use LIGHT_DEF; give the object bright instead:

manipulate {MANIPULATE_TAKE, MANIPULATE_HOLD}
bright 2

Containers

#define CONTAINER_DEF(max_capacity)  \
   type ITEM_CONTAINER               \
   capacity max_capacity

The capacity is the weight of what fits inside, in pounds: a 230 pound corpse needs a capacity of 230. The macro sets no manipulate flags, and nothing can be put into an object without MANIPULATE_ENTER. A sack:

CONTAINER_DEF(50)
manipulate {MANIPULATE_TAKE, MANIPULATE_ENTER}

A heavy chest that stays where it is, locked, with its key:

CONTAINER_DEF(300)
manipulate {MANIPULATE_ENTER}
open {EX_OPEN_CLOSE, EX_CLOSED, EX_LOCKED} difficulty 40
key chest_key

There is no key macro. A key is any object; type ITEM_KEY and manipulate {MANIPULATE_TAKE, MANIPULATE_HOLD} are enough.

Money

/* This is ALL you need to define money, rest is inserted at runtime. */
#define MONEY(coin_type, coins) \
  type ITEM_MONEY               \
  manipulate MANIPULATE_TAKE    \
  title coin_type               \
  value[0] coins

The coin type is IRON_PIECE, COPPER_PIECE, SILVER_PIECE, GOLD_PIECE or PLATINUM_PIECE, and coins is how many (at least 1; 0 is logged as an error and made 1). The game gives the money its names, title, description and weight when it is loaded, so the symbolic name and the macro are all you write:

silver_pile
MONEY(SILVER_PIECE, 20)
end

The macro sets the title to the coin's abbreviation, so don't write a title of your own.

Cursed objects

/* To be used when a object is cursed so that it can't be unequipped */
#define CURSED_OBJECT \
affect         \
   id ID_CURSE \
   duration -1 \
   firstf TIF_NONE \
   tickf  TIF_NONE \
   lastf  TIF_NONE \
   applyf APF_MOD_OBJ_FLAGS \
   data[0] OBJ_NO_UNEQUIP;

Once worn, a cursed object can't be removed until the curse is lifted with the remove curse spell. Characters who detect curses see it. Just put the macro in the object:

CURSED_OBJECT

Potions, scrolls, wands and staffs

#define POTION_DEF(power,spell1,spell2,spell3)  \
   manipulate {MANIPULATE_TAKE, MANIPULATE_HOLD} \
   flags {UNIT_FL_MAGIC} \
   spell power      \
   type ITEM_POTION \
   value[0] power   \
   value[1] spell1  \
   value[2] spell2  \
   value[3] spell3

#define SCROLL_DEF(power,spell1,spell2,spell3)  \
   manipulate {MANIPULATE_TAKE, MANIPULATE_HOLD} \
   flags {UNIT_FL_MAGIC} \
   spell power      \
   type ITEM_SCROLL \
   value[0] power   \
   value[1] spell1  \
   value[2] spell2  \
   value[3] spell3

#define WAND_DEF(power,charge,spell1,spell2)  \
   manipulate {MANIPULATE_TAKE, MANIPULATE_HOLD} \
   flags {UNIT_FL_MAGIC} \
   spell power      \
   type ITEM_WAND \
   value[0] power   \
   value[1] charge  \
   value[2] spell1  \
   value[3] spell2  \
   value[4] charge  /* The max charge */

#define STAFF_DEF(power,charge,spell1,spell2)  \
   manipulate {MANIPULATE_TAKE, MANIPULATE_HOLD} \
   flags {UNIT_FL_MAGIC} \
   spell power      \
   type ITEM_STAFF  \
   value[0] power   \
   value[1] charge  \
   value[2] spell1  \
   value[3] spell2  \
   value[4] charge  /* The max charge */
power
How strongly the spells are cast, like a caster's skill in the spell. The public zones use 20 to 60.
charge
How many times a wand or staff can be used.
spell1, spell2, spell3
Spells from values.h, such as SPL_CURE_WOUNDS_1 (see Spell definitions in values.h). Potions and scrolls hold three spells, wands and staffs two. Fill an unused place with SPL_NONE, not 0: 0 is a spell number too.

How they are used:

  • A potion is drunk with quaff: every spell in it is cast on the drinker, and the potion is gone.
  • A scroll is read with recite, which needs the scroll use skill; the scroll is gone afterwards.
  • A wand is held and pointed with use wand <target>. It needs the wand use skill, measured against the wand's power, and can't be used blind.
  • A staff is held and tapped on the ground with use staff. Its spells hit everyone in the room except the user and the user's group.
  • Each use of a wand or staff costs one charge; with none left it does nothing.
POTION_DEF(30, SPL_CURE_WOUNDS_1, SPL_NONE, SPL_NONE)
WAND_DEF(40, 5, SPL_LIGHTNING_1, SPL_NONE)

Bows, arrows and traps

#define MISSILE_DEF(weapon_category, craftsmanship, magic_bonus, \
                    race_sl, spel_type)  \
   manipulate {MANIPULATE_WIELD, MANIPULATE_TAKE, MANIPULATE_HOLD} \
   type ITEM_WEAPON            \
   value[0] weapon_category    \
   value[1] craftsmanship      \
   value[2] magic_bonus        \
   value[3] race_sl            \
   value[4] spel_type

#define RANGED_DEF(spel_type, craftsmanship, magic_bonus, \
                   race_sl, weapon_category, s_power)  \
   manipulate {MANIPULATE_TAKE, MANIPULATE_HOLD} \
   type ITEM_FIREWEAPON        \
   value[0] spel_type          \
   value[1] craftsmanship      \
   value[2] magic_bonus        \
   value[3] race_sl            \
   value[4] weapon_category    \
   spell s_power               \
   dilcopy ranged_need@skills();

#define TRAP_DEF(craftsmanship, magic_bonus) \
   manipulate {MANIPULATE_TAKE} \
   type ITEM_TRAP               \
   value[1] craftsmanship       \
   value[2] magic_bonus

RANGED_DEF makes a bow, crossbow or sling (WPN_BOW, WPN_CROSSBOW, WPN_SLING) for the shoot command. With spel_type 0 it shoots missiles; with a spell it shoots that spell instead and needs no missiles. MISSILE_DEF makes the arrows, bolts or stones; their weapon category must be the launcher's (WPN_BOW for arrows). race_sl is a slaying race, or RACE_DO_NOT_USE. TRAP_DEF makes a trap for the trap skill. The ranger items in vme/zone/skills.zon (a bow, an arrow and a man trap) show them in use.

RANGED_DEF(0, BONUS_GOOD, BONUS_AVERAGE, RACE_DO_NOT_USE, WPN_BOW, 0)
MISSILE_DEF(WPN_BOW, BONUS_AVERAGE, BONUS_AVERAGE, RACE_DO_NOT_USE, 0)

Bonuses while the object is used

These macros give the character something for as long as the object is worn, wielded or held, and take it away again when it is removed. Each also sets UNIT_FL_MAGIC.

Macro Gives
STR_TRANSFER(amount), DEX_TRANSFER, CON_TRANSFER, CHA_TRANSFER, BRA_TRANSFER, MAG_TRANSFER, DIV_TRANSFER More (or less) strength, dexterity, constitution, charisma, brain, magic or divine ability.
HIT_TRANSFER(amount) More (or less) of the hit point ability, so more hit points.
SKILL_TRANSFER(skill, amount) A better skill, SKI_*.
WEAPON_TRANSFER(weapon, amount) A better weapon skill, a weapon or a group, WPN_*.
SPELL_TRANSFER(spell, amount) A better spell skill, SPL_*.
CHAR_FLAG_TRANSFER(flags) Character flags, such as CHAR_DETECT_INVISIBLE.
SPEED_TRANSFER(delta_speed) Faster combat: a positive number lowers the combat speed (12 is normal, 4 the fastest).
SLOW_TRANSFER(delta_speed) Slower combat. The number must be negative.
PROTECTION_FROM_EVIL, PROTECTION_FROM_GOOD
20 defence in melee against evil (or good) attackers.
CURSED_OBJECT See above.

The amount is on the bonus scale, -7 to +7. An ability, skill, weapon or spell goes up or down by about 10 points at ±7 (the table in vme/src/common.cpp: 1, 2, 4, 5, 6, 8, 10 for 1 to 7). vmc refuses an amount outside -7..+7. A speed change must be between -8 and 8; vmc doesn't check it, and the game ignores one outside that range.

A belt that makes its wearer stronger but a worse mage:

ARMOUR_LEATHER(BONUS_AVERAGE, BONUS_AVERAGE)
manipulate {MANIPULATE_WEAR_WAIST}
STR_TRANSFER(BONUS_GOOD)
MAG_TRANSFER(BONUS_BAD)

A ring of seeing:

manipulate {MANIPULATE_TAKE, MANIPULATE_WEAR_FINGER}
type ITEM_WORN
CHAR_FLAG_TRANSFER(CHAR_DETECT_INVISIBLE)
SKILL_TRANSFER(SKI_SEARCH, BONUS_GOOD_PLUS)

The full definitions are in wmacros.h and on Complete magical transfers macros listing.

Previous: The Objects Section
Next: Building your first object