Difference between revisions of "Manual:Zone Manual/The Objects Section/DIL functions for objects"

From DikuMUD Wiki
Jump to navigation Jump to search
(checked against the current code (wiki review 2026-11-15))
 
Line 1: Line 1:
 
=== DIL functions for objects ===
 
=== DIL functions for objects ===
  
−
The DIL language is the language a builder can use to make his own
+
DIL is the language for writing your own special behaviour for rooms, NPCs and objects. This manual
−
special functions on rooms, NPCs, objects, PCs, and much more. This
+
is about writing zones, so it doesn't teach DIL (that is the [[Manual:DIL Manual|DIL Manual]]); but
−
manual is for basic zone writing and therefore will not go into how to
+
the zones that come with the server contain many ready-made DIL functions that you can put on your
−
write your own DIL functions.  The VME however is released with many
+
objects without writing any DIL. This page describes the ones made for objects: the restrictions,
−
functions for you as an Administrator and your builders to use to make
+
the Tuborg drink, the message board and blowaway.
−
special rooms, NPCs, and objects. The following sections contain a full list of all object
+
 
−
functions released with the VME 2.0 server.
+
You put a function on an object with a <code>dilcopy</code> line in the object, ending in a semicolon:
 +
<pre>
 +
dilcopy abi_restrict@function(ABIL_STR, 40, 0, 25, "");
 +
</pre>
 +
<code>abi_restrict</code> is the name of the function and <code>function</code> the zone it is in
 +
(<code>function.zon</code>). vmc checks that the constants you use exist, but it doesn't check the
 +
function's name, nor the number or types of its arguments: a mistake there shows up only when the
 +
server boots or the function runs, in the server log. So copy the argument lists below carefully.
 +
See also [[Manual:DIL Manual/dilcopy()|dilcopy()]].
 +
 
 
==== Restriction functions ====
 
==== Restriction functions ====
  
−
The desire to have different equipment comes from every players
+
The restriction functions keep an item away from players who shouldn't use it: only paladins, only
−
desire to be different.  The restrict functions were designed to help
+
players who have done a quest, only players strong enough, and so on. An item may have several;
−
make this a reality by only allowing certain groups of players to wear
+
the player then has to pass all of them.
−
some items. The restrict functions can be used alone or together to
+
 
−
make a greater restricted item. for example you could make an item,
+
They all work the same way. When a player has worn, wielded or held the item
−
restricted to only females or you could make an item, restricted to females that had a strength greater than 20 and who have
+
(they wait for [[Manual:DIL Manual/SFB DONE|SFB_DONE]] after those commands) and fails the test:
−
done a certain quest.
+
* the player is told so ("Your <i>item</i> burns you and you drop it to the ground.", and a line that says what is wrong, such as "Being in the right guild might help.");
 +
* the player loses hit points (see below);
 +
* the item is taken off and put on the floor of the room.
 +
The test is made only at that moment: a player who stops qualifying later keeps the item on until
 +
he wears it again.
 +
 
 +
Not tested:
 +
* immortals (level 200, <code>IMMORTAL_LEVEL</code>, and up);
 +
* NPCs, unless they serve a player (their master is a player). A reset can therefore equip an NPC with a restricted item. <code>vlevel_restrict</code> and <code>anti_guild</code> never test NPCs.
  
−
All restrict functions have a name that describes what the
+
The last three arguments are the same for every restriction:
−
restriction function is for and four other arguments.  the 2nd, 3rd, and
+
<pre>
−
4th argument is the exact same for all restrict functions only the name
+
..., damage, percent, action);
−
of the restrict and the first argument changes. The format for the
+
</pre>
−
restrict functions is as follows.
+
;damage, percent
−
<nowiki>
+
: Meant as the damage done to a player who fails: <code>percent</code> percent of his current hit points, at most <code>damage</code> points; with <code>percent</code> 0, exactly <code>damage</code> points; -1 for a random amount. '''In the current code these two arguments are ignored''': every restriction sets them to 0 and 25 before it tests, so a failing player always loses a quarter of his current hit points. Many zones write <code>0, 25</code>.
−
dilcopy &lt;function name&gt; (arg 1, &lt;max damage&gt;,
+
;action
−
    &lt;percentage&gt;,&lt;Optional DIL&gt;);</nowiki>
+
: <code>""</code> for the standard messages. Otherwise the name of a DIL procedure, as <code>"name@zone"</code>, which is called instead of the messages (the damage and the drop still happen). It runs on the item, so <code>self</code> is the item and <code>self.outside</code> the player. Some restrictions pass it an argument, listed in the table below; it must take exactly those arguments, or the call stops the restriction program (see [[Manual:DIL Manual/Functions|calling a template by a name in a string]]).
−
We will skip the function name and the first argument and get back
 
−
to them later.
 
  
−
;max damage and percentage
+
An example of an action, in the <code>%dil</code> section of a zone called <code>ex</code>, and the line that uses it:
−
: The second and third arguments set the damage done when the wrong player wears an object. The reason we are explaining them together is they can work together or separately depending on how you set them.
+
<pre>
−
The second argument is the max damage the third argument is the
+
dilbegin too_weak(needed : integer);
−
percentage damage.
+
code
 +
{
 +
  act("You need a strength of " + itoa(needed) + " to wear $2n.",
 +
      A_ALWAYS, self.outside, self, null, TO_CHAR);
 +
  act("$1n can't carry the weight of $2n and drops it.",
 +
      A_SOMEONE, self.outside, self, null, TO_REST);
 +
  return;
 +
}
 +
dilend
 +
</pre>
 +
<pre>
 +
dilcopy abi_restrict@function(ABIL_STR, 40, 0, 25, "too_weak@ex");
 +
</pre>
  
−
When both arguments are set to 0 no damage will be
+
The restrictions, all in <code>function.zon</code>:
−
done when the item is illegally worn. When the second argument is set
 
−
to a number like 100 and the third argument is set to 0, exactly 100
 
−
damage will be done to the player no matter how many hit points he/she
 
−
has.  So by setting the second argument to a number and setting the
 
−
third to 0 you could possibly kill your victim since it will remove the
 
