<!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> <h3><a name="entry_prog">entry_prog</a></h3> <p> Usage: </p> <pre>entry_prog [integer percentage]<br /></pre> <p> This type of prog checks a percentage chance every time the mob moves into a new room. If the random number generated is equal to or below the percentage of the entry_prog when the mob steps into a new room, then the prog is triggered. This prog has a variety of uses, for instance, you can use it in conjunction with the inroom function to make sure a mob stays in the same room or never oversteps a boundary, or to have the mob attack players as it enters the room. There are many possibilities. </p> <p> EXAMPLES: </p> <pre>entry_prog 25<br /></pre> <p> This will trigger 25% of the time when the mob enters a room. </p> <pre>entry_prog 100<br /></pre> <p> This will trigger 100%, or every time, the mob enters a room.</p> <h3><a name="execmsg_prog">execmsg_prog</a></h3> <p>Usage:</p> <pre>execmsg_prog [message code] [commands/keyword list]<br />execmsg_prog [message code] p [commands/keyword list]<br />execmsg_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 while a particular and valid 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 whenever the desired message does, or a list of player command line words matching 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>See also <span style="font-weight: bold;">cnclmsg_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, BORROW</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>execmsg_prog get all<br /> mpecho $n likes $p.<br />~<br /></pre> <p> This will trigger if a player or a mob attempts to get something.</p> <pre>execmsg_prog GET p get rock<br /> mpecho $n has gotten a rock!<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. </p> <p>MULTIPLE PROGS: You can have more than one execmsg_prog, not only in the same script, but regarding the very same message codes if you like. However, only the first one that triggers will count.</p> <h3><a name="exit_prog">exit_prog</a></h3> <p> Usage: </p> <pre>exit_prog [integer percentage]<br /></pre> <p> This type of prog checks a percentage chance every time a mob moves out of a the room the scripted mob is in. If the random number generated is equal to or below the percentage of the exit_prog when the mob steps out of the room, then the prog is triggered. This prog has a variety of uses, for instance, you can use it in conjunction with the inroom function to make sure other mobs stay in the same room or never oversteps a boundary, or to have the mob attack remaining players when one leaves. There are many possibilities. </p> <p> EXAMPLES: </p> <pre>exit_prog 25<br /></pre> <p> This will trigger 25% of the time when a mob leaves the room. </p> <pre>exit_prog 100<br /></pre> <p> This will trigger 100%, or every time, a mob leaves the room. </p> <h3><a name="fight_prog">fight_prog</a></h3> <p> Usage: </p> <pre>fight_prog [integer percentage]<br /></pre> <p> This type of mobprog checks a percentage chance every round of combat that the mob is in. If the random number generated between 1 and 100 is equal to or less than the percentage of the fight_prog, then it will be triggered. This type of mobprog is generally used to have the mob do certain things in combat, for instance, cast spells or use skills. Sometimes it is used to ensure a mob doesn't fight at all, or to perform special, more complicated actions in combat. </p> <p> EXAMPLES: </p> <pre>fight_prog 10<br /></pre> <p> This will trigger 10% of the time each round of combat the mob is in. That means that it is probable that this mobprog will go off every 10 rounds or so, although it is not guaranteed to do so. </p> <pre>fight_prog 75<br /></pre> <p> This will trigger 75% of the time each combat round. That means it's a safe bet that the trigger will go off 3 out of every 4 rounds. </p> <h3><a name="function_prog">function_prog</a></h3> <p> Usage: </p> <pre>function_prog [string name of the function]<br /></pre> <p> This type of prog provides a named placeholder for the series of commands that follows. This type of mobprog is never independently triggered, but instead relys on one of the commands, MPCALLFUNC, to trigger it manually. The usefulness of doing this will become apparent in the discussion of MPCALLFUNC. </p> <p> EXAMPLES: </p> <pre>function_prog Destroy Everyone<br /></pre> <p> This will trigger only when called by MPCALLFUNC. </p> <h3><a name="get_prog">get_prog</a></h3> <p> Usage: </p> <pre>get_prog [keyword list]<br />get_prog p [keyword list]<br />get_prog all<br /></pre> <p> This type of mobprog is triggered by getting an object. If the object picked up matches the keywords of the get_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 get_prog. If there is not, then any object with any of the keywords in the list in it will trigger it. If a get_prog all is used, then the get_prog will trigger from any object at all being picked up. 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>get_prog orange apple banana<br /></pre> <p> This will trigger if the object picked up has any of the keywords orange, apple, or banana. This means that it would be triggered by getting a banana, an apple pie, or even an orange shield. </p> <pre> get_prog p apple pie delicious<br /> </pre> <p> This will trigger if the object picked up has the exact keywords apple pie delicious. The prog would not be triggered by getting an object with keywords red apple or blackberry pie or anything except the exact order and wording of the keyword list. </p> <pre>get_prog all<br /></pre> <p> This will trigger if any object is picked up. </p> <p> MULTIPLE PROGS: You can have more than one get_prog on a mob. Generally it is best not to have get_progs with the same keywords in them, unless they are a get_prog p with different keyword lists but some of the same keywords – for example a get_prog p apple red juicy and a get_prog p apple red poisoned. </p> <h3><a name="give_prog">give_prog</a></h3> <p> Usage: </p> <pre>give_prog [keyword list]<br />give_prog p [keyword list]<br />give_prog all<br /></pre> <p> This type of mobprog is triggered by the mob being given an object. If the object given to the mob matches the keywords of the give_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 give_prog. If there is not, then any object with any of the keywords in the list in it will trigger it. If a give_prog all is used, then the give_prog will trigger from any object at all being given to the mob. 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>give_prog orange apple banana<br /></pre> <p> This will trigger if the object given to the mob has any of the keywords orange, apple, or banana. This means that it would be triggered by being given a banana, an apple pie, or even an orange shield.) </p> <pre>give_prog p apple pie delicious<br /></pre> <p> This will trigger if the object given to the mob has the exact keywords apple pie delicious. The prog would not be triggered by being given an object with keywords red apple or blackberry pie or anything except the exact order and wording of the keyword list. </p> <pre>give_prog all<br /></pre> <p> This will trigger if any object is given to the mob. </p> <p> MULTIPLE PROGS: You can have more than one give_prog on a mob. Generally it is best not to have give_progs with the same keywords in them, unless they are a give_prog p with different keyword lists but some of the same keywords – for example a give_prog p apple red juicy and a give_prog p apple red poisoned. </p> <p> SPECIAL NOTES: More often than not, you'll want to remember to have the mob use the mpjunk command to get rid of the object given so people cannot steal the item back and use it again. It does depend on what you are doing of course, but it is something to keep in mind. It is also not a bad idea to have a give_prog all to have the mob drop items other than the ones it will accept in other give_progs. </p> <h3><a name="greet_prog">greet_prog</a></h3> <p> Usage: </p> <pre>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 greet_prog, the prog is triggered. Note that 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>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>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 greet_progs, specifically in the difference between mobs and player characters. Note that greet_progs will trigger except if a person is sneaking. Also, the mob must have detect invisibility to see invisible people, infravision to see people in the dark, and will not see people if blinded. </p> <h3><a name="hitprcnt_prog">hitprcnt_prog</a></h3> <p> Usage: </p> <pre>hitprcnt_prog [integer percentage]<br /></pre> <p> This type of mobprog checks every round of combat to see if the mob's hit points are equal to or under the percentage given to the hitprcnt_prog. This type of prog is used mainly to have the mob do something at a certain percentage of hit points. Keep in mind, however, that this prog will trigger EVERY round of combat in which the mob's hit points are under the percentage. So if you want the mob to do only one thing, you will have to set up the mobprog that way with if checks. </p> <p> EXAMPLES: </p> <pre>hitprcnt_prog 50<br /></pre> <p> This will trigger if the mob's hit points are 50% or under every round of combat. </p> <pre>hitprcnt_prog 100<br /></pre> <p> This will trigger if the mob's hit points are 100% or under every round of combat. This means, more or less, every round of combat the mob will ever be in.</p> <h3><a name="imask_prog">imask_prog</a></h3> <p> Usage:<br /> </p> <pre>imask_prog [trigger message]<br />imask_prog p [trigger message]<br /></pre> <p> This type of mobprog will trigger when the mob does a thing that generates 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 to have one action trigger another. The possibilities are almost endless, except that this trigger is meaningless unless the scripted object is a mob, since only mobs can generate events. </p> <p> EXAMPLES: </p> <pre>imask_prog wolf dog coyote<br /></pre> <p> This will trigger whenever the mob does something that generates 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 mob does something that generates this precise message. Note that punctuation is important here as well. </p> <p> MULTIPLE PROGS: You can have more than one imask_prog on a mob, but you shouldn't have multiple imask_progs that trigger off of the same message. </p> <p> SPECIAL NOTES: ANSI colors on objects don't seem to work well with imask_progs, so avoid using ANSI colors in anything that may be part of your imask_prog trigger. Variables and Codes are not used in imask_progs, so do not try to use them; it won't work.</p> <h3><a name="kill_prog">kill_prog</a></h3> <p> Usage: </p> <pre>kill_prog<br /></pre> <p> This mobprog type triggers when the mob causes death. The kill_prog has a wide range of uses. The kill_prog is queued just before the target dies, so it is considered to be the target's last gasp. At the end of the kill-prog, however, the target dies. Even if the target sets its hit points to full, it will die. Other than that, the mob can mpjunk equipment it has, mptrasnfer a new room to die, unlock a door, load an object of some kind, etc. </p> <p> MULTIPLE PROGS: You can have multiple kill_progs on the same mob. </p> <h3><a name="level_prog">level_prog</a></h3> <p> Usage: </p> <pre>level_prog [integer percentage]<br /></pre> <p> This type of mobprog checks a percentage chance every time a player gains a level anywhere in the game. If the random number generated between 1 and 100 is equal to or below the percentage of the level_prog, the prog is triggered. </p> <p> EXAMPLES: </p> <pre>level_prog 25<br /></pre> <p> This prog will be triggered 25% of the time when someone levels. </p> <pre>level_prog 100<br /></pre> <p> This prog will be triggered 100% of the time when someone levels. This means every time. </p> <p> SPECIAL NOTES: This program will trigger every time a player levels, regardless of whether they are in the same room, or even whether the scripted monster can see or detect the player. The exception to this is cloaked admins, which will not trigger. </p> <h3><a name="lock_prog">lock_prog</a></h3> <p> Usage: </p> <pre>lock_prog [keyword list]<br />lock_prog p [keyword list]<br />lock_prog all<br /> </pre> <p> This type of mobprog is triggered by locking 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 locked is the scripted one. If the target matches the keywords of the lock_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 lock_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 "lock_prog all" is used, then the lock_prog will trigger from any object at all being locked. 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>lock_prog door gate<br /></pre> <p>This will trigger if the object locked has any of the keywords door gate. This means that it would be triggered by locking a door or gate.</p> <pre>lock_prog p a large chest<br /></pre> <p> This will trigger if the object locked has the exact keywords a large chest.. The prog would not be triggered by locking an object with keywords large or chest or anything except the exact order and wording of the keyword list. </p> <pre>lock_prog all<br /></pre> <p>This will trigger if any object is locked.)</p> <p> MULTIPLE PROGS: You can have more than one lock_prog on an item, mob, or room. Generally it is best not to have lock_progs with the same keywords in them, unless they are a lock_prog p with different keyword lists but some of the same keywords - for example a lock_prog p door gate and a lock_prog p door to the gate </p> <h3><a name="login_prog">login_prog</a></h3> <p> Usage: </p> <pre>login_prog [integer percentage]<br /></pre> <p> This type of mobprog checks a percentage chance every time someone enters the game. If the random number generated between 1 and 100 is equal to or below the percentage of the login_prog, the prog is triggered. </p> <p> EXAMPLES: </p> <pre>login_prog 25<br /></pre> <p> This prog will be triggered 25% of the time when someone enters the game. </p> <pre>login_prog 100<br /></pre> <p> This prog will be triggered 100% of the time when someone enters the game. This means every time. </p> <p> SPECIAL NOTES: This program will trigger every time a player enters the game, regardless of whether they are in the same room, or even whether the scripted monster can see or detect the player. The exception to this is cloaked admins, which will not trigger </p> <h3><a name="logoff_prog">logoff_prog</a></h3> <p> Usage: </p> <pre>logoff_prog [integer percentage]<br /></pre> <p> This type of mobprog checks a percentage chance every time someone leaves the game. If the random number generated between 1 and 100 is equal to or below the percentage of the logoff_prog, the prog is triggered. </p> <p> EXAMPLES: </p> <pre>logoff_prog 25<br /></pre> <p> This prog will be triggered 25% of the time when someone leaves the game. </p> <pre>logoff_prog 100<br /></pre> <p> This prog will be triggered 100% of the time when someone leaves the game. This means every time. </p> <p> SPECIAL NOTES: This program will trigger every time a player leaves the game, regardless of whether they are in the same room, or even whether the scripted monster can see or detect the player. The exception to this is cloaked admins, which will not trigger.</p> <h3><a name="llook_prog">llook_prog</a></h3> <h3><a name="look_prog">look_prog</a></h3> <p> Usage: </p> <pre>look_prog [keyword list]<br />look_prog p [keyword list]<br />look_prog all<br />llook_prog [keyword list]<br />llook_prog p [keyword list]<br />llook_prog all<br /> </pre> <p> This type of mobprog is triggered by looking at the scripted item. The "llook" version triggers if the item is "examined". If the target matches the keywords of the lock_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 look_prog. 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>llook_prog all<br /></pre> <p>This will trigger if any the scripted item, room, or mob is examined.</p> <pre>look_prog all<br /></pre> <p>This will trigger if any the scripted item, room, or mob is looked at.</p> <p> MULTIPLE PROGS: It is generally useless to have more than one look_prog on an item, mob, or room. </p> <h3><a name="once_prog">once_prog</a></h3> <p> Usage: </p> <pre>once_prog<br /></pre> <p> This type of mobprog is triggered immediately by the script engine under all circumstances, but is never triggered again. This makes it useful for doing initialization or other tasks which only need to be done once after the mud boots. 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>once_prog<br /></pre> <p> This will trigger once, right away </p> <p> MULTIPLE PROGS: You can have only one once_prog on a mob. </p> <h3><a name="open_prog">open_prog</a></h3> <p>Usage:</p> <pre>open_prog [keyword list]<br />open_prog p [keyword list]<br />open_prog all<br /> </pre> <p>This type of mobprog is triggered by opening 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 opened is the scripted one. Otherwise, if the target matches the keywords of the open_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 open_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 "open_prog all" is used, then the open_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>open_prog door gate <br /> </pre> <p> This will trigger if the object opened has any of the keywords door gate. This means that it would be triggered by opening a door or gate.</p> <pre>open_prog p a large chest<br /> </pre> <p> This will trigger if the object opened has the exact keywords a large chest.. The prog would not be triggered by opening an object with keywords large or chest or anything except the exact order and wording of the keyword list. </p> <pre>open_prog all <br /> </pre> <p> This will trigger if any object is opened.</p> <p>MULTIPLE PROGS: You can have more than one open_prog on an item, mob, or room. Generally it is best not to have open_progs with the same keywords in them, unless they are a open_progs p with different keyword lists but some of the same keywords - for example a open_prog p door gate and a open_prog p door to the gate.</p> <h3><a name="quest_time_prog">quest_time_prog</a></h3> <p> Usage: </p> <pre>quest_time_prog [quest name] [number of minutes remaining]<br /></pre> <p> This kind of mobprog triggers only if the script is part of an official Quest, and only if the number of minutes remaining in the quest is equal to the number of minutes specified. This is used as part of a quest plot line, to allow the mobs to give warnings about a quest that is running out of time. If the Scriptable behavior was granted as part of a Quest, then * may be substituted for the questname. </p> <p> EXAMPLES: </p> <pre>quest_time_prog 'my quest' 20<br /></pre> <p> This quest_time_prog will be triggered on the final 20th minute of the quest 'my quest'. </p> <pre>quest_time_prog 'my quest' 1<br /></pre> <p> This quest_time_prog will be triggered on the final minute of the quest 'that quest'. </p> <h3><a name="put_prog">put_prog</a></h3> <p> Usage: </p> <pre>put_prog [keyword list]<br />put_prog p [keyword list]<br />put_prog all<br /></pre> <p> This type of mobprog is triggered by putting something in a container. If the container being used matches the keywords of the put_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 put_prog. If there is not, then any container with any of the keywords in the list in it will trigger it. If a put_prog all is used, then the put_prog will trigger from any container at all being used. 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>put_prog orange apple banana<br /></pre> <p> This will trigger if the container used has any of the keywords orange, apple, or banana. This means that it would be triggered by putting something into a banana, an apple pie, or even an orange shield. </p> <pre>put_prog p apple pie delicious<br /></pre> <p> This will trigger if the container used up has the exact keywords apple pie delicious. The prog would not be triggered by putting anything into a container with keywords red apple or blackberry pie or anything except the exact order and wording of the keyword list. </p> <pre>put_prog all<br /></pre> <p> This will trigger if any container is used. </p> <p> MULTIPLE PROGS: You can have more than one put_prog on a mob. Generally it is best not to have put_progs with the same keywords in them, unless they are a put_prog p with different keyword lists but some of the same keywords – for example a put_prog p apple red juicy and a put_prog p apple red poisoned. </p> <h3><a name="rand_prog">rand_prog</a></h3> <p> Usage: </p> <pre>rand_prog [integer percentage]<br /></pre> <p> This kind of mobprog checks a percentage chance every tick. If the random number generated between 1 and 100 is equal to or below the percentage of the rand_prog, then it will be triggered. This type of mobprog can be triggered at any time, so long as the mob is alive, including while it is sleeping or fighting. They are very useful for setting up certain elements of your zone, or for giving personality to your mobs, such as having a blacksmith who pounds out a sword. This kind of mobprog ONLY goes off when a player is in the same zone that your mob is in. </p> <p> EXAMPLES: </p> <pre>rand_prog 20<br /></pre> <p> This rand_prog will be triggered 20% of each tick. </p> <pre>rand_prog 75<br /></pre> <p> This rand_prog will be triggered 75% of each tick. </p> <p> SPECIAL NOTES: While using rand_progs seems really easy, having a lot of them can slow down your zone. Having extremely long rand_progs on many, many mobs is generally not a good idea. If possible, consider other options, and only use rand_progs that go off at a high rate on mobs that will perform the rand_prog once and then never again, either because they have some sort of internal check, or because they go and mppurge themselves afterwards. </p> <h3><a name="regmask_prog">regmask_prog</a></h3> <p> Usage: </p> <pre>regmask_prog [java regular expression]<br />regmask_prog p [exact, case sensitive 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 precisely the same, case included, as the string generated. If 'p' is not the first character, then the trigger will attempt to find the first match of the given java regular expression string. 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>regmask_prog a*be<br /></pre> <p> This will trigger whenever the mob sees a segment of text starting with the lowercase letter a, then containing 0 or more other letter as followed by the string "be". This would match aaaaabe </p> <pre>regmask_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 and case is important here as well. </p> <p> MULTIPLE PROGS: You can have more than one regmask_prog on a mob, but you shouldn't have multiple regmask_progs that trigger off of the same message. </p> <p> SPECIAL NOTES: ANSI colors on objects don't seem to work well with regmask_progs, so avoid using ANSI colors in anything that may be part of your regmask_prog trigger. Variables and Codes are not used in regmask_progs, so do not try to use them; it won't work. </p> <h3><a name="remove_prog">remove_prog</a></h3> <p> Usage: </p> <pre>remove_prog [keyword list]<br />remove_prog p [keyword list]<br />remove_prog all<br /></pre> <p> This type of mobprog is triggered by removing an object. If the object removed matches the keywords of the remove_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 remove_prog. If there is not, then any object with any of the keywords in the list in it will trigger it. If a remove_prog all is used, then the remove_prog will trigger from any object at all being removed by the mob. 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>remove_prog orange apple banana<br /></pre> <p> This will trigger if the object removed has any of the keywords orange, apple, or banana. This means that it would be triggered by removing a banana, an apple pie, or even an orange shield. </p> <pre>remove_prog p apple pie delicious<br /></pre> <p> This will trigger if the object removed has the exact keywords apple pie delicious. The prog would not be triggered by removing an object with keywords red apple or blackberry pie or anything except the exact order and wording of the keyword list. </p> <pre>remove_prog all<br /></pre> <p> This will trigger if any object is removed. </p> <p> MULTIPLE PROGS: You can have more than one remove_prog on a mob. Generally it is best not to have remove_progs with the same keywords in them, unless they are a remove_prog p with different keyword lists but some of the same keywords – for example a remove_prog p apple red juicy and a remove_prog p apple red poisoned. </p> <h3><a name="sell_prog">sell_prog</a></h3> <p> Usage: </p> <pre>sell_prog [keyword list]<br />sell_prog p [keyword phrase]<br />sell_prog all<br /></pre> <p> This type of mobprog is triggered by selling an item to a shopkeeper. If the item being sold has any of the keywords of the sell_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 sell_prog. If there is not, then any item with any of the keywords in the list in it will trigger it. If a sell_prog all is used, then the sell_prog will trigger for any item at all being sold. 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>sell_prog orange apple banana<br /></pre> <p> This will trigger if the item being sold has any of the keywords orange, apple, or banana. This means that it would be triggered by selling a banana, an apple pie, or even an orange shield. </p> <pre>sell_prog p apple pie delicious<br /></pre> <p> This will trigger if the item being sold has the exact keywords apple pie delicious. The prog would not be triggered by selling anything with keywords red apple or blackberry pie or anything except the exact order and wording of the keyword list. </p> <pre>sell_prog all<br /></pre> <p> This will trigger if any sort of item is sold. </p> <p> MULTIPLE PROGS: You can have more than one sell_prog on a mob. Generally it is best not to have sell_progs with the same keywords in them, unless they are a sell_prog p with different keyword lists but some of the same keywords – for example a sell_prog p apple red juicy and a sell_prog p apple red poisoned.<br /> </p> <h3><a name="social_prog">social_prog</a></h3> <p> Usage: </p> <pre>social_prog [social name]</pre> <p>This type of mobprog is triggered by a social of the looked for name being done in the same room. 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>social_prog smile<br /></pre> <p> This will trigger if the smile social is done in the same room as the scripted object.<br /> </p> <p>MULTIPLE PROGS: You can have more than one social_prog on a mob. Generally it is best not to have social_progs with the same social trigger in them.<br /> </p> <pre></pre> <h3><a name="speech_prog">speech_prog</a></h3> <p> Usage: </p> <pre>speech_prog [trigger message]<br />speech_prog p [trigger message]<br /></pre> <p> This type of mobprog is triggered by someone saying the trigger line, be it mob or player. If a 'p' is inserted in the prog as above, the line spoken must exactly match the trigger message; if it is not, then any of the keywords listed will trigger the mobprog. A keyword of ALL will trigger on any speech. This type of mobprog is useful for setting up internal quests, giving out background information to people exploring your zone, or setting up passwords that must be spoken. This type of prog can also be used to have a mob trigger itself if you want to have multiple connected progs – see complex progs for details. Note that this kind of mobprog is only triggered by someone using the say command. </p> <p> EXAMPLES: </p> <pre>speech_prog dog wolf coyote<br /></pre> <p> This will trigger the prog whenever dog, wolf, or coyote is said in the room with the mob. If more than one of the keywords is spoken in the same line, the prog will trigger more than once. </p> <pre>speech_prog p The dog barks at the cat<br /></pre> <p> This will trigger the prog only if the exact expression is said. Note that punctuation counts, although you don't *have* to use it. </p> <p> MULTIPLE PROGS: You can have more than one speech_prog on a mob. It is generally not a good idea to have more than one speech_prog be triggered by the same expression. </p> <h3><a name="time_prog">time_prog</a></h3> <p> Usage: </p> <pre>time_prog [list of hours in the day]<br /></pre> <p> This type of mobprog triggers once per mud hour, on the hours of the day listed. This allows you to have a script which triggers infrequently. There are 16 hours per day (0-15) in CoffeeMud. </p> <p> EXAMPLES: </p> <pre>time_prog 10 1 2<br /></pre> <p> This will trigger if hour of the day is 10, 1, or 2. </p> <pre>time_prog 3<br /></pre> <p> This will trigger on the 3rd hour of every day. </p> <h3><a name="unlock_prog">unlock_prog</a></h3> <p>Usage:</p> <pre>unlock_prog [keyword list]<br />unlock_prog p [keyword list]<br />unlock_prog all<br /></pre> <p>This type of mobprog is triggered by unlocking 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 unlocked is the scripted one. If the target matches the keywords of the unlock_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 unlock_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 "unlock_prog all" is used, then the unlock_prog will trigger from any object at all being unlocked. 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>unlock_prog door gate<br /></pre> <p> This will trigger if the object unlocked has any of the keywords door gate. This means that it would be triggered by unlocking a door or gate.</p> <pre>unlock_prog p a large chest<br /></pre> <p> This will trigger if the object unlocked has the exact keywords a large chest.. The prog would not be triggered by unlocking an object with keywords large or chest or anything except the exact order and wording of the keyword list.</p> <pre>unlock_prog all<br /></pre> <p> This will trigger if any object is unlocked.</p> <p> MULTIPLE PROGS: You can have more than one unlock_prog on an item, mob, or room. Generally it is best not to have unlock_progs with the same keywords in them, unless they are a unlock_prog p with different keyword lists but some of the same keywords - for example a unlock_prog p door gate and a unlock_prog p door to the gate. </p> <h3><a name="wear_prog">wear_prog</a></h3> <p> Usage: </p> <pre>wear_prog [keyword list]<br />wear_prog p [keyword list]<br />wear_prog all<br /></pre> <p> This type of mobprog is triggered by wearing, wielding, or holding an item. If the object worn matches the keywords of the wear_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 wear_prog. If there is not, then any object with any of the keywords in the list in it will trigger it. If a wear_prog all is used, then the wear_prog will trigger from any object at all worn. 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>wear_prog orange apple banana<br /></pre> <p> This will trigger if the object worn has any of the keywords orange, apple, or banana. This means that it would be triggered by wearing a banana, an apple pie, or even an orange shield. </p> <pre>wear_prog p apple pie delicious<br /></pre> <p> This will trigger if the object worn has the exact keywords apple pie delicious. The prog would not be triggered by wearing an object with keywords red apple or blackberry pie or anything except the exact order and wording of the keyword list. </p> <pre>wear_prog all<br /></pre> <p> This will trigger if any object is worn. </p> <p> MULTIPLE PROGS: You can have more than one wear_prog on a mob. Generally it is best not to have wear_progs with the same keywords in them, unless they are a wear_prog p with different keyword lists but some of the same keywords – for example a wear_prog p apple red juicy and a wear_prog p apple red poisoned. </p> <h2> <a name="codes">Scripting Codes</a> </h2> <p> Most commands in your scripts allow you to use variable-like scripting Codes instead of literals. A literal is a specific static string or number, such as 'the hairy blog' or 'green' or '72'. A scripting code, however, is a special string which represents a literal and stands for it in your scripts. </p> <p> Understanding scripting codes is absolutely necessary for you to write scripts successfully. When a DEATH_PROG triggers, for example, it is impossible for the commands that execute to guess the name of the mobs killer. Therefore the name of the killer is stored in a scripting code for you. In this case, that code is $n. This allows you to use the code $n in your DEATH_PROG commands and be sure that wherever you use it, it is referring to "the creature that killed me". </p> <p> Also, when using commands that cause strings to echo, you may want to use a pronoun to refer to the creature who triggers an event. Guessing, however, won't work here either. In the case of our DEATH_PROG example, we could use the code $m and be sure that, whever it appears, the word 'his', 'her', or 'it' will replace it appropriately. </p> <p><a name="dollarCode"> </a> Below is a list of the simple scripting codes, along with their meaning. The term 'monster' below refers to whatever object, mob, item, room, exit, etc actually has the Scriptable behavior and is running the script. Otherwise, we also refer to the source of the trigger event and the target of the trigger event. For instance, when someone 'A' gets a sword off the ground in front of a mob 'B' with the Scriptable behavior, the MASK_PROG might trigger with the monster being the mob 'B', the source being the someone 'A', and the target being the sword. </p> <table bgcolor="#add8e6" border="1" width="100%"> <tbody> <tr> <td width="25%"> $a </td> <td> Name of the area the monsters in. </td> </tr> <tr> <td valign="top">$c<br /> </td> <td valign="top">A random pc or npc inhabitants name<br /> </td> </tr> <tr> <td valign="top">$C<br /> </td> <td valign="top">A random pc or npd inhabitants name<br /> </td> </tr> <tr> <td> $i </td> <td> The Monsters name. </td> </tr> <tr> <td> $I </td> <td> The Monsters display text. </td> </tr> <tr> <td> $n </td> <td> The Source of the triggers name. </td> </tr> <tr> <td> $N </td> <td> The Source of the triggers name. </td> </tr> <tr> <td> $t </td> <td> The Target of the triggers name. </td> </tr> <tr> <td> $T </td> <td> The Target of the triggers name. </td> </tr> <tr> <td> $r </td> <td> A random pc inhabitants name. </td> </tr> <tr> <td> $R </td> <td> A random pc inhabitants name. </td> </tr> <tr> <td> $j </td> <td> The pronoun he/she of the monster. </td> </tr> <tr> <td> $e </td> <td> The pronoun he/she of the source of the trigger. </td> </tr> <tr> <td> $f </td> <td> Name of the person which the monster follows. </td> </tr> <tr> <td> $E </td> <td> The pronoun he/she of the trigger target. </td> </tr> <tr> <td> $F </td> <td> The he/she of the person which the monster follows. </td> </tr> <tr> <td> $J </td> <td> The pronoun he/she of a random pc inhabitant. </td> </tr> <tr> <td> $k </td> <td> The possessive pronoun his/her of the monster. </td> </tr> <tr> <td> $l </td> <td> A list of all mobs (excluding monster). See "." syntax below. </td> </tr> <tr> <td> $L </td> <td> A list of all Items in room. See "." syntax below. </td> </tr> <tr> <td> $m </td> <td> The pronoun his/her of the source of the trigger. </td> </tr> <tr> <td> $M </td> <td> The pronoun his/her of the target of the trigger. </td> </tr> <tr> <td> $d </td> <td> The title of the room of the scripted monster. </td> </tr> <tr> <td> $D </td> <td> The long description of the room of the scripted monster. </td> </tr> <tr> <td> $K </td> <td> The pronoun his/her of a random pc inhabitant. </td> </tr> <tr> <td> $o </td> <td> The name of item#1. </td> </tr> <tr> <td> $O </td> <td> The name of item#1. </td> </tr> <tr> <td> $p </td> <td> The name of item#2. </td> </tr> <tr> <td> $P </td> <td> The name of item#2. </td> </tr> <tr> <td> $w </td> <td> The name of the owner of item#1. </td> </tr> <tr> <td> $W </td> <td> The name of the owner of item#2. </td> </tr> <tr> <td> $g </td> <td> The lowercase form of the message or parameters from a MPCALLFUNC, MASK_PROG or SPEECH_PROG. </td> </tr> <tr> <td> $G </td> <td> The uppercase form of the message or parameters from a MPCALLFUNC, MASK_PROG or SPEECH_PROG. </td> </tr> <tr> <td> $x </td> <td> Displays a random (or specified) exit by the exits direction code (north, south, etc) </td> </tr> <tr> <td> $X </td> <td> Displays a random (or specified) exit by the exits direction name (door, etc etc) </td> </tr> <tr> <td> $xN </td> <td> Specified directions name (Where N may be N, S, E, W, U, or D). Will display the direction Code. Use $X for exit name. </td> </tr> <tr> <td>$0 .. $9</td> <td>Temporary variables used by other commands, especially FOR, MPARGSET command.</td> </tr> <tr> <td> $<[code] [var name]> </td> <td> The variable of the given name, and the given code. Where code is $i, $n, $t, $o, $w, $W, or $p. See MPSETVAR below. </td> </tr> <tr> <td> ${[num] [*/quest name]} </td> <td> A mob name from the given quest, if the quest is running. The number corresponds to the order in which mobs were designated in the quest script. Counting starts at 1. </td> </tr> <tr> <td> $[[num] [*/quest name]] </td> <td> An item name from the given quest, if the quest is running. The number corresponds to the order in which items were designated in the quest script. Counting starts at 1. </td> </tr> </tbody> </table> <p> Any of the above codes may be followed by a period and a literal number to designate a particular word inside a string of many words. For instance, if $o evaluates to "a magic wand", then $o.1 would evalulate to "magic". If $l evaluated to "orc bob hassan", then $l.2 would give "hassan". This can be very useful when used with the $l or $L codes to iterate through the contents of a room. This syntax can also be used to generate substrings by following the number with two periods "..". For instance, of $l evaluates to "orc bob hassan", then $l.1.. would give "bob hassan". </p> <p><a name="percentCode"> </a> The last code we are going to discuss is also the most powerful. It allows you to fill in a value from a function call. The format of this code is as follows: </p> <table bgcolor="#add8e6" border="1" width="100%"> <tbody> <tr> <td width="25%"> $%[function name]([parameters])% </td> <td> This will replace the code with a value from one of the internal functions listed below. While the names are the same as the eval functions used in IF statements, their parameters will be slightly different. </td> </tr> </tbody> </table> <p> The [function name] must be the name of one of the functions listed in the following chart. All functions must have parenthesis after their names, and most functions require one or more parameters inside the parenthesis. </p> <p> The parameters usually include a [code]. This may be either the string name of either a mob or an item (whichever is appropriate to the function), or a code from the previous chart which represents a mob or an item. The description for each function will specify whether mob names or codes representing mobs are more appropriate, or whether item names or codes representing items are more appropriate. </p> <p> Here is an example of this code being used in a say statement: </p> <pre>say I am $%isgood($i)% and my favourite number is $%rand()%.<br /></pre> <p> This string would replace the $%.. codes with the results of the given function calls. </p> <p> Here is the list of accepted functions for the $% code. Where 'monster' is referred to below, you may assume this to be whatever object (mob, item, room, exit) which has the Scriptable behavior on it. Usually this is an npc mob. In the case of an item, it refers to a mob who takes the place of the item for scripting purposes. For this reason, using $i and $I codes, or using functions which only return information about the scripted monster when an item is being scripted is totally useless. </p> <table bgcolor="#90ee90" border="1" width="100%"> <tbody> <tr> <td width="25%"> AFFECTED([code]) </td> <td> Returns the name of a random spell affect on the given mob or item. </td> </tr> <tr> <td> BASECLASS([code]) </td> <td> Returns the base class of the given mob. </td> </tr> <tr> <td> CALLFUNC([function name] [parms]) </td> <td> Calls the FUNCTION_PROG of the given name, with the given parameters, and returns the value returned by the program using the RETURN statement. </td> </tr> <tr> <td> CLAN([code]) </td> <td> Returns the clan of the given mob. </td> </tr> <tr> <td> CLANRANK([code]) </td> <td> Returns the rank of the given mob in their clan. </td> </tr> <tr> <td> CLANDATA([clan code] [variable]) </td> <td> Returns data about the given clan. See CLANDATA function below for variables. </td> </tr> <tr> <td> CLASS([code]) </td> <td> Returns the class of the given mob. </td> </tr> <tr> <td> CURRENCY([code]) </td> <td> Returns the native currency of the given mob or coins. </td> </tr> <tr> <td> DEITY([code]) </td> <td> Returns the deity of the given mob. </td> </tr> <tr> <td> EVAL() </td> <td> Not implemented -- do not use. </td> </tr> <tr> <td valign="top">EXP([code])<br /> </td> <td valign="top">Returns the experience points of the given mob.<br /> </td> </tr> <tr> <td> EXPLORED([code] [areaname or world]) </td> <td> Returns the % the given mob has explored of the world or the specified area. </td> </tr> <tr> <td> FACTION([mob code] [faction id]) </td> <td> Returns the range name for the given mob within the given faction. </td> </tr> <tr> <td> GOLDAMT([code]) </td> <td> Returns the total value of the money the given mob has, or value of item, expressed in base gold. </td> </tr> <tr> <td> GSTAT([code] [stat variable]) </td> <td> Value of the given stat variable for the given mob or item. For example: <em>$%GSTAT($i strength)%</em> See the MPGSET command below for a complete list of variables. </td> </tr> <tr> <td> HAS([code]) </td> <td> Returns the name of a random item in the scripted monsters inventory. </td> </tr> <tr> <td> HASNUM([code] [item name]) </td> <td> Returns the number of a given item in the given mob or rooms inventory. </td> </tr> <tr> <td> HASTITLE([code]) </td> <td> Returns the selected title of the given player mob. </td> </tr> <tr> <td> HITPRCNT([code]) </td> <td> Return the % of hit points remaining for the given mob. </td> </tr> <tr> <td> INCONTAINER([code]) </td> <td> Teturns the name of the container of the given item, or the mount of the given mob, depending on the code. </td> </tr> <tr> <td> INLOCALE() </td> <td> Returns the name of the room type the monster is in (plains, city, mountains, hills, watersurface, etc). </td> </tr> <tr> <td> INROOM() </td> <td> Returns the raw id of the room the scripted monster is in. </td> </tr> <tr> <td> IPADDRESS([code]) </td> <td> Returns the ipaddress of the player. </td> </tr> <tr> <td> ISABLE([code] [skill name]) </td> <td> Returns the given mobs proficiency in the given skill/spell/ability. </td> </tr> <tr> <td> ISALIVE([code]) </td> <td> Returns the health of the given mob. </td> </tr> <tr> <td> ISBEHAVE([code]) </td> <td> Returns the class ids of the behaviors on the given mob or item. </td> </tr> <tr> <td>ISBIRTHDAY([code])</td> <td>Returns a description of the given mobs birthday date.</td> </tr> <tr> <td> ISCHARMED([code]) </td> <td> Returns the name of the charm spell the mob is under. </td> </tr> <tr> <td> ISDAY() </td> <td> Returns word the word day or the word evening. </td> </tr> <tr> <td> ISEVIL([code]) </td> <td> Returns the short alignment string of the given mob. </td> </tr> <tr> <td> ISFIGHT([code]) </td> <td> Returns the name of the creature the given mob is fighting, or nothing otherwise. </td> </tr> <tr> <td> ISFOLLOW([code]) </td> <td> Returns the name of the creature the given mob is following, or nothing otherwise. </td> </tr> <tr> <td> ISGOOD([code]) </td> <td> Returns the alignment string of the given mob. </td> </tr> <tr> <td> ISHERE() </td> <td> Returns the name of the area the scripted monster is in. </td> </tr> <tr> <td> ISIMMORT([code]) </td> <td> not implemented. </td> </tr> <tr> <td>ISLIKE([zapper mask])</td> <td>Returns human-readable description of the given mask.</td> </tr> <tr> <td> ISLOCKED([code or direction]) </td> <td> Returns the key name if the given container name or direction has a lock. The code may refer to an item container with a lock, or a direction name, such as north, south, east, etc. </td> </tr> <tr> <td> ISMOON() </td> <td> Returns the moon phase description. </td> </tr> <tr> <td> ISNAME([code]) </td> <td> Returns the real/full name of the given object. </td> </tr> <tr> <td> ISNEUTRAL([code]) </td> <td> Returns the alignment number of the given mob (0-1000). </td> </tr> <tr> <td> ISNPC([code]) </td> <td> Not implemented -- do not use. </td> </tr> <tr> <td> ISOPEN([code or direction]) </td> <td> Returns "true" if the container item is open, or the exit in the given direction name is open. </td> </tr> <tr> <td> ISPC([code]) </td> <td> Not implemented -- do not use.. </td> </tr> <tr> <td> ISQUESTMOBALIVE() </td> <td> Not implemented -- do not use.. </td> </tr> <tr> <td>ISRECALL([code])</td> <td>Returns the start room of the given mob.</td> </tr> <tr> <td> ISSEASON() </td> <td> Returns the name of the season. </td> </tr> <tr> <td> ISSERVANT([code]) </td> <td> Returns the name of the creature the given mob is serving, or nothing otherwise. </td> </tr> <tr> <td> ISTIME() </td> <td> Returns the approximate time of day in words. </td> </tr> <tr> <td> ISWEATHER() </td> <td> Returns a description of the weather in a short sentence. </td> </tr> <tr> <td> LEVEL([code]) </td> <td> Returns the level of the given mob. </td> </tr> <tr> <td valign="top">MATH([expression](<br /> </td> <td valign="top">Returns result of evaluated mathematical expression. Use +, -, *, or \<br /> </td> </tr> <tr> <td> MOBITEM([code] [integer number]) </td> <td> Returns the nth item owned by the given mob. </td> </tr> <tr> <td>MOOD([code])</td> <td>Returns the mood of the given mob.</td> </tr> <tr> <td> NUMBER([integer number or code]) </td> <td> Returns the numeric value of the given argument. </td> </tr> <tr> <td> NUMITEMSMOB([code]) </td> <td> Returns the number of items the given mob has. </td> </tr> <tr> <td> NUMITEMSROOM() </td> <td> Returns the number of items in the room. </td> </tr> <tr> <td> NUMMOBS([name]) </td> <td> Returns the number of mobs in the world matching the given mob name.Can also use MASK=<zapper mask> to pick out certain kinds of mobs. </td> </tr> <tr> <td> NUMMOBSINAREA([name]) </td> <td> Returns the number of mobs in the scripted monsters area matching the given mob name.Can also use MASK=<zapper mask> to pick out certain kinds of mobs. </td> </tr> <tr> <td> NUMMOBSROOM([*/name]) </td> <td> Returns the number of mobs in the same room as the scripted monster, including the monster, whose name or display text matches the name pattern. Can also use MASK=<zapper mask> to pick out certain kinds of mobs. </td> </tr> <tr> <td> NUMPCSAREA() </td> <td> Returns the number of pcs in the same area as the scripted monster. </td> </tr> <tr> </tr> <tr> <td> NUMPCSROOM() </td> <td> Returns the number of pcs in the same room as the scripted monster. </td> </tr> <tr> <td> NUMRACEINAREA([race name]) </td> <td> Returns the number of mobs in the same area as the scripted monster whose race matches the given string. </td> </tr> <tr> <td> NUMRACES([race name]) </td> <td> Returns the number of mobs in the world whose race matches the given string. </td> </tr> <tr> <td> POSITION([code]) </td> <td> Returns the sitting/standing/sleeping position name of the given mob. </td> </tr> <tr> <td>PRACS([code])</td> <td>Returns the number of practices the given mob has.</td> </tr> <tr> <td> QUESTITEM() </td> <td> Not implemented -- do not use. </td> </tr> <tr> <td> QUESTMOB() </td> <td> Not implemented -- do not use. </td> </tr> <tr> <td>QUESTPOINTS([code])</td> <td>Returns the number of quest points the given mob has.</td> </tr> <tr> <td> QUESTWINNER() </td> <td> Not implemented -- do not use. </td> </tr> <tr> <td>QVAR([*/quest name] [var])</td> <td>Returns value of one of the internal Quest variable strings, See MPQSET for more info.</td> </tr> <tr> <td> RACE([code]) </td> <td> Returns the name of the race of the given mob. </td> </tr> <tr> <td> RACECAT([code]) </td> <td> Returns the racial category of the given mob. </td> </tr> <tr> <td> RAND() </td> <td> Returns random number between 1 and 100. </td> </tr> <tr> <td> RAND0NUM([integer number or code]) </td> <td> Returns a random number from 0..given value-1. </td> </tr> <tr> <td> RANDNUM([integer number or code]) </td> <td> Returns a random number from 1..given value. </td> </tr> <tr> <td> ROOMITEM([integer number]) </td> <td> Returns the name of the nth item in the same room as the scripted monster. </td> </tr> <tr> <td> ROOMMOB([integer number]) </td> <td> Returns the name of the nth mob in the same room as the scripted monster. </td> </tr> <tr> <td> SEX([code]) </td> <td> Returns the sex of the given mob. </td> </tr> <tr> <td> STAT([code] [stat variable]) </td> <td> Returns the value of the given stat for the given object, mob, or item. See MPSTAT in the section on Commands for more information. </td> </tr> <tr> <td> STRIN([string] [string]) </td> <td> Returns the word number (0..n) where the second string appears in the first. This function deals in whole words only. </td> </tr> <tr> <td>TRAINS([code])</td> <td>Returns the number of training points the given mob has.</td> </tr> <tr> <td> VALUE([code] [currency name]) </td> <td> Returns the base value of the mob or coins but only in the given currency. </td> </tr> <tr> <td> VAR([code] [variable name]) </td> <td> Returns the value of the given variable. See MPSETVAR in the section on Commands for more information. </td> </tr> <tr> <td> WORN([code]) </td> <td> The name of a random worn item in the given mobs inventory. </td> </tr> </tbody> </table> <h2> <a name="commands">Scripting Commands</a> </h2> <p> Commands inside your scripts should each be terminated by a carriage return (ENTER) or a semicolon, depending upon the manner in which your script is presented. </p> <p> Commands are of two general types: MUD Commands, and MOBPROG (MP) Commands. </p> <p> MUD Commands you should already be familiar with, as they include commands such as GET, PUT, SAY, DROP, etc. It is not within the scope of this document to list or describe the standard MUD Commands. The help files inside the mud itself can do a far better job. It is sufficient to say that issuing the command in your script cause the scripted mob to attempt to perform the command exactly as it is written. If you enter a script line such as: </p> <pre>get sword<br /></pre> <p> .. and there is a sword, the mob will get it. If there is NO sword, the mob will not appear to be doing anything at all. </p> <p> MP Commands are what we will be discussing in more detail here. Like MUD Commands, they each have a syntax and structure which must be followed. </p> <pre>commandword parameter1 parameter2 ... parametern<br /></pre> <p> Like MUD Commands, MP Commands all have a key command word followed by one or more parameters. As in MUD Commands, those parameters are delimited by spaces. If you need to specify a single parameter which contains a space, you would put double quotes (") around the parameter. </p> <pre>say "the scary monster" hi!<br /></pre> <p> In an MP Command, however, this is not true. In an MP Command, the single quote (') is used around a parameter when it contains spaces. Keep this difference in mind when writing your scripts, lest you run into problems. This difference is actually more important with MP Functions. This is because most MP Commands only have one parameter, so that parameter word grouping using quotes is usually not necessary. </p> <h3><a name="if">if, else, endif</a></h3> <p> Usage: </p> <pre>if [condition]<br />[commands]<br />else<br />[commands]<br />...<br />endif<br /></pre> <p> The if command is the cornerstone of Scripting, and the only other condition mechanism outside of the MPWHILE command. The way the if command works is by deciding whether or not the condition that is given is true, and if so, executing the commands following the if condition. When the condition is not true, the commands before an endif statement or, (if given), an else statement are not executed. If an else statement lies between an if statement and the endif statement, then the statements between the else statement and the endif statement will be executed whenever the condition is false, but not ever if the condition is true. Either way, statements after an endif statement are executed regardless. </p> <p> Every if statement MUST have a corresponding endif statement somewhere after it. The else statement is completely optional, but if it is used, it must be between the if statement and the endif statement. A BREAK statement may be included inside an IF..ENDIF block to skip the remaining statements in that block. </p> <p> Of course, everything that happens or doesn't happen in an if condition depends on the condition itself. Every condition consists of a valid function name followed by an open parenthesis, followed by any parameters required by that function, and a close parenthesis. A simple example is below: </p> <pre>if sex($n == M)<br /></pre> <p> In this example, the sex function is called to determine whether $n (which is a variable representing the cause of a trigger) is male. If the mob who caused the trigger is male, the condition is true. Otherwise it is false. In the particular function above, the '==' symbols mean 'equal to'. </p> <p> Conditional statements may be negated using the "!" character as follows: </p> <pre>if !sex($n == M)<br /></pre> <p> In this case, the condition evaluates to false if the mob who caused the trigger is male, and true otherwise. </p> <p> Conditional statements may contain more than one function call if they are separated by the key words 'and' or 'or'. In the case of an 'and' key word, the condition evaluates to true if the functions on either side both evaluate to true, and it evaluates to false otherwise. In the case of the 'or' key word, the condition evaluates to true if either of the functions on either side evaluate to true, and false otherwise. Here are some examples of those in use: </p> <pre>if sex($n == F) or race($n == Harpy)<br /></pre> <pre>if sex($n == M) and isevil($n)<br /></pre> <p> Lastly, conditional statements may group together their function calls using parenthesis. This can be used to ensure that certain sets of function calls are evaluated together, while others are not. For instance: </p> <pre>if sex($n == M) or isevil($n) and race($n == Harpy)<br /></pre> <pre>if ( sex($n == M) or isevil($n) ) and race($n == Harpy)<br /></pre> <p> In these examples, if $n happens to refer to a Good Male Gnome, then the first statement would evaulate to true, while the second statement would evaluate to false. This is because the parenthesis force the sex and isevil checks to be evaulated first in the second example. </p> <p> Please see the section below on functions for a list of the conditional functions and their uses.</p> <h3><a name="switch">switch, case, default, endswitch</a></h3> <p> Usage: </p> <pre>switch [variable]<br />case [value]<br />[commands]<br />case [value]<br />[commands]<br />case [value]<br />[commands]<br />...<br />endswitch<br /></pre> The switch command is an alternative to the if/endif syntax above for comparing a single variable to many different variables. A switch statement is essentially a stand-in for this syntax:<br /> <br /> <pre>if VAR($i MYVAR == 'value1')<br /> [commands1]<br />else<br /> if VAR($i MYVAR == 'value2')<br /> [commands2]<br /> else<br /> if VAR($i MYVAR == 'value3')<br /> [commands3]<br /> else<br /> [commands4]<br /> endif<br /> endif<br />endif<br /></pre> Notice how, in the above example, we are comparing the same variable over and over again to different values, and doing something different depending on that value. This is what the switch command allows you to do without having to nest so many if-statements. Here would be the equivalent switch statement to the above:<br /> <pre>switch $%VAR($i MYVAR)%<br />case 'value1'<br />[commands1]<br />case 'value2'<br />[commands2]<br />case 'value3'<br />[commands3]<br />default<br />[commands4]<br />endswitch<br /><br /></pre> In the above <span style="font-weight: bold;">switch</span> statement, we declare the value we wish to check after the key word <span style="font-weight: bold;">switch</span>, which is the value of the variable $i MYVAR. In the ensueing <span style="font-weight: bold;">case</span> statements, we declare what we want the value of $i MYVAR to be equal to in order for the commands which follow the <span style="font-weight: bold;">case</span> statement to be executed. Each <span style="font-weight: bold;">case </span>statement defines its own value which $i MYVAR must be equal to in order for its following commands to be executed. The <span style="font-weight: bold;">default</span> statement is a special case is executed only if a value of $i MYVAR did not match any of the previous <span style="font-weight: bold;">case</span> values. Finally, the <span style="font-weight: bold;">endswitch</span> declares that no more cases will be given. Consider another example:<br /> <br /> <pre>switch $%RANDNUM(5)%<br />case 1<br /> [commands1]<br />case 2<br /> [commands2]<br />case 3<br /> [commands3]<br />case 4<br /> [commands4]<br />case 5<br /> [commands5]<br />endswitch<br /></pre> In this example, we are comparing a randomly generated number from 1-5 to each of the possible values in our <span style="font-weight: bold;">case</span> statements. Since we have covered all possible values of $%RANDNUM(5)%, we do not need to include a <span style="font-weight: bold;">default</span> case. <h3><a name="for">for, next</a></h3> <p> Usage: </p> <pre>for $[digit] = [number] to [number]<br />[commands]<br />...<br />next<br /></pre> <p> The for command is the simplest way to execute one or more other commands numerous times. It allows you to specify a numeric range for the scripting engine to count from and to, executing the commands after the for statement (and before the next statement) as many times as is required to complete the counting. The value of the current digit during counting is stored in one of the temporary variables $0, $1, $2, $3, ... $9. Here's an example:</p> <pre>for $0 = 1 to 10<br /> mpecho I have done this $0 times!<br />next<br /></pre> <p>If you execute the above script, you will see the mpecho command repeated 10 times, which is one time for every digit between 1 and 10. Each time it executes the mpecho command, the value of the temporary variable $0 will be incremented. That's the basics, simple huh?</p> <p>For loops can be nested, so long as all of the outer for loops are using different temporary variables than the inner ones. Since there are 10 temporary variables, this gives you a limit of a nested depth of 10. </p> <p>The two number expressions can be literal numbers as shown above, or any expression which might evaluate to a number, such as $% syntax. Here's an example of what I mean:</p> <pre>for $0 = 1 to '$%NUMMOBSROOM(*)%'<br /> mpecho $%ROOMMOB($0)% is here.<br />next<br /></pre> <p> You'll see that the NUMMOBSROOM() function is used here to return the number of mobs in the room, so we can count them. Each one we count, we can pass the $0 variable used in this loop to the ROOMMOB() function to get their name. </p> <p> Please see the section below on functions for a list of the functions and their uses.</p> <h3><a name="script"><SCRIPT></a></h3> <p> This command denotes the beginning of a section of ECMA Javascript. Any lines of text following this command, and before the adjoining </SCRIPT> command will be assumed to be executable Javascript. These commands can only be embedded in standard event handlers as described above. </p> <p> Javascript is a wholly different language than the standard Scriptable/MOBPROG language described in this document. You should read the JavaScripting section of the CoffeeMud <a href="Programming.html"> Programming Guide</a> for more information, as well as the following web sites which discuss the usage and syntax of the Javascript language itself: <a href="http://www.mozilla.org/js/">http://www.mozilla.org/js/</a> and <a href="http://www.mozilla.org/rhino/">http://www.mozilla.org/rhino/</a>. </p> <p> After you've read the above documentation, there are still a few small details to be aware of before getting started. One is that the Scriptable behavior will provide certain methods for accessing important event-related objects from inside your Javascript. These include the object functions source(), target(), host(), monster(), item1(), item2(), and message(). Another important detail is that Javascript variables defined will be lost from execution to execution, even of the same script. For this reason, additional methods String getVar(String host, String variableName), and void setVar(String host, String variableName, String value) have been provided to save the variables globally. The last important detail relates to semicolon characters. It is lucky that Javascript does not require them, because the Scriptable behavior will strip them out as part of its command parsing process. For this reason, if you absolutely must keep a semicolon ANYWHERE in your javascript, whether as part of a displayable string, or a line delimeter, it must be escaped: \; </p> <p> Here is an example: </p> <pre>GREET_PROG 100<br />mpecho Greetings $n! This command is mpecho, a mobprog command!<br /><br /><SCRIPT><br />var greetedBefore=getVar(source().Name(),"GREETEDBEFORE");<br />source().tell("However, this greeting comes from Javascript!");<br />if(greetedBefore == 'true')<br /> source().tell("We've met before\; we will meet again!!");<br />else<br /> setVar(source().Name(),"GREETEDBEFORE","true");<br /></SCRIPT><br /><br />if var($n GREETEDBEFORE == true)<br /> mpecho The variable set in Javascript can be read here in mobprog land also!<br />endif<br />~<br /></pre> <h3><a name="mpaffect">mpaffect</a></h3> <p> Usage: </p> <pre>mpaffect [spell name] [target] [parameters]<br /></pre> <p> This command will put the target under the affect of the given spell, chant, prayer, song, skill, or CoffeeMud property. This is not the same as someone casting the given spell on the target. Instead, this command causes the target simply to come under the affect (as if the whole casting process were skipped). This means that not all spells will work with this command. Fireball, for instance, since it has no effect after casting, would do nothing under this command. The parameters given apply specifically to CoffeeMud properties, and are unnecessary for most spells, chants, etc. </p> <p> EXAMPLES: </p> <pre>mpaffect Invisibility $n<br />mpaffect Prop_PracticeDummy $n KILLABLE<br /></pre> <h3><a name="mpalarm">mpalarm</a></h3> <p> Usage: </p> <pre>mpalarm [ticks] [command]<br /></pre> <p> This very simple command will wait the given number of ticks (4 second intervals) before executing the command given in the parameters. This command does NOT end execution. Any commands after mpalarm will be executed immediately. It is only the command given in the mpalarm parameters that will be executed after the delay. It is for this reason that the trigger type function_prog exists: namely to allow you to execute the group of instructions in the function_prog after some delay. </p> <p> EXAMPLES: </p> <pre>mpalarm 10 say umm.. what was the question?<br />mpalarm 30 mpecho You think you heard something.<br />mpalarm 30 mpcallfunc myfunction<br /><br /></pre> <h3><a name="mpalarm">mpargset</a></h3> <p> Usage: </p> <span style="font-family: monospace;">mpargset [$var] [value or $var]</span><br /> <p> This powerful but complex command is used to change one of the internal object variables, such as $n, $i, $t, $o, $p, $d, $0..$9, to point to a different object. This can then affect subsequent commands that refer to them. While $0..$9 may be set to any value, the standard $n..$d variables must be set to an object of the same kind. </p> <p> EXAMPLES: </p> <pre>mpargset $o $p <br />mpargset $0 $n<br />mpargset $1 $0<br />mpargset $0 'my value'<br /></pre> <h3><a name="mpasound">mpasound</a></h3> <p> Usage: </p> <pre>mpasound [text string]<br /></pre> <p> This command will echo the text string to all of the rooms adjacent to the one the mob is in, much like the echo when a mob yells. This can be useful for creating dramatic deaths from mobs, or for use with mobs such as a wandering minstrel or the like. </p> <p> EXAMPLES: </p> <pre>mpasound You hear a scream from nearby!<br />mpasound A delightful music fills the air from somewhere near here.<br />mpasound The drunken hollering of $n can be heard nearby.<br />mpasound The earth thunders as $n's corpse falls to the ground nearby.<br /></pre> <p> SPECIAL NOTES: Keep in mind that mpasound does not echo to those in the room with the mob, only to rooms adjacent to it. So if you want people in the room to hear the mpasound too, you'll need to use an mpecho as well. </p> <h3><a name="mpat">mpat</a></h3> <p> Usage: </p> <pre>mpat [destination] [command]<br /></pre> <p> Performs the desired command at a designated location. The destination can be either a room id, a key word from the room description, or the name of a mob. The command can be just about anything you want it to be. This command is very useful for doing slight of hand kind of tricks with mobs by performing actions away from the player, or doing things elsewhere in the zone for you. It has many potential uses. </p> <p> EXAMPLES: </p> <pre>mpat MyArea#1232 unlock door<br />mpat guardone poke guardone<br />mpat 'a lovely pool' mpechoat $n You feel weakened from your escape.<br />mpat Sewers#1252 drop all<br /></pre> <p> SPECIAL NOTES: When using mpat, it is not a bad idea to give your mobs specific, unique keywords so they can be manipulated with no error. The command is usually essential for zones that have complicated quests, and can be used to trigger other mobs, unlock and open doors and chests away from the mob, and a variety of other things. </p> <h3><a name="mpbeacon">mpbeacon</a></h3> <p> Usage: </p> <pre>mpbeacon [destination] [target]<br /></pre> <p> This command changes the recall/start room of the target, which must be a player. </p> <p> EXAMPLES: </p> <pre>mpbeacon MyArea#1232 all<br />mpbeacon guardone $n<br />mpbeacon 'a lovely pool' $n<br /></pre> <h3><a name="mpbehave">mpbehave</a></h3> <p> Usage: </p> <pre>mpbehave [behavior id] [target] [parameters]<br /></pre> <p> This command will put the target under the affect of the given CoffeeMud behavior. The parameters given apply specifically to CoffeeMud behaviors. The Archon may use LIST BEHAVIORS, and AHELP [behavior name] for more information. </p> <p> EXAMPLES: </p> <pre>mpbehave Aggressive $n<br />mpbehave Mobile $n<br />mbehave Scriptable $n ONCE_PROG;say hello;~;<br /></pre> <h3><a name="mpcallfunc">mpcallfunc</a></h3> <p> Usage: </p> <pre>mpcallfunc [function name] [parameters]<br /></pre> <p> This command allows you to execute a group of other predefined commands without typing them all again. This is done by first defining a group of commands using the trigger function_prog. Once it is defined, the commands inside the function_prog may be executed by placing mpcallfunc followed by the function_prog's name parameter into another set of commands. This is useful for executing a set of commands that would normally have to be typed identically into your triggers over and over again. It is especially useful when used in conjunction with commands like mpalarm. The parameters passed into the mpcallfunc can be referenced using the $g and $G codes. </p> <p> EXAMPLES: </p> <pre>mpcallfunc CompleteTask $n 'my house'<br />mpcallfunc MyFunction<br /></pre> <h3><a name="mpcast">mpcast</a></h3> <p> Usage: </p> <pre>mpcast [spell] [target]<br /></pre> <p> This command causes the host mob to cast the given spell, chant, prayer, song, or use the given skill against the given target. Unlike using the mundane cast command, this scripting form does not require the mob to actually have the skill. Although there is still the 1-in-20 chance of failure of any skill, and the level of the host will affect the probability of success. </p> <p> EXAMPLES: </p> <pre>mpcast fireball $r<br />mpcast 'stinking cloud'<br /></pre> <h3><a name="mpchannel">mpchannel</a></h3> <p> Usage: </p> <span style="font-family: monospace;">mpchannel [channel name] [message]<br /> </span><span style="font-family: monospace;">mpchannel ![channel name] [message]<br /> </span> <p>This command causes the host mob to send a message to the given public channel, overriding any read-only restrictions which may be established. If the channel name is preceded by a !, then the message will be unattributed, a system message. </p> <p> EXAMPLES: </p> mpchannel gossip Hello all!<br /> mpchannel !info Somewhere, a script is running. <h3><a name="mpclose">mpclose</a></h3> <p> Usage: </p> <pre>mpclose [target]<br /></pre> <p> This command closes a lid on a container, or the door on an exit. This command has no effect if there is no lid or door, or it is already closed. </p> <p> EXAMPLES: </p> <pre>mpclose $xN<br />mpclose the magic door<br /></pre> <h3><a name="mpdamage">mpdamage</a></h3> <p> Usage: </p> <pre>mpdamage [target] [min amount] [max amount]<br />mpdamage [target] [min amount] [max amount] kill<br /></pre> <p> This command does damage to a mob or item specified as the target. The amount of damage will be randomly between the min and max amounts. This command, by default, will never ever kill the target UNLESS the parameters are followed by the word kill as shown in the example below. Also, this command will treat any items that do not normally display a condition (like mundane items, wands, etc) as having 1 hit point. Other items (weapons, armor) will have a number of hit points equal to their condition. This command is useful not only for hurting mobs, but for scratching up their armor when acid falls from the ceiling or something similar. </p> <p> EXAMPLES: </p> <pre>mpdamage $r 1 10 KILL<br />mpdamage $n 10 50<br /></pre> <h3><a name="mpdisable">mpdisable</a></h3> <p> Usage: </p> <pre>mpdisable [target] [spell]<br />mpdisable [target] [expertise]<br /><br /></pre> <p> This command causes the target mob to lose the spell, skill, prayer, expertise, etc specified. It does nothing if the mob does not have the skill. Skills can be granted using the mpenable command. </p> <p> EXAMPLES: </p> <pre>mpdisable $n fireball<br />mpdisable $n pass door<br />mpdisable $n STEALTHY3</pre> <h3><a name="mpecho">mpecho</a></h3> <p> Usage: </p> <pre>mpecho [text string]<br /></pre> <p> Quite simply, the mpecho command sends a message to the room of the mob. This message can be anything you like. It supports all of the character codes the mud uses, and can also use variables set by the mpsetvar command. This has a wide range of uses, from setting background noise to a mob, to allowing the mob to express itself safely as if speaking. The mpecho command does not set off speech_progs, although it does set off act_progs. </p> <p> EXAMPLES: </p> <pre>mpecho $i says, ‘Hey how's it going?'<br />mpecho A blast of strong wind rushes into the room suddenly!<br />mpecho $i hisses, ‘So, $n, you've come to face me…'<br />mpecho A dagger flashes into $i's hand, and $j snickers softly.<br /></pre> <p> SPECIAL NOTES: Using mpecho $i says, ‘blah' is a safe way to have a mob talk. Anytime you want to have a mob say something, you should use this, unless you want it to trigger speech_progs. Also, remember that whatever is mpechoed is seen be everyone in the room exactly the same. So if you want a message that targets a specific person, see the mpechoat and mpechoaround commands. </p> <h3><a name="mpechoaround">mpechoaround</a></h3> <p> Usage: </p> <pre>mpechoaround [target] [text string]<br /></pre> <p> This command is similar to the mpecho command, but instead of echoing to everyone in the room, can be used to echo to everyone BUT the targeted person. Why would you do this? If used in conjunction with the mpechoat command, you can create text strings which look right to everyone involved. The way to make mpechoaround do this is to use the mpat command. </p> <p> EXAMPLES: </p> <pre> mpechoaround $n You hear voices speaking all around you.<br /> mpechoaround $n $N cringes as a poisoned dart strikes $s chest!<br /> mpechoaround $n A pile of rocks rains down upon $n!<br /> mpechoaround $n A circle of light surrounds $n, and then $e vanishes.<br /> </pre> <h3><a name="mpechoat">mpechoat</a></h3> <p> Usage: </p> <pre>mpechoat [target] [text string]<br /></pre> <p> This command functions similar to the mpecho command, but can be used in such a way that only the targeted person or place sees the text string. This is useful for cutting down on spam from greet_prog mpechos, for example, as well as personalizing the text string for all parties involved in conjunction with the mpechoaround command. It also allows mobs to emulate the announce command. The target may be a local mob name, the word "world", the word "area", a room id, or an area name. </p> <p> EXAMPLES: </p> <pre>mpechoat $n You hear voices speaking all around you.<br />mpechoat $n You cringe as a poisoned dart strikes you in the chest!<br />mpechoat $n A pile of rocks rains down upon you!<br />mpechoat $n A circle of light surrounds you, and you are transported.<br /></pre> <h3><a name="mpenable">mpenable</a></h3> <p> Usage: </p> <pre>mpenable [target mob] [ability] [integer proficiency] [parameters]<br />mpenable [target mob] [expertise name]<br />mpenable [target mob] [ability] [++integer proficiency] [parameters]<br />mpenable [target mob] [ability] [--integer proficiency] [parameters]<br /><br /></pre> <p> This command grants a skill, spell, prayer, chant, song, expertise, or other ability to the target mob, or can be used to modify the proficiency of an existing skill. This acts like a forced 'GAIN' command, giving the target the skill permanently. The proficiency parameter should be between 0 and 100 when adding a new skill, or ++ followed by an adjustment integer, or -- followed by an adjustment integer. The final parameters are optional. Abilities can be removed with the mpdisable command. </p> <p> EXAMPLES: </p> <pre>mpenable $n Fireball 100<br />mpenable $n 'Summon Elemental' 0 EARTH<br />mpenable $n 'Summon Elemental' ++20<br />mpenable $n 'Summon Elemental' --5<br />mpenable $n STEALTHY3<br /><br /></pre> <h3><a name="mpendquest">mpendquest</a></h3> <p> Usage: </p> <pre>mpendquest [quest name]<br /></pre> <p> This command forces a Quest which is in progress to shut itself down gracefully, removing its specific mobs, items, and properties from your map. If the Scriptable behavior was granted as part of a Quest, then * may be substituted for the questname. </p> <p> EXAMPLES: </p> <pre>mpendquest smurfocide<br /></pre> <h3><a name="mpexp">mpexp</a></h3> <p> Usage: </p> <pre>mpexp [target] [exp amount]<br />mpexp [target] [pct exp to next level%]<br /></pre> <p> This command gives an amount of experience to the target, or a percentage of the experience they need to the next level. This is a useful command to use to award players for completing in zone quests, etc. that you have set up. If you want to award more experience than the capped amount, you can have the mob give several experience awards in a row. It is best when you award an experience award to give some sort of message to the player about why they are receiving the award. </p> <p> EXAMPLES: </p> <pre>mpexp $n 500<br />mpexp $n 10%<br /></pre> <p> SPECIAL NOTES: Players can level off of these experience awards, just as if they had killed something. Be careful with this command. You don't want to give out awards for every little thing characters do, nor do you want to give large awards for menial tasks. You also will, of course, not want to make it so a mob can accidentally give the same award over and over endlessly, or something equally abusable. </p> <h3><a name="mpfaction">mpfaction</a></h3> <p> Usage: </p> <pre>mpfaction [target mob] [faction id] [new value, range, or +--change]<br /></pre> <p> This command forces the victim to gain the given faction, and the given value within it. The target can be a character variable or a keyword of a mob. The faction id is the Faction to give to the player or mob. The new value, difference, or range may be a positive numeric value, a negative numeric value, it may be the name of one of the faction ranges, or it may be a difference expressed by +number or by --number (two - characters are required to distinguish a negative difference from a single negative numeric value). This command can be used to introduce a player to a faction they otherwise would not be able to gain, or it can be used in combination with the FACTION function to modify the value of a faction. </p> <p> EXAMPLES: </p> <pre>mpfaction $n alignment.ini 1000<br />mpfaction $n alignment.ini -50000<br />mpfaction $i alignment.ini 'pure goodness'<br />mpfaction $n alignment.ini +1<br />mpfaction $n alignment.ini -1<br /><br /></pre> <h3><a name="mpforce">mpforce</a></h3> <p> Usage: </p> <pre>mpforce [target] [command]<br /></pre> <p> This command forces the victim to do the designated command. The target can be a character variable or a keyword of a mob. This command has a lot of uses, but is mostly use in combat to do particularly nasty things, like force the player to heal the mob, etc. It can also be used to trigger other mobs by forcing them to perform a specific action which triggers an act_prog. </p> <p> EXAMPLES: </p> <pre>mpforce $n flee<br />mpforce $i sleep<br />mpforce guardtwo poke self<br />mpforce $n cast "heal serious" $i<br /></pre> <p> SPECIAL NOTES: Remember that whatever you force something to do, it needs to be typed out exactly as if they were typing the command themselves. That means if you want a player, for example, to be forced to cast ‘heal serious' on your mob, you need to make sure you observe the double-quote rule for word groupings, as opposed to the single quote rule for mobprog commands. </p> <h3><a name="mpgoto">mpgoto</a></h3> <p> Usage: </p> <pre>mpgoto [destination]<br /></pre> <p> Quite simply, this command will move the mob to the designated location. The destination can be a room id, keyword from a room description , or keyword of a mob. There is no message given to this command, so if you want there to be one, you need to include an mpecho in your mobprog. This command is a good way to move your mob around your zone should you need to. </p> <p> EXAMPLES: </p> <pre>mpgoto Area#10076<br />mpgoto guardthree<br /></pre> <h3><a name="mpgset">mpgset</a></h3> <p> Usage: </p> <pre>mpgset [target] [variable] [value]<br /></pre> <p> This powerful command lets you change all kinds of aspects of the target mob or item or whatever. </p> <p> Valid variable names for items include: "CLASS", "USES", "LEVEL", "ABILITY", "NAME", "DISPLAY", "DESCRIPTION", "SECRET", "PROPERWORN", "WORNAND", "BASEGOLD", "ISREADABLE", "ISDROPPABLE", "ISREMOVABLE", "MATERIAL", "AFFBEHAV", "DISPOSITION", "WEIGHT", "ARMOR", "DAMAGE", "ATTACK", "READABLETEXT", "MINRANGE", "MAXRANGE", "WEAPONTYPE", "WEAPONCLASS", "AMMOTYPE", "AMMOCAPACITY", "HASLOCK", "HASLID", "CAPACITY", "CONTAINTYPES", "NOURISHMENT", "RIDEBASIS", "MOBSHELD", "SENSES", "DISPOSITION", "LEVEL", "ABILITY", "REJUV", "WEIGHT", "HEIGHT", "ARMOR", "DAMAGE", "ATTACK" </p> <p> Valid variable names for mobs include: "CLASS", "RACE", "LEVEL", "ABILITY", "NAME", "DISPLAY", "DESCRIPTION", "MONEY", "ALIGNMENT", "DISPOSITION", "SENSES", "ARMOR", "DAMAGE", "ATTACK", "SPEED", "AFFBEHAV", "ABLES", "INVENTORY", "TATTS", "EXPS", "RIDEBASIS", "MOBSHELD", "WHATISELL", "PREJUDICE", "BANKCHAIN", "COININT", "LOANINT", "IGNOREMASK", "POSTCHAIN", "POSTMIN", "POSTLBS", "POSTHOLD", "POSTNEW", "POSTHELD", "ITEMINT", "HITS", "MANA", "MOVE", "HUNGER", "THIRST", "FATIGUE", "STRENGTH", "INTELLIGENCE", "DEXTERITY", "CONSTITUTION", "CHARISMA", "WISDOM", "GENDER", "PARALYSIS SAVE", "SAVE VS FIRE", "SAVE VS COLD", "SAVE VS WATER", "SAVE VS GAS", "SAVE VS MIND", "GENERAL SAVE", "JUSTICE SAVE", "SAVE VS ACID", "SAVE VS ELECTRICITY", "SAVE VS POISON", "SAVE VS UNDEAD", "SAVE VS MAGIC", "SAVE VS DISEASE", "SAVE VS TRAPS", "MAX STRENGTH ADJ.", "MAX INTELLIGENCE ADJ.", "MAX DEXTERITY ADJ.", "MAX CONSTITUTION ADJ.", "MAX CHARISMA ADJ.", "MAX WISDOM ADJ.", "SENSES", "DISPOSITION", "LEVEL", "ABILITY", "REJUV", "WEIGHT", "HEIGHT", "ARMOR", "DAMAGE", "ATTACK", "HITS", "MANA", "MOVE", "HUNGER", "THIRST", "FATIGUE", "BASEHITS", "BASEMANA", "BASEMOVE", "BASEHUNGER", "BASETHIRST", "BASEFATIGUE"</p> <p>Valid variable names for player mobs also include: "FRIENDS", "IGNORE", "TITLES", "ALIAS","LASTIP","LASTDATETIME", "CHANNELMASK", "COLORSTR", "PROMPT", "POOFIN", "POOFOUT", "TRANPOOFIN", "TRAINPOOFOUT", "ANNOUNCEMSG", "NOTES", "WRAP", "BIRTHDAY", "ACCTEXPIRATION", "INTRODUCTIONS" </p> <p> EXAMPLES: </p> <pre>mpgset $n CHARISMA 10<br />mpgset $n NAME my name is mud<br /></pre> <p> SPECIAL NOTES: Be very careful with this command when dealing with players. If used poorly it can cause bad things to happen to them, so make sure you have good checks to ensure they get affected correctly and fairly. </p> <h3><a name="mphide">mphide</a></h3> <p> Usage: </p> <pre>mphide [target]<br /></pre> <p> This command makes the target totally and completely undetectable by any means, magical or mundane. This is useful for making something "go away", but not really. mpunhide can restore such a hidden thing to sight. </p> <p> EXAMPLES: </p> <pre>mphide $n<br /></pre> <h3><a name="mpjunk">mpjunk</a></h3> <p> Usage: </p> <pre>mpjunk [object]<br /></pre> <p> This command destroys the object that the mob is referring to. The object must be in the mob's inventory or part of its equipment. You can also have a mob mpjunk all, which destroys everything on their person. You can also do things such as mpjunk all.sword or mpjunk all.bread, and can use the character variable $o. The command gives no message about its use, so it is a good way to secretly handle the junking of items. It is useful for getting rid of quest items given to the mob for give_progs, or if you have more complicated mobs where you must perform some sort of action in order to get its equipment, for example. </p> <p> EXAMPLES: </p> <pre>mpjunk chalice<br />mpjunk greatsword<br />mpjunk all.arrow<br />mpjunk all<br /></pre> <p> SPECIAL NOTES: This command is very good for give_progs where you want to destroy the thing given so it can load again or not be used again by the same people. It is a good idea to give quest objects like that unique keywords so there is no mistaking what the mob is mpjunking. </p> <h3><a name="mpkill">mpkill</a></h3> <p> Usage: </p> <pre>mpkill [victim]<br /></pre> <p> This command basically causes the mob to attack the victim. The only real benefit of using this command is if your mob is low level or attacking someone under the affect of an awe spell. Other than that, there is no difference between this command and say, kill. </p> <p> EXAMPLES: </p> <pre>mpkill $n<br />mpkill guardfour<br />mpkill $r<br />mpkill giant<br /></pre> <p> SPECIAL NOTES: Really, this command doesn't get used much. It was built for other MUD's which might have level requirements for kill, etc. You can use it, but it more or less works exactly the same as kill, murder, hit, etc.</p> <h3><a name="mploadquestobj">mploadquestobj</a></h3> <p> Usage: </p> <pre>mploadquestobj [questname] [variable expression/name] [$var]<br /></pre> <p> This command reads in a named object or string value for the given quest, and stores it in the internal temp variable object referred to by $var. $var may be $n, $o, $p, $i, $t, $d, $0..$9. Normally, this command only works when the object returned is of the same type as the $var, however, since the $0..$9 variables can hold any type of data, it is usually best to use one of those. Either way, this command can profoundly effect subsequent commands that use the $var specified. The quest name may be the name of a loaded quest, or * if this Scriptable object was loaded directly by a Quest script. </p> <p>The variable expressions may be one of these standard string values (non-objects): "CLASS", "NAME", "DURATION", "WAIT", "MINPLAYERS", "PLAYERMASK", "RUNLEVEL", "DATE", "MUDDAY", "INTERVAL"</p> <p>The variable expressions may also be based on one of these quest objects: "LOADEDMOBS", "LOADEDITEMS", "AREA", "ROOM", "MOBGROUP", "ITEMGROUP", "ROOMGROUP", "ITEM", "ENVOBJ", "STUFF" or one of the following Mystery quest objects: "FACTION", "FACTIONGROUP", "AGENT", "AGENTGROUP", "ACTION", "ACTIONGROUP", "TARGET", "TARGETGROUP", "MOTIVE", "MOTIVEGROUP", "WHEREHAPPENED", "WHEREHAPPENEDGROUP", "WHEREAT", "WHEREATGROUP", "WHENHAPPENED", "WHENHAPPENEDGROUP", "WHENAT", "WHENATGROUP", "TOOL", "TOOLGROUP". Some of these objects are actually groups of objects, such as STUFF, LOADEDMOBS, LOADEDITEMS, and the ones that end with ..GROUP. The ones that end in group can be used as-is to load the group of objects into one of the $0..$9 vars. However, you can also tack on a "#" to the end of the name to return the number of items in the group instead of the group itself. After that, you can tack on a number like "#n" to return the nth item in the group. See the examples for more information on that. </p> <p> EXAMPLES: </p> <pre>mploadquestobj 'myquest' 'MOB' $t <br />mploadquestobj 'myquest' 'TOOLGROUP#' $0<br />for $1 = 1 to $0<br /> mploadquestobj 'myquest' 'TOOLGROUP#$1' $2<br /> mpecho $2 is now the $1th tool of $0 total in the myquest toolgroup.<br />next</pre> <h3><a name="mploadvar">mploadvar</a></h3> <p> Usage: </p> <pre>mploadvar [mob name] [variable name]<br /></pre> <p> This command loads a variable stored in the database using the given parameters. The variable is then available to the VAR function, as well as the $< syntax. The mob name can for a variable can be a literal name string or a code like $n or $i. The variable name must be a literal string. </p> <p> EXAMPLES: </p> <pre>mploadvar $n KILLS<br />mploadvar guardfour RESCUES<br /></pre> <h3><a name="mplock">mplock</a></h3> <p> Usage: </p> <pre>mplock [target]<br /></pre> <p> This command locks the target item or exit. If the target is already locked, or does not have a door or lock, nothing happens </p> <p> EXAMPLES: </p> <pre>mplock $xN<br />mplock east<br />mplock chest<br /></pre> <h3><a name="mplog">mplog</a></h3> <p> Usage: </p> mplog error [module] [message]<br /> mplog info [module] [message]<br /> mplog debug [module] [message]<br /> <br /> <p> This command outputs the given message to the coffeemud log file. For debug style messages to appear, the appropriate DBGMSGS entry in the coffeemud.ini file must be turned on. </p> <p> EXAMPLE: </p> mplog info MyQuest $n has successfully completed my quest.<br /> <h3><a name="mpm2i2m">mpm2i2m</a></h3> <p> Usage: </p> <pre>mpm2i2m [target]<br /></pre> <p> This strange command turns a target mob into an item, and an item back into a mob. The target may be a mob, or an item which was created with mpm2i2m or the Cage skill. </p> <p> EXAMPLES: </p> <pre>mpm2i2m $n<br /></pre> <p> SPECIAL NOTES: If anyone comes up with a practical use for this command in an actual script, please let me know! </p> <h3><a name="mpmload">mpmload</a></h3> <p> Usage: </p> <pre>mpmload [mob name]<br />mpmload fromfile [cmare filename] [mob name]<br />mpmload fromfile [cmare filename] any<br /></pre> <p> This command loads the mob designated by name into the room. If you want the mob loaded somewhere besides the room the mpmloading mob is located, you'll need to use the mpat command. This command gives no message to the world, so if you want one, you'll use the mpecho command. This command is useful for loading mobs to assist the calling mob in combat, load in-zone quest mobs, etc. The mob of that name will be searched for throughout the map, so if you want to make sure the mob is available for this command, he should be carefully hidden. The fromfile syntax will allow you to load a mob from a cmare file created using the Archon EXPORT MOBS command. </p> <p> EXAMPLES: </p> <pre>mpmload the nasty bat<br />mpmload fromfile mymobs.cmare the nasty bat<br />mpmload fromfile mymobs.cmare any<br /></pre> <p> SPECIAL NOTES: Remember that this newly loaded mob may not have interacted with the world just yet, so having your mob, for example, mpforce it to kill $n will not work, since the new mob has no idea who $n is. </p> <h3><a name="mpnotrigger">mpnotrigger</a></h3> <p> Usage: </p> <pre>mpnotrigger [trigger name] [time in miliseconds]<br /></pre> <p> This command will prevent a scriptable event with the given trigger name on the same creature to trigger for the given amount of time. Where trigger name may be any of the above scriptable triggers, such as "greet_prog" or "level_prog" or any other. After the amount of time has passed, the trigger will be allowed. </p> <p> EXAMPLES: </p> <pre>mpnotrigger greet_prog 10000<br /></pre> <p> SPECIAL NOTES: This command is useful mainly to most easily prevent a greet_prog from firing for an entire group, or in cases where someone leaves and re-enters very quickly. </p> <h3><a name="mpoload">mpoload</a></h3> <p> Usage: </p> <pre>mpoload [item name]<br />mpoload fromfile [cmare filename] [item name]<br />mpoload fromfile [cmare filename] any<br />mpoload [item name] into [container name]<br /></pre> <p> This command loads an item of the designated name into the inventory of the mob. If you want to load an item into a room, you must use the mpoloadroom command. This command gives no message to the world, so if you want one you'll have to use the mpecho command. This command is very useful for loading in-zone quest objects, mob pelts, portals, etc. It has many, many uses. The item of that name will be searched for throughout the map, so if you want to make sure the item is available for this command, it should be carefully hidden. The <b>fromfile </b>syntax will allow you to load an item from a cmare file created using the Archon EXPORT ITEMS command The <b>into </b>syntax will allow you to load the item into a pre-existing container, even if the container is in the room. </p> <p> EXAMPLES: </p> <pre>mpoload the baseball bat<br />mpoload fromfile myitems.cmare the baseball bat<br />mpoload fromfile myitems.cmare any<br />mpoload fromfile myitems.cmare any into wooden chest<br /></pre> <p> SPECIAL NOTES: You can do a lot with this command. There is no max on items loaded in this way, so keep that in mind. </p> <h3><a name="mpoloadroom">mpoloadroom</a></h3> <p> Usage: </p> <pre>mpoloadroom [item name]<br />mpoloadroom fromfile [cmare filename] [item name]<br />mpoloadroom fromfile [cmare filename] any<br />mpoloadroom [item name] into [container name]<br /></pre> <p> This command loads an item of the designated name into the same room as the mob. If you want to load an item into a mobs inventory, you must use the mpoload command. This command gives no message to the world, so if you want one you'll have to use the mpecho command. This command is very useful for loading in-zone quest objects, mob pelts, portals, etc. It has many, many uses. The item of that name will be searched for throughout the map, so if you want to make sure the item is available for this command, it should be carefully hidden. The <b>fromfile </b>syntax will allow you to load an item from a cmare file created using the Archon EXPORT ITEMS command. The <b>into </b>syntax will allow you to load the item into a pre-existing container in the room. </p> <p> SPECIAL NOTES: You can do a lot with this command. There is no max on items loaded in this way, so keep that in mind. Using this command along with the mppurge command can create shifting portals and the like. </p> <h3><a name="mpopen">mpopen</a></h3> <p> Usage: </p> <pre>mpopen [target]<br /></pre> <p> This command opens a lid on a container, or the door on an exit. This command has no effect if there is no lid or door, or it is already open. </p> <p> EXAMPLES: </p> <pre>mpopen $xN<br />mpopen the magic door<br /></pre> <h3><a name="mpplayerclass">mpplayerclass</a></h3> <p> Usage: </p> <pre>mpplayerclass [target] [char class id] ([level] [char class id] [level] ...)<br /></pre> <p> This command allows you to change the current character class of a player, to add new character classes to a player, and to modify specific class levels all with one command. The first parameter is the player or mobs code. The next parameter must be a valid character class id, such as Fighter or Necromancer. This will instantly set that class as the targets current class, adding it if necessary. This may be optionally followed by a level integer, which will change the class level of that current class. The level parm may then be followed by another character class id, which will change the players current class again, and may be followed again by a level integer to change the new current character class level, and so on. </p> <p> EXAMPLES: </p> <pre>mpplayerclass $n Fighter<br />mpplayerclass $n Thief 20<br />mpplayerclass guardtwo Fighter 10<br />mpplayerclass $n Thief 20 Fighter 10 Mage 5</pre> <h3><a name="mppracs">mppracs</a></h3> <p> Usage: </p> <pre>mppracs [target] [amount]<br />mppracs [target] ++[amount]<br />mppracs [target] --[amount]</pre> <p> This command sets the mobs number of practices to the given number, or adjusts their existing practices by an amount upwards or downloads depending on syntax. A number alone will change their existing number of practices to the given number. The ++ syntax followed by a number will raise their amount by the given number. The -- syntax followed by a number will lower their amount by the given number. This is a useful command to use to award players for completing in zone quests, etc. that you have set up. It is best when you reward a player using this command that you alsogive some sort of message to the player about why they are receiving the award. </p> <p> EXAMPLES: </p> <pre>mppracs $n 0<br />mppracs $n ++3<br />mppracs $n --1</pre> <p> SPECIAL NOTES: Be careful with this command. You don't want to give out awards for every little thing characters do, nor do you want to give large awards for menial tasks. You also will, of course, not want to make it so a mob can accidentally give the same award over and over endlessly, or something equally abusable. </p> <h3><a name="mppurge">mppurge</a></h3> <p> Usage: </p> <pre>mppurge [argument]<br /></pre> <p> This command destroys the argument in the room with the mob. This argument can be a mob keyword, item keyword, character variable, or self. If the argument all is given, then the mob clears the room of all objects in the room. If you are going to have a mob mppurge itself, it must be the last command the mob does, or bad things will happen. Also, never ever mppurge oneself as part of a death_prog. This is a very useful command. With it you can destroy charmed mobs, switch portals and the like, and clear out mobs and objects you may have loaded. </p> <p> EXAMPLES: </p> <pre>mppurge portalone<br />mppurge guardthree<br />mppurge $n<br />mppurge self<br /></pre> <p> SPECIAL NOTES: It is a good idea to have unique keywords for mobs and items you are sure you are going to be mppurging. That way there is no mistake what you are trying to mppurge. Also, you should avoid mppurging players, as it basically causes them to be ejected from the game. Use this command for mobs that set up special quests and then go away, so each zone reset you'll have a fresh zone for adventurers to pillage.</p> <h3><a name="mpqset">mpqset</a></h3> <p> Usage: </p> <pre>mpqset [questname] [variable] [value]</pre> <p>This command is used to set one of the internal quest variables. These variables can be one of the standard Quest settings, such as: "CLASS", "NAME", "DURATION", "WAIT", "MINPLAYERS", "PLAYERMASK", "RUNLEVEL", "DATE", "MUDDAY", or "INTERVAL". More commonly though, they are user-defined variables which are only available for the duration of the quest, and reset each time the quest is started. Questname may be the name of a quest, or it may be * if this Scriptable object was assigned by a Quest. These variables can be read with the QVAR function. </p> <p> EXAMPLES: </p> <pre>mpqset 'myquest' 'myspecialquestvariable' $n<br /></pre> <h3><a name="mpquestpoints">mpquestpoints</a></h3> <p> Usage: </p> <pre>mpquestpoints [target] [amount]<br />mpquestpoints [target] ++[amount]<br />mpquestpoints [target] --[amount]</pre> <p> This command sets the mobs number of quest points to the given number, or adjusts their existing quest points by an amount upwards or downloads depending on syntax. A number alone will change their existing number of quest points to the given number. The ++ syntax followed by a number will raise their amount by the given number. The -- syntax followed by a number will lower their amount by the given number. This is a useful command to use to award players for completing in zone quests, etc. that you have set up. It is best when you reward a player using this command that you alsogive some sort of message to the player about why they are receiving the award. </p> <p> EXAMPLES: </p> <pre>mpquestpoints $n 0<br />mpquestpoints $n ++3<br />mpquestpoints $n --1</pre> <p> SPECIAL NOTES: Be careful with this command. You don't want to give out awards for every little thing characters do, nor do you want to give large awards for menial tasks. You also will, of course, not want to make it so a mob can accidentally give the same award over and over endlessly, or something equally abusable.<br /> </p> <h3><a name="mpquestwin">mpquestwin</a></h3> <p> Usage: </p> <pre>mpquestwin [mob name] [quest name]<br /></pre> <p> This command declares the given mob as the winner of the quest of the given name. This makes the mob available to the QUESTWINNER function. This command is absolutely necessary to ensuring that players do not repeatedly win the same quests over and over again. If the Scriptable behavior was granted as part of a Quest, then * may be substituted for the questname. </p> <p> EXAMPLES: </p> <pre>mpquestwin $n smurfocide<br /></pre> <h3><a name="mpreset">mpreset</a></h3> <p> Usage: </p> <pre>mpreset area<br />mpreset room<br />mpreset [area name]<br />mpreset [room id]<br /></pre> <p> This command allows you to force the system to reload an area or a room from the database. The keywords area and room will refer to the scripted objects current area and room. Otherwise, the name of the area, or the full roomID can be specified. </p> <p> EXAMPLES: </p> <pre>mpreset area<br /></pre> <p> SPECIAL NOTES: Be very careful with this command when dealing with players in the area. It will end their combat, clean up items in the rooms they are in, and otherwise freeze them up while the reset process completes. This process can be time consuming for large areas, so take that into consideration. </p> <h3><a name="mpsavevar">mpsavevar</a></h3> <p> Usage: </p> <pre>mpsavevar [mob name] [variable name]<br /></pre> <p> This command saves a variable to the database using the given parameters. This will ensure that the variable, if reloaded later using mploadvar, survives reboots, resets, and other catastrophes. The variable specified must be one created by the MPSETVAR command. </p> <p> The mob name can for a variable can be a literal name string or a code like $n or $i. The mob name can also be *, which will save the value of every existing variable of the given variable name. Likewise, the variable name can also be *, which will save the value of every existing variable for the given mob. </p> <p> EXAMPLES: </p> <pre>mpsavevar $n KILLS<br />mpsavevar guardfour RESCUES<br /></pre> <h3><a name="mpset">mpset</a></h3> <p> Usage: </p> <pre>mpset [target] [variable] [value]<br /></pre> <p> This powerful command lets you change all kinds of aspects of the target mob or item or whatever. This command differentiates between generic and standard items and mobs. Standard items and mobs do not have as many changeable properties as generic items do. For the maximum range of available variables, use mpgset. </p> <p> Valid variable names are identical to those listed under mpset. Please see that command above for a list of valid variables. </p> <p> EXAMPLES: </p> <pre>mpset $n CHARISMA 10<br />mpset $n NAME my name is mud<br /></pre> <p> SPECIAL NOTES: Be very careful with this command when dealing with players. If used poorly it can cause bad things to happen to them, so make sure you have good checks to ensure they get affected correctly and fairly. </p> <h3><a name="mpsetclandata">mpsetclandata</a></h3> <p> Usage: </p> <pre>mpsetclandata [clan] [variable] [value]<br /></pre> <p> This powerful command lets you change several aspects of the given clan based on the given variable. The clan code may be either a mob code to denote that mobs clan, or a clan name. Valid variables for setting are: ACCEPTANCE, DONATEROOM, EXP, GOVT, MORGUE, POLITICS, PREMISE, RECALL, STATUS, TAXES, TROPHIES. </p> <p> EXAMPLES: </p> <pre>mpsetclandata 'Groovy Clan' EXP 0<br />mpecho Groovy Clans experience is now gone!<br />mpset $n PREMISE my premise is new.<br />mpecho Whoever $n is, their clan now has a new premise!<br /></pre> <p> SPECIAL NOTES: Be very careful with this command, to ensure no damage is done to clan records. </p> <h3><a name="mpsetvar">mpsetvar</a></h3> <p> Usage: </p> <pre>mpsetvar [mob name] [variable name] [value]<br />mpsetvar [mob name] [variable name] ++<br />mpsetvar [mob name] [variable name] --<br />mpsetvar [mob name] [variable name] +[number]<br />mpsetvar [mob name] [variable name] -[number]<br />mpsetvar [mob name] [variable name] *[number]<br />mpsetvar [mob name] [variable name] /[number]<br /></pre> <p> This command creates a variable for a mob or player and stores a value in it. You can mpsetvar any name that you choose to, and the value can be a specific text string, an integer, or an expanded character variable. The value can even be mathematical expression as shown above. The starting value of the variable will be affected by the expression given instead of merely set to it. </p> <p> The mob name can be a literal name string or a code like $n or $i. The mob name can also be *, which will change the value of every existing variable of the given variable name. Likewise, the variable name can also be *, which will change the value of every existing variable for the given mob. A value is normally required, but not giving a value removes that variable from memory, so if you want a variable to remain in memory so as to be accessible to * syntax, you will need to include some value. </p> <p> EXAMPLES: </p> <pre>mpsetvar $i bugcount 1<br />mpsetvar $i bugcount ++<br />mpsetvar 'frog boy' 'my victim' The guard<br />mpsetvar $n 'my victim' var-actor<br />mpsetvar $i bugcount $<$n bugcount><br />mpsetvar * bugcount<br />mpsetvar $i * null<br /></pre> <p> SPECIAL NOTES: Variables rock. You can do almost anything you ever wanted to do once you get the hang of them. </p> <h3><a name="mpslay">mpslay</a></h3> <p> Usage: </p> <pre>mslay [victim]<br /></pre> <p> This command kills the victim dead. </p> <p> EXAMPLES: </p> <pre>mpslay $n<br />mpslay ogre<br /></pre> <h3><a name="mpstartquest">mpstartquest</a></h3> <p> Usage: </p> <pre>mpstartquest [quest name]<br /></pre> <p> This command causes the given Quest name to start running. If the Quest is already running, nothing will happen. This command is useful for having scripted mobs start quests for you. If the Scriptable behavior was granted as part of a Quest, then * may be substituted for the questname. </p> <p> EXAMPLES: </p> <pre>mpstartquest smurfocide<br /></pre> <h3><a name="mpstop">mpstop</a></h3> <p> Usage: </p> <pre>mpstop [target]<br /></pre> <p> This command forces the target to stop fighting. If the target happens to be in the middle of working with a common skill, it will stop that too. </p> <p> EXAMPLES: </p> <pre>mpstop $n<br />mpstop ogre<br /></pre> <h3><a name="mptattoo">mptattoo</a></h3> <p> Usage: </p> <pre>mptattoo [target] (-)[tattoo name]<br /></pre> <p> This command grants or removes from the target a tattoo of the given name. This is useful for permanently flagging players in some way which can be checked and acted on elsewhere, for instance using the HASTATTOO function. The tattoo must begin with the character - to denote removal. </p> <p>When adding new tattoos, you can prefix the name with a number to create a temporary tattoo that disappears in the given number of ticks.</p> <p> EXAMPLES: </p> <pre>mptattoo $n smurfkiller<br />mptattoo $n -smurfkiller<br />mptattoo $n '50 smurfkiller'<br /><br /></pre> <h3><a name="mptitle">mptitle</a></h3> <p> Usage: </p> <pre>mptitle [target] (-)[title string]<br /></pre> <p> This command grants or removes from the target a title given. Title strings are are name replacements for player mobs in which any * character in the string is replaced with the players name. The player uses the TITLE command to select which of any granted titles they may use. This command is completely case sensitive. </p> <p> EXAMPLES: </p> <pre>mptitle $n '*, slayer of smurfs'<br />mptitle $n '-*, slayer of smurfs'<br /> </pre> <h3><a name="mptrackto">mptrackto</a></h3> <p> Usage: </p> <pre>mptrackto [mob name]<br />mptrackto [room id]<br />mptrackto [area name]<br /></pre> <p> This command causes the mob to begin walking towards the given target. If there are doors in his way, he will open them. If they are locked, he will unlock them. If there are no-mob areas in the way, he will walk through them. Nothing short of combat will stop him from getting to the target room. This command is identical to the mpwalkto command, except that this command will allow paths through the air or water if those paths are shorter. This command should never be chosen over mpwalkto, unless the tracking mob is a fish or a bird. </p> <p> EXAMPLES: </p> <pre>mptrackto the master guildsmith<br />mptrackto myArea#123<br />mptrackro Smurf Villiage</pre> <h3><a name="mptrains">mptrains</a></h3> <p> Usage: </p> <pre>mptrains [target] [amount]<br />mptrains [target] ++[amount]<br />mptrains [target] --[amount]</pre> <p> This command sets the mobs number of training sessions to the given number, or adjusts their existing training sessions by an amount upwards or downloads depending on syntax. A number alone will change their existing number of training sessions to the given number. The ++ syntax followed by a number will raise their amount by the given number. The -- syntax followed by a number will lower their amount by the given number. This is a useful command to use to award players for completing in zone quests, etc. that you have set up. It is best when you reward a player using this command that you alsogive some sort of message to the player about why they are receiving the award. </p> <p> EXAMPLES: </p> <pre>mptrains $n 0<br />mptrains $n ++3<br />mptrains $n --1</pre> SPECIAL NOTES: Be careful with this command. You don't want to give out awards for every little thing characters do, nor do you want to give large awards for menial tasks. You also will, of course, not want to make it so a mob can accidentally give the same award over and over endlessly, or something equally abusable.<br /> <h3><a name="mptransfer">mptransfer</a></h3> <p> Usage: </p> <pre>mptransfer [victim] [destination]<br /></pre> <p> This command sends the victim to a designated destination. The victim can be either a mob keyword or a character variable. The destination can be a room id, room name or description, a mob keyword, or a character variable. If there is no destination given, the mob transfers the victim to the same room that it is in. There is no message given to this command, so if you want there to be one, you need to include an mpecho in your mobprog. This command is a good way to move players around your zone or into other zones. </p> <p> EXAMPLES: </p> <pre> mptransfer $n myarea#10049<br /> mptransfer $n<br /> mptransfer guardeight myarea#1252<br /> mptransfer guardten $n<br /> </pre> <p> SPECIAL NOTES: You need to be careful with this command. First of all, you should never transfer a character variable that is a mob. Why not? Because you may actually end up transferring a different mob entirely with a keyword that is the same. You can mptransfer mobs if they have unique keywords. Also, be sure to be careful about mptransfering mobs to players. If a player recalls or dies, you will end up transferring a mob into town. </p> <h3><a name="mpunaffect">mpunaffect</a></h3> <p> Usage: </p> <pre>mpunaffect [target] [affect id]<br /></pre> <p> This command dispels the given affect from the target. If no affect name is given, or ALL is given, then all non-permanent affects will be removed. Any affects listed by name will always be removed, even if they are permanent. You should check out the list of skills, spells, and properties for a list of valid ids to give. </p> <p> EXAMPLES: </p> <pre>mpunaffect $n<br />mpunaffect $n Spell_Sleep<br />mpunaffect $n Skill_Track<br /></pre> <h3><a name="mpunbehave">mpunbehave</a></h3> <p> Usage: </p> <pre>mpunbehave [behavior id] [target]<br /></pre> <p> This command removes the given behavior from the target. You should check out the list behaviors by entering LIST BEHAVIORS on the command line. </p> <p> EXAMPLES: </p> <pre>mpunbehave Mobile $n<br /></pre> <h3><a name="mpunhide">mpunhide</a></h3> <p> Usage: </p> <pre>mpunhide [target]<br /></pre> <p> This command reverses the affects of mphide, making the target (possibly) visible again. </p> <p> EXAMPLES: </p> <pre>mpunhide $n<br /><br /></pre> <h3><a name="mpunhide">mpunloadscript</a></h3> <p> Usage: </p> mpunloadscript [file name]<br /> <p> This command accepts only the name of a Scriptable script file that has already been loaded from the filesystem by a Scriptable behavior and parsed for processing. The parameter MUST resolve to a valid file in your CoffeeMud file system, and is usually the result of putting a LOAD=<filename> parameter on a Scriptable behavior. Remember that, since this is a Scriptable filename, that /resources/ is implied.</p> <p>The purpose of this command is to allow the script writer to de-cache his scripts automatically for cases where scripts are being dynamically built, so that they can be re-read and re-processed by the CoffeeMud Scripting Engine. </p> <p> EXAMPLES: </p> mpunloadscript progs/myscript.script<span style="font-weight: bold;"> </span> <h3><a name="mpunlock">mpunlock</a></h3> <p> Usage: </p> <pre>mpunlock [target]<br /></pre> <p> This command unlocks the given container or exit. This command has no effect if the target does not have a lid, does not have a lock, or is already unlocked or open. No key is required. </p> <p> EXAMPLES: </p> <pre>mpunlock $xN<br />mpunlock chest<br /></pre> <h3><a name="mpwhile">mpwhile</a></h3> <p> Usage: </p> <pre>mpwhile ([condition]) [command]<br /></pre> <p> This command repeatedly executes the given command, so long as the given condition remains true. This is the only mechanism for looping in Scripts, so it should be used carefully, although a safeguard is in place to prevent an mpwhile loop from ever running longer than 4 seconds. The [condition] must be enclosed in parenthesis, and is subject to the same rules listed under the IF command above. Since only one command parameter is allowed, it is necessary for you to use MPCALLFUNC and FUNCTION_PROG in order to execute more than one command during a loop cycle. </p> <p> EXAMPLES: </p> <pre>mpwhile (VAR($n bittlock < 1)) MPCALLFUNC myprogram $<$n bittlock><br /></pre> <h3><a name="mpwalkto">mpwalkto</a></h3> <p> Usage: </p> <pre>mpwalkto [mob name]<br />mpwalkto [room id]<br />mpwalkto [area name]<br /></pre> <p> This command causes the mob to begin walking towards the given target. If there are doors in his way, he will open them. If they are locked, he will unlock them. If there are no-mob areas in the way, he will walk through them. Nothing short of combat will stop him from getting to the target room. This command is identical to the mptrackto command, except that this command only finds land-surface paths, ignoring possible paths through the air or over water. This command should always be used instead of mptrackto, unless the tracking mob is a fish or a bird. </p> <p> EXAMPLES: </p> <pre>mpwalkto the master guildsmith<br />mpwalkto myArea#123<br />mpwalkto Smurf Villiage<br /></pre> <h3><a name="return">return</a></h3> <p> Usage: </p> <pre>return ([string])<br /></pre> <p> This command causes the current script block to immediately cease executing. If this statement is used inside of a FUNCTION_PROG triggered script, it will return a value from the function. This value can be accessed only if the FUNCTION_PROG was called using the CALLFUNC scripting function (see below). </p> <p> EXAMPLES: </p> <pre>return<br />return $<$n myvariable><br /></pre> <h2><a name="functions">Scripting Functions</a></h2> <p> Functions are what make your IF checks work. They can be fairly simple, and they can be massively complicated. There are quite a few of them, but knowing how and where to use them is rewarding if you want to have truly unique and intelligent scripts. </p> <h3><a name="logicalOperators">Logical Operators</a></h3> <p> These operators are found in many of the functions below. Here are their meanings: </p> <pre>== This operator means ‘equal to'<br />!= This operator means ‘not equal to'<br />> This operator means ‘greater than'<br />< This operator means ‘less than'<br />>= This operator means ‘equal or greater than'<br /><= This operator means ‘equal or less than'<br /></pre> <h3><a name="affected">affected</a></h3> <p> Usage: </p> <pre>affected(character spellid)<br /></pre> <p> This checks whether the character is under the effects of the given spell. The spellid must be the full Java name of the spell, skill, prayer, property, chant, or whatever. </p> <p> EXAMPLE: </p> <pre>if affected($n, Spell_Sleep)<br /> mpecho The actor triggering me is asleep.<br />else<br /> mpecho The actor triggering me is not under the effects of the sleep spell.<br />endif<br /></pre> <h3><a name="baseclass">baseclass</a></h3> <p> Usage: </p> <pre>baseclass(character == baseclassname)<br /></pre> <p> This checks whether the character is a class which is part of the given baseclass. Where '==' may be another logical operator from above. Valid baseclasses include Archon, Artisan, Fighter, Druid, Mage, Cleric, Thief, or Bard. </p> <p> EXAMPLE: </p> <pre>if baseclass($n == Archon)<br /> mpecho The actor triggering me is an Archon.<br />else<br /> mpecho The actor triggering me is not an Archon.<br />endif<br /></pre> <h3><a name="callfunc">callfunc</a></h3> <p> Usage: </p> <pre>callfunc(myfunctionname parm1 parm2...parmn)<br /></pre> <p> This function, similar to the MPCALLFUNC statement above, will cause the script block with the trigger type FUNCTION_PROG and the given name to execute. The parameters passed into the callfunc can be referenced using the $g and $G codes. See the MPCALLFUNC statement above for more information on creating functions. </p> <p> The callfunc function returns true ONLY if the FUNCTION_PROG includes a RETURN statement that includes a non-empty string parameter. </p> <p> EXAMPLE: </p> <pre>function_prog myfunc<br />return $g<br />~<br /><br />once_prog<br />if callfunc(myfunc ASTRING)<br /> mpecho This callfunc function will always return true.<br /> mpecho This is because myfunc just returns the parameter it is given.<br /> mpecho And this callfunc is passing in a non-empty string as a parameter.<br />endif<br /><br />if !callfunc(myfunc)<br /> mpecho This callfunc function will always return false, since my parameters are empty.<br />endif<br />~<br /></pre> <h3><a name="clan">clan</a></h3> <p> Usage: </p> <pre>clan(character == clanname)<br /></pre> <p> This checks the name of the clan of the character variable. Where '==' may be another logical operator from above. </p> <p> EXAMPLE: </p> <pre>if clan($n == 'The Unholy Goobers')<br /> mpecho The actor triggering me appears to be an Unholy Goober.<br />else<br /> mpecho The actor triggering me appears not to be a Goober.<br />endif<br /></pre> <h3><a name="clandata">clandata</a></h3> <p> Usage: </p> <pre>clandata(clan variable == value)<br /></pre> <p> This checks the value of a piece of datum about the given clan. The clan parameter may be either a mob to denote the mobs clan, or a clan name. Where variable should be one of the following ACCEPTANCE, DETAIL, DONATEROOM, EXP, GOVT, MORGUE, POLITICS, PREMISE, RECALL, SIZE, STATUS, TAXES, TROPHIES, TYPE, AREAS, MEMBERLIST, or TOPMEMBER. Where '==' may be another logical operator from above. The value may be any numeric, string, or literal. </p> <p> EXAMPLE: </p> <pre>if clandata($n SIZE <= 1)<br /> mpecho The actor triggering me appears to be the only solitary member of the clan.<br />else<br /> mpecho The actor triggering me appears to be part of a clan larger than 1 member.<br />endif<br /></pre> <h3><a name="clanrank">clanrank</a></h3> <p> Usage: </p> <pre>clanrank(character == integer)<br /></pre> <p> This checks the rank of the character in their clan. Where '==' may be another logical operator from above. Valid values include: APPLICANT=0, MEMBER=1, STAFF=2, ENCHANTER=4, TREASURER=8, LEADER=16, BOSS=32 </p> <p> EXAMPLE: </p> <pre>if clanrank($n == 0)<br /> mpecho The actor triggering me appears to be an APPLICANT.<br />else<br /> mpecho The actor triggering me appears not to be an APPLICANT.<br />endif<br /></pre> <h3><a name="class">class</a></h3> <p> Usage: </p> <pre>class(character == classname)<br /></pre> <p> This checks the class of the character variable. For players, this is their class, or in the case of a multi-classed character, the class they multied into. For disguised characters, this is the class they appear to be. Where '==' may be another logical operator from above. </p> <p> EXAMPLE: </p> <pre>if class($n == Gaian)<br /> mpecho The actor triggering me appears to be a Gaian.<br />else<br /> mpecho The actor triggering me appears not to be a Gaian.<br />endif<br /></pre> <h3><a name="currency">currency</a></h3> <p> Usage: </p> <pre> currency(character == currencyname)<br /></pre> <p> This compares the player character or coin item native currency to the string. The '==' may also be '!='. </p> <p> EXAMPLE: </p> <pre>if currency($n == 'COPPER')<br /> mpecho You are using the bits currency.<br />else<br /> mpecho You must be using something else.<br />endif<br /></pre> <h3><a name="deity">deity</a></h3> <p> Usage: </p> <pre>deity(character == deityname)<br /></pre> <p> This checks the name of the deity of the character variable. Where '==' may be another logical operator from above. </p> <p> EXAMPLE: </p> <pre>if deity($n == 'Gothon')<br /> mpecho The actor triggering me appears to worship an Unholy Goober.<br />else<br /> mpecho The actor triggering me appears not to worship Gothon.<br />endif<br /></pre> <h3><a name="eval">eval</a></h3> <p> Usage: </p> <pre>eval(expression == expression)<br /></pre> <p> This powerful function compares the first expression to the second expression. Expressions may be codes, literal strings, or literal numbers. This function also allows you to compare variables. Where '==' may be any other logical operator from above. This is an extremely powerful function that can, if used properly, take care of all of the evaluation needs which other functions do not provide. Examine carefully the section on codes above to see all the different things you can evaluate. </p> <p> EXAMPLE: </p> <pre>if eval($n == an orc) or eval('$<$i VAR>' != 7)<br /> mpecho Evaluates to true.<br />else<br /> mpecho Evaluates to false.<br />endif</pre> <h3><a name="exp">exp</a></h3> <p> Usage: </p> exp(character > amount)<br /> <p> This evaluates the total amount of experience that the character variable has earned. Where '==' may be any other logical operator from above. </p> <p> EXAMPLE: </p> if exp($n < 10000)<br /> mpecho The actor has less than 10000 experience<br /> else<br /> mpecho The actor has 10000 experience<br /> endif <h3><a name="explored">explored</a></h3> <p> Usage: </p> <pre>explored(character areaname == number)<br />explored(character world == number)<br /></pre> <p> This function compares the percentage of the given area or of the world which the given mob has explored. The number should always be between 0 and 100, reflecting what percentage of the area or world that the character has explored. Where '==' may be any other logical operator from above. Remember that percentage exploration is only stored for players, not for NPC mobs. </p> <p> EXAMPLES: </p> <pre>if explored($n $a > 10)<br /> mpecho You have explored more than 10% of this area.<br />else<br /> mpecho You have explored less than 10% of this area.<br />endif<br /><br />if explored($n world > 10)<br /> mpecho You have explored more than 10% of the world.<br />else<br /> mpecho You have explored less than 10% of the world.<br />endif<br /></pre> <h3><a name="faction">faction</a></h3> <p> Usage: </p> <pre>faction(character factionid == value)<br /></pre> <p> This function checks to see if the player or mob given has the given faction. If it does not, the value will always be empty string. Otherwise, it compares the value of the players faction with the value. If the value is numeric, it will compare the numeric value of the players faction. If the value is non-numeric, it will compare the name of the range into which the player falls in the given faction with the value given. </p> <p> EXAMPLE: </p> <pre>if faction($n alignment.ini >500 ) or faction($n alignment.ini == 'Pure Goodness')<br /> mpecho The actor is either just north of neutral, or very very good.<br />else<br /> mpecho The actor is some other alignment.<br />endif<br /></pre> <h3><a name="goldamt">goldamt</a></h3> <p> Usage: </p> <pre>goldamt(character > amount)<br /></pre> <p> This evaluates the total amount of money that the character variable has on hand, or the value of the item if an item code is used instead of a character code. Where '==' may be any other logical operator from above. The value is always expressed in base gold, regardless of currency or denomination. </p> <p> EXAMPLE: </p> <pre>if goldamt($n < 10000)<br /> mpecho The actor has less than 10000 coins on hand<br />else<br /> mpecho The actor has 10000 coins or more on hand<br />endif<br /></pre> <h3><a name="gstat">gstat</a></h3> <p> Usage: </p> <pre>gstat(target variable == value)<br /></pre> <p> This is another powerful function which allows you to make comparisons based on numerous characteristics of the target. The target may be any code, including mobs or items. The variable may be any of those listed above under MPGSET in the section on Scriptable Commands. The '==' may be any of the above logical operators, and the value any expression, including codes. </p> <p> EXAMPLES: </p> <pre>if gstat($n CHARISMA > 10)<br /> mpecho The actor has a charisma greater than 10.<br />endif<br /></pre> <h3><a name="has">has</a></h3> <p> Usage: </p> <pre>has(character item)<br /></pre> <p> This checks whether the character has the given item in their inventory or on their person. </p> <p> EXAMPLE: </p> <pre>if has($n a long sword)<br /> mpecho The actor has a long sword.<br />else<br /> mpecho The actor does not have anything called 'a long sword'.<br />endif<br /></pre> <h3><a name="hasnum">hasnum</a></h3> <p> Usage: </p> <pre>hasnum(character item > value)<br /></pre> <p> This checks whether the character has some number of the given item in their inventory or on their person. The character may also be the code for a room. </p> <p> EXAMPLE: </p> <pre>if hasnum($n 'a long sword' > 1)<br /> mpecho The actor has several long swords.<br />else<br /> mpecho The actor does not have anything called 'a long sword', or only has 1.<br />endif<br /></pre> <h3><a name="hastattoo">hastattoo</a></h3> <p> Usage: </p> <pre>hastattoo(character item)<br /></pre> <p> This checks whether the character has had the given tattoo assigned to them. </p> <p> EXAMPLE: </p> <pre>if hastattoo($n beastmark)<br /> mpecho The actor has the tattoo called beastmark.<br />else<br /> mpecho The actor does not have the tattoo called beastmark.<br />endif<br /></pre> <h3><a name="hitprcnt">hitprcnt</a></h3> <p> Usage: </p> <pre>hitprcnt(character == amount)<br /></pre> <p> This checks compares the character's percentage of hitpoints remaining with the amount give. Where '==' may be any logical operator from above. The amount must evaluate to something between 1 and 100. </p> <p> EXAMPLE: </p> <pre>if hitprcnt($n <= 20)<br /> mpecho The actor has 20% of their hit points or less remaining.<br />else<br /> mpecho The actor has more than 20% of their hit points less.<br />endif<br /></pre> <h3><a name="incontainer">incontainer</a></h3> <p> Usage: </p> <pre>incontainer(character container/mount)<br /></pre> <p> This checks whether the character is on the given mount, or, if the character is an item, whether the item is in the given container. </p> <p> EXAMPLES: </p> <pre>if incontainer($n a chair)<br /> mpecho The actor is sitting on a chair<br />else<br /> mpecho The actor is not sitting on a chair<br />endif<br /><br />if incontainer($p a sack)<br /> mpecho The item is in a sack.<br />else<br /> mpecho The item is not in a sack.<br />endif<br /></pre> <h3><a name="inlocale">inlocale</a></h3> <p> Usage: </p> <pre>inlocale(character roomclass)<br /></pre> <p> This checks whether the character is presently standing in a room of a given class. The roomclass must be a specific Java name for a Room class. Values like CaveMaze, Jungle, InTheAir, Plains, etc are what we are after here. </p> <p> EXAMPLES: </p> <pre>if inlocale($n InTheAir)<br /> mpecho The actor either flying or falling.<br />else<br /> mpecho The actor is not up in the air.<br />endif<br /></pre> <h3><a name="inroom">inroom</a></h3> <p> Usage: </p> <pre>inroom(target == roomcode)<br /></pre> <p> This checks to see if the target is in the room specified by the room code. The room code may be a room id, a mob name, or text from the rooms name or description. The '==' may also be '!='. </p> <p> EXAMPLES: </p> <pre>if inroom($i == a bathroom)<br /> mpecho This means I am in a bathroom.<br />else<br /> mpecho I am not in a bathroom.<br />endif<br /><br />if inroom($i != MyArea#20001)<br /> mpecho I am not in room MyArea#20001.<br />else<br /> mpecho I am in room MyArea#20001.<br />endif<br /></pre> <h3><a name="ipaddress">ipaddress</a></h3> <p> Usage: </p> <pre>ipaddress(character == string)<br /></pre> <p> This compares the player characters ipaddress to the string. The '==' may also be '!='. </p> <p> EXAMPLE: </p> <pre>if ipaddress($n == '127.0.0.1')<br /> mpecho You are logging on from the mud server<br />else<br /> mpecho You must be someone else.<br />endif<br /></pre> <h3><a name="isable">isable</a></h3> <p> Usage: </p> <pre>isable(character spellid)<br /></pre> <p> This checks whether the character has the given spell. The spellid may be any key word from any spell, skill, prayer, property, chant, or whatever. </p> <p> EXAMPLE: </p> <pre>if isable($n Write)<br /> mpecho The actor has the writing skill.<br />else<br /> mpecho The actor triggering me does not have the writing skill.<br />endif<br /></pre> <h3><a name="isalive">isalive</a></h3> <p> Usage: </p> <pre>isalive(character)<br /></pre> <p> This checks whether the character is alive. </p> <p> EXAMPLE: </p> <pre>if isalive($i)<br /> mpecho I am not yet dead!<br />endif<br /></pre> <h3><a name="isbehave">isbehave</a></h3> <p> Usage: </p> <pre>isbehave(character behaviorid)<br /></pre> <p> This checks whether the character has a given behavior. The behaviorid must be the full Java name of the behavior. </p> <p> EXAMPLE: </p> <pre>if isbehave($n Mobile)<br /> mpecho The actor triggering me is mobile.<br />else<br /> mpecho The actor triggering me is not mobile.<br />endif<br /><br /></pre> <h3><a name="isbirthday">isbirthday</a></h3> <p> Usage: </p> isbirthday(character)<br /> <p> This checks to see if the characters birthday is today (on the global clock). </p> <p> EXAMPLE: </p> if isbirthday($n)<br /> mpecho Happy Birthday $n.<br /> else<br /> mpecho Happy Un-Birthday $n!<br /> endif <h3><a name="ischarmed">ischarmed</a></h3> <p> Usage: </p> <pre>ischarmed(character)<br /></pre> <p> This checks to see if the character variable is charmed. </p> <p> EXAMPLE: </p> <pre>if ischarmed($n)<br /> mpecho This means the person triggering me is charmed.<br />else<br /> mpecho This person triggering my prog is not charmed.<br />endif<br /></pre> <h3><a name="isday">isday</a></h3> <p> Usage: </p> <pre>isday(number)<br /></pre> <p> This checks whether the current day of the month is the one given. </p> <p> EXAMPLE: </p> <pre>if isday(10)<br /> mpecho It is the 10th of the month.<br />endif<br /></pre> <h3><a name="isevil">isevil</a></h3> <p> Usage: </p> <pre>isevil(character)<br /></pre> <p> This checks whether the character is evil. </p> <p> EXAMPLE: </p> <pre>if isevil($i)<br /> mpecho I am evil!<br />else<br /> mpecho I am either neutral or good.<br />endif<br /></pre> <h3><a name="isfight">isfight</a></h3> <p> Usage: </p> <pre>isfight(character)<br /></pre> <p> This checks to see if the character variable is in combat. </p> <p> EXAMPLE: </p> <pre>if isfight($i)<br /> mpecho I am fighting right now.<br />else<br /> mpecho I am not fighting.<br />endif<br /></pre> <h3><a name="isfollow">isfollow</a></h3> <p> Usage: </p> <pre>isfollow(character)<br /></pre> <p> This checks to see if the character variable's master (the person they are following) is in the room. </p> <p> EXAMPLE: </p> <pre>if isfollow($i)<br /> mpecho I am following someone and they are in the room with me.<br />else<br /> mpecho I am not following someone, or they are not in the room.<br />endif<br /></pre> <h3><a name="isgood">isgood</a></h3> <p> Usage: </p> <pre>isgood(character)<br /></pre> <p> This checks whether the character is good. </p> <p> EXAMPLE: </p> <pre>if isgood($i)<br /> mpecho I am good!<br />else<br /> mpecho I am either neutral or evil.<br />endif<br /></pre> <h3><a name="ishere">ishere</a></h3> <p> Usage: </p> <pre>ishere(name)<br /></pre> <p> This checks whether a mob or item of the given name is in the room. Obviously, checking for $i will always return true when a mob is being scripted, so the best choice for an argument is a literal string. </p> <p> EXAMPLE: </p> <pre>if ishere(a happy frog)<br /> mpecho A happy frog is in the room.<br />else<br /> mpecho A happy frog is not in the room.<br />endif<br /></pre> <span style="font-family: monospace;"></span> <h3><a name="isimmort">isimmort</a></h3> <p> Usage: </p> <pre>isimmort(character)<br /></pre> <p> This checks to see if the character variable is immortal. In CoffeeMud, that means they have the security code IMMORT, which makes them unable to die. </p> <p> EXAMPLE: </p> <pre>if isimmort($n)<br /> mpecho The person triggering my prog is an immortal or lord.<br />else<br /> mpecho The person triggering my prog is a mortal.<br />endif<br /></pre> <h3><a name="ishere">islike</a></h3> <p> Usage: </p> <span style="font-family: monospace;"> islike(target mask)</span><br /> <p> This checks whether a mob or item target of the given name meets the criterium described by the given mask. The format of the mask is described in the online help for properties like Prop_HaveZapper and Prop_EnterZapper, which is why the masks are still referred to as "zapper mask syntax". </p> <p> EXAMPLE: </p> <span style="font-family: monospace;">if islike($n '-TATTOO +KILLERBOY')</span><br style="font-family: monospace;" /> <span style="font-family: monospace;"> mpecho The person has the killerboy tattoo.</span><br style="font-family: monospace;" /> <span style="font-family: monospace;">else</span><br style="font-family: monospace;" /> <span style="font-family: monospace;"> mpecho </span><span style="font-family: monospace;">The person does not have the killerboy tattoo.</span><br style="font-family: monospace;" /> <span style="font-family: monospace;">endif</span> <h3><a name="islocked">islocked</a></h3> <p> Usage: </p> <pre>islocked(target)<br />islocked(direction)<br /></pre> <p> This checks to see if the target container or exit is closed and locked. The target may be either an item, or an item code ($o, $p), or a direction name (north, south, east, west, etc.), or a direction code ($x, $xN, $xS, etc..) </p> <p> EXAMPLE: </p> <pre>if islocked(the chest)<br /> mpecho The chest is locked.<br />else<br /> mpecho The chest is not locked.<br />endif<br /></pre> <h3><a name="ismoon">ismoon</a></h3> <p> Usage: </p> <pre>ismoon()<br />ismoon(phase)<br /></pre> <p> If no parameter is given, this function checks whether the moon can be seen by the monster. Typically this means that it is nighttime, they are outside, and the sky is clear. With a parameter, this function only checks the phase of the moon, regardless of whether or not it can be seen. Accepted phases are: "NEW", "WAXCRESCENT", "WAXQUARTER", "WAXGIBBOUS", "FULL", "WANEGIBBOUS", "WANEQUARTER", "WANECRESCENT", or "BLUE". </p> <p> EXAMPLE: </p> <pre>if ismoon(waxquarter)<br /> mpecho There is a waxing quarter moon in the sky.<br />else<br /> mpecho There is not a waxing quarter moon in the sky.<br />endif<br /></pre> <h3><a name="isname">isname</a></h3> <p> Usage: </p> <pre>isname(character keyword)<br /></pre> <p> This function returns whether the keyword appears in the name of the character. </p> <p> EXAMPLES: </p> <pre>if isname($n goober)<br /> mpecho The actor who caused the trigger is named goober.<br />else<br /> mpecho The actor who caused the trigger is not named goober.<br />endif<br /><br />if isname($n $i)<br /> mpecho I, or someone with my name, am/is the actor!<br />else<br /> mpecho Someone else is the actor.<br />endif<br /></pre> <h3><a name="isneutral">isneutral</a></h3> <p> Usage: </p> <pre>isneutral(character)<br /></pre> <p> This checks whether the character is neutral. </p> <p> EXAMPLE: </p> <pre>if isneutral($i)<br /> mpecho I am neutral!<br />else<br /> mpecho I am either good or evil.<br />end<br /></pre> <h3><a name="isnpc">isnpc</a></h3> <p> Usage: </p> <pre>isnpc(character)<br /></pre> <p> This checks to see if a character variable is a mob. </p> <p> EXAMPLE: </p> <pre>if isnpc($n)<br /> mpecho The actor setting my prog off is a mob.<br />else<br /> mpecho The actor setting my prog off is a player character.<br />endif<br /></pre> <h3><a name="isopen">isopen</a></h3> <p> Usage: </p> <pre>isopen(target)<br />isopen(direction)<br /></pre> <p> This checks to see if the target container or exit is open. The target may be either an item, or an item code ($o, $p), or a direction name (north, south, east, west, etc.), or a direction code ($x, $xN, $xS, etc..) </p> <p> EXAMPLE: </p> <pre>if isopen(the chest)<br /> mpecho The chest is open.<br />else<br /> mpecho The chest is not open.<br />endif<br /></pre> <h3><a name="ispc">ispc</a></h3> <p> Usage: </p> <pre>ispc(character)<br /></pre> <p> This checks to see if a character variable is a player character. </p> <p> EXAMPLE: </p> <pre>if ispc($n)<br /> mpecho The actor setting my prog off is a player character.<br />else<br /> mpecho The actor setting my prog off is not a player character.<br />endif<br /></pre> <h3><a name="ispkill">ispkill</a></h3> <p> Usage: </p> <pre>ispc(character)<br /></pre> <p> This checks to see if a character has their pkill flag set. Only really matters with pcs, so it is best to use this function in conjunction with ispc(character). </p> <p> EXAMPLE: </p> <pre>if ispc($n) and ispkill($n)<br /> mpecho The actor setting my prog off is a player killer.<br />else<br /> mpecho The actor setting my prog off is not a player killer.<br />endif<br /></pre> <h3><a name="isquestmobalive">isquestmobalive</a></h3> <p> Usage: </p> <pre>isquestmobalive(number questname)<br />isquestmobalive(mobname questname)<br /></pre> <p> This function only works if the script was assigned to a mob as part of the ADDBEHAVIOR quest command. It checks to see if a mob of the given number or name is alive. The numbers refer to the order in which they were designated in the quest script. If the Scriptable behavior was granted as part of a Quest, then * may be substituted for the questname. </p> <p> EXAMPLE: </p> <pre>if isquestmobalive(1 myquest)<br /> mpecho The first set mob in the quest myquest is still alive.<br />else<br /> mpecho He's not dead yet.<br />endif<br /><br /></pre> <h3><a name="isrecall">isrecall</a></h3> <p> Usage: </p> isroom(target == roomcode)<br /> <p> This checks to see if the target is originally from the room specified by the room code. The room code may be a room id, a mob name (to compare start rooms), or text from the rooms name or description. The '==' may also be '!='. </p> <p> EXAMPLES: </p> <span style="font-family: monospace;">if isrecall($i == a bathroom)</span><br style="font-family: monospace;" /> <span style="font-family: monospace;"> mpecho This means I am from a bathroom.</span><br style="font-family: monospace;" /> <span style="font-family: monospace;">else</span><br style="font-family: monospace;" /> <span style="font-family: monospace;"> mpecho I am not from a bathroom.</span><br style="font-family: monospace;" /> <span style="font-family: monospace;">endif</span><br style="font-family: monospace;" /> <br style="font-family: monospace;" /> <span style="font-family: monospace;">if isrecall($i != MyArea#20001)</span><br style="font-family: monospace;" /> <span style="font-family: monospace;"> mpecho I am not from room MyArea#20001.</span><br style="font-family: monospace;" /> <span style="font-family: monospace;">else</span><br style="font-family: monospace;" /> <span style="font-family: monospace;"> mpecho I am from room MyArea#20001.</span><br style="font-family: monospace;" /> <span style="font-family: monospace;">endif</span> <h3><a name="isseason">isseason</a></h3> <p> Usage: </p> <pre>isseason(seasonname)<br /></pre> <p> This function is used to check the season of the year. Valid seasonnames include "WINTER", "SPRING", "SUMMER", or "FALL". </p> <p> EXAMPLE: </p> <pre>if isseason(summer)<br /> mpecho Yea, its summertime!<br />else<br /> mpecho Boo! It's not summer yet.<br />endif<br /></pre> <h3><a name="isservant">isservant</a></h3> <p> Usage: </p> <pre>isservant(character)<br /></pre> <p> This function is used to check whether the given player or mob is serving anyone in the room. </p> <p> EXAMPLE: </p> <pre>if isservant($i)<br /> say I greet my master.<br />else<br /> say I await my master.<br />endif<br /></pre> <h3><a name="istime">istime</a></h3> <p> Usage: </p> <pre>istime(integer)<br />istime(todword)<br /></pre> <p> This function is used to check the time. You may either specify a numeric hour of the day, or a time of day description, such as "DAY", "DAWN", "DUSK", or "NIGHT". </p> <p> EXAMPLE: </p> <pre>if istime(night)<br /> mpecho It is nighttime.<br />else<br /> mpecho It must be dawn, dusk, or daytime.<br />endif<br /></pre> <h3><a name="isweather">isweather</a></h3> <p> Usage: </p> <pre>isweather(weathername)<br /></pre> <p> This function is used to check the weather where the monster is at. If the monster is indoors, this function will only return true for "CLEAR". Other valid weathernames include: "CLOUDY", "WINDY", "RAIN", "THUNDERSTORM", "SNOW", "HAIL", "HEAT", "SLEET", "BLIZZARD", "DUST", "DROUGHT", "COLD" </p> <p> EXAMPLE: </p> <pre>if isweather(rain)<br /> mpecho Rain, rain go away...<br />else<br /> mpecho We can play! No Rain!<br />endif<br /></pre> <h3><a name="level">level</a></h3> <p> Usage: </p> <pre>level(character == number)<br /></pre> <p> This checks the total level of the character variable. Where '==' may be any of the logical operators mentioned above. </p> <p> EXAMPLES: </p> <pre>if level($n <= 15)<br /> mpecho The actor triggering me is 15th level or less.<br />else<br /> mpecho The actor triggering me is above 15th level.<br />endif<br /><br />if level($n > $%level($i)%)<br /> mpecho The actor triggering me is higher level than me.<br />else<br /> mpecho The actor triggering me is my level or under.<br />endif<br /></pre> <h3><a name="math">math</a></h3> <p> Usage: </p> math(expression == expression)<br /> <p> This function compares the total results of evaluating two very simple mathematical expressions. Variables can be included in the expressions via the normal $ code syntax, but the only operators allowed are +, -, *, or \. You may also use () to group expressions within an expression, or the ? to separate a random range. The '==' may also be any of the logical operators from above. </p> <p> EXAMPLES: </p> if math('1+1' != '2')<br /> mpecho There is something wrong with the universe!<br /> endif<br /> if math('1?5' > 3)<br /> mpecho Ahh, I did not pick a random number from 1-5 that was greater than 3. Darn!<br /> endif <h3><a name="mobitem">mobitem</a></h3> <p> Usage: </p> <pre>mobitem(character number keywords)<br /></pre> <p> This infrequently used function checks whether the numberth item in characters inventory has keywords in its name. </p> <p> EXAMPLE: </p> <pre>if mobitem($n 1 sword) or mobitem ($n $g.1 sword)<br /> mpecho Either the actors first item is a sword,<br /> mpecho or an item whose cardinality is represented by the code<br /> mpecho $g.1 is a sword.<br />else<br /> mpecho Neither of those items is a sword.<br />endif<br /><br /></pre> <h3><a name="mood">mood</a></h3> <p> Usage: </p> mood(character == GRUMPY)<br /> <p> This checks the mood of the character variable. Where '==' may be another logical operator from above. </p> <p> EXAMPLE: </p> <span style="font-family: monospace;">if mood($n == 'LONELY')</span><br style="font-family: monospace;" /> <span style="font-family: monospace;"> mpecho The actor triggering me appears to be lonely.</span><br style="font-family: monospace;" /> <span style="font-family: monospace;">else</span><br style="font-family: monospace;" /> <span style="font-family: monospace;"> mpecho The actor triggering me appears not to be lonely.</span><br style="font-family: monospace;" /> <span style="font-family: monospace;">endif</span> <h3><a name="number">number</a></h3> <p> Usage: </p> <pre>number(string)<br /></pre> <p> This function returns whether the string given is a number. </p> <p> EXAMPLES: </p> <pre>if number($g.2)<br /> mpecho The second parameter to this function_prog is a number.<br />else<br /> mpecho The second parameter to this function_prog is not a number.<br />endif<br /></pre> <h3><a name="numitemsmob">numitemsmob</a></h3> <p> Usage: </p> <pre>numitemsmob(character == number)<br /></pre> <p> This function compares the total number of items in the characters inventory to the number given. This function only counts items not in a container, or sheathed. It does count worn items. The '==' may also be any of the logical operators from above. </p> <p> EXAMPLES: </p> <pre>if numitemsmob($n > 10)<br /> mpecho The actor has an inventory size greater than 10.<br />else<br /> mpecho The actor has an inventory size less than or equal to 10.<br />endif<br /></pre> <h3><a name="numitemsroom">numitemsroom</a></h3> <p> Usage: </p> <pre>numitemsroom( == number)<br /></pre> <p> This function compares the total number of items in the same room as the monster to the number given. This function only counts items not in a container. The '==' may also be any of the logical operators from above. </p> <p> EXAMPLES: </p> <pre>if numitemsroom( > 10)<br /> mpecho There are more than 10 items in this room.<br />else<br /> mpecho There are 10 or less items in the room.<br />endif<br /></pre> <h3><a name="nummobs">nummobs</a></h3> <p> Usage: </p> <pre>nummobs(name == number)<br />nummobs('MASK=zappermask' == number)<br /></pre> <p> This function compares the total number of mobs with the given name to the number. The second syntax allows you to substitute a zapper mask for the name, provided it starts with the MASK= string. See help on Prop_HaveZapper for more information on how to format a zapper mask. This function counts every single mob in the whole world, whether they are seen or detectable or not. The '==' may also be any of the logical operators from above. </p> <p> EXAMPLES: </p> <pre>if nummobs(goobers > 10)<br /> mpecho There are more than 10 goobers in the world.<br />else<br /> mpecho There are 10 or less goobers in the world.<br />endif<br /></pre> <h3><a name="nummobsinarea">nummobsinarea</a></h3> <p> Usage: </p> <pre>nummobsinarea(name == number)<br />nummobsinarea('MASK=zappermask' == number) <br /></pre> <p>This function compares the total number of mobs with the given name to the number. The second syntax allows you to substitute a zapper mask for the name, provided it starts with the MASK= string. See help on Prop_HaveZapper for more information on how to format a zapper mask. This function counts every single mob in the same area as the scripted monster or object, whether they are seen or detectable or not. The '==' may also be any of the logical operators from above. </p> <p> EXAMPLES: </p> <pre>if nummobsinarea(goobers > 10)<br /> mpecho There are more than 10 goobers in this area.<br />else<br /> mpecho There are 10 or less goobers in this area.<br />endif<br /></pre> <h3><a name="nummobsroom">nummobsroom</a></h3> <p> Usage: </p> <pre>nummobsroom(pattern == number)<br />nummobsroom('MASK=zappermask' == number)<br /></pre> <p> This function compares the total number of mobs in the same room as the monster, whose names or display texts match the given pattern to the number given. A pattern of * may be used to count all mobs of any name. The second syntax allows you to substitute a zapper mask for the name pattern, provided it starts with the MASK= string. See help on Prop_HaveZapper for more information on how to format a zapper mask. This function counts players, npcs, and the hidden and undetectable. The '==' may also be any of the logical operators from above. </p> <p> EXAMPLES: </p> <pre>if nummobsroom(* > 10)<br /> mpecho There are more than 10 mobs in this room.<br />else<br /> mpecho There are 10 or less mobs in the room.<br />endif<br /></pre> <h3><a name="numpcsroom">numpcsroom</a></h3> <p> Usage: </p> <pre>numpcsarea( == number)<br /></pre> <p> This function compares the total number of players in the same area as the monster to the number given. This function counts players only, including the hidden and undetectable. The '==' may also be any of the logical operators from above. </p> <p> EXAMPLES: </p> <pre>if numpcsarea( > 10)<br /> mpecho There are more than 10 pcs in this area.<br />else<br /> mpecho There are 10 or less pcs in the area.<br />endif<br /></pre> <h3><a name="numpcsroom">numpcsroom</a></h3> <p> Usage: </p> <pre>numpcsroom( == number)<br /></pre> <p> This function compares the total number of players in the same room as the monster to the number given. This function counts players only, including the hidden and undetectable. The '==' may also be any of the logical operators from above. </p> <p> EXAMPLES: </p> <pre>if numpcsroom( > 10)<br /> mpecho There are more than 10 pcs in this room.<br />else<br /> mpecho There are 10 or less pcs in the room.<br />endif<br /></pre> <h3><a name="numraces">numraces</a></h3> <p> Usage: </p> <pre>numraces( race == number)<br /></pre> <p> This function compares the total number of mobs with the given race to the number. This function counts every single mob in the whole world, whether they are seen or detectable or not. The '==' may also be any of the logical operators from above. </p> <p> EXAMPLES: </p> <pre>if numraces(Goblin > 10)<br /> mpecho There are more than 10 goblins in the world.<br />else<br /> mpecho There are 10 or less goblins in the world.<br />endif<br /></pre> <h3><a name="numracesinarea">numracesinarea</a></h3> <p> Usage: </p> <pre>numracesinarea(race== number)<br /></pre> <p> This function compares the total number of mobs with the given race to the number. This function counts every single mob in the same area as the scripted monster or object, whether they are seen or detectable or not. The '==' may also be any of the logical operators from above. </p> <p> EXAMPLES: </p> <pre>if numracesinarea(Goblin > 10)<br /> mpecho There are more than 10 goblins in this area.<br />else<br /> mpecho There are 10 or less goblins in this area.<br />endif<br /></pre> <h3><a name="position">position</a></h3> <p> Usage: </p> <pre>position(character == posword)<br /></pre> <p> This checks the position of the character variable. The position is a word, either SITTING, STANDING, or SLEEPING. The '==' may also be another of the logical operators from above. </p> <p> EXAMPLES: </p> <pre>if position($n == STANDING)<br /> mpecho This means that the actor is standing.<br />else<br /> mpecho This means the actor is not standing.<br />endif<br /></pre> <h3><a name="pracs">pracs</a></h3> <p> Usage: </p> <pre>pracs(character == number)<br /></pre> <p> This checks the number of practice points the mob variable has. Where '==' may be any of the logical operators mentioned above. </p> <p> EXAMPLES: </p> <pre>if pracs($n <= 15)<br /> mpecho The actor triggering me has fewer than 16 practices.<br />else<br /> mpecho The actor triggering me has more than 15 practices.<br />endif<br /><br />if pracs($n > $%pracs($i)%)<br /> mpecho The actor triggering me has more practices than me.<br />else<br /> mpecho The actor triggering me has the same or fewer practices than me.<br />endif</pre> <h3><a name="questitem">questitem</a></h3> <p> Usage: </p> <pre>questitem(item questname)<br /></pre> <p> This checks whether the given item is an official item created by a quest of the given questname. If the Scriptable behavior was granted as part of a Quest, then * may be substituted for the questname. </p> <p> EXAMPLES: </p> <pre>if questitem($o myquest)<br /> mpecho This means that item is a quest item for quest myquest.<br />else<br /> mpecho This means the item is not a quest item for quest myquest.<br />endif<br /></pre> <h3><a name="questmob">questmob</a></h3> <p> Usage: </p> <pre>questmob(character questname)<br /></pre> <p> This checks whether the given character is an official mob created by a quest of the given questname. If the Scriptable behavior was granted as part of a Quest, then * may be substituted for the questname. </p> <p> EXAMPLES: </p> <pre>if questmob($n myquest)<br /> mpecho This means that the actor is a quest mob for quest myquest.<br />else<br /> mpecho This means the the actor is not a quest mob for quest myquest.<br />endif<br /></pre> <h3><a name="questpoints">questpoints</a></h3> <p> Usage: </p> <pre>questpoints(character == number)<br /></pre> <p> This checks the number of quest points the mob variable has. Where '==' may be any of the logical operators mentioned above. </p> <p> EXAMPLES: </p> <pre>if questpoints($n <= 15)<br /> mpecho The actor triggering me has fewer than 16 quest points.<br />else<br /> mpecho The actor triggering me has more than 15 quest points.<br />endif<br /><br />if questpoints($n > $%questpoints($i)%)<br /> mpecho The actor triggering me has more quest points than me.<br />else<br /> mpecho The actor triggering me has the same or fewer quest points than me.<br />endif</pre> <h3><a name="questwinner">questwinner</a></h3> <p> Usage: </p> <pre>questmob(character questname)<br /></pre> <p> This checks whether the given character has been declared a winner of the quest in the past via the MPQUESTWIN command. If the Scriptable behavior was granted as part of a Quest, then * may be substituted for the questname. </p> <p> EXAMPLES: </p> <pre>if questwinner($n myquest)<br /> mpecho This means that the actor has been a winner of the quest myquest.<br />else<br /> mpecho This means the the actor has not been a winner of the quest myquest.<br />endif<br /><br /></pre> <h3><a name="qvar">qvar</a></h3> <p> Usage: </p> <span style="font-family: monospace;">qvar(questname varname == value)</span><br /> <p>This is used to evaluate one of the official or user-defined quest variables. User-defined quest variables are defined using MPQSET. Official variables names include: "CLASS", "NAME", "DURATION", "WAIT", "MINPLAYERS", "PLAYERMASK", "RUNLEVEL", "DATE", "MUDDAY", or "INTERVAL". If the Scriptable behavior was granted as part of a Quest, then * may be substituted for the questname. Where '==' may be any of the logical operators mentioned above. </p> <p> EXAMPLES: </p> <pre style="font-family: monospace;">if qvar(myquest myvarname == 'myvalueformyvarname')<br /> mpecho This means that the user defined variable 'myvarname' has been previously set.<br />else<br /> mpecho This means the user defined variable 'myvarname' has not been previously set.<br />endif</pre> <pre><br /></pre> <h3><a name="race">race</a></h3> <p> Usage: </p> <pre>race(character == race)<br /></pre> <p> This function compares the race of the character variable with the race name given. For a list of race names, do LIST RACES from the command line in the mud. The '==' may also be another of the logical operators from above. </p> <p> EXAMPLE: </p> <pre>if race($n == Goblin)<br /> mpecho The actor is a goblin.<br />else<br /> mpecho The actor is not a goblin.<br />endif<br /></pre> <h3><a name="racecat">racecat</a></h3> <p> Usage: </p> <pre>race(character == category)<br /></pre> <p> This function compares the racial category of the race of the character variable with the racial category given. For a list of racial categories, do LIST RACES from the command line in the mud. The '==' may also be another of the logical operators from above. </p> <p> EXAMPLE: </p> <pre> if racecat($n == Elf)<br /> mpecho The actor is an Elf, or Elf-kin.<br /> else<br /> mpecho The actor is not an Elf-Kin.<br /> endif<br /> </pre> <h3><a name="rand">rand</a></h3> <p> Usage: </p> <pre>rand(integer)<br /></pre> <p> This generates a random number and checks to see if it is under the integer. This is best used for random events where there are only two outcomes. </p> <p> EXAMPLE: </p> <pre>if rand(40)<br /> mpecho This is under 40% chance for me to echo this.<br />else<br /> mpecho Not under 40%.<br />endif<br /></pre> <h3><a name="rand0num">rand0num</a></h3> <p> Usage: </p> <pre>rand0num(integer == integer)<br /></pre> <p> This generates a random number from 0 to the first integer given minus 1, and checks to see if it is under the value give in the second integer. This is best used not in its pure function form, but as a string variable (see the $% format above). It allows one to randomly grab an item in a string list. See the example below. </p> <p> EXAMPLE: </p> <pre>if rand0num(2 == 0)<br /> MPSETVAR $i GREETINGLIST hi howdy hello greetings ho<br /> say I just wanted to say $<$i GREETINGLIST>.$%RAND0NUM(5)%!<br />endif<br /></pre> <h3><a name="randnum">randnum</a></h3> <p> Usage: </p> <pre>randnum(integer == integer)<br /></pre> <p> This generates a random number from 1 to the first integer given, and checks to see if it is under the value give in the second integer. This is best used for random events where there are only two outcomes. </p> <p> EXAMPLE: </p> <pre>if rand(1000 == 5)<br /> mpecho This is under a 5 in 1000 chance for me to echo this.<br />else<br /> mpecho Not under 5 in 1000.<br />endif<br /></pre> <h3><a name="roomitem">roomitem</a></h3> <p> Usage: </p> <pre>roomitem(number keywords)<br /></pre> <p> This infrequently used function checks whether the numberth item in the room has keywords in its name. </p> <p> EXAMPLE: </p> <pre>if roomitem(1 sword) or roomitem ($g.1 sword)<br /> mpecho Either the rooms first item is a sword,<br /> mpecho or an item whose cardinality is represented by<br /> mpecho the code $g.1 is a sword.<br />else<br /> mpecho Neither of those items is a sword.<br />endif<br /></pre> <h3><a name="roommob">roommob</a></h3> <p> Usage: </p> <pre>roommob(number keywords)<br /></pre> <p> This infrequently used function checks whether the numberth mob in the room has keywords in its name. </p> <p> EXAMPLE: </p> <pre>if roommob(1 joe) or roommob($g.1 joe)<br /> mpecho Either the rooms first mob is named joe,<br /> mpecho or a mob whose cardinality is represented by<br /> mpecho the code $g.1 is joe.<br />else<br /> mpecho Neither of those mobs is joe.<br />endif<br /></pre> <h3><a name="sex">sex</a></h3> <p> Usage: </p> <pre>sex(character == letter)<br /></pre> <p> This compares the sex of the character variable to the letter given. The letter may be "M", "F", or "N". The '==' may also be another of the logical operators from above. </p> <p> EXAMPLES: </p> <pre>if sex($n == M)<br /> mpecho The actor triggering me is a male.<br />else<br /> mpecho The actor triggering me is not a male.<br />endif<br /><br />if sex($n != $%sex($n)%)<br /> mpecho The actor triggering me is not the same sex as me.<br />else<br /> mpecho The actor triggering me is the same sex as me.<br />endif<br /></pre> <h3><a name="stat">stat</a></h3> <p> Usage: </p> <pre>stat(target variable == value)<br /></pre> <p> This is a powerful function which allows you to make comparisons based on numerous characteristics of the target. The target may be any code, including mobs or items. The variable may be any of those listed above under MPGSET in the section on Scriptable Commands. The '==' may be any of the above logical operators, and the value any expression, including codes. This function is like gstat, with one important difference: stat respects only the variables which the target has available. For Generic mobs and items, this will be many more than for Standard mobs and items. For this reason, it is almost always preferable to use gstat. </p> <p> EXAMPLES: </p> <pre>if stat($n CHARISMA > 10)<br /> mpecho The actor, if a generic mob, has a charisma greater than 10.<br />endif<br /><br /></pre> <h3><a name="strcontains">strcontains</a></h3> <p> Usage: </p> <span style="font-family: monospace;">strcontains(string words)</span><br /> <p> This function searches the first string to see if the set of words described by the second string is contained therein. The search is case-insensitve, and ignores all punctuation. The set of words may be double-quoted to include spaces. Each word or word grouping must be separated by one of three special characters:</p> <p>word1 word2 means the string contains word1 which is immediately followed by word2<br /> word1 & word2 means the string must contains word1 and word2 in any order<br /> word1 | word2 means the string contains word1 or word2<br /> word1 > word2 means the string contains both word1 and word2, but word2 comes after word1 in the string (though other words may separate them)<br /> word1 < word2 means the string contaisn both word1 and word2, but word1 comes after word2 in the strong</p> <p>You may also use parenthesis to group word checks together.<br /> <br /> EXAMPLE: </p> i<span style="font-family: monospace;">f strcontains('one two three four' '(one > four) & (two three)')</span><br style="font-family: monospace;" /> <span style="font-family: monospace;"> mpecho The string meets my word criteria</span><br style="font-family: monospace;" /> <span style="font-family: monospace;">else</span><br style="font-family: monospace;" /> <span style="font-family: monospace;"> mpecho The string does not meet my word criteria.</span><br style="font-family: monospace;" /> <span style="font-family: monospace;">endif<br /> </span> <h3><a name="strin">strin</a></h3> <p> Usage: </p> <pre>strin(string string)<br /></pre> <p> This function searches the first string to see if the second string appears as a whole word within it. If so, this function returns true. </p> <p> EXAMPLE: </p> <pre>if strin('one two three four' 'three')<br /> mpecho The word three appears in the list of words.<br />else<br /> mpecho Since no variables were used in the example, this is technically impossible.<br />endif<br /></pre> <h3><a name="trains">trains</a></h3> <p> Usage: </p> <pre>trains(character == number)<br /></pre> <p> This checks the number of training sessions the mob variable has. Where '==' may be any of the logical operators mentioned above. </p> <p> EXAMPLES: </p> <pre>if trains($n <= 15)<br /> mpecho The actor triggering me has fewer than 16 trains.<br />else<br /> mpecho The actor triggering me has more than 15 trains.<br />endif<br /><br />if trains($n > $%trains($i)%)<br /> mpecho The actor triggering me has more trains than me.<br />else<br /> mpecho The actor triggering me has the same or fewer trains than me.<br />endif</pre> <h3><a name="value">value</a></h3> <p> Usage: </p> <pre>value(character currency > amount)<br />value(coinitem currency > amount)<br /></pre> <p> This evaluates the total amount of money that the character variable has on hand in the given currency, or the value of the coins of the given currency. Where '==' may be any other logical operator from above. The value is always expressed in base gold for comparison purposes only. If a coin item is not of the given currency, the value will always be 0. </p> <p> EXAMPLE: </p> <pre>if value($n 'COPPER' < 10000)<br /> mpecho The actor has less than 10000 base-gold with of money in the 'COPPER' currency on hand<br />else<br /> mpecho The actor has plenty<br />endif<br /></pre> <h3><a name="var">var</a></h3> <p> Usage: </p> <pre>var(character variable == value)<br /></pre> <p> This function compares the variable belonging to the character to the given value. The character is almost always a code of some sort, where the variable is almost always a literal string. The value may be anything necessary. Where '==' may be any of the above logical operators. See MPSETVAR for information on settings variables. </p> <p> EXAMPLE: </p> <pre>if var($n KILLS > 10)<br /> mpecho The actor's KILLS variable is greater than 10.<br />else<br /> mpecho The actor's KILLS variable is equal to or less than 10.<br />endif<br /></pre> <h3><a name="worn">worn</a></h3> <p> Usage: </p> <pre>worn(character item)<br /></pre> <p> This function checks whether the character is wearing an item of the given name. </p> <p> EXAMPLE: </p> <pre>if worn($n brass shirt)<br /> mpecho The actor is wearing a brass shirt somewhere.<br />else<br /> mpecho The actor is not wearing a brass shirt.<br />endif<br /></pre> </td> </tr> <tr> <td valign="top"><br /> </td> <td valign="top"><br /> </td> </tr> </tbody> </table> </center> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> <br /> </body> </html>