Scripting in CoffeeMud 4.7

Introduction to Scripting
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.
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.
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:
load=path/file name
The starting path for the Scriptable behavior is the resources directory in your CoffeeMud package. Any further paths will branch from that directory. The file specified is a text file containing the script.
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.
RAND_PROG 50;bounce;say "hi!";~;
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.
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.
Script Structure
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 occurrance 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:
EVENT_TRIGGER parameter1
parameter2 ...
command1
command2
...
commandN
~
ANOTHER_EVENT_TRIGGER
parameter1 parameter2 ...
command1
command2
...
commandN
~
etc.
Scripting Events
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:http://aoc.pandapub.com/home.shtml.
all_greet_prog
Usage:
all_greet_prog [integer percentage]
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.
EXAMPLES:
all_greet_prog 25 (This
prog will be triggered 25% of the time when someone enters the room where the
mob currently is.)
all_greet_prog 100 (This prog will be triggered 100% of the time when someone enters the room where the mob currently is. This means every time.)
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.
act_prog
mask_prog
Usage:
act_prog [trigger message]
act_prog
p [trigger message]
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.
EXAMPLES:
act_prog wolf dog coyote (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.)
act_prog p A wolf howls at the moon. (This will trigger the prog when it sees this precise message. Note that punctuation is important here as well.)
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.
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.
bribe_prog
Usage:
bribe_prog [money value]
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, 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 the absolute gold value of the default currency. See the Archon's Guide under currency if you don't know what that means.
EXAMPLES:
bribe_prog
1 (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.)
bribe_prog 500
(This bribe_prog will trigger if someone gives the mob an amount of money
equal to or greater than 500 coins.)
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.
buy_prog
Usage:
buy_prog [keyword list]
buy_prog p [keyword
phrase]
buy_prog all
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.
EXAMPLES:
buy_prog orange apple banana (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.)
buy_prog p apple pie delicious (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.)
buy_prog all (This will trigger if any sort of item is bought.)
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.
consume_prog
Usage:
consume_prog [keyword list]
consume_prog p [keyword list]
consume_prog all
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.
EXAMPLES:
consume_prog orange apple banana (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.)
consume_prog p apple pie delicious (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.)
consume_prog all (This will trigger if any object is ate or drank.)
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.
damage_prog
Usage:
damage_prog
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 seconday 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.
EXAMPLES:
damage_prog This program will trigger when damage is taken by a mob, or given by the scripted item.
day_prog
Usage:
day_prog [list of integer day of the month]
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.
EXAMPLES:
day_prog 20 21 22 (This will trigger if day of the month is 20, 21, or 22. )
day_prog 10 (This will trigger on the 10th day of every month .)
death_prog
Usage:
death_prog
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.
MULTIPLE PROGS: You can
have multiple death_progs on the same mob.
delay_prog
Usage:
delay_prog [integer, minimum number of ticks] [integer,
maximum number of ticks]
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.
EXAMPLES:
delay_prog 10 20 (This delay_prog will be triggered after 10-20 ticks have elapsed.)
delay_prog 1 11 (This delay_prog will be triggered after 1-11 ticks have elapsed.)
drop_prog
Usage:
drop_prog [keyword list]
drop_prog
p [keyword list]
drop_prog all
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.
EXAMPLES:
drop_prog orange apple banana (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.)
drop_prog p apple pie delicious (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.)
drop_prog all (This will trigger if any object is dropped.)
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.
entry_prog
Usage:
entry_prog [integer percentage]
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.
EXAMPLES:
entry_prog 25 (This
will trigger 25% of the time when the mob enters a room.)
entry_prog 100 (This will trigger 100%, or every time, the mob enters a room.)
exit_prog
Usage:
exit_prog [integer percentage]
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.
EXAMPLES:
exit_prog 25 (This
will trigger 25% of the time when a mob leaves the room.)
exit_prog 100 (This will trigger 100%, or every time, a mob leaves the room.)
fight_prog
Usage:
fight_prog [integer percentage]
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.
EXAMPLES:
fight_prog 10 (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.)
fight_prog 75 (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.)
function_prog
Usage:
function_prog [string name of the function]
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 usefullness of doing this will become apparant in the discussion of MPCALLFUNC.
EXAMPLES:
function_prog Destroy
Everyone (This will trigger only when
called by MPCALLFUNC)
get_prog
Usage:
get_prog [keyword list]
get_prog p
[keyword list]
get_prog all
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.
EXAMPLES:
get_prog orange apple banana (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.)
get_prog p apple pie delicious (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.)
get_prog all (This will trigger if any object is picked up.)
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.
give_prog
Usage:
give_prog [keyword list]
give_prog
p [keyword list]
give_prog all
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.
EXAMPLES:
give_prog orange apple banana (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.)
give_prog p apple pie delicious (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.)
give_prog all (This will trigger if any object is given to the mob.)
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.
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.
greet_prog
Usage:
greet_prog [integer percentage]
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.
EXAMPLES:
greet_prog 25 (This
prog will be triggered 25% of the time when someone enters the room where the
mob currently is.)
greet_prog 100 (This prog will be triggered 100% of the time when someone enters the room where the mob currently is. This means every time.)
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.
hitprcnt_prog
Usage:
hitprcnt_prog [integer percentage]
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.
EXAMPLES:
hitprcnt_prog 50 (This will trigger if the mob’s hit points are 50% or under every round of combat.)
hitprcnt_prog 100 (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.)
login_prog
Usage:
login_prog [integer percentage]
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.
EXAMPLES:
login_prog 25 (This
prog will be triggered 25% of the time when someone enters the game.)
login_prog 100 (This prog will be triggered 100% of the time when someone enters the game. This means every time.)
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.
logoff_prog
Usage:
logoff_prog [integer percentage]
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.
EXAMPLES:
logoff_prog 25 (This
prog will be triggered 25% of the time when someone leaves the game.)
logoff_prog 100 (This prog will be triggered 100% of the time when someone leaves the game. This means every time.)
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.
once_prog
Usage:
once_prog
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 initiazation 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 usesmmediately by the script once it is loaded, and never .
EXAMPLES:
once_prog (This will trigger once, right away)
MULTIPLE PROGS: You can have only one once_prog on a mob.
quest_time_prog
Usage:
quest_time_prog [quest name] [number of minutes
remaining]
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.
EXAMPLES:
quest_time_prog 'my quest' 20 (This quest_time_prog will be triggered on the final 20th minute of the quest 'my quest'.)
quest_time_prog 'that quest' 1 (This quest_time_prog will be triggered on the final minute of the quest 'that quest'.)
put_prog
Usage:
put_prog [keyword list]
put_prog p
[keyword list]
put_prog all
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.
EXAMPLES:
put_prog orange apple banana (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.)
put_prog p apple pie delicious (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.)
put_prog all (This will trigger if any container is used.)
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.
rand_prog
Usage:
rand_prog [integer percentage]
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.
EXAMPLES:
rand_prog 20 (This rand_prog will be triggered 20% of each tick.)
rand_prog
75
(This rand_prog will be triggered 75% of each tick.)
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.
remove_prog
Usage:
remove_prog [keyword list]
remove_prog p [keyword list]
remove_prog all
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.
EXAMPLES:
remove_prog orange apple banana (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.)
remove_prog p apple pie delicious (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.)
remove_prog all (This will trigger if any object is removed.)
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.
sell_prog
Usage:
sell_prog [keyword list]
sell_prog
p [keyword phrase]
sell_prog all
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.
EXAMPLES:
sell_prog orange apple banana (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.)
sell_prog p apple pie delicious (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.)
sell_prog all (This will trigger if any sort of item is sold.)
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.
speech_prog
Usage:
speech_prog [trigger message]
speech_prog p [trigger message]
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. 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.
EXAMPLES:
speech_prog dog wolf coyote (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.)
speech_prog p The dog barks at the cat. (This will trigger the prog only if the exact expression is said. Note that punctuation counts, although you don't *have* to use it.)
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.
time_prog
Usage:
time_prog [list of hours in the day]
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.
EXAMPLES:
time_prog 10 1 2 (This will trigger if hour of the day is 10, 1, or 2. )
time_prog 3 (This will trigger on the 3rd hour of every day.)
wear_prog
Usage:
wear_prog [keyword list]
wear_prog
p [keyword list]
wear_prog all
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.
EXAMPLES:
wear_prog orange apple banana (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.)
wear_prog p apple pie delicious (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.)
wear_prog all (This will trigger if any object is worn.)
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.
Scripting Codes
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.
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".
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.
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.
| $a | Name of the area the monsters in. | |
| $i | The Monsters name. | |
| $I | The Monsters display text. | |
| $n | The Source of the triggers name. | |
| $N | The Source of the triggers name. | |
| $t | The Target of the triggers name. | |
| $T | The Target of the triggers name. | |
| $r | A random pc inhabitants name. | |
| $R | A random pc inhabitants name. | |
| $j | The pronoun he/she of the monster. | |
| $e | The pronoun he/she of the source of the trigger. | |
| $f | Name of the person which the monster follows. | |
| $E | The pronoun he/she of the trigger target. | |
| $F | The he/she of the person which the monster follows. | |
| $J | The pronoun he/she of a random pc inhabitant. | |
| $k | The possessive pronoun his/her of the monster. | |
| $l | A list of all mobs (excluding monster). See "." syntax below. | |
| $L | A list of all Items in room. See "." syntax below. | |
| $m | The pronoun his/her of the source of the trigger. | |
| $M | The pronoun his/her of the target of the trigger. | |
| $d | The title of the room of the scripted monster. | |
| $D | The long description of the room of the scripted monster. | |
| $K | The pronoun his/her of a random pc inhabitant. | |
| $o | The name of item#1. | |
| $O | The name of item#1. | |
| $p | The name of item#2. | |
| $P | The name of item#2. | |
| $w | The name of the owner of item#1. | |
| $W | The name of the owner of item#2. | |
| $g | The lowercase form of the message or parameters from a MPCALLFUNC, MASK_PROG or SPEECH_PROG. | |
| $G | The uppercase form of the message or parameters from a MPCALLFUNC, MASK_PROG or SPEECH_PROG. | |
| $x | A random valid exit's direction name (north, south, east, west, up, or down). | |
| $X | A random valid exit's name (a door, a walkway, etc). | |
| $xN | The specified directions name (Where N may be N, S, E, W, U, or D) | |
| $<[CODE] [VAR NAME]> | The variable of the given name, and the given code. Where code is $i, $n, $t, $o, $w, $W, or $p. See MPSETVAR below. | |
| ${[NUM] [QUEST NAME]} | 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. | |
| $[[NUM] [QUEST NAME]] | 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. | |
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".
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:
| $%[function name]([parameters])% | 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. | |
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.
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.
Here is an example of this code being used in a say statement:
say I am $%isgood($i)% and my favourite number is $%rand()%.
This string would replace the $%.. codes with the results of the given function calls.
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.
| AFFECTED([code]) | Returns the name of a random spell affect on the given mob or item. |
| BASECLASS([code]) | Returns the base class of the given mob. |
| CALLFUNC([function name] [parms]) | Calls the FUNCTION_PROG of the given name, with the given parameters, and returns the value returned by the program using the RETURN statement. |
| CLAN([code]) | Returns the clan of the given mob. |
| CLANRANK([code]) | Returns the rank of the given mob in their clan. |
| CLANDATA([clan code] [variable]) | Returns data about the given clan. See CLANDATA function below for variables. |
| CLASS([code]) | Returns the class of the given mob. |
| DEITY([code]) | Returns the deity of the given mob. |
| EVAL() | Not implemented -- do not use. |
| GOLDAMT([code]) | Returns the number of gold coins the given mob has. |
| GSTAT([code] [stat variable]) | Value of the given stat variable for the given mob or item. For example: $%GSTAT($i strength)% See the MPGSET command below for a complete list of variables. |
| HAS([code]) | Returns the name of a random item in the scripted monsters inventory. |
| HASTITLE([code]) | Returns the selected title of the given player mob. |
| HITPRCNT([code]) | Return the % of hit points remaining for the given mob. |
| INCONTAINER([code]) | Teturns the name of the container of the given item, or the mount of the given mob, depending on the code. |
| INLOCALE() | Returns the name of the room type the monster is in (plains, city, mountains, hills, watersurface, etc). |
| INROOM() | Returns the raw id of the room the scripted monster is in. |
| IPADDRESS([code]) | Returns the ipaddress of the player. |
| ISABLE([code] [skill name]) | Returns the given mobs profficiency in the given skill/spell/ability. |
| ISALIVE([code]) | Returns the health of the given mob. |
| ISBEHAVE([code]) | Returns the class ids of the behaviors on the given mob or item. |
| ISCHARMED([code]) | Returns the name of the charm spell the mob is under. |
| ISDAY() | Returns word the word day or the word evening. |
| ISEVIL([code]) | Returns the short alignment string of the given mob. |
| ISFIGHT([code]) | Returns the name of the creature the given mob is fighting, or nothing otherwise. |
| ISFOLLOW([code]) | Returns the name of the creature the given mob is following, or nothing otherwise. |
| ISGOOD([code]) | Returns the alignment string of the given mob. |
| ISHERE() | Returns the name of the area the scripted monster is in. |
| ISIMMORT([code]) | not implemented. |
| ISLOCKED([code or direction]) | 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. |
| ISMOON() | Returns the moon phase description. |
| ISNAME([code]) | Returns the real/full name of the given object. |
| ISNEUTRAL([code]) | Returns the alignment number of the given mob (0-1000). |
| ISNPC([code]) | Not implemented -- do not use. |
| ISOPEN([code or direction]) | Returns "true" if the container item is open, or the exit in the given direction name is open. |
| ISPC([code]) | Not implemented -- do not use.. |
| ISQUESTMOBALIVE() | Not implemented -- do not use.. |
| ISSEASON() | Returns the name of the season. |
| ISTIME() | Returns the approximate time of day in words. |
| ISWEATHER() | Returns a description of the weather in a short sentence. |
| LEVEL([code]) | Returns the level of the given mob. |
| MOBITEM([code] [integer number]) | Returns the nth item owned by the given mob. |
| NUMBER([integer number or code]) | Returns the numberic value of the given argument. |
| NUMITEMSMOB([code]) | Returns the number of items the given mob has. |
| NUMITEMSROOM() | Returns the number of items in the room. |
| NUMMOBS([name]) | Returns the number of mobs in the world matching the given mob name. |
| NUMMOBSINAREA([name]) | Returns the number of mobs in the scripted monsters area matching the given mob name. |
| NUMMOBSROOM() | Returns the number of mobs in the same room as the scripted monster, including the monster. |
| NUMPCSROOM() | Returns the number of pcs in the same room as the scripted monster. |
| NUMRACEINAREA([race name]) | Returns the number of mobs in the same area as the scripted monster whose race matches the given string. |
| NUMRACES([race name]) | Returns the number of mobs in the world whose race matches the given string. |
| POSITION([code]) | Returns the sitting/standing/sleeping position name of the given mob. |
| QUESTITEM() | Not implemented -- do not use. |
| QUESTMOB() | Not implemented -- do not use. |
| QUESTWINNER() | Not implemented -- do not use. |
| RACE([code]) | Returns the name of the race of the given mob. |
| RACECAT([code]) | Returns the racial category of the given mob. |
| RAND() | Returns random number between 1 and 100. |
| RAND0NUM([integer number or code]) | Returns a random number from 0..given value-1. |
| RANDNUM([integer number or code]) | Returns a random number from 1..given value. |
| ROOMITEM([integer number]) | Returns the name of the nth item in the same room as the scripted monster. |
| ROOMMOB([integer number]) | Returns the name of the nth mob in the same room as the scripted monster. |
| SEX([code]) | Returns the sex of the given mob. |
| STAT([code] [stat variable]) | Returns the value of the given stat for the given object, mob, or item. See MPSTAT in the section on Commands for more information. |
| STRIN([string] [string]) | Returns the word number (0..n) where the second string appears in the first. This function deals in whole words only. |
| VAR([code] [variable name]) | Retturns the value of the given variable. See MPSETVAR in the section on Commands for more information. |
| WORN([code]) | The name of a random worn item in the given mobs inventory. |
Scripting Commands
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.
Commands are of two general types: MUD Commands, and MOBPROG (MP) Commands.
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 issueing 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:
get sword
.. 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.
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.
commandword
parameter1 parameter2 ... parametern
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.
say "the scary monster" hi!
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.
if, else, endif
Usage:
if [condition]
[commands]
...
else
[commands]
...
endif
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.
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.
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:
if sex($n == M)
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'.
Conditional statements may be negated using the "!" character as follows:
if !sex($n == M)
In this case, the condition evaluages to false if the mob who caused the trigger is male, and true otherwise.
Conditional statements may contain more than one function call if they are seperated 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 evaulate to true, and it evaulates to false otherwise. In the case of the 'or' key word, the condition evaulates to true if either of the functions on either side evaluate to true, and false otherwise. Here are some examples of those in use:
if sex($n == F) or race($n == Harpy)
if sex($n == M) and isevil($n)
Lastly, conditional statements may group together their function calls using parenthesis. This can be used to ensure that certain sets of function calls are evaulated together, while others are not. For instance:
if sex($n == M) or isevil($n) and race($n == Harpy)
if ( sex($n == M) or isevil($n) ) and race($n == Harpy)
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.
Please see the section below on functions for a list of the conditional functions and their uses.
mpaffect
Usage:
mpaffect [spell name] [target]
[parameters]
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.
EXAMPLES:
mpaffect Invisibility $n
mpaffect Prop_PracticeDummy $n KILLABLE
mpalarm
Usage:
mpalarm [ticks] [command]
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.
EXAMPLES:
mpalarm 10 say umm.. what was the question?
mpalarm 30 mpecho You think you heard something.
mpalarm 30 mpcallfunc myfunction
mpasound
Usage:
mpasound [text string]
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.
EXAMPLES:
mpasound You
hear a scream from nearby!
mpasound A delightful music
fills the air from somewhere near here.
mpasound The
drunken hollering of $n can be heard nearby.
mpasound
The earth thunders as $n’s corpse falls to the ground nearby.
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.
mpat
Usage:
mpat [destination] [command]
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.
EXAMPLES:
mpat MyArea#1232 unlock door
mpat guardone poke guardone
mpat 'a lovely pool' mpechoat $n You
feel weakened from your escape.
mpat Sewers#1252 drop
all
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.
mpbeacon
Usage:
mpbeacon [destination] [target]
This command changes the recall/start room of the target, which must be a player. .
EXAMPLES:
mpbeacon MyArea#1232 all
mpbeacon guardone $n
mpbeacon 'a lovely
pool' $n
mpbehave
Usage:
mpbehave [behavior id] [target] [parameters]
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.
EXAMPLES:
mpbehave Aggressive $n
mpbehave Mobile $n
mbehave Scriptable $n
ONCE_PROG;say hello;~;
mpcallfunc
Usage:
mpcallfunc [function name] [parameters]
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.
EXAMPLES:
mpcallfunc CompleteTask $n 'my house'
mpcallfunc MyFunction
mpcast
Usage:
mpcast [spell] [target]
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.
EXAMPLES:
mpcast fireball
$r
mpcast 'stinking cloud'
mpclose
Usage:
mpclose [target]
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.
EXAMPLES:
mpclose $xN
mpclose the magic door
mpdamage
Usage:
mpdamage [target] [min amount] [max amount]
mpdamage [target] [min amount] [max amount]
kill
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.
EXAMPLES:
mpdamage $r 1
10 KILL
mpdamage $n 10 50
mpdisable
Usage:
mpdisable [target] [spell]
This command causes the target mob to lose the spell, skill, prayer, etc specified. It does nothing if the mob does not have the skill. Skills can be granted using the mpenable command.
EXAMPLES:
mpdisable $n
fireball
mpdisable $n pass door
mpecho
Usage:
mpecho [text string]
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.
EXAMPLES:
mpecho $i says,
‘Hey how’s it going?’
mpecho A blast of strong wind
rushes into the room suddenly!
mpecho $i hisses, ‘So,
$n, you’ve come to face me…’
mpecho A dagger flashes
into $i’s hand, and $j snickers softly.
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.
mpechoaround
Usage:
mpechoaround [target] [text string]
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.
EXAMPLES:
mpechoaround $n
You hear voices speaking all around you.
mpechoaround $n
$N cringes as a poisoned dart strikes $s chest!
mpechoaround $n A pile of rocks rains down upon $n!
mpechoaround $n A circle of light surrounds $n, and then $e
vanishes.
mpechoat
Usage:
mpechoat [target] [text string]
This command functions similar to the mpecho command, but can be used in such a way that only the targeted person 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.
EXAMPLES:
mpechoat $n You hear voices
speaking all around you.
mpechoat $n You cringe as a
poisoned dart strikes you in the chest!
mpechoat $n A
pile of rocks rains down upon you!
mpechoat $n A circle
of light surrounds you, and you are transported.
mpenable
Usage:
mpenable [target mob] [ability] [integer proficiency]
[parameters]
This command grants a skill, spell, prayer, chant, song, or other ability to the target mob. This acts like a forced 'GAIN' command, giving the target the skill permanently. The proficiency parameter should be between 0 and 100, and the final parameters are optional. Abilities can be removed with the mpdisable command.
EXAMPLES:
mpenable $n Fireball 100
mpenable $n 'Summon Elemental' 0 EARTH
mpendquest
Usage:
mpendquest [quest name]
This command forces a Quest which is in progress to shut itself down gracefully, removing its specific mobs, items, and properties from your map.
EXAMPLES:
mpendquest smurfocide
mpexp
Usage:
mpexp [target] [exp amount]
This command gives an amount of experience to the target. 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.
EXAMPLES:
mpexp $n 500
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.
mpforce
Usage:
mpforce [target] [command]
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.
EXAMPLES:
mpforce $n
flee
mpforce $i sleep
mpforce guardtwo poke self
mpforce
$n cast "heal serious" $i
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.
mpplayerclass
Usage:
mpplayerclass [target] [char class id] ([level] [char
class id] [level] ...)
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.
EXAMPLES:
mpplayerclass
$n Fighter
mpplayerclass $n Thief 20
mpplayerclass guardtwo Fighter 10
mpplayerclass $n Thief 20 Fighter 10 Mage 5
mpgoto
Usage:
mpgoto [destination]
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.
EXAMPLES:
mpgoto Area#10076
mpgoto guardthree
mpgset
Usage:
mpgset [target] [variable] [value]
This powerful command lets you change all kinds of aspects of the target mob or item or whatever.
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"
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", "EDUS", "RIDEBASIS", "MOBSHELD", "WHATISELL", "PREJUDICE", "BANKCHAIN", "COININT", "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"
EXAMPLES:
mpgset $n CHARISMA 10
mpgset $n NAME my name is mud
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.
mphide
Usage:
mphide [target]
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.
EXAMPLES:
mphide $n
mpjunk
Usage:
mpjunk [object]
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.
EXAMPLES:
mpjunk
chalice
mpjunk greatsword
mpjunk
all.arrow
mpjunk all
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.
mpkill
Usage:
mpkill [victim]
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.
EXAMPLES:
mpkill $n
mpkill guardfour
mpkill $r
mpkill giant
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.
mploadvar
Usage:
mploadvar [mob name] [variable name]
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.
EXAMPLES:
mploadvar $n
KILLS
mploadvar guardfour RESCUES
mplock
Usage:
mplock [target]
This command locks the target item or exit. If the target is already locked, or does not have a door or lock, nothing happens
EXAMPLES:
mplock $xN
mplock east
mplock chest
mpm2i2m
Usage:
mpm2i2m [target]
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.
EXAMPLES:
mpm2i2m $n
SPECIAL NOTES: If anyone comes up with a practical use for this command in an actual script, please let me know!
mpmload
Usage:
mpmload [mob name]
mpmload fromfile
[cmare filename] [mob name]
mpmload fromfile [cmare
filename] any
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.
EXAMPLES:
mpmload the nasty bat
mpmload fromfile mymobs.cmare the nasty bat
mpmload fromfile mymobs.cmare any
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.
mpoload
Usage:
mpoload [item name]
mpoload
fromfile [cmare filename] [item name]
mpoload fromfile
[cmare filename] any
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 fromfile syntax will allow you to load an item from a cmare file created using the Archon EXPORT ITEMS command
EXAMPLES:
mpoload the baseball bat
mpoload fromfile
myitems.cmare the baseball bat
mpoload fromfile
myitems.cmare any
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.
mpoloadroom
Usage:
mpoloadroom [item name]
mpoloadroom
fromfile [cmare filename] [item name]
mpoloadroom
fromfile [cmare filename] any
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 fromfile syntax will allow you to load an item from a cmare file created using the Archon EXPORT ITEMS command
EXAMPLES:
mpoload the baseball bat
mpoload fromfile
myitems.cmare the baseball bat
mpoload fromfile
myitems.cmare any
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.
mpopen
Usage:
mpopen [target]
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.
EXAMPLES:
mpopen $xN
mpopen the magic door
mppurge
Usage:
mppurge [argument]
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.
EXAMPLES:
mppurge portalone
mppurge guardthree
mppurge $n
mppurge self
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.
mpquestwin
Usage:
mpquestwin [mob name] [quest name]
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.
EXAMPLES:
mpquestwin
$n smurfocide
mpsavevar
Usage:
mpsavevar [mob name] [variable name]
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.
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. Likewide, the variable name can also be *, which will save the value
of every existing variable for the given mob.
EXAMPLES:
mpsavevar $n
KILLS
mpsavevar guardfour RESCUES
mpset
Usage:
mpset [target] [variable] [value]
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 changable properties as generic items do. For the maximum range of available variables, use mpgset.
Valid variable names are identical to those listed under mpset. Please see that command above for a list of valid variables.
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.
mpsetclandata
Usage:
mpsetclandata [clan] [variable] [value]
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.
EXAMPLES:
mpsetclandata 'Groovy Clan'
EXP 0
mpecho Groovy Clans experience is now
gone!
mpset
$n PREMISE my premise is new.
mpecho Whoever $n is,
their clan now has a new premise!
SPECIAL NOTES: Be very careful with this command, to ensure no damage is done to clan records.
mpsetvar
Usage:
mpsetvar [mob name] [variable name] [value]
mpsetvar [mob name] [variable name] ++
mpsetvar [mob name] [variable name] --
mpsetvar [mob name] [variable name] +[number]
mpsetvar [mob name] [variable name] -[number]
mpsetvar [mob name] [variable name] *[number]
mpsetvar [mob name] [variable name] /[number]
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.
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. Likewide, 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.
See the examples below.
EXAMPLES:
mpsetvar $i bugcount 1
mpsetvar $i bugcount ++
mpsetvar 'frog boy' 'my victim' The guard
mpsetvar $n 'my victim' var-actor
mpsetvar $i bugcount $<$n bugcount>
mpsetvar * bugcount
mpsetvar $i *
null
mpslay
Usage:
mslay [victim]
EXAMPLES:
mpslay $n
mpslay ogre
mpstartquest
Usage:
mpstartquest [quest name]
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.
EXAMPLES:
mpstartquest smurfocide
mptattoo
Usage:
mptattoo [target] (-)[tattoo name]
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.
EXAMPLES:
mptattoo $n smurfkiller
mptattoo $n -smurfkiller
mptitle
Usage:
mptitle [target] (-)[title string]
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.
mptrackto
Usage:
mptrackto [mob name]
mptrackto
[room id]
mptrackto [area name]
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.
mptransfer
Usage:
mptransfer [victim] [destination]
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.
EXAMPLES:
mptransfer $n myarea#10049
mptransfer $n
mptransfer guardeight
myarea#1252
mptransfer guardten $n
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.
mpunaffect
Usage:
mpunaffect [target] [affect id]
This command dispells 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.
EXAMPLES:
mpunaffect $n
mpunaffect $n Spell_Sleep
mpunaffect $n Skill_Track
mpunbehave
Usage:
mpunbehave [behavior id] [target]
This command removes the given behavior from the target. You should check out the list behaviors by entering LIST BEHAVIORS on the command line.
EXAMPLES:
mpunbehave
Mobile $n
mpunhide
Usage:
mpunhide [target]
This command reverses the affects of mphide, making the target (possibly) visible again.
EXAMPLES:
mpunhide $n
mpunlock
Usage:
mpunlock [target]
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.
EXAMPLES:
mpunlock $xN
mpunlock chest
mpwhile
Usage:
mpwhile ([condition]) [command]
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.
EXAMPLES:
mpwhile (VAR($n bittlock < 1))
MPCALLFUNC myprogram $<$n bittlock>
mpwalkto
Usage:
mpwalkto [mob name]
mpwalkto [room
id]
mpwalkto [area name]
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.
return
Usage:
return ([string])
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).
EXAMPLES:
return
return $<$n myvariable>
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.
Logical Operators
These operators are found in many of the
functions below. Here are their meanings.
==
This operator means ‘equal to’
!=
This operator means ‘not equal to’
>
This operator means ‘greater than’
<
This operator means ‘less than’
>=
This operator means ‘equal or greater than’
<=
This operator means ‘equal or less than’
affected
Usage:
affected(character spellid)
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.
EXAMPLE:
if affected($n,
Spell_Sleep)
mpecho The actor triggering me is asleep.
else
mpecho The actor
triggering me is not under the effects of the sleep spell.
endif
baseclass
Usage:
baseclass(character == baseclassname)
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.
EXAMPLE:
if
baseclass($n == Archon)
mpecho The actor
triggering me is an Archon.
else
mpecho The actor triggering me is not an Archon.
endif
callfunc
Usage:
callfunc(myfunctionname parm1 parm2...parmn)
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.
The callfunc function returns true ONLY if the FUNCTION_PROG includes a RETURN statement that includes a non-empty string parameter.
EXAMPLE:
function_prog
myfunc
return $g
~
once_prog
if callfunc(myfunc
ASTRING)
mpecho This callfunc function
will always return true.
mpecho This
is because myfunc just returns the parameter it is given.
mpecho And this callfunc is passing in a
non-empty string as a parameter.
endif
if !callfunc(myfunc)
mpecho
This callfunc function will always return false, since my parmeters are
empty.
endif
~
clan
Usage:
clan(character == clanname)
This checks the name of the clan of the character variable. Where '==' may be another logical operator from above.
EXAMPLE:
if clan($n ==
'The Unholy Goobers')
mpecho The actor triggering me appears to be
an Unholy Goober.
else
mpecho The actor
triggering me appears not to be a Goober.
endif
clandata
Usage:
clandata(clan variable == value)
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.
EXAMPLE:
if clandata($n
SIZE <= 1)
mpecho The actor triggering me appears to be
the only solitary member of the clan.
else
mpecho The actor triggering me appears to be part of a clan larger than 1
member.
endif
clanrank
Usage:
clanrank(character == integer)
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
EXAMPLE:
if clanrank($n
== 0)
mpecho The actor triggering me appears to be
an APPLICANT.
else
mpecho The actor
triggering me appears not to be an APPLICANT.
endif
class
Usage:
class(character == classname)
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.
EXAMPLE:
if class($n ==
Gaian)
mpecho The actor triggering me appears to be
a Gaian.
else
mpecho The actor
triggering me appears not to be a Gaian.
endif
deity
Usage:
deity(character == deityname)
This checks the name of the deity of the character variable. Where '==' may be another logical operator from above.
EXAMPLE:
if deity($n ==
'Gothon')
mpecho The actor triggering me appears to
worship an Unholy Goober.
else
mpecho The actor triggering me appears not to worship Gothon.
endif
eval
Usage:
eval(expression == expression)
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.
EXAMPLE:
if eval($n ==
an orc) or eval('$<$i VAR>' != 7)
goldamt
Usage:
goldamt(character > amount)
This evaluates the amount of gold that the character variable has on hand. Where '==' may be any other logical operator from above.
EXAMPLE:
if goldamt($n
< 10000)
mpecho The actor has less
than 10000 coins on hand
else
mpecho The actor has 10000 coins or more on
hand
endif
gstat
Usage:
gstat(target variable == value)
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.
EXAMPLES:
if gstat($n
CHARISMA > 10)
mpecho The actor has a charisma
greater than 10.
endif
has
Usage:
has(character item)
This checks whether the character has the given item in their inventory or on their person.
EXAMPLE:
if has($n a
long sword)
mpecho The actor has a long sword.
else
mpecho The actor
does not have anything called 'a long sword'.
endif
hastattoo
Usage:
hastattoo(character item)
This checks whether the character has had the given tattoo assigned to them.
EXAMPLE:
if hastattoo($n
beastmark)
mpecho The actor has the tattoo called
beastmark.
else
mpecho The actor
does not have the tattoo called beastmark.
endif
hitprcnt
Usage:
hitprcnt(character == amount)
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.
EXAMPLE:
if hitprcnt($n
<= 20)
mpecho The actor has 20% of their hit points
or less remaining.
else
mpecho The actor
has more than 20% of their hit points less.
endif
incontainer
Usage:
incontainer(character container/mount)
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.
EXAMPLES:
if
incontainer($n a chair)
mpecho The actor is sitting on a chair
else
mpecho The actor is
not sitting on a chair
endif
if
incontainer($p a sack)
mpecho The item is in a sack.
else
mpecho The item is
not in a sack.
endif
inlocale
Usage:
inlocale(character roomclass)
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 flass. Values like CaveMaze, Jungle, InTheAir, Plains, etc are what we are after here.
EXAMPLES:
if inlocale($n
InTheAir)
mpecho The actor either flying or falling.
else
mpecho The actor is
not up in the air.
endif
inroom
Usage:
inroom(target == roomcode)
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 '!='.
EXAMPLES:
if inroom($i ==
a bathroom)
mpecho This means I am in a
bathroom.
else
mpecho I am not in
a bathroom.
endif
if inroom($i !=
MyArea#20001)
mpecho I am not in room MyArea#20001.
else
mpecho I am in room
MyArea#20001.
endif
ipaddress
Usage:
ipaddress(character == string)
This compares the player characters ipaddress to the string. The '==' may also be '!='.
EXAMPLE:
if ipaddress($n
== '127.0.0.1')
mpecho You are logging on from the mud
server
else
mpecho You must be someone else.
endif
isable
Usage:
isable(character spellid)
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.
EXAMPLE:
if isable($n
Write)
mpecho The actor has the writing skill.
else
mpecho The actor
triggering me does not have the writing skill.
endif
isalive
Usage:
isalive(character)
This checks whether the character is alive.
EXAMPLE:
if
isalive($i)
mpecho I am NOT dead!
end
isbehave
Usage:
isbehave(character behaviorid)
This checks whether the character has a given behavior. The behaviorid must be the full Java name of the behavior.
EXAMPLE:
if isbehave($n
Mobile)
mpecho The actor triggering me is mobile.
else
mpecho The actor
triggering me is not mobile.
endif
ischarmed
Usage:
ischarmed(character)
This checks to see if the character variable is charmed.
EXAMPLE:
if
ischarmed($n)
mpecho This means the person triggering me is
charmed.
else
mpecho This person
triggering my prog is not charmed.
endif
isday
Usage:
isday(number)
This checks whether the current day of the month is the one given.
EXAMPLE:
if isday(10)
mpecho It is the 10th of the month.
end
isevil
Usage:
isevil(character)
This checks whether the character is evil.
EXAMPLE:
if
isevil($i)
mpecho I am evil!
else
mpecho I am either
neutral or good.
end
isfight
Usage:
isfight(character)
This checks to see if the character variable is in combat.
EXAMPLE:
if
isfight($i)
mpecho I am fighting right now.
else
mpecho I am not
fighting.
endif
isfollow
Usage:
isfollow(character)
This checks to see if the character variable’s master (the person they are following) is in the room.
EXAMPLE:
if
isfollow($i)
mpecho I am following someone and they are in
the room with me.
else
mpecho I am not
following someone, or they are not in the room.
endif
isgood
Usage:
isgood(character)
This checks whether the character is good.
EXAMPLE:
if
isgood($i)
mpecho I am good!
else
mpecho I am either
neutral or evil.
end
ishere
Usage:
ishere(name)
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.
EXAMPLE:
if ishere(a
happy frog)
mpecho A happy frog is in the room.
else
mpecho A happy frog is
not in the room.
end
isimmort
Usage:
isimmort(character)
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.
EXAMPLE:
if
isimmort($n)
mpecho The person triggering my prog is an
immortal or lord.
else
mpecho The person
triggering my prog is a mortal.
endif
islocked
Usage:
islocked(target)
islocked(direction)
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..)
EXAMPLE:
if islocked(the
chest)
mpecho The chest is locked.
else
mpecho The chest is
not locked.
endif
ismoon
Usage:
ismoon()
ismoon(phase)
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".
EXAMPLE:
if
ismoon(waxquarter)
mpecho There is a waxing quarter moon in the
sky.
else
mpecho There is not
a waxing warter moon in the sky.
endif
isname
Usage:
isname(character keyword)
This function returns whether the keyword appears in the name of the character.
EXAMPLES:
if isname($n
goober)
mpecho The actor who caused the trigger is
named goober.
else
mpecho The actor
who caused the trigger is not named goober.
endif
if isname($n $i)
mpecho I, or
someone with my name, is the actor!
else
mpecho Someone else is the actor.
endif
isneutral
Usage:
isneutral(character)
This checks whether the character is neutral.
EXAMPLE:
if isneutral($i)
mpecho I am neutral!
else
mpecho I am either good or evil.
end
isnpc
Usage:
isnpc(character)
This checks to see if a character variable is a mob.
EXAMPLE:
if isnpc($n)
mpecho The actor setting my prog off is a mob.
else
mpecho The actor
setting my prog off is a player character.
endif
isopen
Usage:
isopen(target)
isopen(direction)
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..)
EXAMPLE:
if isopen(the
chest)
mpecho The chest is open.
else
mpecho The chest is
not open.
endif
ispc
Usage:
ispc(character)
This checks to see if a character variable is a player character.
EXAMPLE:
if ispc($n)
mpecho The actor setting my prog off is a player character.
else
mpecho The actor
setting my prog off is not a player character.
endif
ispkill
Usage:
ispc(character)
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).
EXAMPLE:
if ispc($n) and
ispkill($n)
mpecho The actor setting my prog off is a
player killer.
else
mpecho The actor
setting my prog off is not a player killer.
endif
isquestmobalive
Usage:
isquestmobalive(number questname)
isquestmobalive(mobname questname)
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.
EXAMPLE:
if
isquestmobalive(1 myquest)
mpecho The first
set mob in the quest myquest is still alive.
else
mpecho He's not dead yet.
endif
isseason
Usage:
isseason(seasonname)
This function is used to check the season of the year. Valid seasonnames include "WINTER", "SPRING", "SUMMER", or "FALL".
EXAMPLE:
if
isseason(summer)
mpecho Yea, its summertime!
else
mpecho Boo! It's
not summer yet.
endif
istime
Usage:
istime(integer)
istime(todword)
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".
EXAMPLE:
if
istime(night)
mpecho It is nighttime.
else
mpecho It must be
dawn, dusk, or daytime.
endif
isweather
Usage:
isweather(weathername)
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"
EXAMPLE:
if
isweather(rain)
mpecho Rain, rain go away...
else
mpecho We can play!
No Rain!
endif
level
Usage:
level(character == number)
This checks the total level of the character variable. Where '==' may be any of the logical operators mentioned above.
EXAMPLES:
if
level($n <= 15)
mpecho The actor triggering me is 15th level
or less.
else
mpecho The actor
triggering me is above 15th level.
endif
if level($n
> $%level($i)%)
mpecho The actor triggering me is higher
level than me.
else
mpecho The actor
triggering me is my level or under.
endif
mobitem
Usage:
mobitem(character number keywords)
This infrequently used function checks whether the numberth item in characters inventory has keywords in its name.
EXAMPLE:
if
mobitem($n 1 sword) or mobitem ($n $g.1 sword)
mpecho Either the actors first item is a sword, or an item whose
cardinality is represented by the code $g.1 is a sword.
else
mpecho Neither of
those items is a sword.
endif
number
Usage:
number(string)
This function returns whether the string given is a number.
EXAMPLES:
if number($g.2)
mpecho The second parameter to this function_prog is a number.
else
mpecho The second
parameter to this function_prog is not a number.
endif
numitemsmob
Usage:
numitemsmob(character == number)
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.
EXAMPLES:
if numitemsmob($n > 10)
mpecho The actor has an inventory size greater than 10.
else
mpecho The actor
has an inventory size less than or equal to 10.
endif
numitemsroom
Usage:
numitemsroom( == number)
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 anyof the logical operators from above.
EXAMPLES:
if numitemsroom( > 10)
mpecho There are more than 10 items in this room.
else
mpecho There are 10
or less items in the room .
endif
nummobs
Usage:
nummobs(name == number)
This function compares the total number of mobs with the given name 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.
EXAMPLES:
if nummobs(goobers >
10)
mpecho There are more than 10 goobers in the
world.
else
mpecho There are 10
or less goobers in the world .
endif
nummobsinarea
Usage:
nummobsinarea(name == number)
This function compares the total number of mobs with the given name 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.
EXAMPLES:
if nummobsinarea(goobers >
10)
mpecho There are more than 10 goobers in this
area.
else
mpecho There are 10
or less goobers in this area.
endif
nummobsroom
Usage:
nummobsroom( == number)
This function compares the total number of mobs in the same room as the monster to the number given. This function counts players, npcs, and the hidden and undetectable. The '==' may also be any of the logical operators from above.
EXAMPLES:
if nummobsroom( > 10)
mpecho There are more than 10 mobs in this room.
else
mpecho There are 10
or less mobs in the room .
endif
numpcsroom
Usage:
numpcsroom( == number)
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.
EXAMPLES:
if numpcsroom( > 10)
mpecho There are more than 10 pcs in this room.
else
mpecho There are 10
or less pcs in the room .
endif
numraces
Usage:
nummobs(race== number)
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.
EXAMPLES:
if numraces(Goblin> 10)
mpecho There are more than 10 goblins in the world.
else
mpecho There are 10
or less goblins in the world .
endif
numracesinarea
Usage:
numracesinarea(race== number)
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.
EXAMPLES:
if numracesinarea(Goblin >
10)
mpecho There are more than 10 goblins in this
area.
else
mpecho There are 10
or less goblins in this area.
endif
position
Usage:
position(character == posword)
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.
EXAMPLES:
if position($n
== STANDING)
mpecho This means that the actor is
standing.
else
mpecho This means
the actor is not standing.
endif
questitem
Usage:
questitem(item questname)
This checks whether the given item is an official item created by a quest of the given questname.
EXAMPLES:
if questitem($o
myquest)
mpecho This means that item is a quest item
for quest myquest.
else
mpecho This means
the item is not a quest item for quest myquest.
endif
questmob
Usage:
questmob(character questname)
This checks whether the given character is an official mob created by a quest of the given questname.
EXAMPLES:
if questmob($n
myquest)
mpecho This means that the actor is a quest
mob for quest myquest.
else
mpecho This means the the actor is not a quest mob for quest
myquest.
endif
questwinner
Usage:
questmob(character questname)
This checks whether the given character has been declared a winner of the quest in the past via the MPQUESTWIN command.
EXAMPLES:
if
questwinner($n myquest)
mpecho This means that the actor has been a
winner of the quest myquest.
else
mpecho This means the the actor hss not been a winner of
the quest myquest.
endif
race
Usage:
race(character == race)
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.
EXAMPLE:
if race($n == Goblin)
mpecho The actor is a goblin.
else
mpecho The actor is not a goblin.
endif
racecat
Usage:
race(character == category)
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.
EXAMPLE:
if racecat($n == Elf)
mpecho The actor is an Elf, or Elf-kin.
else
mpecho The actor is not an Elf-Kin.
endif
rand
Usage:
rand(integer)
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.
EXAMPLE:
if rand(40)
mpecho This is under 40% chance for me to echo this.
else
mpecho Not under
40%.
endif
rand0num
Usage:
rand0num(integer == integer)
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.
EXAMPLE:
if rand0num(2 == 0)
MPSETVAR $i GREETINGLIST hi howdy hello greetings
ho
say I just wanted to say $<$i
GREETINGLIST>.$%RAND0NUM(5)%!
endif
randnum
Usage:
randnum(integer == integer)
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.
EXAMPLE:
if
rand(1000 == 5)
mpecho This is under a 5 in
1000 chance for me to echo this.
else
mpecho Not under 5 in 1000.
endif
roomitem
Usage:
roomitem(number keywords)
This infrequently used function checks whether the numberth item in the room has keywords in its name.
EXAMPLE:
if roomitem(1
sword) or roomitem ($g.1 sword)
mpecho Either the
rooms first item is a sword, or an item whose cardinality is represented by the
code $g.1 is a sword.
else
mpecho Neither of
those items is a sword.
endif
roommob
Usage:
roommob(number keywords)
This infrequently used function checks whether the numberth mob in the room has keywords in its name.
EXAMPLE:
if roommob(1
joe) or roommob($g.1 joe)
mpecho Either the
rooms first mob is named joe, or a mob whose cardinality is represented by
the code $g.1 is joe.
else
mpecho Neither of
those mobs is joe.
endif
sex
Usage:
sex(character == letter)
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.
EXAMPLES:
if sex($n == M)
mpecho The actor triggering me is a male.
else
mpecho The actor triggering me is not a male.
endif
if sex($n != $%sex($n)%)
mpecho The actor triggering me is not the same sex as me.
else
mpecho The actor
triggering me is the same sex as me.
endif
stat
Usage:
stat(target variable == value)
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.
EXAMPLES:
if stat($n
CHARISMA > 10)
mpecho The actor, if a
generic mob, has a charisma greater than 10.
endif
strin
Usage:
strin(string string)
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.
EXAMPLE:
if strin('one two three
four' 'three')
mpecho The word three appears in the list of
words.
else
mpecho Since no
variables were used in the example, this is technically impossible.
endif
var
Usage:
var(character variable == value)
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.
EXAMPLE:
if var($n KILLS
> 10)
mpecho The actor's KILLS variable is greater
than 10.
else
mpecho The actor's
KILLS variable is equal to or less than 10.
endif
worn
Usage:
worn(character item)
This function checks whether the character is wearing an item of the given name.
EXAMPLE:
if worn($n
brass shirt)
mpecho The actor is wearing a brass shirt
somewhere.
else
mpecho The actor is
not wearing a brass shirt.
endif