−
amount specified no matter how much the player has.
 
  
−
If you do not want
+
{| class="wikitable"
−
to possibly kill your victim the Third argument should be used.  If you
+
|+ Restriction functions
−
set the second argument to 0 and the third argument to a number it will
+
! Function and arguments !! Who may use the item !! The action gets
−
do a percent of damage to the player. for example if The third argument
+
|-
−
was set to 25 it would do 25 % damage to a player.
+
| <code>guild_restrict(guilds : stringlist, damage, percent, action)</code> || members of any of the guilds || nothing
 +
|-
 +
| <code>anti_guild(guilds : stringlist, damage, percent, action)</code> || players in none of the guilds || nothing
 +
|-
 +
| <code>prof_restrict(prof : integer, damage, percent, action)</code> || players of that profession || nothing
 +
|-
 +
| <code>quest_restrict(quest : string, damage, percent, action)</code> || players who have the quest || nothing
 +
|-
 +
| <code>nquest_restrict(quests : stringlist, damage, percent, action)</code> || players who have any one of the quests || nothing
 +
|-
 +
| <code>quests_restrict(quests : stringlist, damage, percent, action)</code> || the same as <code>nquest_restrict</code>: any one of the quests || nothing
 +
|-
 +
| <code>ali_restrict(max : integer, min : integer, damage, percent, action)</code> || players with an alignment from min to max || max, min
 +
|-
 +
| <code>level_restrict(level : integer, damage, percent, action)</code> || players of at least that level || the levels missing
 +
|-
 +
| <code>vlevel_restrict(vlevel : integer, damage, percent, action)</code> || players of at least that virtual level || the levels missing
 +
|-
 +
| <code>mvlev_restrict(vlevel : integer, damage, percent, action)</code> || players of at most that virtual level || the levels too many, as a negative number
 +
|-
 +
| <code>race_restrict(race : integer, damage, percent, action)</code> || everyone '''except''' that race || nothing
 +
|-
 +
| <code>sex_restrict(sex : integer, damage, percent, action)</code> || players of that sex || nothing
 +
|-
 +
| <code>ply_restrict(name : string, damage, percent, action)</code> || the player with that name || nothing
 +
|-
 +
| <code>abi_restrict(ability : integer, min : integer, damage, percent, action)</code> || players with at least min in the ability || min
 +
|-
 +
| <code>ski_restrict(skill : integer, min : integer, damage, percent, action)</code> || players with at least min in the skill || min
 +
|-
 +
| <code>sp_restrict(spell : integer, min : integer, damage, percent, action)</code> || players with at least min in the spell || min
 +
|-
 +
| <code>weap_restrict(weapon : integer, min : integer, damage, percent, action)</code> || players with at least min in the weapon skill || min
 +
|}
  
−
  You can also use the second and third argument together if you want to set a max amount of
+
The constants for the first argument come from the headers that macros.h includes. The values.h
−
damage without possibly killing them. for example if you set the second
+
appendices list several of them.
−
argument to 100 and third to 25. The item will do 25% damage up to 100
 
−
hit points of damage. This all might be a bit confusing so let me show
 
−
you a few examples and tell you what they would do.
 
  
−
;second= 0 third = 25
+
===== guild_restrict and anti_guild =====
−
: This would do 25% damage to a player. second =100 third = 0 this would do 100 damage to a player no matter his amount of hit points.
+
The guilds are given by name, with the <code>GUILD_*</code> macros in values.h (<code>GUILD_PALADIN</code>
−
;second = 25 third = 25
+
is "Midgaard Paladin", <code>GUILD_SORCERER</code> is "Midgaard Sorcerer", and so on). An item only
−
: This would do 25 % damage to a player up to 25 hit points.
+
paladins and sorcerers can use:
−
So if a player had 150 hit points the max that could be removed is 25
+
<pre>
−
hit points.
+
dilcopy guild_restrict@function({GUILD_PALADIN, GUILD_SORCERER}, 0, 25, "");
 +
</pre>
 +
An item that paladins and sorcerers can't use:
 +
<pre>
 +
dilcopy anti_guild@function({GUILD_PALADIN, GUILD_SORCERER}, 0, 25, "");
 +
</pre>
 +
There is no <code>anti_guild_restrict</code>; the function is called <code>anti_guild</code>.
  
−
;optional DIL
+
===== prof_restrict =====
−
: All restrict DIL functions have a default set of acts.  If you want to make your own set of acts you have to create your own DIL that does nothing more than act.  If you don't understand how this works.  You may want to look in the DIL manual about passing DIL functions as arguments.
+
The profession is one of the <code>PROFESSION_*</code> constants in values.h:
 +
<pre>
 +
dilcopy prof_restrict@function(PROFESSION_BARBARIAN, 0, 25, "");
 +
</pre>
  
−
Now we should get back to the first argument and function name
+
===== quest_restrict, nquest_restrict and quests_restrict =====
−
since they are what control the restricts. The function name has been
+
The quest is the name of an entry in the player's [[Manual:DIL Manual/quests|quests]]. One quest:
−
chosen so you can easily tell what the restrict was created for
+
<pre>
−
while the first argument changes depending on which restrict you use.
+
dilcopy quest_restrict@function("Eagles quest complete", 0, 25, "");
−
The following are what each function restricts name is and what the function
+
</pre>
−
name and first argument are.
+
Any one of several quests:
 +
<pre>
 +
dilcopy nquest_restrict@function({"Eagles quest complete",
 +
                                  "Feather fall quest complete"}, 0, 25, "");
 +
</pre>
 +
<code>quests_restrict</code> does the same as <code>nquest_restrict</code>. To require several
 +
quests, add one <code>quest_restrict</code> line for each.
  
−
; Guild Restrict
+
===== ali_restrict =====
−
*
+
The first two arguments are the highest and the lowest alignment that may use the item (if you
−
This function restricts an object to players in a certain
+
swap them, the function swaps them back). Alignment goes from -1000 to 1000. An item for good
−
guild or guilds.  Anyone not in the guild or guilds, will have the damage done as set in the
+
players only:
−
2nd and 3rd arguments unless none is set.  Even if no damage is set the
+
<pre>
−
object will be removed off of the players equipment and placed in their
+
dilcopy ali_restrict@function(1000, 350, 0, 25, "");
−
inventory.  The following is the definition of the DIL as found in
+
</pre>
−
''function.zon''.
 
−
<nowiki>
 
−
dilbegin guild_restrict
 
−
(guilds:stringlist,damage:integer,percent:integer,action:string);</nowiki>
 
−
As the definition indicates the first argument is a stringlist.  This
 
−
means you can restrict this item to more than one guild.  All guilds in
 
−
the string list will be able to wear this object.  If we wanted to make
 
−
an item that only Paladins and sorcerers could wear it would look like
 
−
this.
 
−
<nowiki>
 
−
dilcopy guild_restrict@function ({"Midgaard Paladin",
 
−
                        "Midgaard Sorcerer"},0,25,"");</nowiki>
 
−
;Anti-guild Restrict
 
−
: This function restricts an object to players not in a certain guild or guilds.  Anyone not in the guild or guilds listed, will have the damage done as set in the 2nd and 3rd arguments unless none is set.  Even if no damage is set the object will be removed off of the players equipment and placed in their inventory.  The following is the definition of the DIL as found in
 
−
''function.zon''.
 
−
<nowiki>
 
−
dilbegin anti_guild_restrict
 
−
(guilds:stringlist,damage:integer,percent:integer,action:string);</nowiki>
 
−
As the definition indicates the first argument is a stringlist. This
 
−
means you can restrict this item from more than one guild.  All guilds in
 
−
the string list will not be able to wear this object. If we wanted to make
 
