Scriptable.html
guides/Scriptable.html · 714.0 KB
From the archive CoffeeMud_5_2_11.zip
Download the archive « Back to the archive contents
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Scripting in CoffeeMud 5.2</title>
<link rel="StyleSheet" href="style.css" type="text/css" media="screen" />
<!-- Modified by Josh Mueller, 2006-05-05, fix validation problems, add index, and fix spelling errors --><!-- Modified by Josh Mueller, 2006-05-06, add close_prog, lock_prog, unlock_prog, open_prog -->
</head>
<body>
<center>
<table border="1" bordercolor="gray" cellpadding="10" cellspacing="0" width="90%">
<tbody>
<tr>
<td colspan="2" align="left" bgcolor="#dfdfdf" width="100%">
<h1>Scripting in CoffeeMud 5.2</h1>
</td>
</tr>
<tr>
<td align="left" valign="top" width="20%">
<ul>
<li><a href="#introduction">Introduction</a></li>
<li><a href="#structure">Script Structure</a></li>
<li><a href="#events">Scripting Events</a>
<ul>
<li><a href="#all_greet_prog">all_greet_prog</a></li>
<li><a href="#act_prog">act_prog</a></li>
<li><a href="#mask_prog">mask_prog</a></li>
<li><a href="#bribe_prog">bribe_prog</a></li>
<li><a href="#buy_prog">buy_prog</a></li>
<li><a href="#channel_prog">channel_prog</a></li>
<li><a href="#close_prog">close_prog</a></li>
<li><a href="#cnclmsg_prog">cnclmsg_prog</a></li>
<li><a href="#consume_prog">consume_prog</a></li>
<li><a href="#damage_prog">damage_prog</a></li>
<li><a href="#day_prog">day_prog</a></li>
<li><a href="#death_prog">death_prog</a></li>
<li><a href="#delay_prog">delay_prog</a></li>
<li><a href="#drop_prog">drop_prog</a></li>
<li><a href="#entry_prog">entry_prog</a></li>
<li><a href="#execmsg_prog">execmsg_prog</a></li>
<li><a href="#exit_prog">exit_prog</a></li>
<li><a href="#fight_prog">fight_prog</a></li>
<li><a href="#function_prog">function_prog</a></li>
<li><a href="#get_prog">get_prog</a></li>
<li><a href="#give_prog">give_prog</a></li>
<li><a href="#greet_prog">greet_prog</a></li>
<li><a href="#hitprcnt_prog">hitprcnt_prog</a></li>
<li><a href="#imask_prog">imask_prog</a></li>
<li><a href="#kill_prog">kill_prog</a></li>
<li><a href="#level_prog">level_prog</a></li>
<li><a href="#lock_prog">lock_prog</a></li>
<li><a href="#login_prog">login_prog</a></li>
<li><a href="#logoff_prog">logoff_prog</a></li>
<li><a href="#llook_prog">llook_prog</a></li>
<li><a href="#look_prog">look_prog</a></li>
<li><a href="#once_prog">once_prog</a></li>
<li><a href="#open_prog">open_prog</a></li>
<li><a href="#quest_time_prog">quest_time_prog</a></li>
<li><a href="#put_prog">put_prog</a></li>
<li><a href="#rand_prog">rand_prog</a></li>
<li><a href="#regmask_prog">regmask_prog</a></li>
<li><a href="#remove_prog">remove_prog</a></li>
<li><a href="#social_prog">social_prog</a></li>
<li><a href="#sell_prog">sell_prog</a></li>
<li><a href="#speech_prog">speech_prog</a></li>
<li><a href="#time_prog">time_prog</a></li>
<li><a href="#unlock_prog">unlock_prog</a></li>
<li><a href="#wear_prog">wear_prog</a></li>
</ul>
</li>
<li><a href="#codes">Scripting Codes</a>
<ul>
<li><a href="#dollarCode">$ codes</a></li>
<li><a href="#percentCode">% codes</a></li>
</ul>
</li>
<li><a href="#commands">Scripting Commands</a>
<ul>
<li><a href="#if">if, else, endif</a></li>
<li><a href="#switch">switch, case</a></li>
<li><a href="#for">for, next</a></li>
<li><a href="#script"><SCRIPT></a></li>
<li><a href="#mpaffect">mpaffect</a></li>
<li><a href="#mpalarm">mpalarm</a></li>
<li><a href="#mpargset">mpargset</a></li>
<li><a href="#mpasound">mpasound</a></li>
<li><a href="#mpat">mpat</a></li>
<li><a href="#mpbeacon">mpbeacon</a></li>
<li><a href="#mpbehave">mpbehave</a></li>
<li><a href="#mpcallfunc">mpcallfunc</a></li>
<li><a href="#mpcast">mpcast</a></li>
<li><a href="#mpchannel">mpchannel</a></li>
<li><a href="#mpclose">mpclose</a></li>
<li><a href="#mpdisable">mpdisable</a></li>
<li><a href="#mpecho">mpecho</a></li>
<li><a href="#mpechoaround">mpechoaround</a></li>
<li><a href="#mpechoat">mpechoat</a></li>
<li><a href="#mpenable">mpenable</a></li>
<li><a href="#mpendquest">mpendquest</a></li>
<li><a href="#mpexp">mpexp</a></li>
<li><a href="#mpfaction">mpfaction</a></li>
<li><a href="#mpforce">mpforce</a></li>
<li><a href="#mpplayerclass">mpplayerclass</a></li>
<li><a href="#mpgoto">mpgoto</a></li>
<li><a href="#mpgset">mpgset</a></li>
<li><a href="#mphide">mphide</a></li>
<li><a href="#mpjunk">mpjunk</a></li>
<li><a href="#mpkill">mpkill</a></li>
<li><a href="#mploadquestobj">mploadquestobj</a></li>
<li><a href="#mploadvar">mploadvar</a></li>
<li><a href="#mplock">mplock</a></li>
<li><a href="#mplog">mplog</a></li>
<li><a href="#mpm2i2m">mpm2i2m</a></li>
<li><a href="#mpmload">mpmload</a></li>
<li><a href="#mpnotrigger">mpnotrigger</a></li>
<li><a href="#mpoload">mpoload</a></li>
<li><a href="#mpoloadroom">mpoloadroom</a></li>
<li><a href="#mpopen">mpopen</a></li>
<li><a href="#mppracs">mppracs</a></li>
<li><a href="#mppurge">mppurge</a></li>
<li><a href="#questpoints">mpquestpoints</a></li>
<li><a href="#mpquestwin">mpquestwin</a></li>
<li><a href="#mpqset">mpqset</a></li>
<li><a href="#mpreset">mpreset</a></li>
<li><a href="#mpsavevar">mpsavevar</a></li>
<li><a href="#mpset">mpset</a></li>
<li><a href="#mpsetclandata">mpsetclandata</a></li>
<li><a href="#mpsetvar">mpsetvar</a></li>
<li><a href="#mpslay">mpslay</a></li>
<li><a href="#mpstartquest">mpstartquest</a></li>
<li><a href="#mpstop">mpstop</a></li>
<li><a href="#mptattoo">mptattoo</a></li>
<li><a href="#mptitle">mptitle</a></li>
<li><a href="#mptrackto">mptrackto</a></li>
<li><a href="#mptrains">mptrains</a></li>
<li><a href="#mptransfer">mptransfer</a></li>
<li><a href="#mpunaffect">mpunaffect</a></li>
<li><a href="#mpunbehave">mpunbehave</a></li>
<li><a href="#mpunhide">mpunhide</a></li>
<li><a href="#mpunloadscript">mpunloadscript</a></li>
<li><a href="#mpunlock">mpunlock</a></li>
<li><a href="#mpwhile">mpwhile</a></li>
<li><a href="#mpwalkto">mpwalkto</a></li>
<li><a href="#return">return</a></li>
</ul>
</li>
<li><a href="#functions">Scripting Functions</a>
<ul>
<li><a href="#logicalOperators">Logical
Operators</a></li>
<li><a href="#affected">affected</a></li>
<li><a href="#baseclass">baseclass</a></li>
<li><a href="#callfunc">callfunc</a></li>
<li><a href="#clan">clan</a></li>
<li><a href="#clandata">clandata</a></li>
<li><a href="#clanrank">clanrank</a></li>
<li><a href="#class">class</a></li>
<li><a href="#currency">currency</a></li>
<li><a href="#deity">deity</a></li>
<li><a href="#eval">eval</a></li>
<li><a href="#exp">exp</a><br />
</li>
<li><a href="#explored">explored</a></li>
<li><a href="#faction">faction</a></li>
<li><a href="#goldamt">goldamt</a></li>
<li><a href="#gstat">gstat</a></li>
<li><a href="#has">has</a></li>
<li><a href="#hasnum">hasnum</a></li>
<li><a href="#hastattoo">hastattoo</a></li>
<li><a href="#hitprcnt">hitprcnt</a></li>
<li><a href="#incontainer">incontainer</a></li>
<li><a href="#inlocale">inlocale</a></li>
<li><a href="#inroom">inroom</a></li>
<li><a href="#ipaddress">ipaddress</a></li>
<li><a href="#isable">isable</a></li>
<li><a href="#isalive">isalive</a></li>
<li><a href="#isbehave">isbehave</a></li>
<li><a href="#isbirthday">isbirthday</a></li>
<li><a href="#ischarmed">ischarmed</a></li>
<li><a href="#isday">isday</a></li>
<li><a href="#isevil">isevil</a></li>
<li><a href="#isfight">isfight</a></li>
<li><a href="#isfollow">isfollow</a></li>
<li><a href="#isgood">isgood</a></li>
<li><a href="#ishere">ishere</a></li>
<li><a href="#isimmort">isimmort</a></li>
<li><a href="#islike">islike</a></li>
<li><a href="#islocked">islocked</a></li>
<li><a href="#ismoon">ismoon</a></li>
<li><a href="#isname">isname</a></li>
<li><a href="#isnpc">isnpc</a></li>
<li><a href="#isopen">isopen</a></li>
<li><a href="#ispc">ispc</a></li>
<li><a href="#ispkill">ispkill</a></li>
<li><a href="#isquestmobalive">isquestmobalive</a></li>
<li><a href="#isrecall">isrecall</a></li>
<li><a href="#isseason">isseason</a></li>
<li><a href="#isservant">isservant</a></li>
<li><a href="#istime">istime</a></li>
<li><a href="#isweather">isweather</a></li>
<li><a href="#level">level</a></li>
<li><a href="#math">math</a><br />
</li>
<li><a href="#mobitem">mobitem</a></li>
<li><a href="#mood">mood</a></li>
<li><a href="#number">number</a></li>
<li><a href="#numitemsmob">numitemsmob</a></li>
<li><a href="#numitemsroom">numitemsroom</a></li>
<li><a href="#nummobs">nummobs</a></li>
<li><a href="#nummobsinarea">nummobsinarea</a></li>
<li><a href="#nummobsroom">nummobsroom</a></li>
<li><a href="#numpcsarea">numpcsarea</a></li>
<li><a href="#numpcsroom">numpcsroom</a></li>
<li><a href="#numraces">numraces</a></li>
<li><a href="#numracesinarea">numracesinarea</a></li>
<li><a href="#position">position</a></li>
<li><a href="#pracs">pracs</a></li>
<li><a href="#questitem">questitem</a></li>
<li><a href="#questmob">questmob</a></li>
<li><a href="#questpoints">questpoints</a></li>
<li><a href="#questwinner">questwinner</a></li>
<li><a href="#qvar">qvar</a></li>
<li><a href="#race">race</a></li>
<li><a href="#racecat">racecat</a></li>
<li><a href="#rand">rand</a></li>
<li><a href="#rand0num">rand0num</a></li>
<li><a href="#randnum">randnum</a></li>
<li><a href="#roomitem">roomitem</a></li>
<li><a href="#roommob">roommob</a></li>
<li><a href="#sex">sex</a></li>
<li><a href="#stat">stat</a></li>
<li><a href="#strcontains">strcontains</a></li>
<li><a href="#strin">strin</a></li>
<li><a href="#trains">trains</a></li>
<li><a href="#value">value</a></li>
<li><a href="#var">var</a></li>
<li><a href="#worn">worn</a></li>
</ul>
</li>
</ul>
</td>
<td align="left" valign="top">
<p class="center"> <img src="images/mug.jpg" alt="coffeemud logo" />
</p>
<h2> <a name="introduction">Introduction to Scripting</a>
</h2>
<p> Scripting is the ability to makes something behave proactively,
or respond to game stimuli, in a way specified by the game
builders. A Script is the set of commands written by the builders
to perform this function. In CoffeeMud, any object may be scripted.
This means that rooms, areas, items, and especially MOBs can be scripted.
</p>
<p> Scripting is accomplished through the Scriptable Behavior.
Giving an object this behavior makes it capable of running scripts
on its behalf. The parameters of the Scriptable behavior define
the source of the script itself. </p>
<p> The most common parameter for the Scriptable behavior is
the LOAD command, which specifies a text file containing the script.
The syntax for this is as follows: </p>
<pre>load=path/file name<br /></pre>
<p> The starting path for the Scriptable behavior is the <span style="font-family: monospace; font-weight: bold;">/resources/</span>
directory in your CoffeeMud package. Any further paths will branch
from that directory. The file specified is a text file containing
the script. You can also specify more than one script in the Scriptable
parameters by separating LOAD= commands with the ~ character like so:
</p>
<pre>load=progs/mrinfo.script~load=progs/strangetrader.script~</pre>
<p> A less common way to specify a script for the Scriptable
behavior is to enter the script itself into the parameter. Scripts
entered in this way differ from scripts entered into text files for
the LOAD parameter in one significant sense: Every line of a script
entered in this way must be terminated by a semicolon. Here is an
example. </p>
<pre>RAND_PROG 50;bounce;say "hi!";~;<br /></pre>
<p> Scripts which are entered into text files for the LOAD parameter
have their lines terminated by carriage returns (ENTER) instead
of semicolons. The script syntax is, in all other ways, identical.
If you need to put special characters (like ; ~ or LOAD=) into
particular commands, you may need to escape those characters by
putting a \ character before them, to tell the Scriptable behavior
not to consider them line or script delimiters. </p>
<p> When the Scriptable behavior loads a file using the LOAD=
syntax, it automatically keeps a copy of it in memory for future
use. This memory cache is called the CoffeeMud Resources. If you
have a Scriptable prog you have entered using the LOAD= syntax, you
can see its entry in the cache by using your Archon character to
enter LIST RESOURCES from the CoffeeMud command line. Because the
script files from disk are kept in memory for quick access, any
changes or additions to your script on disk will not be immediately
noticed by the CoffeeMud engine. To force the engine to notice your
changes, you must first UNLOAD your script file from the Resources
cache. This is done by using the Archon command UNLOAD. Check the ahelp
entry for that command for more information on how to use it when
developing Scriptable behavior files on disk. </p>
<p> Those who are familiar with the mobprog scripting language
in other mud codebases will have no trouble picking up on the
CoffeeMud scripting language. In fact, most of your existing
scripts will probably work without changes. </p>
<h2> <a name="structure">Script Structure</a> </h2>
<p> The CoffeeMud scripting language is an "event-based" language.
Each script may contain one or more event "triggers". Each
trigger defines the conditions of its occurrence on a single line.
This line is followed by commands underneath it which are executed
only when the trigger event occurs. Each event trigger/command grouping
is terminated by a ~ character, which should appear on a line by
itself. Putting this together, we have a high level syntax that looks
like this: </p>
<pre>EVENT_TRIGGER parameter1 parameter2 ...<br />command1<br />command2<br />...<br />commandN<br />~<br /><br />ANOTHER_EVENT_TRIGGER parameter1 parameter2 ...<br />command1<br />command2<br />...<br />commandN<br />~<br />etc.<br /></pre>
<h2> <a name="events">Scripting Events</a> </h2>
<p> Below are a list of the valid event triggers, along with
their parameters, and a description of the events or circumstances
under which the events occur. These docs borrow heavily from the
nicely written MOBPROG Tutorial at: <a href="http://aoc.pandapub.com/home.shtml">http://www.pandapub.com/tutorial/MobprogTutorial.htm</a>.
</p>
<h3><a name="all_greet_prog">all_greet_prog</a></h3>
<p> Usage: </p>
<pre>all_greet_prog [integer percentage]<br /></pre>
<p> This type of mobprog checks a percentage chance every time
someone enters the room that the mob is currently in. If the
random number generated between 1 and 100 is equal to or below
the percentage of the all_greet_prog, the prog is triggered. Note
that all_greet_progs are triggered by both players and mobs, and
a mob in a maze can actually sometimes end up triggering itself!
This type of mobprog has all sorts of uses, ranging from giving in-zone
quest information to people entering the room, creating aggressive
progs, etc. </p>
<p> EXAMPLES: </p>
<pre>all_greet_prog 25<br /></pre>
<p> This prog will be triggered 25% of the time when someone enters
the room where the mob currently is. </p>
<pre>all_greet_prog 100<br /></pre>
<p> This prog will be triggered 100% of the time when someone
enters the room where the mob currently is. This means every time.
</p>
<p> SPECIAL NOTES: You'll probably want to do a large number
of if checks in all_greet_progs, specifically in the difference between
mobs and player characters. Note that all_greet_progs will
trigger even if a person is sneaking, though the mob must have detect
invisibility to see invisible people, infravision to see people
in the dark, sense sneaking to see sneakers, and will not see people
if blinded. </p>
<h3><a name="act_prog">act_prog</a></h3>
<h3><a name="mask_prog">mask_prog</a></h3>
<p> Usage:<br />
</p>
<pre>act_prog [trigger message]<br />act_prog p [trigger message]<br /></pre>
<p> This type of mobprog will trigger when the mob sees a certain
string of text. When the 'p' is inserted into the trigger line,
the string of text must be precise, while if it is not, any of
the words in the list can trigger the mobprog. This type of mobprog
has many uses, one of which is communication between mobs. There
are a few socials which create a message only to the person performing
them and to the one receiving them. You can use these and act_progs
to safely have mobs trigger each other, without people seeing what
is going on. Other uses include triggering off of people fleeing, moving
out of the room, etc. The possibilities are endless. </p>
<p> EXAMPLES: </p>
<pre>act_prog wolf dog coyote<br /></pre>
<p> This will trigger whenever the mob sees a segment of
text containing any of the words wolf, dog, or coyote. If the
string contains more than one of these, the prog will be triggered
multiple times. </p>
<pre>act_prog p A wolf howls at the moon.<br /></pre>
<p> This will trigger the prog when it sees this precise
message. Note that punctuation is important here as well.
</p>
<p> MULTIPLE PROGS: You can have more than one act_prog on a
mob, but you shouldn't have multiple act_progs that trigger off of
the same message. </p>
<p> SPECIAL NOTES: ANSI colors on objects don't seem to work
well with act_progs, so avoid using ANSI colors in anything that may
be part of your act_prog trigger. Variables and Codes are not
used in act_progs, so do not try to use them; it won't work. </p>
<h3><a name="bribe_prog">bribe_prog</a></h3>
<p> Usage: </p>
<pre>bribe_prog [money value]<br /></pre>
<p> This type of mobprog is triggered when a value of money is
given to the mob. If the amount of money is equal to or more than
the money value of the bribe_prog, the prog will go off. If it
is less than the value of the bribe_prog, or the money is not in
the local currency, it will not go off. This type of prog is normally
used for in-zone quests, perhaps bribing guards to let a prisoner
free or bribing a bartender to give you some information. It can
also be used for larger, special mob behavior, such as a ferryman
who will move a player to another spot in the world for a fee. The
money value is always expressed in absolute gold value of the default
currency. See the Archon's Guide under currency if you don't know what
that means. </p>
<p> EXAMPLES: </p>
<pre>bribe_prog 1<br /></pre>
<p> This bribe_prog will trigger whenever the mob is given
an amount of gold equal to or greater than 1 coin. Of course,
this means that the prog will be triggered if any amount of money
is given to the mob at all. </p>
<pre>bribe_prog 500<br /></pre>
<p> This bribe_prog will trigger if someone gives the mob
an amount of money equal to or greater than 500 coins.) </p>
<p> MULTIPLE PROGS: You can have multiple bribe_progs on the
same mob. However, these must be listed in order from largest gold
amount to smallest gold amount. So if you have a bribe_prog 250
and a bribe_prog 100, the 250 must be listed first, and then the
100. If you don't do this your larger sum bribe_progs will never be
triggered. </p>
<h3><a name="buy_prog">buy_prog</a></h3>
<p> Usage: </p>
<pre>buy_prog [keyword list]<br />buy_prog p [keyword phrase]<br />buy_prog all<br /></pre>
<p> This type of mobprog is triggered by buying an item from
a shopkeeper. If the item being bought has any of the keywords of
the buy_prog, the prog is triggered. If there is a ‘p' placed
before the keyword list, the keywords of the item must exactly match
that of the buy_prog. If there is not, then any item with any of the
keywords in the list in it will trigger it. If a buy_prog all is used,
then the buy_prog will trigger for any item at all being bought. This
type of prog is usually used for in-zone quests and special mob behavior,
and has a variety of uses. </p>
<p> EXAMPLES: </p>
<pre>buy_prog orange apple banana<br /></pre>
<p> This will trigger if the item being bought has any
of the keywords orange, apple, or banana. This means that it would
be triggered by buying a banana, an apple pie, or even an orange shield.
</p>
<pre>buy_prog p apple pie delicious<br /></pre>
<p> This will trigger if the item being bought has the
exact keywords apple pie delicious. The prog would not be triggered
by buying anything with keywords red apple or blackberry pie or anything
except the exact order and wording of the keyword list. </p>
<pre>buy_prog all<br /></pre>
<p> This will trigger if any sort of item is bought. </p>
<p> MULTIPLE PROGS: You can have more than one buy_prog on a
mob. Generally it is best not to have buy_progs with the same keywords
in them, unless they are a buy_prog p with different keyword
lists but some of the same keywords – for example a buy_prog p apple
red juicy and a buy_prog p apple red poisoned. </p>
<h3><a name="channel_prog">channel_prog</a></h3>
<p> Usage: </p>
<pre>channel_prog [channel name] [trigger words]<br />channel_prog [channel name] p [trigger message]<br /></pre>
<p> This type of mobprog will trigger when the mob sees a certain
string of text over the specified channel. When the 'p' is
inserted into the trigger line, the string of text must be precise,
while if it is not, any of the words in the list can trigger the
mobprog. This type of mobprog has many uses, one of which is communication
between mobs. The possibilities are endlessly finite. </p>
<p> EXAMPLES: </p>
<pre>channel_prog help me<br /></pre>
<p> This will trigger whenever the mob sees a segment of
text containing any of the words help or me. If the string contains
more than one of these, the prog will be triggered multiple times.
</p>
<pre>channel_prog p GOSSIP hello.<br /></pre>
<p> This will trigger the prog when it sees this message
channeled. Note that punctuation is important here as well.
</p>
<p> MULTIPLE PROGS: You can have more than one channel_prog on
a mob, but you shouldn't have multiple channel_progs that trigger
off of the same message. </p>
<p> SPECIAL NOTES: ANSI colors on objects don't seem to work
well with channel_progs, so avoid using ANSI colors in anything that
may be part of your channel_prog trigger. Variables and Codes are
not used in channel_progs, so do not try to use them; it won't
work. </p>
<h3><a name="close_prog">close_prog</a></h3>
<p>Usage:</p>
<pre>close_prog [keyword list]<br />close_prog p [keyword list]<br />close_prog all<br /></pre>
<p> This type of mobprog is triggered by closing a container or door.
If the script is on a container-type object, such as a door or container
item, it will trigger only if the object being closed is the scripted
one. Otherwise, if the target matches the keywords of the close_prog,
the prog is triggered. If there is a 'p' placed before the keyword list,
the keywords of the object must exactly match that of the close_prog.
If there is not, then any object with any of the keywords in the list
in it will trigger it. If the scripted item is not a container or door,
and a "close_prog all" is used, then the close_prog will trigger from any
object at all being opened. This type of prog is usually used for in-zone
quests and special mob behavior, and has a variety of uses. As is normal,
if the scripted object is a mob, this event will not trigger if the scripted
mob is the originator of the activity.</p>
<p>EXAMPLES:</p>
<pre>close_prog door gate<br /></pre>
<p> This will trigger if the object closed has any of the keywords
door gate. This means that it would be triggered by closing a door or gate.</p>
<pre>close_prog p a large chest<br /> </pre>
<p> This will trigger if the object closed has the exact keywords a
large chest.. The prog would not be triggered by closing an object with keywords
large or chest or anything except the exact order and wording of the keyword
list. </p>
<pre>close_prog all <br /></pre>
<p> This will trigger if any object is closed. </p>
<p>MULTIPLE PROGS: You can have more than one close_prog on an item,
mob, or room. Generally it is best not to have close_progs with the
same keywords in them, unless they are a close_progs p with different
keyword lists but some of the same keywords - for example a close_progs
p door gate and a close_prog p door to the gate.
</p>
<h3><a name="cnclmsg_prog">cnclmsg_prog</a></h3>
<p>Usage:</p>
<pre>cnclmsg_prog [message code] [commands/keyword list]<br />cnclmsg_prog [message code] p [commands/keyword list]<br />cnclmsg_prog [message code] all</pre>
<p>This type of mobprog is definitely for those very familiar with CoffeeMud.
In fact, I'd recommend at least a cursory knowledge of the Programmer's
Guide to consider using it. The purpose of this trigger is that it
executes before a particular event or "message" occurs in the mud. The kind
of event is called the "message code". The trigger also requires either
the word "all" to always execute before the desired message does, or a list
of player command line words matches those typed by the player most recently
to the arrival of this message. Since mobs, unlike players, do not
enter commands on a command line, you should use the ALL form liberally.</p>
<p>The body of the trigger executes before the given message occurs,
and the fact that the trigger executes is no guarentee that the event will
end up occuring at all. For instance, this trigger may execute when
a player tries to leave the room while under the effects of the "Hold"
spell, meaning the player will not actually be allowed to leave regardless
of what is done in your trigger. However, this type of trigger is
most useful as a means of testing and cancelling certain types of event
messages; thus the name. To cause the triggered event to be cancelled, you
need only add a RETURN CANCEL command to the body of this script.</p>
<p>See also <span style="font-weight: bold;">execmsg_prog</span>. Valid
message codes include the following:</p>
<span style="font-family: monospace;">AREAAFFECT, PUSH,
PULL, RECALL, OPEN, CLOSE, PUT, GET, UNLOCK, LOCK, WIELD, GIVE, BUY, SELL,
DROP, WEAR, FILL, DELICATE_HANDS_ACT, VALUE, HOLD, NOISYMOVEMENT, QUIETMOVEMENT,
WEAPONATTACK, LOOK, READ, NOISE, SPEAK, CAST_SPELL, LIST, EAT, ENTER, FOLLOW,
LEAVE, SLEEP, SIT, STAND, FLEE, NOFOLLOW, WRITE, FIRE, COLD, WATER, GAS,
MIND, GENERAL, JUSTICE, ACID, ELECTRIC, POISON, UNDEAD, MOUNT, DISMOUNT,
OK_ACTION, OK_VISUAL, DRINK, HANDS, PARALYZE, WAND_USE, SERVE, REBUKE,
ADVANCE, DISEASE, DEATH, DEPOSIT, WITHDRAW, EMOTE, QUIT, SHUTDOWN, VIEW,
RETIRE, RETREAT,PANIC, THROW, EXTINGUISH, TELL, SITMOVE, KNOCK, PRACTICE,
TEACH, REMOVE, EXPCHANGE, DAMAGE, HEALING, ROOMRESET, RELOAD, SNIFF, ACTIVATE,
DEACTIVATE, FACTIONCHANGE, LOGIN, LEVEL, EXAMINE, ORDER, EXPIRE, BORROW,
HUH</span>
<p>And here are some general message code types that may also be used:<br />
</p>
<span style="font-family: monospace;">TOUCH,MOVE,EYES,MOUTH,SOUND,GENERAL,MAGIC,DELICATE,MALICIOUS,CHANNEL,OPTIMIZE</span>
<p>EXAMPLES:</p>
<pre>cnclmsg_prog hands p smile<br /> mpechoat $n No smiling is allowed here!<br /> return cancel<br />~<br /></pre>
<p> This will trigger if a player (not a mob) around the scripted object
attempts to smile.</p>
<pre>cnclmsg_prog GET p get rock<br /> mpechoat $n You may not get the rock.<br /> return cancel<br />~<br /></pre>
<p>This will trigger if a player (not a mob) enters the command
"get rock" at the command line, this will trigger and cancel he attempt..
</p>
<p>The CNCLMSG_PROG is especially useful for creating new command that
only apply in particular rooms or with respect to particular mobs. This
is because entering an incorrect command, which normally generates a "Huh?"
message, can also be canceled and re-applied. For instance, suppose
you wanted users to be able to enter "plastify sword" at some part in
your quest and have it do something. In this case, you'd need to
capture the HUH message as so:<br />
</p>
<pre>cnclmsg_prog HUH p plastify sword<br /> mpechoat $n The sword has been plastified! Thank you!<br /> return cancel<br />~<br /></pre>
<p>MULTIPLE PROGS: You can have more than one cnclmsg_prog, not only
in the same script, but regarding the very same message codes if you like.</p>
<h3><a name="consume_prog">consume_prog</a></h3>
<p> Usage: </p>
<pre>consume_prog [keyword list]<br />consume_prog p [keyword list]<br />consume_prog all<br /></pre>
<p> This type of mobprog is triggered eating or drinking from
an object. If the object used matches the keywords of the
consume_prog, the prog is triggered. If there is a ‘p' placed
before the keyword list, the keywords of the object must exactly
match that of the consume_prog. If there is not, then any object
with any of the keywords in the list in it will trigger it. If a
consume_prog all is used, then the consume_prog will trigger from
any object at all. This type of prog is usually used for in-zone
quests and special mob behavior, and has a variety of uses. </p>
<p> EXAMPLES: </p>
<pre>consume_prog orange apple banana<br /></pre>
<p> This will trigger if the object eaten has any of the
keywords orange, apple, or banana. This means that it would be
triggered by eating a banana, an apple pie, or even an orange shield.
</p>
<pre>consume_prog p apple pie delicious<br /></pre>
<p> This will trigger if the object eaten has the exact
keywords apple pie delicious. The prog would not be triggered
by eating an object with keywords red apple or blackberry pie or
anything except the exact order and wording of the keyword list.
</p>
<pre>consume_prog all<br /></pre>
<p> This will trigger if any object is ate or drank. </p>
<p> MULTIPLE PROGS: You can have more than one consume_prog on
a mob. Generally it is best not to have consume_progs with the
same keywords in them, unless they are a consume_prog p with different
keyword lists but some of the same keywords – for example a
consume_prog p apple red juicy and a consume_prog p apple red poisoned.
</p>
<h3><a name="damage_prog">damage_prog</a></h3>
<p> Usage: </p>
<pre>damage_prog<br /></pre>
<p> This type of mobprog is triggered whenever the scripted mob
is damaged, or the scripted item is used to deliver damage. The
source and target mobs will be as you expect. The secondary item
will be the weapon used to deliver the damage, if it was a physical
item (spells are not items). The string returned in $g will be
the amount of damage taken. </p>
<p> EXAMPLES: </p>
<pre>damage_prog<br /></pre>
<p> This program will trigger when damage is taken by a
mob, or given by the scripted item. </p>
<h3><a name="day_prog">day_prog</a></h3>
<p> Usage: </p>
<pre>day_prog [list of integer day of the month]<br /></pre>
<p> This type of mobprog triggers once per mud day, on the days
of the month listed. This allows you to have a script which triggers
very infrequently indeed. There are 30 days per month in
CoffeeMud. </p>
<p> EXAMPLES: </p>
<pre>day_prog 20 21 22<br /></pre>
<p> This will trigger if day of the month is 20, 21, or 22.
</p>
<pre>day_prog 10<br /></pre>
<p> This will trigger on the 10th day of every month. </p>
<h3><a name="death_prog">death_prog</a></h3>
<p> Usage: </p>
<pre>death_prog<br /></pre>
<p> This mobprog type triggers on the mob's death. The death_prog
has a wide range of uses. The death_prog is queued just before
the mob dies, so it is considered to be the mob's last gasp. At
the end of the death-prog, however, the mob dies. Even if the mob
sets its hit points to full, it will die. Other than that, the
mob can mpjunk equipment it has, mpgoto a new room to die, unlock
a door, load an object of some kind, etc. </p>
<p> MULTIPLE PROGS: You can have multiple death_progs on the
same mob. </p>
<h3><a name="delay_prog">delay_prog</a></h3>
<p> Usage: </p>
<pre>delay_prog [integer, minimum number of ticks] [integer, maximum number of ticks]<br /></pre>
<p> This kind of mobprog triggers after a random number of ticks
have elapsed. The number of random ticks is between the two integers
provided. This trigger is used to take some of the load off of
rand_prog type programs. </p>
<p> EXAMPLES: </p>
<pre>delay_prog 10 20<br /></pre>
<p> This delay_prog will be triggered after 10-20 ticks have
elapsed. </p>
<pre>delay_prog 1 11<br /></pre>
<p> This delay_prog will be triggered after 1-11 ticks have elapsed.
</p>
<h3><a name="drop_prog">drop_prog</a></h3>
<p> Usage: </p>
<pre>drop_prog [keyword list]<br />drop_prog p [keyword list]<br />drop_prog all<br /></pre>
<p> This type of mobprog is triggered by dropping an object.
If the object dropped matches the keywords of the drop_prog, the prog
is triggered. If there is a ‘p' placed before the keyword list, the
keywords of the object must exactly match that of the drop_prog.
If there is not, then any object with any of the keywords in the
list in it will trigger it. If a drop_prog all is used, then the
drop_prog will trigger from any object at all being dropped. This
type of prog is usually used for in-zone quests and special mob behavior,
and has a variety of uses. </p>
<p> EXAMPLES: </p>
<pre>drop_prog orange apple banana<br /></pre>
<p> This will trigger if the object dropped has any of
the keywords orange, apple, or banana. This means that it would be
triggered by dropping a banana, an apple pie, or even an orange shield.
</p>
<pre>drop_prog p apple pie delicious<br /></pre>
<p> This will trigger if the object dropped has the exact
keywords apple pie delicious. The prog would not be triggered
by dropping an object with keywords red apple or blackberry pie
or anything except the exact order and wording of the keyword list.
</p>
<pre>drop_prog all<br /></pre>
<p> This will trigger if any object is dropped. </p>
<p> MULTIPLE PROGS: You can have more than one drop_prog on a
mob. Generally it is best not to have drop_progs with the same
keywords in them, unless they are a drop_prog p with different
keyword lists but some of the same keywords – for example a drop_prog
p apple red juicy and a drop_prog p apple red poisoned. </p>
Showing the first 100 KB of 714.0 KB. Download the archive for the full file.