−
an item that only Paladins and sorcerers could not wear it would look like
 
−
this.
 
−
<nowiki>
 
−
dilcopy anti_guild_restrict@function ({"Midgaard Paladin",
 
−
                              "Midgaard Sorcerer"},0,25,"");</nowiki>
 
−
;Quest Restrict
 
−
: This function restricts an object to players who have done a certain quest.  Any  player who has not done the quest,
 
−
will have the damage done as set in the 2nd and 3rd arguments unless
 
−
none is set.  Even if no damage is set the object will be removed off of
 
−
the players equipment and placed in their inventory.  The following is
 
−
the definition of the DIL as found in
 
−
''function.zon''.
 
−
<nowiki>
 
−
dilbegin quest_restrict
 
−
(qst:string,damage:integer,percent:integer,action:string);</nowiki>
 
−
As the definition indicates the first argument is a string.  The
 
−
quest restrict is only made to restrict the by one quest at a time.  If
 
−
you want the item to have multiple quests restrictions you just add
 
−
another dilcopy to it.  The following Would be an object
 
−
restricted to one quest.
 
−
<nowiki>
 
−
dilcopy quest_restrict@function ("Eagles quest complete",0,25,"");</nowiki>
 
−
;Quests Restrict
 
−
: This function restricts an object to players who have a certain quest or quests.  Anyone not having all quests in the list of quests, will have the damage done as set in the 2nd and 3rd arguments unless none is set.  Even if no damage is set the object will be removed off of the players equipment and placed in their inventory.  The following is the definition of the DIL as found in
 
−
''function.zon''.
 
−
<nowiki>
 
−
dilbegin quests_restrict
 
−
(qsts:stringlist,damage:integer,percent:integer,action:string);</nowiki>
 
−
As the definition indicates the first argument is a stringlist.  This
 
−
means you can restrict this item to more than one quest.  Players that
 
−
have not done every quest will not be able to use the object.
 
−
If we wanted to make an item that only players that have finished both
 
−
the 'Eagles quest complete' and the 'Feather fall quest complete' could
 
−
wear.  It would look like this.
 
−
<nowiki>
 
−
dilcopy quests_restrict@function ({"Eagles quest complete",
 
−
                          "Feather fall quest complete"},0,25,"");</nowiki>
 
−
;Alignment Restrict
 
−
: This function restricts an object to players with a certain alignment range.
 
−
Anyone not in the alignment range,
 
−
will have the damage done as set in the 3nd and 4th arguments unless
 
−
none is set.  Even if no damage is set the object will be removed off of
 
−
the players equipment and placed in their inventory.
 
  
−
We said at the beginning of this section that all restricts have
+
===== level_restrict, vlevel_restrict and mvlev_restrict =====
−
only 4 arguments.  This was a bit of a lie since this restrict has five
+
<code>level_restrict</code> tests the [[Manual:DIL Manual/level|level]], which for players stops at
−
arguments.  The reason we didn't count this one is because the first and
+
50; above that only the virtual level, [[Manual:DIL Manual/vlevel|vlevel]], goes up. So use
−
second argument in the alignment restrict function are used together and
+
<code>vlevel_restrict</code> for a minimum above 50. <code>mvlev_restrict</code> sets a maximum
−
thus are only really one argument. The following is the definition of the DIL as found in
+
instead, for items meant for low level players.
−
''function.zon''.
+
<pre>
−
<nowiki>
+
dilcopy level_restrict@function(20, 0, 25, "");
−
dilbegin ali_restrict
+
dilcopy vlevel_restrict@function(100, 0, 25, "");
−
(max:integer,min:integer,damage:integer,percent:integer,action:string);</nowiki>
+
dilcopy mvlev_restrict@function(50, 0, 25, "");
−
As the definition indicates the first and second arguments are two
+
</pre>
−
integers.  the first is the max alignment that can wear or use this
 
−
object and the second is the minimum alignment.  So if we wanted to
 
−
restrict an item to only good players it would look like this.
 
−
<nowiki>
 
−
dilcopy ali_restrict@function (1000,350,0,25,"");</nowiki>
 
−
;Level restrict
 
−
: This function restricts an object to players above or equal to a certain level.  Any player not at least the level or higher, will have the damage done as set in the 2nd and 3rd arguments unless none is set.  Even if no damage is set the object will be removed off of the players equipment and placed in their inventory.  This restrict works in the old level system from one to fifty which means if the level restrict is set higher than fifty no player will be able to wear or use this object.  This is good if you have objects that only your administrators should be able to use.  If you want to restrict an object to greater than level fifty for players you need to use the 'vlevel' restrict.  The following is the definition of the DIL as found in ''function.zon''.
 
−
<nowiki>
 
−
dilbegin level_restrict
 
−
(lvl:integer,damage:integer,percent:integer,action:string);</nowiki>
 
−
As the definition indicates the first argument is an integer.  The
 
−
integer for the level restrict can range from 1 to 255.  Thus if we
 
−
wanted to make an object that only administrator could wear or use it would
 
−
look like this
 
−
<nowiki>
 
−
dilcopy level_restrict@function (51, 0,25,"");</nowiki>
 
−
;Virtual Level Restrict
 
−
: This function restricts an object to players above or equal to a certain level.  Any player not at least the level or higher, will have the damage done as set in the 2nd and 3rd arguments unless none is set.  Even if no damage is set the object will be removed off of the players equipment and placed in their inventory.  This restrict works in the new level system from one to infinity.
 
−
The following is the definition of the DIL as found in ''function.zon''.
 
−
<nowiki>
 
−
dilbegin vlevel_restrict
 
−
(lvl:integer,damage:integer,percent:integer,action:string);</nowiki>
 
−
As the definition indicates the first argument is an integer.  The
 
−
integer for the level restrict can range from 1 to infinite.  Thus if we
 
−
wanted to make an object that only players that have reached the level
 
−
of 5000 could wear or use, it would look like this.
 
−
<nowiki>
 
−
dilcopy vlevel_restrict@function (5000, 0,25,"");</nowiki>
 
−
;Race restrict
 
−
: This function restricts an object from players of a certain race. Any player not of the selected race, will have the damage done as set in the 2nd and 3rd arguments unless none is set.  Even if no damage is set the object will be removed off of the players equipment and placed in their inventory.  The following is the definition of the DIL as found in ''function.zon''.
 
−
<nowiki>
 
−
dilbegin race_restrict
 
−
(rc:integer,damage:integer,percent:integer,action:string);</nowiki>
 
−
As the definition indicates the first argument is an integer.  The
 
−
integer being passed in should be the race you want to restrict the
 
−
object from.  You can pass in the defines as listed in (Link to app-c) or if you have added races you will find the list of
 
−
races in ''values.h''.  If we wanted to restrict an
 
−
object from humans the following is what it would look like.
 
−
<nowiki>
 
−
dilcopy race_restrict@function (RACE_HUMAN,0,25,"");</nowiki>
 
−
;Gender restrict
 
−
: This function restricts an object to players of a certain gender.  Anyone not of the gender, will have the damage done as set in the 2nd and 3rd arguments unless none is set.  Even if no damage is set the object will be removed off of the players equipment and placed in their inventory.  The following is the definition of the DIL as found in
 
−
''function.zon''.
 
−
<nowiki>
 
−
dilbegin sex_restrict
 
−
(sx:integer,damage:integer,percent:integer,action:string);</nowiki>
 
−
As the definition indicates the first argument is an integer.  The
 
−
integer you should pass in is one of the defines from
 
−
''vme.h''.  The gender defines are as follows.
 
−
<nowiki>
 
−
#define SEX_NEUTRAL  0
 
−
#define SEX_MALE      1
 
−
#define SEX_FEMALE    2</nowiki>
 
−
If we wanted to make an item that could only be worn by a female
 
−
player, it would look like this.
 
−
<nowiki>
 
−
dilcopy sex_restrict (SEX_FEMALE,0,25,"");</nowiki>
 
−
;Player restrict
 
−
: This function restricts an object to players who have a specific name. Any player of the wrong name, will have the damage done as set in the 2nd and 3rd arguments unless none is set.  Even if no damage is set the object will be removed off of the players equipment and placed in their inventory.  The following is the definition of the DIL as found in
 
−
''function.zon''.
 
−
<nowiki>
 
−
dilbegin ply_restrict
 
−
(pname:string,damage:integer,percent:integer,action:string);</nowiki>
 
−
As the definition indicates the first argument is a string.  The
 
−
quest restrict is only made to restrict the quest to one person at a
 
−
time.  While this DIL was designed to be put on when a player receives a
 
−
quest item and thus was made to be dilcopied in a DIL you can still put
 
−
it on when you first create the object if you are making special items
 
−
for administrators or players that you know in advance.  If you want more
 
−
information about copying a DIL from with in another DIL you will have
 
−
to read the DIL manual If however you want to restrict this to a single
 
−
player at compile time of your zone it would look something like
 
−
this.
 
−
<nowiki>
 
−
dilcopy ply_restrict@function ("Whistler",0,25,"");</nowiki>
 
−
;Ability restrict
 
−
: This function restricts an object from a player with less than a certain amount of a certain ability. Any player not having the correct amount of a certain ability, will have the damage done as set in the 3nd and 4th arguments unless none is set.  Even if no damage is set the object will be removed off of the players equipment and placed in their inventory.
 
  
−
We said at the beginning of this section that all restricts have
+
===== race_restrict =====
−
only 4 arguments.  This was a bit of a lie since this restrict has five
+
This one works the other way round: it keeps one race '''out'''. The race is a <code>RACE_*</code>
−
arguments.  The reason we didn't count this one is because the first and
+
constant from values.h. An item humans can't use:
−
second argument in the ability restrict function are used together and
+
<pre>
−
thus are only really one argument. The following is the definition of the DIL as found in
+
dilcopy race_restrict@function(RACE_HUMAN, 0, 25, "");
−
''function.zon''.
+
</pre>
−
<nowiki>
 
−
dilbegin abi_restrict
 
−
(abi:integer,min_abi:integer,damage:integer,percent:integer,action:string);</nowiki>
 
−
As the definition indicates the first and second arguments are two
 
−
integers. the first is the ability type and the second is the amount of
 
−
that ability the player needs to have or greater to wear or use the
 
−
item.  the ability types can be found in ''vme.h'' and
 
−
are listed here for convenience.
 
−
<nowiki>
 
−
#define ABIL_MAG              0
 
−
#define ABIL_DIV              1
 
−
#define ABIL_STR              2
 
−
#define ABIL_DEX              3
 
−
#define ABIL_CON              4
 
−
#define ABIL_CHA              5
 
−
#define ABIL_BRA              6
 
−
#define ABIL_HP                7</nowiki>
 
−
If you wanted to restrict an object to people having more than 50%
 
−
strength it would look like this:
 
−
<nowiki>
 
−
dilcopy abi_restrict@function (ABIL_STR,50,0,25,"");</nowiki>
 
−
If you want to restrict an object to more than one ability you
 
−
only need to add another restrict to the item.  For example if you
 
−
wanted to restrict it to people having greater than or equal to 50%
 
−
divine and 30% brain.  The item would have these two lines.
 
−
<nowiki>
 
−
dilcopy abi_restrict@function (ABIL_DIV,50,0,25,"");
 
−
dilcopy abi_restrict@function (ABIL_BRA,30,0,25,"");</nowiki>
 
−
;Skill restrict
 
−
: This function restricts an object from a player with less than a certain amount of a certain skill. Any player not having the correct amount of a certain skill, will have the damage done as set in the 3nd and 4th arguments unless none is set.  Even if no damage is set the object will be removed off of the players equipment and placed in their inventory.
 
  
−
We said at the beginning of this section that all restricts have
+
===== sex_restrict =====
−
only 4 arguments.  This was a bit of a lie since this restrict has five
+
The sex is <code>SEX_NEUTRAL</code>, <code>SEX_MALE</code> or <code>SEX_FEMALE</code> (vme.h). An
−
arguments.  The reason we didn't count this one is because the first and
+
item only female players can use:
−
second argument in the skill restrict function are used together and
+
<pre>
−
thus are only really one argument. The following is the definition of the DIL as found in
+
dilcopy sex_restrict@function(SEX_FEMALE, 0, 25, "");
−
''function.zon''.
+
</pre>
−
<nowiki>
 
−
dilbegin ski_restrict
 
−
(ski:integer,min_ski:integer,damage:integer,percent:integer,action:string);</nowiki>
 
−
As the definition indicates the first and second arguments are two
 
−
integers.  the first is the skill and the second is the amount of
 
−
that skill the player needs to have or greater to wear or use the
 
−
item.  the skills can be found in (Link to app-g) and
 
−
''values.h''. We have also included the first five skills
 
−
here for convenience in explaining how the function works.
 
−
<nowiki>
 
−
#define SKI_TURN_UNDEAD        0
 
−
#define SKI_SCROLL_USE        1
 
−
#define SKI_WAND_USE          2
 
−
#define SKI_CONSIDER          3
 
−
#define SKI_DIAGNOSTICS        4</nowiki>
 
−
If you wanted to restrict an object to people having more than 50%
 
−
'turn undead' it would look like this:
 
−
<nowiki>
 
−
dilcopy ski_restrict@function (ASKI_TURN_UNDEAD,50,0,25,"");</nowiki>
 
−
If you want to restrict an object to more than one skill you
 
−
only need to add another restrict to the item.  For example if you
 
−
wanted to restrict it to people having greater than or equal to 50%
 
−
in 'turn undead' and 30% in 'scroll use'.  The item would have these two lines.
 
−
<nowiki>
 
−
dilcopy ski_restrict@function (SKI_TURN_UNDEAD,50,0,25,"");
 
−
dilcopy ski_restrict@function (SKI_SCROLL_USE,30,0,25,"");</nowiki>
 
−
;Spell restrict
 
−
: This function restricts an object from a player with less than a certain amount of a certain spell. Any player not having the correct amount of a certain spell, will have the damage done as set in the 3nd and 4th arguments unless none is set.  Even if no damage is set the object will be removed off of the players equipment and placed in their inventory.
 
  
−
We said at the beginning of this section that all restricts have
+
===== ply_restrict =====
−
only 4 arguments. This was a bit of a lie since this restrict has five
+
The item belongs to one player. Looking at it also shows "Whistler owns this ...". It is mostly put
−
arguments. The reason we didn't count this one is because the first and
+
on an item by a quest, from DIL, when the player is known; in a zone file it is for an item made
−
second argument in the spell restrict function are used together and
+
for a player you know in advance.
−
thus are only really one argument. The following is the definition of the DIL as found in
+
<pre>
−
''function.zon''.
+
dilcopy ply_restrict@function("Whistler", 0, 25, "");
−
<nowiki>
+
</pre>
−
dilbegin sp_restrict
 
−
(spl:integer,min_sp:integer,damage:integer,percent:integer,action:string);</nowiki>
 
−
As the definition indicates the first and second arguments are two
 
−
integers.  the first is the spell and the second is the amount of
 
−
that spell the player needs to have or greater to wear or use the
 
−
item.  the spells can be found in (Link to app-h) and
 
−
''values.h''. We have also included the first five
 
−
spells here for convenience in explaining how the function works.
 
−
<nowiki>
 
−
#define SPL_LOCK              52
 
−
#define SPL_UNLOCK            53
 
−
#define SPL_DROWSE            54
 
−
#define SPL_SLOW              55
 
−
#define SPL_DUST_DEVIL        56</nowiki>
 
−
If you wanted to restrict an object to people having more than 50%
 
−
'lock' spell, it would look like this:
 
−
<nowiki>
 
−
dilcopy sp_restrict@function (ASPL_LOCK,50,0,25,"");</nowiki>
 
−
If you want to restrict an object to more than one spell you
 
−
only need to add another restrict to the item.  For example if you
 
−
wanted to restrict it to people having greater than or equal to 50%
 
−
in 'lock' and 30% in 'unlock' spells.  The item would have these two lines.
 
−
<nowiki>
 
−
dilcopy sp_restrict@function (SPL_LOCK,50,0,25,"");
 
−
dilcopy SPL_restrict@function (SPL_LOCK,30,0,25,"");</nowiki>
 
−
;Weapon restrict
 
−
: This function restricts an object from a player with less than a certain amount of a certain weapon. Any player not having the correct amount of a certain weapon, will have the damage done as set in the 3nd and 4th arguments unless none is set.  Even if no damage is set the object will be removed off of the players equipment and placed in their inventory.
 
  
−
We said at the beginning of this section that all restricts have
+
===== abi_restrict, ski_restrict, sp_restrict and weap_restrict =====
−
only 4 arguments.  This was a bit of a lie since this restrict has five
+
The first argument is the ability, skill, spell or weapon, the second the least the player must
−
arguments.  The reason we didn't count this one is because the first and
+
have of it. The abilities are <code>ABIL_MAG</code>, <code>ABIL_DIV</code>, <code>ABIL_STR</code>,
−
second argument in the weapon restrict function are used together and
+
<code>ABIL_DEX</code>, <code>ABIL_CON</code>, <code>ABIL_CHA</code>, <code>ABIL_BRA</code> and
−
thus are only really one argument. The following is the definition of the DIL as found in
+
<code>ABIL_HP</code> (vme.h); skills are <code>SKI_*</code>, spells <code>SPL_*</code> and weapons
−
''function.zon''.
+
<code>WPN_*</code>, all in values.h (see
−
<nowiki>
+
[[Manual:Zone Manual/Appendices/Skill definitions in values.h|Skill definitions]],
−
dilbegin weap_restrict
+
[[Manual:Zone Manual/Appendices/Spell definitions in values.h|Spell definitions]] and
−
(wpn:integer,min_wpn:integer,damage:integer,percent:integer,action:string);</nowiki>
+
[[Manual:Zone Manual/Appendices/weapon definitions in values.h|weapon definitions]]).
−
As the definition indicates the first and second arguments are two
+
<pre>
−
integers. the first is the weapon and the second is the amount of
+
dilcopy abi_restrict@function(ABIL_STR, 50, 0, 25, "");
−
that weapon the player needs to have or greater to wear or use the
+
dilcopy ski_restrict@function(SKI_TURN_UNDEAD, 50, 0, 25, "");
−
item.  the weapons can be found in (Link to app-d) and
+
dilcopy sp_restrict@function(SPL_LOCK, 50, 0, 25, "");
−
''values.h''. We have also included the first five
+
dilcopy weap_restrict@function(WPN_BATTLE_AXE, 50, 0, 25, "");
−
weapons here for convenience in explaining how the function works.
+
</pre>
−
<nowiki>
+
For more than one ability, add a line for each. An item for players with at least 50 divinity and 30 brains:
−
#define WPN_BATTLE_AXE    7  /* Two Handed */
+
<pre>
−
#define WPN_HAND_AXE      8
+
dilcopy abi_restrict@function(ABIL_DIV, 50, 0, 25, "");
−
#define WPN_WAR_MATTOCK  9  /* Two Handed */
+
dilcopy abi_restrict@function(ABIL_BRA, 30, 0, 25, "");
−
#define WPN_WAR_HAMMER  10
+
</pre>
−
#define WPN_GREAT_SWORD  11  /* Two Handed */</nowiki>
 
−
If you wanted to restrict an object to people having more than 50%
 
−
'battle axe', it would look like this:
 
−
<nowiki>
 
−
dilcopy weap_restrict@function (WPN_BATTLE_AXE,50,0,25,"");</nowiki>
 
−
If you want to restrict an object to more than one weapon you
 
−
only need to add another restrict to the item.  For example if you
 
−
wanted to restrict it to people having greater than or equal to 50%
 
−
in 'hand axe' and 30% in 'battle axe' spells.  The item would have these two lines.
 
−
<nowiki>
 
−
dilcopy weap_restrict@function (WPN_HAND_AXE,50,0,25,"");
 
−
dilcopy weap_restrict@function (WPN_BATTLE_AXE,30,0,25,"");</nowiki>
 
−
==== Tuborg function ====
 
  
−
What game would be complete with out the Denmark water!  With that
+
===== The *_RESTRICT macros =====
−
in mind the VME 2.0 has a tuborg function that makes a drink give
+
values.h also has macros such as <code>LEVEL_RESTRICT(...)</code> and <code>ABILITY_RESTRICT(...)</code>.
−
endurance and health when drank.  The function is defined in
+
They only add a hidden extra to the item, and nothing in the current game reads those extras, so
−
''function.zon'' as follows:
+
they restrict nothing. Use the functions above.
−
<nowiki>
+
 
−
dilbegin tuborg (s:string);</nowiki>
+
==== Tuborg ====
−
As the definition indicates the tuborg function only has one
+
 
−
argument.  The real surprise is that the argument is not used yet in the
+
<code>tuborg@function</code> turns a drink into a Tuborg that gives endurance:
−
DIL so no matter what you set it to it doesn't matter. In the future
+
<pre>
−
this argument is going to allow different kinds of tuborgs to be made
+
dilcopy tuborg@function("");
−
but for now its just a place holder and all that is needed is a set of
+
</pre>
−
double quotes.
+
The argument isn't used; give it an empty string. Put it on a drink container (made with a
 +
<code>LIQ_*</code> macro, the liquid's name last in its names). When a player drinks from it, the whole
 +
container is emptied in one go: the player's thirst and fullness go up by 5 (to at most 24) and his
 +
endurance by 25 (to at most his maximum). A player whose thirst is above 20 is told "You are not
 +
thirsty."; <code>sip</code> and <code>taste</code> only give a message. After one drink the function
 +
ends, so a refilled container is an ordinary drink again.
  
−
To create a tuborg you just add the following line to your drink
 
−
container.
 
−
<nowiki>
 
−
dilcopy tuborg@function ("");</nowiki>
 
 
==== Message board ====
 
==== Message board ====
  
−
Every game needs a way for Administrators and players to exchange
+
Boards let players and administrators leave messages for each other. A board is an object with
−
ideas.  The message boards have been designed for this purpose. The
+
<code>board@boards</code> on it, from <code>boards.zon</code>:
−
boards function can be easy to use or more difficult depending on what
+
<pre>
−
all you want them to do.  The board function is defined in
+
dilbegin board(idxfile : string, l_res : string, r_res : string, p_res : string, bmax : integer);
−
''boards.zon'' as follows.
+
</pre>
−
<nowiki>
+
The function makes the object an <code>ITEM_BOARD</code> itself. Players <code>look</code> at the
−
dilbegin board
+
board for the list of posts, and use <code>read</code>, <code>write</code>, <code>reply</code> and
−
(idxfile:string,l_res:string,r_res:string,p_res:string,bmax:integer);</nowiki>
+
<code>remove</code>.
−
This looks pretty hard I know but to make a normal board we have
 
−
made it as simple as possible while allowing for the boards to be used
 
−
in almost any situation.  After you make your first board it is pretty
 
−
much block and copy and change the first argument. The arguments are as
 
−
follows:
 
  
 
;idxfile
 
;idxfile
−
: The first argument is the board index filename.  It tells the board DIL what name to store the board under so if you create more boards with the same name they will all be pointing to the same messages.  You can put any legal symbolic name in this string and it will work with no problems.
+
: The name the posts are saved under. Every board with the same name shows the same posts, so choose a name no other board uses, unless you want two boards to share their posts. The function also adds this name to the board's names.
 
;l_res
 
;l_res
−
: the second argument is a DIL you pass in that does any checks to see if the player looking at the board is allowed to. This requires some knowledge in DIL but we have given some example DIL functions in the
+
: Who may look at the board and read its posts: the name of a DIL function, or <code>""</code> for everyone.
−
''boards.zon''.
+
;r_res
−
<nowiki>
+
: Who may remove other players' posts: a function, or <code>""</code> for everyone. A player can always remove his own posts.
−
//used to restrict players access to a board
+
;p_res
−
dilbegin string admin_res (u:unitptr,v:unitptr);
+
: Who may post: a function, or <code>""</code> for every player of level 10 or higher.
 +
;bmax
 +
: How many posts the board holds. When it is full, a player who tries to write is told "The board is full."
  
−
//used to restrict non-admin from removing posts
+
The three checks are DIL functions that get the player and the board and return a string:
−
dilbegin string rem_res (u:unitptr, v:unitptr);</nowiki>
+
<code>""</code> to allow, or the message to show when the player isn't allowed. <code>boards.zon</code>
−
So with the 'admin_res' you could do something like
+
has two:
−
this:
+
<pre>
−
<nowiki>
+
// only administrators (level 200 and up)
−
dilcopy board@boards ("wizbrd","admin_res@boards"...);</nowiki>
+
dilbegin string admin_res(u : unitptr, v : unitptr);
−
Putting the 'admin_res' function in the second argument would make
+
 
−
it so only administrators could look at the board.  If you put an empty
+
// administrators, and players who have the quest "Valhalla Editor"
−
string or two double quotes as the argument it will let anyone look at
+
dilbegin string rem_res(u : unitptr, v : unitptr);
−
the board.
+
</pre>
−
;r_res
+
Use <code>admin_res</code> to keep a board for administrators and <code>rem_res</code> to let
−
: the third argument is a DIL you pass in that does any checks to see if the player trying to remove a post at the board is allowed to. This requires some knowledge in DIL but we have given some example DIL functions in the
+
only administrators clean a public board. A function of your own needs the same arguments and
−
''boards.zon''
+
return type, and its name as <code>"name@zone"</code>.
−
<nowiki>
 
−
//used to restrict players access to a board
 
−
dilbegin string admin_res (u:unitptr,v:unitptr);
 
  
−
//used to restrict non-admin from removing posts
+
A board where anyone can read, post and remove, for 50 posts:
−
dilbegin string rem_res (u:unitptr, v:unitptr);</nowiki>
+
<pre>
−
So with the 'rem_res' you could do something like
+
dilcopy board@boards("free", "", "", "", 50);
−
this:
+
</pre>
−
<nowiki>
+
A board everyone can read and post on, where only administrators remove other people's posts:
−
dilcopy board@boards ("citizen","","rem_res@boards",...);</nowiki>
+
<pre>
−
With the 'rem_res' in the third argument only administrators can
+
dilcopy board@boards("citizen", "", "rem_res@boards", "", 100);
−
now remove from this board but anyone can look at it because of the empty
+
</pre>
−
string in the second argument.  Putting an empty string in the third
+
A board only administrators can use at all:
−
argument will make it so anyone can remove from this board.
+
<pre>
−
;p_res
+
dilcopy board@boards("wizard", "admin_res@boards", "admin_res@boards",
−
: the forth argument is a DIL you pass in that does any checks to see if the player trying to post at the board is allowed to.  This requires some knowledge in DIL but we have given some example DIL functions in the
+
                    "admin_res@boards", 100);
−
''boards.zon''.
+
</pre>
−
<nowiki>
+
A complete board object is on [[Manual:Zone Manual/The Objects Section/More complex objects|More complex objects]].
−
//used to restrict players access to a board
 
−
dilbegin string admin_res (u:unitptr,v:unitptr);
 
  
−
//used to restrict non-admin from removing posts
+
==== Blowaway ====
−
dilbegin string rem_res (u:unitptr, v:unitptr);</nowiki>
 
−
As you can see we haven't made a post restriction DIL because as of
 
−
yet we haven't found a need for one.  If you have a need for one just
 
−
look over the two restrict DIL functions we have already mentioned and you will
 
−
find it is really easy to make.  We want to allow anyone to post so our
 
−
dilcopy looks like this:
 
−
<nowiki>
 
−
dilcopy board@boards ("citizen","","rem_res@boards","",...);</nowiki>
 
−
With the 'rem_res' in the third argument only administrators can
 
−
now remove from this board but anyone can post to it because of the empty
 
−
string in the forth argument.  The empty string again in the second
 
−
argument also allows everyone to look at the board.
 
−
;max
 
−
: The fifth argument is simply the amount of posts that you want to allow to be posted before the board is full.
 
  
−
To make a free for all board where everyone can post, remove
+
<code>blowaway@function(seconds, message)</code> makes an object disappear when it has been lying
−
posts, look at what posts are on the board, and have a max of 50 posts it would simply be as
+
on the floor for a while. Every <code>seconds</code> seconds it looks where the object is; if it is
−
follows:
+
lying in a room, the room sees the message and the object is destroyed. Carried, or inside a
−
<nowiki>
+
container, it is left alone until the next look. In the message, <code>$1n</code> is the object.
−
dilcopy board@boards("citizen","","","",50);</nowiki>
+
<pre>
−
When making a board for players to post concerns to the
+
dilcopy blowaway@function(120, "$1n is eaten by a passing mouse.");
−
administrators and only have the administrators be able to remove them,
+
</pre>
−
wile still allowing everyone to read them it would look like
 
−
this.
 
−
<nowiki>
 
−
dilcopy board@boards("citizen","","rem_res@boards","",100);</nowiki>
 
  
−
<div style='padding-top: 30px; padding-bottom: 20px; text-align: left;float:left;width:50%;'>[[Manual:Zone_Manual/The_Objects_Section/Compiling_and_Debugging_your_first_object|Previous: Compiling and Debugging your first object]]</div>
+
<div style='padding-top: 30px; padding-bottom: 20px; text-align: left;float:left;width:50%;'>[[Manual:Zone Manual/The Objects Section/Compiling and Debugging your first object|Previous: Compiling and Debugging 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/More_complex_objects|Next: More complex objects]]</div>
+
<div style='padding-top: 30px; padding-bottom: 20px; text-align: right;float:right;width:50%;'>[[Manual:Zone Manual/The Objects Section/More complex objects|Next: More complex objects]]</div>

Latest revision as of 06:14, 15 November 2026

DIL functions for objects

DIL is the language for writing your own special behaviour for rooms, NPCs and objects. This manual is about writing zones, so it doesn't teach DIL (that is the DIL Manual); but the zones that come with the server contain many ready-made DIL functions that you can put on your objects without writing any DIL. This page describes the ones made for objects: the restrictions, the Tuborg drink, the message board and blowaway.

You put a function on an object with a dilcopy line in the object, ending in a semicolon:

dilcopy abi_restrict@function(ABIL_STR, 40, 0, 25, "");

abi_restrict is the name of the function and function the zone it is in (function.zon). vmc checks that the constants you use exist, but it doesn't check the function's name, nor the number or types of its arguments: a mistake there shows up only when the server boots or the function runs, in the server log. So copy the argument lists below carefully. See also dilcopy().

Restriction functions

The restriction functions keep an item away from players who shouldn't use it: only paladins, only players who have done a quest, only players strong enough, and so on. An item may have several; the player then has to pass all of them.

They all work the same way. When a player has worn, wielded or held the item (they wait for SFB_DONE after those commands) and fails the test:

  • the player is told so ("Your item burns you and you drop it to the ground.", and a line that says what is wrong, such as "Being in the right guild might help.");
  • the player loses hit points (see below);
  • the item is taken off and put on the floor of the room.

The test is made only at that moment: a player who stops qualifying later keeps the item on until he wears it again.

Not tested:

  • immortals (level 200, IMMORTAL_LEVEL, and up);
  • NPCs, unless they serve a player (their master is a player). A reset can therefore equip an NPC with a restricted item. vlevel_restrict and anti_guild never test NPCs.

The last three arguments are the same for every restriction:

..., damage, percent, action);
damage, percent
Meant as the damage done to a player who fails: percent percent of his current hit points, at most damage points; with percent 0, exactly damage points; -1 for a random amount. In the current code these two arguments are ignored: every restriction sets them to 0 and 25 before it tests, so a failing player always loses a quarter of his current hit points. Many zones write 0, 25.
action
"" for the standard messages. Otherwise the name of a DIL procedure, as "name@zone", which is called instead of the messages (the damage and the drop still happen). It runs on the item, so self is the item and self.outside the player. Some restrictions pass it an argument, listed in the table below; it must take exactly those arguments, or the call stops the restriction program (see calling a template by a name in a string).

An example of an action, in the %dil section of a zone called ex, and the line that uses it:

dilbegin too_weak(needed : integer);
code
{
   act("You need a strength of " + itoa(needed) + " to wear $2n.",
       A_ALWAYS, self.outside, self, null, TO_CHAR);
   act("$1n can't carry the weight of $2n and drops it.",
       A_SOMEONE, self.outside, self, null, TO_REST);
   return;
}
dilend
dilcopy abi_restrict@function(ABIL_STR, 40, 0, 25, "too_weak@ex");

The restrictions, all in function.zon:

Restriction functions
Function and arguments Who may use the item The action gets
guild_restrict(guilds : stringlist, damage, percent, action) members of any of the guilds nothing
anti_guild(guilds : stringlist, damage, percent, action) players in none of the guilds nothing
prof_restrict(prof : integer, damage, percent, action) players of that profession nothing
quest_restrict(quest : string, damage, percent, action) players who have the quest nothing
nquest_restrict(quests : stringlist, damage, percent, action) players who have any one of the quests nothing
quests_restrict(quests : stringlist, damage, percent, action) the same as nquest_restrict: any one of the quests nothing
ali_restrict(max : integer, min : integer, damage, percent, action) players with an alignment from min to max max, min
level_restrict(level : integer, damage, percent, action) players of at least that level the levels missing
vlevel_restrict(vlevel : integer, damage, percent, action) players of at least that virtual level the levels missing
mvlev_restrict(vlevel : integer, damage, percent, action) players of at most that virtual level the levels too many, as a negative number
race_restrict(race : integer, damage, percent, action) everyone except that race nothing
sex_restrict(sex : integer, damage, percent, action) players of that sex nothing
ply_restrict(name : string, damage, percent, action) the player with that name nothing
abi_restrict(ability : integer, min : integer, damage, percent, action) players with at least min in the ability min
ski_restrict(skill : integer, min : integer, damage, percent, action) players with at least min in the skill min
sp_restrict(spell : integer, min : integer, damage, percent, action) players with at least min in the spell min
weap_restrict(weapon : integer, min : integer, damage, percent, action) players with at least min in the weapon skill min

The constants for the first argument come from the headers that macros.h includes. The values.h appendices list several of them.

guild_restrict and anti_guild

The guilds are given by name, with the GUILD_* macros in values.h (GUILD_PALADIN is "Midgaard Paladin", GUILD_SORCERER is "Midgaard Sorcerer", and so on). An item only paladins and sorcerers can use:

dilcopy guild_restrict@function({GUILD_PALADIN, GUILD_SORCERER}, 0, 25, "");

An item that paladins and sorcerers can't use:

dilcopy anti_guild@function({GUILD_PALADIN, GUILD_SORCERER}, 0, 25, "");

There is no anti_guild_restrict; the function is called anti_guild.

prof_restrict

The profession is one of the PROFESSION_* constants in values.h:

dilcopy prof_restrict@function(PROFESSION_BARBARIAN, 0, 25, "");
quest_restrict, nquest_restrict and quests_restrict

The quest is the name of an entry in the player's quests. One quest:

dilcopy quest_restrict@function("Eagles quest complete", 0, 25, "");

Any one of several quests:

dilcopy nquest_restrict@function({"Eagles quest complete",
                                  "Feather fall quest complete"}, 0, 25, "");

quests_restrict does the same as nquest_restrict. To require several quests, add one quest_restrict line for each.

ali_restrict

The first two arguments are the highest and the lowest alignment that may use the item (if you swap them, the function swaps them back). Alignment goes from -1000 to 1000. An item for good players only:

dilcopy ali_restrict@function(1000, 350, 0, 25, "");
level_restrict, vlevel_restrict and mvlev_restrict

level_restrict tests the level, which for players stops at 50; above that only the virtual level, vlevel, goes up. So use vlevel_restrict for a minimum above 50. mvlev_restrict sets a maximum instead, for items meant for low level players.

dilcopy level_restrict@function(20, 0, 25, "");
dilcopy vlevel_restrict@function(100, 0, 25, "");
dilcopy mvlev_restrict@function(50, 0, 25, "");
race_restrict

This one works the other way round: it keeps one race out. The race is a RACE_* constant from values.h. An item humans can't use:

dilcopy race_restrict@function(RACE_HUMAN, 0, 25, "");
sex_restrict

The sex is SEX_NEUTRAL, SEX_MALE or SEX_FEMALE (vme.h). An item only female players can use:

dilcopy sex_restrict@function(SEX_FEMALE, 0, 25, "");
ply_restrict

The item belongs to one player. Looking at it also shows "Whistler owns this ...". It is mostly put on an item by a quest, from DIL, when the player is known; in a zone file it is for an item made for a player you know in advance.

dilcopy ply_restrict@function("Whistler", 0, 25, "");
abi_restrict, ski_restrict, sp_restrict and weap_restrict

The first argument is the ability, skill, spell or weapon, the second the least the player must have of it. The abilities are ABIL_MAG, ABIL_DIV, ABIL_STR, ABIL_DEX, ABIL_CON, ABIL_CHA, ABIL_BRA and ABIL_HP (vme.h); skills are SKI_*, spells SPL_* and weapons WPN_*, all in values.h (see Skill definitions, Spell definitions and weapon definitions).

dilcopy abi_restrict@function(ABIL_STR, 50, 0, 25, "");
dilcopy ski_restrict@function(SKI_TURN_UNDEAD, 50, 0, 25, "");
dilcopy sp_restrict@function(SPL_LOCK, 50, 0, 25, "");
dilcopy weap_restrict@function(WPN_BATTLE_AXE, 50, 0, 25, "");

For more than one ability, add a line for each. An item for players with at least 50 divinity and 30 brains:

dilcopy abi_restrict@function(ABIL_DIV, 50, 0, 25, "");
dilcopy abi_restrict@function(ABIL_BRA, 30, 0, 25, "");
The *_RESTRICT macros

values.h also has macros such as LEVEL_RESTRICT(...) and ABILITY_RESTRICT(...). They only add a hidden extra to the item, and nothing in the current game reads those extras, so they restrict nothing. Use the functions above.

Tuborg

tuborg@function turns a drink into a Tuborg that gives endurance:

dilcopy tuborg@function("");

The argument isn't used; give it an empty string. Put it on a drink container (made with a LIQ_* macro, the liquid's name last in its names). When a player drinks from it, the whole container is emptied in one go: the player's thirst and fullness go up by 5 (to at most 24) and his endurance by 25 (to at most his maximum). A player whose thirst is above 20 is told "You are not thirsty."; sip and taste only give a message. After one drink the function ends, so a refilled container is an ordinary drink again.

Message board

Boards let players and administrators leave messages for each other. A board is an object with board@boards on it, from boards.zon:

dilbegin board(idxfile : string, l_res : string, r_res : string, p_res : string, bmax : integer);

The function makes the object an ITEM_BOARD itself. Players look at the board for the list of posts, and use read, write, reply and remove.

idxfile
The name the posts are saved under. Every board with the same name shows the same posts, so choose a name no other board uses, unless you want two boards to share their posts. The function also adds this name to the board's names.
l_res
Who may look at the board and read its posts: the name of a DIL function, or "" for everyone.
r_res
Who may remove other players' posts: a function, or "" for everyone. A player can always remove his own posts.
p_res
Who may post: a function, or "" for every player of level 10 or higher.
bmax
How many posts the board holds. When it is full, a player who tries to write is told "The board is full."

The three checks are DIL functions that get the player and the board and return a string: "" to allow, or the message to show when the player isn't allowed. boards.zon has two:

// only administrators (level 200 and up)
dilbegin string admin_res(u : unitptr, v : unitptr);

// administrators, and players who have the quest "Valhalla Editor"
dilbegin string rem_res(u : unitptr, v : unitptr);

Use admin_res to keep a board for administrators and rem_res to let only administrators clean a public board. A function of your own needs the same arguments and return type, and its name as "name@zone".

A board where anyone can read, post and remove, for 50 posts:

dilcopy board@boards("free", "", "", "", 50);

A board everyone can read and post on, where only administrators remove other people's posts:

dilcopy board@boards("citizen", "", "rem_res@boards", "", 100);

A board only administrators can use at all:

dilcopy board@boards("wizard", "admin_res@boards", "admin_res@boards",
                     "admin_res@boards", 100);

A complete board object is on More complex objects.

Blowaway

blowaway@function(seconds, message) makes an object disappear when it has been lying on the floor for a while. Every seconds seconds it looks where the object is; if it is lying in a room, the room sees the message and the object is destroyed. Carried, or inside a container, it is left alone until the next look. In the message, $1n is the object.

dilcopy blowaway@function(120, "$1n is eaten by a passing mouse.");
Previous: Compiling and Debugging your first object
Next: More complex objects