abmp.htm

abmp.htm · 92.0 KB

From the archive ab.zip

Download the archive   « Back to the archive contents

<html>
 <head>
  <title>Dizzy Mud Area Coding Guide - MobProgs Explained</title>
 </head>
 <body BGCOLOR="#FFFFFF">
  <h3 ALIGN="center">MobProgs Explained</h3>
  <small>
   This page describes how to write mobprogs for an area file.
  </small>
  <!-- BEGIN Navigator -->
  <HR NOSHADE>
  <table WIDTH="100%">
   <tr>
    <td ALIGN="left">
     <small>
      &lt;&lt; Back to 
      <a HREF="abspec.htm">
       #SPECIALS Section
      </a>
     </small>
    </td>
    <td ALIGN="right">
     <small>
      &gt;&gt; Forward to
      <a HREF="abexamp.htm">
      Example Area
      </a>
     </small>
    </td>
   </tr>
  </table>
  <HR NOSHADE>
  <!-- END Navigator -->
  If you are coding an area and want your mobs to show behavior beyond the 
  built-in acts of wandering, scavenging, aggression and the fixed specials,
  you need to write one or more Mobile Programs, referred to in this document
  as MobProgs. Writing mobprogs is a simple form of programming and places
  the author in the twilight zone between building and coding.
  <p>
  The basic structure of a MobProg is as follows:
  <p>
  <table BORDER=2 CELLPADDING=20 WIDTH="100%">
   <tr>
    <td>
     <p>
     <code>
      <b>
       <strong>&gt;</strong><a HREF="#trigger">trigger</a>
       <a HREF="#args">args</a><strong>~</strong><br>
       <a HREF="#commands">commands</a><br>
       <strong>~</strong>
      </b>
     </code>
    </td>
   </tr>
  </table>
  <p>
  <dl><!-- begin list of things in first box --->
   <dt><b><a NAME="trigger">trigger</a></b></dt>
   <dd>
    A <b>trigger</b> is one of a fixed set of events that the MUD knows about
    which can start a mobprog running, and thus the mob doing something. 
    Here is a list of the currently defined
    triggers, in alphabetical order. 
    Detailed explanations follow later.
    <p>
    <table BORDER=1 CELLSPACING=0>
     <tr>
      <th>Trigger name</th>
      <th>Responds to</th>
     <tr>
      <td><code><b><a HREF="#act_prog">act</a>_prog</b></code></td>
      <td>an action by another character in the room</td>
     </tr>
     <tr>
      <td><code><b><a HREF="#all_greet_prog">all_greet</a>_prog</b></code></td>
      <td>any character entered the room</td>
     </tr>
     <tr>
      <td><code><b><a HREF="#bribe_prog">bribe</a>_prog</b></code></td>
      <td>money is given to the mob</td>
     </tr>
     <tr>
      <td><code><b><a HREF="#buy_prog">buy</a>_prog</b></code></td>
      <td>someone buys something from the mob</td>
     </tr>
     <tr>
      <td><code><b><a HREF="#death_prog">death</a>_prog</b></code></td>
      <td>the mob is about to die</td>
     </tr>
     <tr>
      <td><code><b><a HREF="#entry_prog">entry</a>_prog</b></code></td>
      <td>the mob just entered a room</td>
     </tr>
     <tr>
      <td><code><b><a HREF="#fight_prog">fight</a>_prog</b></code></td>
      <td>the mob enters a new round in a fight</td>
     </tr>
     <tr>
      <td><code><b><a HREF="#give_prog">give</a>_prog</b></code></td>
      <td>an object is given to the mob</td>
     </tr>
     <tr>
      <td><code><b><a HREF="#greet_prog">greet</a>_prog</b></code></td>
      <td>a character, visible to the mob, entered the room</td>
     </tr>
     <tr>
      <td><code><b><a HREF="#hitprcnt_prog">hitprcnt</a>_prog</b></code></td>
      <td>mob is fighting and its hp drop below a given value</td>
     </tr>
     <tr>
      <td><code><b><a HREF="#in_file_prog">in_file</a>_prog</b></code></td>
      <td>dummy trigger for mobprog linkage</td>
     </tr>
     <tr>
      <td><code><b><a HREF="#rand_prog">rand</a>_prog</b></code></td>
      <td>happens randomly once in a while</td>
     </tr>
     <tr>
      <td><code><b><a HREF="#speech_prog">speech</a>_prog</b></code></td>
      <td>a <em>player</em> utters a given word or phrase</td>
     </tr>
    </table>
   </dd>
   <p>
   <dt><b><a NAME="args">args</a></b></dt>
   <dd>
    <b>args</b> is short for "arguments". If you're new to programming you're 
    new to this use of the word; it simply means extra information to
    code on the trigger line which gives the trigger something to work on
    or tells it details about how to work. 
    The information given is specific to the trigger
    and fine-tunes its action. For example, 
    <ul>
     <li>
      the "arg" for a <a HREF="#bribe_prog">bribe_prog</a> 
      is a number specifying how much money is the minimum the mob 
      should respond to. Maybe it should perform a service, but only
      for a goodly price.
     </li>
     <li>
      the "arg" for a <a HREF="#rand_prog">rand_prog</a>
      is a number specifying the percentage probability that a mob
      will perform the specified random action on any given (timer)
      pulse. Many of the other triggers also take a probability
      percentage as an argument.
     </li>
     <li>
      the "arg" for a <a HREF="#speech_prog">speech_prog</a>
      is a word or phrase that the mob should respond to. A speech_prog
      will only be triggered by the exact word or phrase given in "arg".
     </li>
    </ul>
    <p>
    So essentially, "arg" is just what you put on the trigger line after
    the "xxx_prog" word which identifies the trigger. The arguments are
    explained in detail below with each of their appertaining triggers.
    <p>
    I'll be saying it again, but the argument on the trigger line
    <b>must be followed by a tilde ( <strong>~</strong> ) !</b>
   </dd>
   <p>
   <dt><b><a NAME="commands">commands</a></b></dt>
   <dd>
    <b>commands</b> are one or more commands you want the mob to perform
    when the trigger is activated. You must code <b>one command per line</b>.
    The commands may be one of the following:
    <ul>
     <li>One of most 'normal' MUD commands as used by players, with a few
     restrictions:
      <ul>
       <li>Mobs cannot use most channels</li>
       <li>Mobs cannot use the bank or lockers</li>
       <li>Mobs cannot SAVE or BACKUP</li>
       <li>...and a variety of other things. If in doubt, test or ask your
       friendly Coder.</li>
      </ul>
     </li>
     <li>special <a HREF="#mp_commands">mobprog-only commands</a>, usually
     similar to immortal commands</li>
     <li><a HREF="#if">control flow commands:</a> 
     <code><b>IF, ELSE, ENDIF, BREAK</b></code></li>
    </ul>
   </dd>
  </dl>
  <dl><!-- End of things in the first box --->
  <p>
  <hr>
  Before we go on,
  <p>
  <h4 ALIGN="center">Some definitions</h4>
  <dl>
   <!-- Begin definitions --->
   <dt><b>mobile (mob)</b></dt>
   <dd>One of the seemingly living beings running around the MUD, controlled by
    the MUD program.
   </dd>
   <p>
   <dt><b>your mob</b></dt>
   <dd>The mob for which you are currently writing or working on a MobProg.</dd>
   <p>
   <dt><b>player</b></dt>
   <dd>The human person sitting at the keyboard behind the screen, playing in the MUD.
    In the context of this MobProg Guide, though, I use <b>player</b> to mean the
    <b>player character</b>, i.e. the living being which runs around the MUD
    built up and controlled by the player.</dd>
   </dd>
   <p>
   <dt><b>character</b></dt>
   <dd>
    Either a mob or a player character. I refer to <b>character</b> when it's
    not known for sure which of the two it is, or when it doesn't matter.
   </dd>
   <p>
   <dt><b>message</b></dt>
   <dd>
    Most events that happen in the MUD result in a message. This is how 
    players are kept aware of what's happening around them. In an 
    artificial-intelligence sort of way, it's also how the mobs find out
    about events. The game has 
    two different mechanisms for getting messages to characters. They are 
    characterized by the program functions used to generate them, so for 
    simplicity I'll call them "<cite>send_to_char messages</cite>" and 
    "<cite>act messages</cite>". The difference is relevant because
    those MobProg triggers that respond to messages only respond to
    the "<cite>act message</cite>" type.
   </dd>
   <p>
   <dt><b>"send_to_char" messages</b></dt>
   <dd>
    Most "quick" responses to commands entered by a character use the 
    <code>send_to_char()</code> function to acknowledge the character's 
    action or to give him some other information.
    Some well-known examples of these "simple" messages are:
    <ul>
     <li><code>Huh? </code> and </li>
     <li><code>You are thirsty. </code></li>
    </ul>
    Usually such messages only go to the character who caused the message,
    and don't refer to any persons other than "you".
   </dd>
   <p>
   <dt><b><a NAME="act">"act" messages</a></b></dt>
   <dd>
    Most messages informing one character of what another character is 
    doing are of the "act" message type. They use the program function
    <code>act()</code>, which is very versatile and able to conveniently
    build characters' names and personal pronouns into a message, select
    the recipients of the message based on originator, victim, all in room,
    all in room but victim, all in room but originator, etc. If a message
    generated by the game has a character's name in it, it's pretty certain
    to be of this type and thus useable for MobProgs. You may need to
    experiment to be certain, though.
    <p>
    Messages are crucially important in MobProgs. While a human player moves
    around in the MUD because he wants to, is curious, is on a quest or has
    some other motivation, most mobs do things only for two reasons:
    <ul>
     <li>They are responding to a random trigger. This is explained later
     but essentially every few seconds a binary coin is flipped to decide
     whether or not the mob will do something. If the outcome is positive,
     the mob does its thing, whatever that may be. It can have several
     'things' to do.
     </li>
     <li>They are responding to a message 'telling' them that another
      character did something, i.e. they are responding to another character's
      action. There are several different types of actions that can be used
      to set off a response in a mob.
     </li>
    </ul>
   <dd>
   <p>
   <dt><b>word</b></dt>
   <dd>
    In a MobProg setting, a <b>word</b> is any sequence of characters not
    including white space (space or end-of-line). Thus,
    <ul>
     <li>"<cite>rinky-dink</cite>" is <b>one</b> word.</li>
     <li>
      In "<cite>How now, brown cow?</cite>", the second and fourth
      words are "<cite>now,</cite>" and "<cite>cow?</cite>".
     </li>
    </ul>
   </dd>
   <p>
   <dt><b>keyword</b>
   <dd>
    A <b>keyword</b> is a word you specify as an argument (or part of an argument) 
    to a MobProg trigger in the hope of having it match a <b>word</b> in a message
    received by the mob. There are no partial matches on keywords: A keyword
    can only match a word in a message exactly, character for character, or not
    at all. As in the spelling of an in-game spell, two or more words can be
    combined to form a single keyword by placing them in single quotes
    ( <strong>'</strong> ).
   </dd>
   <p>
   <dt><b>keyphrase</b>
   <dd>
    A <b>keyphrase</b> is a sequence of text complete with internal punctuation
    and spaces, which you specify as an argument to a MobProg in the
    hope of having it match a message or a continuous part of a message
    received by the mob. There is no partial matching on keyphrases.
    A keyphrase can only match exactly, character for character, or not at all.
    This means the punctuation and/or number of spaces between words must match
    perfectly as well.
    The end of a keyphrase must match a space or the end of a line. This means
    that, once again, funny characters like punctuation become part of the
    phrase to search for. For a poke in the ribs, the correct way to specify
    the argument would be:
    <p>
    <center>p pokes you in the ribs.~</center>
    <p>
    Note the tilde ( <strong>~</strong> ) right after the end of the keyphrase.
   </dd>
   <p>
   <dt><b><a NAME="probability">probability</a></b></dt>
   <dd>
    In the context of arguments to mobprogs, a <b>probability</b> is a way of
    specifying how likely it is that the trigger will trigger if its
    basic condition is met. This probability is given as number between 1
    and 100 which represents a percentage of probability. <b>Do not write
    a percent sign!</b> A 100 means the trigger is sure to
    trigger. You can use a 0 if you want to temporarily disactivate a
    trigger which takes a probability argument. For long term deactivation,
    you should remove the whole mobprog so it will not take up game memory.
   </dd>
   <!-- end definitions --->
  </dl>
  <hr NOSHADE>
  <h4 ALIGN="center">Connecting a MobProg to a mob</h4>
  In order for a mob to react to events, i.e. in order for the MobProg to be
  effective, the MobProg must be connected to the mob. This connection is
  actually not to a specific mob (you could potentially reset hundreds of
  mobs, all of the same vnum) but to a mob's prototype, which is shared
  among all mobs of the same vnum. You can think of MobProgs as being attached
  to a specific mob vnum and affecting all mobs having that vnum.
  <p>
  There are two different and intermixable ways to connect a MobProg to a
  mob. The first one is simple and comes fairly naturally. For unique
  MobProgs affecting only a single mob vnum, this is all you need. The
  second way is harder to understand, and so far Dizzy MUD has no MobProgs
  attached that way. So, while it may seem illogical to break up the topic,
  I hope to avoid unnecessary confusion by explaining the easy way right 
  after this paragraph and leaving <a HREF="#hardway">the hard way</a> 
  for later.
  <p>
  <b>The Simple Way</b><br>
  The last line of a mobile description (the whole thing you code for a mobile,
  not its short, long or extended description) is the line that reads
  <p>
  <center><code><b>0 0 size 0</b></code></center>
  <p>
  To attach a mobprog, <b>code the mobprog right after this last line</b>.
  You may attach one mobprog or several; essentially you are adding a
  <b>list of mobprogs</b> with one or more mobprogs in it. <b>After the
  last line of the last mobprog</b>, you must <b>terminate the list</b>
  with a <b>single line containing a pipe symbol (&nbsp;<strong>|</strong>&nbsp;)</b>.
  Hunt around on your keyboard, it's there!
  <p>
  <hr NOSHADE>
  <h4>Example 1</h4>
  MobProgs are notoriously difficult for non-programmers to understand.
  Other documents on the topic have made it difficult to understand for
  programmers as well. While the preceding sections have gotten by with
  very few examples, I feel that examples will be essential here.
  <p>
  Although the above is only a cursory overview of mob programming, there
  is enough information there to code a couple of simple MobProgs, as
  follows. The example shows a mob description from the #MOBILES section
  of an area file, complete with two mobprogs.
  <p>
  <table BORDER=1 CELLPADDING=20>
   <tr>
    <td>
     <pre>
      <b>
#6902
beggar~
a poor beggar~
A poor beggar plies his demeaning trade here on the street.
~
The beggar is a Teilysa, unkempt and poorly clothed against
the cold wind blowing through the streets. He is lacking
both legs and an arm. The remaining arm holds a battered
hat containing a few coins. No one is tempted to say,
"Get a job!"
~
teilysa~
BGHZ KLMXd 0 S
10 0 2d6+130 10d9+100 1d8+4 punch
5 5 5 8
0 A 0 CD
sleep rest male 15
0 0 small 0
>rand_prog 4~
wake
say Alms, please! Some coins for a poor beggar!
cough
sleep
~
>bribe_prog 1~
wake
smile
say Thank you, thank you! May God bless you!
sleep
~
|
      </b>   
     </pre>
    </td>
   </tr>
  </table>
  <p>
  The example shows a sleeping beggar who randomly wakes up to beg for alms,
  and who wakes up and thanks his benefactor if given any amount of money.
  Note the right angle bracket ( <strong>&gt;</strong> ) preceding each
  trigger line, the tildes ( <strong>~</strong> ) following the trigger line 
  and MobProg commands, and the pipe symbol ( <strong>|</strong> ) ending the
  list of MobProgs for the mob.
  <p>
  Future examples will show only the MobProg(s), not the mob. They will also
  assume that the MobProg or MobProgs are part of a list which is properly
  terminated with the pipe symbol ( <strong>|</strong> ).
  <p>
  <hr NOSHADE>
  <h4>Trigger Types in Detail</h4>
  In order to program more interesting MobProgs than the ones in the first
  example, you need to be familiar with all the available trigger types
  and how to control them. What follows is a detailed explanation of each
  trigger type. These explanations are intended to tell you all about each
  trigger type. A summary for use as a quick reference is contained in the
  <a HREF="#trigger">Trigger Type Table</a>.
  <p>
  First, some <b>definitions</b>:
  <hr NOSHADE WIDTH="50%">
  Now for the <b>triggers</b>:
  <dl>
   <dt><b>&gt;<a NAME="act_prog">act_prog</a> &nbsp;keyword(s)~</b></dt>
   <dt><b>&gt;act_prog &nbsp;p &nbsp;keyphrase~</b></dt>
   <dd>
    This is the most general trigger. It responds to "<a HREF="#act">act messages</a>" 
    received by the mob if and only if the message matches what you specify
    in the argument. There are two ways to specify this argument:
    <ul>
     <li>
      As a list of (one or more) keywords. The act_prog will trigger
      if all of the keywords you specify is contained in the message the 
      mob receives.
     </li>
     <li>
      As a letter '<b>p</b>', followed by a space and <b>a complete keyphrase</b>.
      The act_prog will trigger only if the message it receives contains the
      exact sequence of words you specify, in the given order and with the
      given spacing. Punctuation characters are taken to be part of the
      words of the message, and once again, there is no partial matching.
      Thus, the correct act_prog phrase trigger for a poke in the ribs 
      would be:
      <p>
      <center><code><b>&gt;act_prog p pokes you in the ribs.~</b></code></center>
      <p>
      Note the period. It's part of the "word", 'ribs.' . It's required for
      an exact match of the keyphrase.
     </li>
    </ul>
    In both cases, the action, i.e. the commands you code under the trigger
    line, happen if the words or phrase match. It's that simple.
   </dd>
   <p>
   <dt><b><a NAME="all_greet_prog">all_greet_prog</a> &nbsp; probability</b></dt>
   <dd>
    This mobprog is triggered when any character enters the room the mob is in,
    <b>unless</b> the mob is fighting.
    The 'all' signifies that it means <em>all</em> characters, including ones
    the mob cannot see. The 'greet' part signifies a typical use: You could have
    your mob greet people arriving. However, you don't want to use THIS trigger
    as it would expose invisible people. There is a 
    <a HREF=#greet_prog>greet_prog</a>
    further down which would be better suited. THIS trigger is more useful for
    high-tech tricks like teleporting players around. Or maybe completely
    impassable guardians.
    <p>
    The <a HREF="#probability">probability</a> specifies how likely it is that
    this trigger will actually activate even if its condition is met. In this
    case, if (for example) you specified "bow" as a command and "50" as a
    probability, the mob would randomly bow to about half the people entering 
    the room.
   </dd>
   <p>
   <dt><b><a NAME="bribe_prog">bribe_prog</a> &nbsp; silver-amount</b></dt>
   <dd>
    Triggered by money given to the mob. The <b>silver-amount</b>
    argument is the minimum number of silver coins (or the gold equivalent)
    for which the trigger will activate. If you want your mob to respond to
    <em>any</em> donation, code a 1. It's hard to give less than 1 silver
    and still give, right? See also <a HREF="#give_prog">give_prog</a>.
   </dd>
   <p>
   <dt><b><a NAME="buy_prog">buy_prog</a> &nbsp; probability</b></dt>
   <dd>
    Triggered if someone buys something from the mob.
    This seems to be local to Dizzy as it's not mentioned in the 'other'
    documentation on MobProgs. Unfortunately, the mob is only aware that
    something has been bought, not what or for how much. So there's not
    much room for individual reactions.
   </dd>
   <p>
   <dt><b><a NAME="death_prog">death_prog</a> &nbsp;probability</b></dt>
   <dd>
    This happens at the same time that, without this trigger, the mob would
    do its death scream: After it was killed but before the body is
    turned into a corpse. The <b>probability</b> arg determines how likely
    it is that this trigger will activate instead of the death cry.
    The mob is put back in a STANDING position before your commands are
    executed, so you can code any commands without having to worry about
    the mob being too dead to perform them. Note, however, that nothing
    you can code can actually prevent the mob's death. Even if the mob
    were to fully restore itself, it would die after executing your 
    commands. Still, some amazing sleight of hand can be accomplished with
    this trigger. The bunnies in the temple of Tao, which get right back
    up after being killed, are a cute example. They load a (fresh and unhurt)
    clone of themselves into their location, issue a message about getting
    up again, then (silently) go into another room to die.
   </dd>
   <p>
   <dt><b><a NAME="entry_prog">entry_prog</a> &nbsp;probability</b></dt>
   <dd>
    This is done when the mob, wandering around, enters a new room.
    It will be done whether the room is inhabited or not (I think)
    so visibility of people in the room is not a problem as with
    <a HREF="#all_greet_prog">(all_)greet_prog</a>. Typical things to
    do are to peer around or to wave hello.
   </dd>
   <p>
   <dt><b><a NAME="fight_prog">fight_prog</a> &nbsp;probability</b></dt>
   <dd>
    This trigger is checked once every PULSE_VIOLENCE during a fight.
    On Dizzy, PULSE_VIOLENCE translates to once every 3 seconds. The
    probability is checked on each occasion, so if you code less than 
    100 here whatever it is will not happen EVERY 3 seconds, but 
    randomly.
    <p>
    This is often used to have the mob throw insults at his opponent.
    If/when MPCAST is implemented, it could be used to throw spells
    instead. Failing that, perhaps the mob could scream for help?
   </dd>
   <p>
   <dt><b><a NAME="give_prog">give_prog &nbsp;object-name</a></b></dt>
   <dd>
    This is triggered when someone GIVEs an object (not money) to the mob.
    There is no probability, it always triggers. The argument specifies, though,
    <em>which</em> object will trigger the mobprog. The <b>object-name</b>
    argument must exactly match the <b>keywords</b> field of the object.
    ID and LORE show the list of keywords in single quotes just after the 
    first word of the output, <b>Object:</b>. In order to match, you must
    specify the entire keyword list, exactly. You do not need to specify
    single quotes around <b>object-name</b>, though.
    <p>
    You can have your mob respond to ANY object given to it by specifying
    <b>all</b> as the argument.
   </dd>
   <p>
   <dt><b><a NAME="greet_prog">greet_prog</a> &nbsp;probability</b></dt>
   <dd>
    Like <a HREF="#all_greet_prog">all_greet_prog</a>, but will not trigger
    if the mob cannot see the character entering the room. Like all_greet_prog,
    it will also not activate if the mob is busy fighting.
    <p>
    Some uses include shopkeepers who greet customers and picky thieves
    mobs who check players' wealth before attacking. Yeah, an attack can
    be a form of greeting too. 
   </dd>
   <p>
   <dt><b><a NAME="hitprcnt_prog">hitprcnt_prog</a> &nbsp;hp-percent</b></dt>
   <dd>
    If your mob is fighting, then the MUD checks very PULSE_VIOLENCE 
    (see <a HREF="#fight_prog">fight_prog</a>) whether the mob's hit points
    are below <b>hp-percent</b> of his maximum hp. If so, this trigger will
    be activated. Although hp-percent is a percentage, please code only a
    number between 0 and 100, <b>no percent sign!</b>
    <p>
    This is one of those triggers of which you can code multiple and of which
    only the first successful one is executed. I'll explain this in more detail
    below. For now, remember that you can have your mob do something different
    for various levels of hurt-ness by coding several mobprogs with percentages
    in <b>ascending</b> order, say 33, 66, 100 for three different stages of
    defeat. The first two will not trigger as long as the mob has better than 66%
    of his hp; after that the second one will trigger, etc.
   </dd>
   <p>
   <dt><b><a NAME="in_file_prog">in_file_prog</a> &nbsp;file-name</b></dt>
   <dd>
    This is not really a trigger, but a way to include a set of mobprogs
    from a different file at the place where this line is coded. It's part
    of <a HREF="#hardway">the hard way</a> to link MobProgs to mobs, so I
    will explain it later.
   </dd>
   <p>
   <dt><b><a NAME="rand_prog">rand_prog</a> &nbsp;probability</b></dt>
   <dd>
    The only condition for this trigger is that there is at least one
    player <b>in the same area</b> as the mob.
    It happens randomly, with the frequency
    controlled by the <b>probability</b> you specify. It is checked by a
    timer running at PULSE_MOBILE, which is (in Dizzy, currently) every 4
    seconds. If you code 100 as the probability, your mob will do this
    every 4 seconds and probably annoy the heck out of people. If you code
    7 for the probability, it will happen, on the average, every 
    (4&nbsp;*&nbsp;100)&nbsp;/&nbsp;7 seconds, or about every minute. This
    is almost tolerable. You may want to cut this down to 3 percent for 
    a little less than once every 2 minutes, average.
   </dd>
   <p>
   <dt><b><a NAME="speech_prog">speech_prog</a> &nbsp;keyword(s)</b></dt>
   <dt><b><a NAME="speech_prog">speech_prog</a> &nbsp;p &nbsp;keyphrase</b></dt>
   <dd>
    This trigger is similar to <a HREF="#act_prog">act_prog</a>, except that
    the triggering word(s) or phrase must be said (using SAY) by a character
    in the same room as the mob, and not ACTed. A simple example for this
    useage is the Acolyte of Isa in the Mud School, which gives cake to
    newbies polite enough to answer 'yes' to her question. You probably don't
    want to code this TOO specifically, because player utterances can vary
    wildly. Consider yourself lucky if you get reasonable matches on a single
    word! 
   </dd>
   <p>
  </dl>
  <h4>Some more conditions governing the firing of triggers</h4>
  There are a number of triggers which may appear a number of times for 
  one mob. <a HREF="#hitprcnt_prog"><b>hitprcnt_prog</b></a> was one
  example. For these triggers, you do <b>not</b> want to see the mob
  performing more than one at any one time. Happily, the MUD program checks
  to make sure that, from each of the following trigger types, only the
  <em>first successful trigger</em> is executed:
  <ul>
   <li>bribe_prog</li>
   <li>death_prog</li>
   <li>entry_prog</li>
   <li>fight_prog</li>
   <li>give_prog</li>
   <li>rand_prog</li>
  </ul>
  This is hard to picture without an example. Say you have 3 <b>entry_prog</b>s
  for a mob, doing "peer", "grumble" and "scan", each with a 33% chance.
  Upon entering a room, chances are 33% that the mob will <b>peer</b>. If it
  does, it will not <b>grumble</b> or <b>scan</b> because it's already done
  one entry_prog and will do no more of the same kind. If it fails to <b>peer</b>,
  there is again a 33% chance that it will <b>grumble</b>. Failing that, 
  there is yet a 33% chance that it will <b>scan</b>. Meanwhile, the occurrence
  of any <em>other</em> triggers is not affected at all; the mob could conceivably
  do a <b>rand_prog</b> the very same second, for example.
  <p>
  If you're any good with math and probabilities, you will notice that the
  probabilities of the events in the example are not as simple as they look.
  There is really truly a 33% chance of the mob doing the <b>first</b> action.
  But the second one only happens in 33% of the 67% left over from the first
  case, which is only 22% chance. The chance of either of the first two events
  happening is 33+22 = 55%. That leaves us only a 100-55 = 45% chance to check 
  the third event. That comes to 33% of 45%, or less than 15%. The events 'further
  down' sort of 'live in the shadow' of the preceding events. 
  And yes: 33+22+15 do not add up to 100 by a long shot, thus
  there is a 31% chance that <em>none</em> of the 3 events will take place,
  although it looked like a 99% sure thing that one of them would.
  <p>
  What's to be learned from all this? Never mind the math. Just remember that
  triggers of the same kind further down the line have less of a chance of
  happening than you would think. Also, if you're despairing of ever getting
  the probabilities just right, take hope from the fact that there are <b>IF</b>s
  and probability checks coming up soon which may help you code exactly what you
  mean.
  <p>
  Something entirely different to be aware of: <b>NONE of these triggers work
  if the mob is charmed!</b> This keeps people from abusing mobprog behavior
  for their own evil plans.
  <p>
  <hr>
  <h4>Example 2</h4>
  <p>
  By way of review, I'll try to put some of the new information together into a
  more advanced example. I'll extend the mobprogs on the poor beggar from Example 1.
  He's getting badly overloaded now. Unless a mob is a central figure in your
  theme, you should probably not heap it with mobprogs to do trivial things like
  these. Consider the following an example of techniques, not of extent.
  <p>
  <table BORDER=1 CELLPADDING=20>
   <tr>
    <td>
     <pre>
      <b>
>rand_prog 33~
snore
~
>rand_prog 50~
cough
~
>rand_prog 100~
moan
~
>hitprcnt_prog 10~
say A miserable life, but I'm about to lose it!
~
>hitprcnt_prog 35~
say Something tells me I'm not going to win this fight.
~
>hitprcnt_prog 70~
say Oh no! I'm bleeding!
~
>hitprcnt_prog 100~
say Have you nothing better to do than to attack defenseless beggars?
~
>bribe_prog 10000~
say My fortune is made!
emote straps on a pair of wooden legs and a wooden arm.
hop
dance
sing
~
>bribe_prog 1000~
say So much gold! This will feed me for days!
cheer
~
>bribe_prog 100~
say A fine donation. Thank you so much!
nod
~
>bribe_prog 1~
say If that's all you have, you might as well keep it!
snicker
~
      </b>
     </pre>
    </td>
   </tr>
  </table>
  <p>
  This example demonstrates 3 techniques:
  <ul>
   <li>How to set up several mutually exclusive 'probability' events such that 
   they have <b>equal chances of happening</b>:
   The first event has 1/3 chance of happening. The second has 50% of the
   remaining 2/3, again 1/3. The last event has 100% of the remaining 1/3 chance 
   of happening. Notice the pattern? 1/3, 1/2, 1/1. The easy and foolproof way
   to set up any old sequence of equally likely events.
   </li>
   <li>Setting up hitprcnt_progs in ascending order so the lowest one will
   trigger appropriately.
   </li>
   <li>Setting up bribe_progs in descending order so the highest one will
   trigger appropriately. Also note the value of 1 in the last one: As this
   is the lowest possible amount for a money donation, it is <em>guaranteed</em>
   to trigger if none of the others do. Of course, this kind of default
   trigger needs to go <b>at the end</b> of a list of triggers of the same type.
   </li>
  </ul>
  <p>
  The examples also point out some deficiencies in the mob progs we are able
  to write so far. In all the examples, the beggar never really interacts with
  any other character. He is dimly 'aware' of certain events happening, and 
  does some things in response, but in so doing completely ignores the character
  who initiated the event. Even in a fight, our beggar talks to himself but
  not to his opponent. The simple reason is that we don't as yet have the means
  to identify characters and objects involved in the events that activate triggers.
  Fortunately, the makers of MobProgs considered this, and included
  <p>
  <h4 ALIGN="center">Variables</h4>
  <p>
  First, a brief synopsis of when and how you would use variables in a
  mobprog.
  <dl>
   <p>
   <dt><b>When:</b></dt>
   <dd>
    Whenever you need to refer to a player, mob, or object and have no way 
    of knowing in advance which player, mob or object you will be referring to;
    or if you want to use personal pronouns like him/her or his/her and don't
    know the sex of the character you want to refer to, or if you want to use
    the indefinite article 'a' and don't know if the object being referred to
    begins with a vowel, requiring 'an'.
   </dd>
   <p>
   <dt><b>How:</b></dt>
   <dd>
    Build the appropriate variable into your MobProg commands in places
    where you would otherwise use names, pronouns or articles. All variables
    consist of two characters, a Dollar sign (&nbsp;<strong>$</strong>&nbsp;) and
    a letter. When your mob executes the mobprog, the MUD program substitutes
    the correct name or whatever for those two characters. 
   </dd>
  </dl>
  <p>
  You can't change the values of these variables as you can in other programming
  languages, but you'll find their contents very useful in giving your mobs a
  life. Note that most of the variable names come in <b>upper and lower case</b>,
  with <b>different meanings</b>! Case is relevant, so make sure you use the correct
  variable name and case for each purpose.
  <p>
  If you've written SOCIALS before, the syntax will seem familiar to you. Alas,
  most of the letter codes have different meanings for MobProgs. I will provide
  the variables in groups based on which character or object they refer to,
  with explanations and examples.
  <p>
  <ul>
   <li><b>The 'Actor'</b><br><!-- begin Actor --->
    This is (at least) the second character in the room, because your mob
    is observing his actions.
    Most MobProgs simply respond to an action of another character.<br>
    Such actions include, among others:
    <ul>
     <li>entering a room</li>
     <li>saying something or</li>
     <li>giving something to our mob.
    </ul>
    I'll call the character who does all these things the <b>Actor</b>.<br>
    There are 5 variables used to refer to the Actor:
    <p>
    <table CELLPADDING="10" BORDER=1>
     <tr>
      <td><b><code>$n</code></b></td>
      <td>the first of the<b>name</b>s of the Actor, who performed the action that set off the trigger.</td>
     </tr>
     <tr>
      <td><b><code>$N</code></b></td>
      <td>the <b>name and title</b> of  the Actor.<br>(rarely used)</td>
     </tr>
     <tr>
      <td><b><code>$e</code></b></td>
      <td><b>he / she / it</b> based on sex of Actor.</td>
     </tr>
     <tr>
      <td><b><code>$m</code></b></td>
      <td><b>him / her / it</b> based on sex of Actor.</td>
     </tr>
     <tr>
      <td><b><code>$s</code></b></td>
      <td><b>his / hers / its</b> based on sex of Actor.</td>
     </tr>
    </table>
    <p>
    Here is a (very contrived) example of a <b>bribe_prog</b> using all of
    these variables to respond to a donation to our beggar:
    <p>
    <table BORDER=1 CELLPADDING=10><!-- Actor Example --->
     <tr><td><b><code>
       >bribe_prog 1~<br>
       thank $n<br>
       yell $N is a very kind person!<br>
       yell $e gave me some of $s money.<br>
       yell I am forever grateful to $m!<br>
       ~
     </code></b></td></tr>
     <tr><td>
      if Elrac is the donor, this translates to:
      <p>
      <b><code>
       thank Elrac<br>
       yell Elrac of Oberrad is a very kind person!<br>
       yell he gave me some of his money.<br>
       yell I am forever grateful to him!
      </code></b>
     </td></tr>
    </table>
    <p>
    Note that this example will work no matter if the Actor is male, female or
    sexless. The variables substitute him/her/it and other words as appropriate.
    However, because of the $N (name and title), it will probably not work if
    the generous donor is a mob.
    <p>
    The 'he' in the second sentence should be capitalized, but is not. 
    MobProgging does have limits, alas.
   </li><!-- End Actor --->
   <p>
   <li><b>The Direct Object</b><br><!-- Begin Direct Object --->
    Other than just appearing on the scene or interacting with our mob,
    the Actor could also do something to or with an object. There are 
    cases involving 2 objects which I'll get to later, but for now assume
    there is only one. Some things the actor can do with one object are:
    Getting it, dropping it, eating it or giving it to your mob.
    <p>
    Here are the variables used to refer to such a Direct Object:
    <p>
    <table CELLPADDING="10" BORDER=1>
     <tr>
      <td><b><code>$o</code></b></td>
      <td>the <b>first</b> of the <b>keywords</b>s of the direct object 
      (The object NActor does something <b>to</b>).<br>
      If an object's keyword field says 'bagel cream cheese', $o would yield 'bagel'.</td>
     </tr>
     <tr>
      <td><b><code>$O</code></b></td>
      <td>the <b>short description</b> of the direct object</td>
     </tr>
     <tr>
      <td><b><code>$a</code></b></td>
      <td><b>a / an</b> based on first letter of direct object</td>
     </tr>
    </table>
    <p>
    Example:
    <p>
    <table BORDER=1 CELLPADDING=10><!-- Direct Object Example --->
     <tr><td><b><code>
      >act_prog drops~<br>
      point $n<br>
      say Hey $n, you dropped $O!<br>
      ~<br>
     </code></b></td></tr>
     <tr><td>
      If Elrac drops his Thunderstriker, this works out to:
      <p>
      <b><code>
       point Elrac<br>
       say Hey Elrac, you dropped Thunderstriker!
      </code></b>
     </td></tr>
    </table>
   </li><!-- End Direct Object --->
   <p>
   <li><b>The Indirect Object</b><br><!-- Indirect Object --->
    This one doesn't see too much use. We're talking about the second object
    involved in an action, such as the backpack in "Elrac puts a pie in his backpack."
    The direct object in this sentence is the pie, but the backpack is also 
    involved... indirectly. Other documentation also calls this the
    'secondary object'. Here are the variable names:
    <p>
    <table CELLPADDING="10" BORDER=1>
     <tr>
      <td><b><code>$p</code></b></td>
      <td>the <b>first</b> of the <b>keywords</b>s of the indirect object</td>
     </tr>
     <tr>
      <td><b><code>$P</code></b></td>
      <td>the <b>short description</b> of the indirect object</td>
     </tr>
     <tr>
      <td><b><code>$A</code></b></td>
      <td><b>a / an</b> based on first letter of indirect object</td>
     </tr>
    </table>
    <p>
    Example:
    <p>
    <table BORDER=1 CELLPADDING=10><!-- Indirect Object Example --->
     <tr><td><b><code>
      >act_prog puts in~<br>
      sigh<br>
      say I wish I had $A $P to put my $O in!<br>
      ~<br>
     </code></b></td></tr>
     <tr><td>
       "Elrac puts longsword in his scabbard" yields:
       <p>
       <b><code>
        sigh<br>
        say I wish I had a scabbard to put my sword in!
       </code></b>
      </td></tr>
    </table>
    <p>
    <hr NOSHADE WIDTH="50%">
    <b>WARNING:</b></a><br>
    There's a potential problem with using the above "Indirect Object" variables.
    Because the problem is shared with the "Victim" variables,
    below, the problem is explained in detail in the
    <a HREF="#victim_warning">Victim&nbsp;Description&nbsp;Warning</a>.
    <p>
    <hr NOSHADE WIDTH="50%">
   </li><!-- End Indirect Object --->
   <p>
   <li><b>The Victim</b><br><!-- Victim --->
    If you get 3 characters into the same room, your mob could end up
    watching another character (the Actor) do something to the third
    character, who is sometimes called the target but whom I'll call 
    the <b>Victim</b>. You could imagine a setting where your mob is a 
    guard watching out for fights in the room. The Victim, of course, 
    does not need to be an actual victim of violence; if the Actor does anything 
    to a character, that character is just called the Victim for the purpose 
    of discussing these variables:
    <p>
    <table CELLPADDING="10" BORDER=1>
     <tr>
      <td><b><code>$t</code></b></td>
      <td>the first of the <b>name</b>s of a secondary character target, the one Actor does something <b>to</b>.</td>
     </tr>
     <tr>
      <td><b><code>$T</code></b></td>
      <td>
       <table BORDER="0" CELLSPACING=0 CELLPADDING=5>
        <tr>
         <td>for mobs:</td><td>the <b>short description</b></td><td ROWSPAN=2>of the target character</td>
        </tr>
        <tr>
         <td>for players:</td><td>the <b>name and title</b></td>
        </tr>
       </table>
      </td>
     </tr>
     <tr>
      <td><b><code>$E</code></b></td>
      <td><b>he / she / it</b> based on sex of Victim.</td>
     </tr>
     <tr>
      <td><b><code>$M</code></b></td>
      <td><b>him / her / it</b> based on sex of Victim.</td>
     </tr>
     <tr>
      <td><b><code>$S</code></b></td>
      <td><b>his / hers / its</b> based on sex of Victim.</td>
     </tr>
    </table>
    <p>
    Example:
    <p>
    Doh, I can't think of one that's reasonably assured of working all
    the time. Triggers alone are not enough to tell whether the victim
    of an action was your mob or a third mob (i.e. a real Victim), so
    it's not possible at this point to produce an appropriate response.
    This problem is fixed by <a HREF="#if">IF&nbsp;Statements</a>, later on.
    <p>
    <a NAME="victim_warning"><b>WARNING:</b></a><br>
    <cite>
     In the internal plumbing of act messages, the same data slot is used
     for the Victim and for the Indirect Object. This saves space because
     any action can have only either a victim or an indirect object but
     never both. Well, it may be possible in English grammar but it just
     doesn't seem to happen in the MUD. So what ends up happening here is
     that if an action has a victim, that victim's name will end up 
     both in $t and the indirect object variable, $p (see below). If an
     action has an indirect object, the object's name will end up both
     in $p and $t. If you're just using the name in a command or a message
     that isn't so bad, it may look stupid but will do no further harm.
     If you use $p or $t in an <a HREF="#if">IF statement</a> (see below) 
     that is specific to characters or objects and it's mismatched, you're in trouble.
     In the happy case, your mobprog will just work incorrectly. However,
     it's also quite likely that the MUD will crash!
    </cite>
   </li><!-- End Victim --->
   <p>
   <li><b>Your mob</b><br><!-- Your Mob --->
    There is one character you can always count on to be around when
    your MobProg runs: The mob itself. In actions performed to itself,
    your commands can easily refer to 'self'. If the mob speaks of itself,
    you can use 'I', 'me' and 'my', which English grammar calls 'the first person'.
    So the following set of variables is
    needed only when the mob refers to itself in the 3rd person in an
    EMOTE or some other command, or if the same MobProg is attached to
    several mobs and these need to identify themselves by name. 
    <p>
    Here are the 5 variables which your mobprog can use to refer to
    its own mob:
    <p>
    <table CELLPADDING="10" BORDER=1>
     <tr>
      <td><b><code>$i</code></b></td>
      <td>the <b>first</b> of the <b>name</b>s of your mob<br>(generally prefer <b><code>$I</code></b>)</td>
     </tr>
     <tr>
      <td><b><code>$I</code></b></td>
      <td>the <b>short description</b> of your mob.</td>
     </tr>
     <tr>
      <td><b><code>$j</code></b></td>
      <td><b>he / she / it</b> based on sex of your mob.</td>
     </tr>
     <tr>
      <td><b><code>$k</code></b></td>
      <td><b>him / her / it</b> based on sex of your mob.</td>
     </tr>
     <tr>
      <td><b><code>$l</code></b></td>
      <td><b>his / hers / its</b> based on sex of your mob.</td>
     </tr>
    </table>
    <p>
    Example:
    <table BORDER=1 CELLPADDING=10>
     <tr><td><b><code>
      >greet_prog 100~<br>
      say Hello, I am $I.<br>
      ~<br>
     </code></b></td></tr>
     <tr><td>
      for the poor beggar, this translates to:
      <p>
      <b><code>
       say Hello, I am a poor beggar.
      </code></b>
     </td></tr>
    </table>
   </li><!-- End Your Mob --->
   <p>
   <li><b>The Random Character</b><br><!-- Random Character --->
    As discussed above, mobs mostly take action based on the action of another
    character or on a random impulse. If you want your mobile to <em>start</em>
    interacting with someone in its room, you don't have an <b>Actor</b> you can
    use to direct the mob's commands at. Instead, the mob must choose a 
    character in the room at random to be the target of its action. The variable
    $r and its brethren allow us to do just this.
    <p>
    <table CELLPADDING="10" BORDER=1>
     <tr>
      <td><b><code>$r</code></b></td>
      <td>the first of the <b>name</b>s of a random char in the room with the mobile<br>
      (never the same as your mob itself)</td>
     </tr>
     <tr>
      <td><b><code>$R</code></b></td>
      <td>
       <table>
        <tr>
         <td>for mobs:</td><td>the <b>short description</b></td>
         <td ROWSPAN=2>of the random char</td>
        </tr>
        <tr>
         <td>for players:</td><td>the <b>name and title</b></td>
        </tr>
       </table>
      </td>
     </tr>
     <tr>
      <td><b><code>$J</code></b></td>
      <td><b>he / she / it</b> based on sex of the random char.</td>
     </tr>
     <tr>
      <td><b><code>$K</code></b></td>
      <td><b>him / her / it</b> based on sex of the random char.</td>
     </tr>
     <tr>
      <td><b><code>$L</code></b></td>
      <td><b>his / hers / its</b> based on sex of the random char.</td>
     </tr>
    </table>
    <p>
    Note that this random character can be either a mob or a player,
    but will never be your mob itself. If there is no other character
    in the room, <b>$r</b> will probably end up being an empty
    string, but this doesn't matter much because nobody will be
    there to watch your mob bungle its grammar.
    <p>
    Example:
    <table BORDER=1 CELLPADDING=10>
     <tr><td><b><code>
      >rand_prog 20~<br>
      say Mirror, mirror on the wall...<br>
      ponder<br>
      say $r is the ugliest here!<br>
      ~
     </code></b></td></tr>
     <tr><td>
      We don't know whom the beggar will point out. That's the idea behind 'random'.
     </td></tr>
    </table>
   </li>
  </ul>
  <p>
  <b>NOTE:</b><br>
  If you are going to use the names of your mobs or objects for mob commands
  which generate output visible to players (SAY, YELL, etc), then you need to
  be aware that the lower case variables ($i, $n, etc) all deliver only the
  <b>first</b> name (keyword) of the mob or object. Thus, you want to code
  these names such that the first of them will make sense when used in your
  messages. You may also want to fine tune the short descriptions so that
  they fit smoothly and grammatically into any messages you are going to
  produce. Because of different conventions of using 'a', 'A' or neither at the
  beginning of short descriptions, this can prove to be a challenge.
  <p>
  <hr>
  <p>
  <center>Another <strong>WARNING!</strong></center>
  <p>
  <quote>
   Something about variables which you need to be aware of is dictated by
   common sense but often overlooked.
   <p>
   <b>The 'actor', 'victim', 'direct object' and 'indirect object' variables
    ($n, $t, $o and $p) and their associated forms will not work in a
    rand_prog or entry_prog!
   </b>
   <p>
   This is just the only hard and fast rule on the topic. But there are other
   examples of progs where variables are undefined. A <b>give_prog</b>, for
   example, does not have a victim, nor an indirect object. Thus, you need to
   <p>
   <b>
    THINK about the trigger type you use, and decide whether the variable
    you are planning to use makes sense in that trigger!
   </b>
   <p>
   If you use a variable that's not defined for the trigger type or context
   you use it in, your MobProg will CRASH the MUD! This will probably not
   happen at load time. It is likely to happen at some time in the middle
   of the game. In the case of a rand_prog, there does not even need to be
   anyone present in the mob's room. This makes such bugs VERY hard to find
   and fix. BE CAREFUL!
  </quote>
  <p>
  <hr>
  <h4 ALIGN="center"><a NAME="if">IF Statements</a></h4>
  <p>
  The 'other' documentation calls these 'control flow syntax'. This is the
  correct terminology from the point of view of a computer scientist, but
  since the term normally encompasses a whole group of statements and we have
  only one type to offer, we can stick with <b>IF Statements</b> here.
  <p>
  IF Statements address our need to more finely control whether or not
  parts of a MobProg are executed. The need arises all over the place.
  Here are some examples:
  <ul>
   <li>
    The beggar is assumed to be sleeping most of the time, and sometimes
    snores. Without further checks, he would also snore in a fight!
   </li>
   <li>
    If the beggar's room is frequented by wandering mobs, it might get spammy
    if he greets every character entering. It would be nice if he could 
    single out only the players for greeting. Mobs are unlikely to donate
    money anyway.
   </li>
   <li>
    I'd like to complete the Victim example, above, but as yet we can't tell the
    differences between actions directed at your mob and those affecting third
    parties, i.e. true Victims.
   </li>
  </ul>
  <p>
  <b>IF Statements</b> allow us to do all this and more. But be warned, unless you're
  a programmer already and <b>IF</b>s are second nature to you, this section 
  will give you gray hair or put hair on your chest, depending on circumstances.
  <p>
  <b>General Description</b><br>
  An <b>IF statement</b> consists of one or more checks for a certain condition which you
  specify, and one or two sets of commands you want performed depending on
  whether the checked condition turns out to be true or false. Before I show you
  the 'official' complete structure of an <bIF</b> statement, I'll show you some
  possible example structures. The names I give them are my own, you don't have
  to remember them.
  <p>
  <table BORDER=0 CELLPADDING=10><!-- Simple IF --->
   <tr VALIGN="bottom">
    <td>
     <table BORDER=1 CELLPADDING=10>
      <caption>"Simple IF"</caption>
      <tr><td>
        <b><code>IF (</b></code>
        <i>condition</i>
        <b><code>)</code></b><br>
        <code>&nbsp;&nbsp;&nbsp;</code><i>"true" command set</i><br>
        <b><code>ENDIF</code></b>
       </td>
      </tr>
     </table>
    </td>
    <td>
     If the <i>condition</i> is true, then the <i>command set</i>
     is performed.<br>
     Otherwise, nothing happens.
    </td>
   </tr>
  </table>
  <table BORDER=0 CELLPADDING=10><!-- Multiple condition simple IF --->
   <tr VALIGN="bottom">
    <td>
     <table BORDER=1 CELLPADDING=10>
      <caption>"Multiple condition simple IF"</caption>
      <tr><td>
       <b><code>IF (</b></code>
       <i>condition</i>
       <b><code>)</code></b><br>
       <b><code>OR (</b></code>
       <i>condition</i>
       <b><code>)</code></b><br>
       <b><code>OR (</b></code>
       <i>condition</i>
       <b><code>)</code></b><br>
       <code>&nbsp;&nbsp;&nbsp;</code><i>"true" command set</i><br>
       <b><code>ENDIF</code></b>
      </td></tr>
     </table>
    </td>
    <td>
     If any one of the <i>condition</i>s is met, then the <i>command set</i>
     is performed.<br>
     Otherwise, nothing happens.<br>
     <p>
     Of course, the number of alternative (<b>OR</b>) conditions does not
     <em>have</em> to be 2, it can be any number. This is just an example.
    </td>
   </tr>
  </table>
  <table BORDER=0 CELLPADDING=10><!-- Two-way IF --->
   <tr VALIGN="bottom">
    <td>
     <table BORDER=1 CELLPADDING=10>
      <caption>"Two-Way IF"</caption>
      <tr><td>
       <b><code>IF (</b></code>
       <i>condition</i>
       <b><code>)</code></b><br>
       <code>&nbsp;&nbsp;&nbsp;</code><i>"true" command set</i><br>
       <b><code>ELSE</code></b><br>
       <code>&nbsp;&nbsp;&nbsp;</code><i>"false" command set</i><br>
       <b><code>ENDIF</code></b>
      </td></tr>
     </table>
    </td>
    <td>
     If the <i>condition</i> is true, then the <i>"true" command set</i>
     is performed.<br>
     Otherwise, the <i>"false" command set</i> is performed.
    </td>
   </tr>
  </table>
  <table BORDER=0 CELLPADDING=10><!-- Multiple Condition Two-way IF --->
   <tr VALIGN="bottom">
    <td>
     <table BORDER=1 CELLPADDING=10>
      <caption>"Multiple Condition Two-Way IF"</caption>
      <tr><td>
       <b><code>IF (</b></code>
       <i>condition</i>
       <b><code>)</code></b><br>
       <b><code>OR (</b></code>
       <i>condition</i>
       <b><code>)</code></b><br>
       <b><code>OR (</b></code>
       <i>condition</i>
       <b><code>)</code></b><br>
       <code>&nbsp;&nbsp;&nbsp;</code><i>"true" command set</i><br>
       <b><code>ELSE</code></b><br>
       <code>&nbsp;&nbsp;&nbsp;</code><i>"false" command set</i><br>
       <b><code>ENDIF</code></b>
      </td></tr>
     </table>
    </td>
    <td>
     If any one of the the <i>condition</i>s is true, then the <i>"true" command set</i>
     is performed.<br>
     Otherwise (none of the <i>condition</i>s is true), the <i>"false" command set</i> 
     is performed.
    </td>
   </tr>
  </table>
  <table BORDER=0 CELLPADDING=10><!-- Complete IF structure --->
   <tr VALIGN="bottom">
    <td>
     <table BORDER=1 CELLPADDING=10>
      <caption>"Complete IF structure diagram with optional things in boxes"</caption>
      <tr><td>
       <b><code>IF (</b></code>
       <i>condition</i>
       <b><code>)</code></b><br>
       <table BORDER=1 CELLSPACING=0 CELLPADDING=1>
        <tr><td>
         <b><code>OR (</b></code>
         <i>condition</i>
         <b><code>)</code></b><br>
         <table BORDER=1 CELLSPACING=0 CELLPADDING=1>
          <tr><td>
           <b><code>OR (</b></code>
           <i>condition</i>
           <b><code>)</code></b><br>
           <table BORDER=1 CELLSPACING=0 CELLPADDING=1 WIDTH="100%">
            <tr><td>
             <i>...</i>
            </td></tr>
           </table>
          </td></tr>
         </table>
        </td></tr>
       </table>
       <code>&nbsp;&nbsp;&nbsp;</code><i>"true" command set</i><br>
       <table BORDER=1 CELLSPACING=0 CELLPADDING=1>
        <tr><td>
         <b><code>ELSE</code></b><br>
         <code>&nbsp;&nbsp;&nbsp;</code><i>"false" command set</i><br>
        </td></tr>
       </table>
       <b><code>ENDIF</code></b>
      </td></tr>
     </table>
    </td>
    <td>
     Looks frightening, doesn't it?<br>
     Notice that if you remove some of the boxes, this diagram looks like
     one of the preceding ones.
    </td>
   </tr>
  </table>
  <p>
  If you are reading this in your browser (the only way, in my opinion)
  then you may have been missing links to <b>condition</b> and <b>command set</b>.
  I didn't want to complicate things any further and distract you with the ability
  to jump around. Here are the explanations I owe you:
  <p>
  <dl>
   <dt><a NAME="command set"><b>command set</b></a></dt>
   <p>
   <dd>
    I'll do <b>Command set</b> first because it's simpler to explain.<br>
    A <b>command set</b> is simply 0 or more commands. 
    Yes, you are allowed to code <em>no</em> statements between the <b>IF</b>
    line (or optional <b>OR</b> line(s)) and the <b>ELSE</b> line. A statement
    like
    <table BORDER=0 CELLPADDING=20><!-- empty THEN --->
     <tr>
      <td>
       <b><code>IF (</code></b> <i>condition</i> <b><code>)</code></b><br>
       <b><code>ELSE</code></b><br>
       <code>&nbsp;&nbsp;&nbsp;<i>command set</i><br>
       <b><code>ENDIF</code></b>
      </td>
      <td>
       is perfectly legal and essentially says that you want the <i>command set</i>
       done if your <i>condition</i> is <b>false</b>.
      </td>
     </tr>
    </table>
    <p>
    The other two applications of empty command sets are also legal, but 
    don't make any sense. If you code
    <table BORDER=0 CELLPADDING=20><!-- empty ELSE --->
     <tr>
      <td>
       <b><code>IF (</code></b> <i>condition</i> <b><code>)</code></b><br>
       <code>&nbsp;&nbsp;&nbsp;<i>command set</i><br>
       <b><code>ELSE</code></b><br>
       <b><code>ENDIF</code></b>
      </td>
      <td>
       then you might as well leave out the <b>ELSE</b> line and make your mobprog
       easier to read and debug.
      </td>
     </tr>
    </table>
    <p>
    If you build one of <b>these</b>,
    <table BORDER=0 CELLPADDING=20><!-- empty IF --->
     <tr>
      <td>
       <b><code>IF (</code></b> <i>condition</i> <b><code>)</code></b><br>
       <b><code>ENDIF</code></b>
      </td>
      <td>
       then you can do without the whole <b>IF</b> statement.
      </td>
     </tr>
    </table>
    <p>
    So, having taken care of the <em>empty</em> case, what can be in a command
    set if it's <em>not</em> empty? Three different things:
    <ul>
     <p>
     <li>
      normal MUD commands to be performed by your MOB, including the
      <a HREF="#mp_commands">MobProg-Only Commands</a> described later
     </li>
     <p>
     <li>
      complete <b>IF</b> statements<br>(that's right, you can have <b>IF</b>
      statements inside of <b>IF</b> statements inside of...)
     </li>
     <p>
     <li>
      <b>BREAK</b> statements.<br>A <b>BREAK</b> statement will bail you right out of
      the processing of the current trigger, no matter how deeply you may
      find yourself nested in <b>IF</b> statements. You write <b>BREAK</b>
      like a normal MUD command, and it essentially means, "this is the last
      command I intend to do for this trigger."
      <p>
      <b>BREAK</b> statements may only be used as part of the <i>command set</i>s
      inside <b>IF</b> statements. They make no sense anywhere else because if you
      wanted to execute no more commands elsewhere, you could simply <em>write</em>
      no more commands.
      <p>
      Even inside an IF, <b>BREAK</b> statements make sense only at the <em>end
      of a <i>command set</i></em>, because any commands <em>after</em>the <b>BREAK</b>
      would never be performed anyway. Of course, it's legal and sometimes useful
      to write a <b>BREAK</b> as the <em>only</em> statement of a <i>command set</i>,
      as your needs and circumstances dictate.
     </li>
    </ul>
    <p>
    <b>Important:</b><br>
    All my examples show the <i>command set</i> indented 3 spaces from the column
    where the <b>IF</b> starts. The MUD program doesn't require this of you, but
    <b>I do!</b> There is very little debugging support for mobprogs, and badly
    written <b>IF</b> statements are a very sure way to crash the MUD. Indentation
    helps you as the MobProg writer visualize the structure of your code and me
    (or some other Coder) to understand it so I have a chance at debugging it if
    you can't.
    <p>
    Correct indenting is very easy to do. As I mentioned before, all the lines of a
    <i>command set</i> are indented 3 spaces from where the <b>IF</b>, the
    <b>ENDIF</b> and (maybe) the <b>OR</b> or <b>ELSE</b> start. When you're done, you 
    should be able to draw a straight vertical line between the <b>I</b> in any 
    <b>IF</b> and the <b>E</b> in its <b>ENDIF</b>, and that line will hit only 
    white space, with the possible exception of the <b>O</b> in one or more <b>OR</b>s
    and/or the <b>E</b> in an <b>ELSE</b>, if there is one.
    <p>
    If there is an <b>IF</b> inside a <i>command set</i>, then the <b>IF</b> and
    <b>ENDIF</b> (as well as the possible <b>OR</b>s and/or <b>ELSE</b>) must line
    up with the other commands (if any), while the <i>command set(s)</i> of <em>that</em>
    <b>IF</b> must be indented <em>another</em> 3 spaces. Thus, your indentation
    will visually reflect what programmers call "your <em>nesting</em> of <b>IF</b>s"
    or, more generally, the structure of your program. If you have trouble picturing
    all this, refer to a complex example. There should be one coming up soon.
   </dd>
   <p>
   <dt><a NAME="condition"><b>condition</b></a></dt>
   <p>
   <dd>
    A <b>condition</b> is a way of asking the MUD a question which expects an answer
    of "yes" or "no". Programmers prefer to think in terms of <b>true</b> or <b>false</b>,
    but these mean the same thing. As a simpleminded example, you could ask the MUD
    if <b>2 + 2</b> equals <b>5</b>, and as long as the universe is right side up, 
    the answer will be "<b>false</b>". It just ain't true. 
    Getting closer to MUD life, you could ask the MUD if your MOB has more than 0 hit points. 
    Unless your mob just got badly trounced in a fight, that will usually be <b>true</b>.
    <p>
    <i>condition</i>s are always coded between paired parentheses 
    (&nbsp;'<strong>(</strong>' and '<strong>)</strong>'&nbsp;) . The parentheses, well,
    kinda hold the condition together. As I mentioned, the condition must come out to
    be something that ends up <b>true</b> or <b>false</b>. Here are the basic legal
    forms of a <i>condition</i>:
    <p>
    <center>
     <table BORDER=1>
      <tr><td ALIGN="center"><i>logical-function</i></td></tr>
      <tr><td ALIGN="center"><i>numeric_function &nbsp; number-compare-op &nbsp; number</i></td>
      <tr><td ALIGN="center"><i>string_function &nbsp; string-compare-op &nbsp; string</i></td></tr>
     </table>
    </center>
    <p>
    All the terms in <i>italics</i> are terms I have yet to explain. There is a lot
    of ground to cover here, so I will need to devote the whole next section to
    these terms and what they represent.
   </dd>
  </dl>
  <p>
  There's no <b>example</b> here. Alas, you can't build an <b>IF</b> statement without the
  as yet unexplained stuff that makes up a <i>condition</i>. But once you know about
  those things, <b>IF</b>s fall into place and we're almost done with all there is
  to MobProgramming. Hopefully this will motivate you to read onward to
  <p>
  <hr>
  <h4 ALIGN="center">Conditional Operands and Operators</h4>
  <p>
  This section deals in depth with what goes inside a <b>conditional</b>, one of
  those expressions that yields an answer of <b>true</b> or <b>false</b> and
  which <b>IF</b> statements need to make their decisions.
  <p>
  <b>Logical functions as conditions</b><br>
  The simplest thing to put inside a <i>conditional</i> is a <i>logical function</i>.
  <table BORDER=0 CELLPADDING=25>
   <tr><td><cite>
    What's a function, you ask? Well, a function is a definition of a calculation
    or some other process that gets a number or some other thing to work on, does
    some grinding, and comes up with a result. The <b>square</b> function, in math,
    takes any old number, multiplies it by itself, and returns the result. The
    <b>square root</b> function does the same thing, only backwards. In the
    MobProgramming context, functions tend to work on characters and objects.
   </cite></td></tr>
  </table>
  The <b>logical function</b>s provided by the MobProg code all look at a
  character and answer some question about him. Following an old C programming
  convention, they all start with <b>is</b> and so they're easy to recognize:
  <center>
   <table BORDER=1>
    <caption><b>Logical Functions</b></caption>
    <tr><th>function name</th><th>what question it answers</th><tr>
    <tr><td><b>isnpc($*)</b></td><td>is $* an NPC (a mob)?</td></tr>
    <tr><td><b>ispc($*)</b></td><td>is $* an PC (a player)?</td></tr>
    <tr><td><b>isgood($*)</b></td><td>does $* have good alignment?</td></tr>
    <tr><td><b>isfight($*)</b></td><td>is $* currently fighting?</td></tr>
    <tr><td><b>isimmort($*)</b></td><td>is $* an Immortal?<br><small>(will also recognize mobs >= LEVEL_IMMORTAL)</td></tr>
    <tr><td><b>ischarmed($*)</b></td><td>is $* affected by CHARM?</td></tr>
    <tr><td><b>isfollow($*)</b></td><td>is $* a follower with their master in the room?</td></tr>
    <tr><td><b>isaffected($*) & number</b></td><td>is $* affected by AFF_xxx?</td></tr>
   </table>
  </center>
  <p>
  You don't actually write '<b>$*</b>'. Instead, you write one of <b>$i</b>,
  <b>$n</b>, <b>$t</b> or <b>$r</b> from the list of variables above. In case
  it's slipped your mind, $i is your mob, $n is the Actor character doing something
  in your mob's room, $t is the Actor's Victim (if any) and $r is a random 
  character in your mob's room. As you can tell from the list of possible
  <b>$</b> types, all of these functions apply to <b>characters only</b>.
  <p>
  The <b>isaffected()</b> function is different from the rest. You need to write
  an ampersand (&nbsp;<strong>&</strong>&nbsp;) and a number after the function.
  The <b>number</b> has to correspond to the flag value of the AFF_whatever
  affect you want to check for (see the <a HREF="abaffect.htm">Affect Flag
  Table</a>). You need to convert the letter codes you're used to using for
  flags into a number; this is explained in <a HREF="abflags.htm">Flag
  Fields Explained</a>.
  <p>
  Finally, we're ready for the next <b>examples:</b>
  <p>
  <table BORDER=1 CELLPADDING=15>
   <tr><td><b><code>
    >greet_prog 100~<br>
    if ( isnpc($n) )<br>
    &nbsp;&nbsp;&nbsp;wink $n<br>
    else<br>
    &nbsp;&nbsp;&nbsp;say Alms for a poor beggar, please!<br>
    endif<br>
    ~<br>
   </code></b></td></tr>
   <tr><td>
    This prog will react to everyone entering the mob's room.<br>
    Depending on whether 
    it's a mob or a player, your mob will either give the secret wink of the MUDwide
    mob conspiracy or simply beg for money.
   </td></tr>
  </table> 
  <p>
  Let's extend this example.
  This beggar knows that immortals are stingy, and will not waste his time
  begging from them.
  <p>
  <table BORDER=1 CELLPADDING=15>
   <tr><td><b><code>
    >greet_prog 100~<br>
    if ( isnpc($n) )<br>
    &nbsp;&nbsp;&nbsp;wink $n<br>
    else<br>
    &nbsp;&nbsp;&nbsp;if ( isimmort($i) )<br>
    &nbsp;&nbsp;&nbsp;else<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;say Alms for a poor beggar, please!<br>
    &nbsp;&nbsp;&nbsp;endif<br>
    endif<br>
    ~<br>
   </code></b></td></tr>
   <tr><td>
    Note the use of ELSE to reverse the question. We don't have an
    <b>ismortal($*)</b> function, so we ask if the potential donor is immortal,
    do nothing if he is and beg only if not.
   </td></tr>
  </table> 
  <p>
  Two more extensions. First, we decide to wink only at mobs of good alignment
  and to growl at the rest.
  Second, we decide also not to beg for money if the player entering the room
  is charmed:
  <p>
  <table BORDER=1 CELLPADDING=15>
   <tr><td><b><code>
    >greet_prog 100~<br>
    if ( isnpc($n) )<br>
    &nbsp;&nbsp;&nbsp;if ( isgood($i) )<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;wink $n<br>
    &nbsp;&nbsp;&nbsp;else<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;growl $n<br>
    &nbsp;&nbsp;&nbsp;endif<br>
    else<br>
    &nbsp;&nbsp;&nbsp;if ( isimmort($n) )<br>
    &nbsp;&nbsp;&nbsp;or ( ischarmed($n) )<br>
    &nbsp;&nbsp;&nbsp;else<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;say Alms for a poor beggar, please!<br>
    &nbsp;&nbsp;&nbsp;endif<br>
    endif<br>
    ~<br>
   </code></b></td></tr>
   <tr><td>
    Here's our first use of <b>OR</b>. Meanwhile, our <b>IF</b>s are
    nested deeply enough to give you some idea of what a properly indented
    complex mobprog looks like. You may well end up coding even more complex
    stuff.
   </td></tr>
  </table> 
  <p>
  <b>Numeric comparisons as conditions</b><br>
  The next kind of condition is a comparison of one number with another.
  First, a handful of functions which provide numbers you can
  test:
  <p>
  <table BORDER=1 CELLPADDING=5>
   <caption><b>Numeric Functions</b></caption>
    <tr><th>function name</th><th ALIGN="center"><b>C</b>hars/<br><b>O</b>bjs</th><th>what number it yields</th><th>range or example</th><tr>
    <tr><td><b>rand(percent)</b></td><td ALIGN="center">-</td><td><b>true</b> if a random number between 0 and 100 is less than <b>percent</b></td><td>0 to 100</td></tr>
    <tr><td><b>hitprcnt($*)</b></td><td ALIGN="center">C</td><td>character's current percentage of his full hp</td><td>0 to 100</td></tr>
    <tr><td><b>inroom($*)</b></td><td ALIGN="center">C</td><td>Room vnum the char is in</td><td>in Dizzy, Recall is 3001</td></tr>
    <tr><td><b>sex($*)</b></td><td ALIGN="center">C</td><td>Character's sex (neutral=0, male=1, female=2)</td><td>0 - 2</td></tr>
    <tr><td><b>position($*)</b></td><td ALIGN="center">C</td><td>Character's position (dead=0, mortally wounded, incapacitated, stunned, sleeping, resting, sitting, fighting, standing, sneak=9)</td><td>0 - 9</td></tr>
    <tr><td><b>level($*)</b></td><td ALIGN="center">C</td><td>Character's level</td><td>1 - MAX_LEVEL</td></tr>
    <tr><td><b>class($*)</b></td><td ALIGN="center">C</td><td>Character's class, as an integer</td><td>0 - MAX_CLASS</td></tr>
    <tr><td><b>goldamt($*)</b></td><td ALIGN="center">C</td><td>Amount of gold carried by char</td><td>0 - ?</td></tr>
    <tr><td><b>objtype($*)</b></td><td ALIGN="center">O</td><td>Object's item type, as a number</td><td>see<br><a HREF="abshopit.htm">Shop Item Type Table</a></td></tr>
    <tr><td><b>objval0($*)<br>objval1($*)<br>objval2($*)<br>objval3($*)<br>objval4($*)</b></td><td ALIGN="center">O</td><td>Current value from one slot (0-4) of object's value line, as a number</td><td>see<br><a HREF="abitem.htm">Item Type and Value Line Table</a></td></tr>
  </table>
  <p>
  Remember, you can only use <b>$o</b> or <b>$p</b> with the last two, which refer to 
  objects only!
  <p>
  To finish coding up your condition (formulating your question), the syntax diagram says
  you still need a <i>number-compare-op</i> and a <i>number</i>.
  <p>
  <b>You</b> provide the number. If you want to check if your mob is at Recall, write 
  <b>3001</b> (or whatever number is the right room vnum for your MUD). If you want to check for
  a female character, write a <b>2</b>. If you're checking for a character with a million
  gold, write <b>1000000</b>. You get the idea. 
  Some of the values may require digging through tables or asking your friendly Coder.
  <p>
  What's left is the <i>number-compare-op</i>, the numeric comparison operator. You can do
  most of the standard comparisons you know and love from math and/or computer programming.
  All of these are coded as one or two symbols, as follows:
  <p>
  <div ALIGN="center">
   <table BORDER=1 CELLPADDING=5>
    <caption>Numeric Comparison Operators</caption>
    <tr><th ALIGN="center">Operator</th><th>Tests for</th></tr>
    <tr><td ALIGN="center"><b><code>==</code></b></td><td>equal<br><small>(<b>two</b> '=' signs!)</b></small></td></tr>
    <tr><td ALIGN="center"><b><code>!=</code></b></td><td>not equal</td></tr>
    <tr><td ALIGN="center"><b><code>&gt;</code></b></td><td>greater</td></tr>
    <tr><td ALIGN="center"><b><code>&lt;</code></b></td><td>less than</td></tr>
    <tr><td ALIGN="center"><b><code>&gt;=</code></b></td><td>greater than or equal</td></tr>
    <tr><td ALIGN="center"><b><code>&lt;=</code></b></td><td>less than or equal</td></tr>
    <tr><td ALIGN="center"><b><code>&amp;</code></b></td><td>bitwise AND</td></tr>
    <tr><td ALIGN="center"><b><code>|</code></b></td><td>bitwise OR</td></tr>
   </table>
  </div>
  <p>
  The last two are a bit weird. I'm including them only for completeness' sake.
  <ul>
   <li>
    The bitwise AND operator (&nbsp;<strong>&amp</strong>&nbsp;)<br>
    yields <b>true</b> if the numbers on both sides have at least one bit set 
    in the same position. 
    This is generally used in tests for flag bits and comes in handy for the
    isaffected() test but nowhere else I can think of.
   </li>
   <li>
    The bitwise OR operator (&nbsp;<strong>|</strong>&nbsp;)<br>
    returns <b>true</b> if either
    of the numbers on both sides of it is not 0.
    I can't think of <em>any</em> use for this.
   </li>
  </ul>
  <p>
  Time for <b>more examples:</b>
  <p>
  <table BORDER=1 CELLPADDING=15>
   <tr><td><b><code>
    >rand_prog 30~<br>
    if ( position($r) < 4 )<br>
    &nbsp;&nbsp;&nbsp;slap $n<br>
    endif<br>
    ~<br>
    >rand_prog 40~<br>
    if ( goldamt($r) > 1000 )<br>
    &nbsp;&nbsp;&nbsp;if ( sex($r) == 2 )<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;beg $r<br>
    &nbsp;&nbsp;&nbsp;endif<br>
    endif<br>
    ~<br>
    >greet_prog 100~<br>
    if ( class($n) != 2 )<br>
    &nbsp;&nbsp;&nbsp;whine $n<br>
    endif<br>
    ~<br>
   </code></b></td></tr>
   <tr><td>
    <ul>
     <li>
      The first prog randomly look for characters in stunned or worse condition
      and tries to revive them by slapping them.
     </li>
     <li>
      The second prog randomly begs from rich women.
     </li>
     <li>
      The third prog whines at anyone entering the room, unless they are a
      thief.
     </li>
    </ul> 
   </td></tr>
  </table> 
  <p>
  <b>String comparisons as conditions</b><br>
  The string comparison stuff is the simplest, and completes the list
  of possible conditions you can have your MobProgs check for.
  There is only one string function:
  <p>
  <center>
   <table BORDER=1 CELLPADDING=5>
    <caption><b>Numeric Functions</b></caption>
    <tr><th>function name</th><th ALIGN="center"><b>C</b>hars/<br><b>O</b>bjs</th><th>what string it yields</th><th>example</th><tr>
    <tr><td><b>name($*)</b></td><td>C,O</td><td>the complete name (from the <b>keywords</b> field) of the char or object</td><td>name($i) gives:<br><b><code>beggar</code></b></td></tr>
   </table>
  </center>
  <p>
  These are the string comparison operators:
  <p>
  <div ALIGN="center">
   <table BORDER=1 CELLPADDING=5>
    <caption>String Comparison Operators</caption>
    <tr><th ALIGN="center">Operator</th><th>Tests for</th></tr>
    <tr><td ALIGN="center"><b><code>==</code></b></td><td>exactly equal<br><small>(<b>two</b> '=' signs!)</b></small></td></tr>
    <tr><td ALIGN="center"><b><code>!=</code></b></td><td>not equal</td></tr>
    <tr><td ALIGN="center"><b><code>/</code></b></td><td>contains<br><small>(right hand string is part of left hand string)</small></td></tr>
    <tr><td ALIGN="center"><b><code>!/</code></b></td><td>does not contain</td></tr>
   </table>
  </div>
  <p>
  String comparisons are <b>case sensitive!</b><br>
  As it stands, the only strings you can test are the names of characters 
  and objects. This coding guide and others advise you to code everything
  in the <b>keyword</b> fields <b>in lower case</b>, so in order for your string
  comparisons to succeed, your tested strings need to be in lower case as well.
  Of course, many older MUD areas have never heard of this convention, so
  the example below shows an exception from this rule.<br>
  Player names, on the other hand, are always 'propercased'. That is, the
  first character is a capital and the rest are lowercase. MobProgs that
  check for player names are generally silly.
  <p>
  As was the case of the numeric comparisons, <b>you</b> provide the string to check 
  against. You can either provide a complete <b>keyword</b> field and test for
  equality (or non-equality) or part of a name and test for a substring
  match. 
  Whatever string you provide, you must <b>not</b> enclose it in single or 
  double quotes. Just write the string as is and the MUD code will figure it out.
  To demonstrate this, here is another <b>example:</b>
  <p>
  <table BORDER=1 CELLPADDING=15>
   <tr><td><b><code>
    >rand_prog 100~<br>
    if ( name($r) != Super Helga )<br>
    &nbsp;&nbsp;&nbsp;if ( name($n) / guard )<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ( rand(25) )<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;north<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;endif<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ( rand(33) )<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;east<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;endif<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ( rand(50) )<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;south<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;endif<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ( rand(100) )<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;west<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;break<br>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;endif<br>
    &nbsp;&nbsp;&nbsp;endif<br>
    endif<br>
    if ( rand(10) )<br>
    &nbsp;&nbsp;&nbsp;beg<br>
    endif<br>
    ~<br>
   </code></b></td></tr>
   <tr><td>
    Another contrived example: The beggar has been told to stop begging in
    the city. The guards enforce this order and punish the beggar if they
    catch him. He can only beg in safety if there are no guards around
    or if he is in the same room with Super Helga, who protects him.
    <p>
    The strategy encoded here is not perfect, of course (the beggar has
    trouble walking around without his legs, too), but it gives you the
    general idea: As often as he possibly can, the beggar randomly
    looks at a random mob in the room. If that mob is Helga, then
    he is safe and need not check for a guard. If the random character 
    he is looking at is a guard, then he tries to move to another room. 
    He randomly chooses one of the 4 main directions.
    <p>
    If he 'runs' away in any direction, the MobProg performs a BREAK. 
    This stops any other coding in this MobProg from happening at this
    time. Note the mutually exclusive probabilities in his
    choice of directions, and how the random values are stacked to
    make all 4 directions equally likely.
    <p>
    The beggar only begs in 10% of all of the rand_prog triggers, which
    gives him 10 'scans' for guards for each 'beg'. This is not an airtight
    strategy but it gives him a good chance of discovering a guard before
    being caught begging.
   </td></tr>
  </table> 
  <p>
  <h4 ALIGN="center"><a NAME="mp_commands">MobProg-Only Commands</a></h4>
  <p>
  In order to do useful and interesting things, mobs need some special abilities,
  some of them similar to those of immortals. These let them do things that
  'normal' mobs and players cannot do. More importantly, these can be used to
  let them <em>appear</em> to be doing things they would not normally do.
  I've capitalized the commands in the explanations below, but like all commands
  they will work regardless of case.
  <p>
  <dl>
   <dt><b>MPJUNK &nbsp; object(s)</b></dt>
   <dd>
    This works like the JUNK command, allowing your mob to get rid of stuff
    in its inventory by destroying it. Two things which make this command
    special are:
    <ul>
     <li>There is no message to anyone about the process, it happens 
     silently and spam-lessly.</li>
     <li>Arguments like <b>all.bread</b> or even <b>all</b> are allowed
     for <b>object(s)</b>, so you can use it to wipe out an entire 
     inventory.
    </ul>
   </dd>
   <p>
   <dt><b>MPKILL &nbsp; victim</b></dt>
   <dd>
    This works like the KILL command, but it allows the mob to get around all
    the usual checks and restrictions there. For instance, your mob does not need 
    to have a minimum level or be in a clan to MPKILL.
   </dd>
   <p>
   <dt><b>MPASOUND &nbsp; text_string</b></dt>
   <dd>
    Prints the text_string to the rooms (possibly several) around the mobile 
    in the same manner as a death cry. 
    Some uses include powerful aggressive mobs 'advertising'
    their presence, and minstrels or musicians performing to more than just
    the one room they are in. There is no "so-and-so says" or anything like
    that in front of the message. You need to code the whole message you want
    players to see, just as you want them to see it. Although the name of the
    command hints at obvious uses, the message does not HAVE to relate to a
    sound. Perhaps players are gripped with fear in the vicinity? Maybe they
    feel the earth shake? Maybe a chill wind blows in?
   </dd>
   <p>
   <dt><b><a NAME="mpecho">MPECHO &nbsp; text_string</a></b></dt>
   <dt><b>MPECHOAROUND &nbsp; victim &nbsp; text_string</b></dt>
   <dt><b>MPECHOAT &nbsp; victim &nbsp; text_string</b></dt>
   <dd>
    These commands output a message in your mob's room. 
    As in <b>MPASOUND</b>, you need to specify the complete message
    that characters are to see. The three variants are:
    <ul>
     <li><b>MPECHO</b> creates a message seen by everyone in the same room
     with the mob.</li>
     <li><b>MPECHOAT</b> sends the message only to the specified <b>victim</b>
     in the room. The word 'victim' doesn't imply a fight, of course. Consider
     it a 'message target'.
     </li>
     <li><b>MPECHOAROUND</b> sends the message to everyone in the room 
     <em>except</em> your mob and its victim.</li>
    </ul>
    One example suggestion for a tricky application was the shopkeeper who,
    as part of his <b>fight_prog</b>, does:<br>
    <center><b>MPAT guard MPECHOAT guard rescue_please</b></center>
    which took me a while to understand, but which does this:<br>
    <ul>
     <li>goes to a guard's location (you'd be advised to use a more specific
     name for the exact guard you want), there to do the following:</li>
     <li>send the following message to exactly one character, namely the guard:</li>
     <li><b>rescue_please</b> is a string not likely to appear in a normal action;
     but presumably the guard has an <b>act_prog</b> sensitive to this string
     and will come to the merchant's rescue. Note that although the string is 
     used in something like an ACT, it doesn't matter that it's weird because
     only the intended recipient, the guard, will ever see it.
    </ul>
   </dd>
   <p>
   <dt><b>MPFORCE &nbsp; victim &nbsp; command</b></dt>
   <dd>
    This works like the Immortal <b>FORCE</b> command, it causes the victim
    (either mob or mortal character) to perform the <b>command</b> specified.
    There is no message to the victim about being forced, but the victim 
    sees himself performing the action, so you usually want to add an explanatory
    MPECHO. Even then, players doing things without or against their will is
    kind of strange, if not rude, so use this command sparingly.
   </dd>
   <p>
   <dt><b><a NAME="mpgoto">MPGOTO &nbsp; destination</a></b></dt>
   <dd>
    This command works like the Immortal <b>GOTO</b> command: Your mob, upon
    performing this command, will leave its current location and reappear
    at the location specified by <b>destination</b>, which can be one of:
    <ul>
     <li>A room vnum; this is the most assured of working, especially if the
     room you specify is in your area</li>
     <li>The name of a mob; you will want this to be very specific, and 
     even then it could fail if the target mob is killed or moved. Anyway, if 
     the target mob is found, the mob executing the command will move to the
     room at which the target mob is.</li>
     <li>The name of a player; probably not a good idea as they move around
     a lot, can have any old name and are often out of the game. If successful,
     though, the command will take your mob to the player's current room.
     </li>
    </ul>
    Your mob disappears from its previous room without a message of any sort,
    so unless characters there eventually bother to LOOK, they will not
    notice the mob left. Likewise, there is no message at the room where
    your mob arrives. If characters are to be informed of its arrival, as they
    usually should be, your mob will need to provide its own arrival message
    using <b><a HREF="#mpecho">MPECHO</a></b> or something.
   </dd>
   <p>
   <dt><b>MPAT &nbsp; destination &nbsp; command</b></dt>
   <dd>
    This is similar to the immortal <b>AT</b> command. Your mob does whatever
    command you specify as <b>command</b>, but it does it at the location you
    specify with <b>destination</b>. Your mob essentially does an 
    <b><a HREF="#mpgoto">MPGOTO</a></b> to the destination room, performs
    the action, then <b>MPGOTO</b>s back to its original room. You specify
    the <b>destination</b> as for the <b>MPGOTO</b> command, with the same
    options and caveats. Your mob moves from location to location with <em>no</em>
    message as for MPGOTO, so it can be as obvious or as sneaky as it wants.
    One popular use of MPAT is not so much to make a certain action happen
    at the destination room as rather to <em>not</em> make it happen where
    the mob is currently interacting with other characters. I already
    mentioned the bunnies going elsewhere to die so they seem not to.
    Another example is the healer, who painstakingly loads a long list of
    objects and stuffs them into a newbie bag. The healer ducks into an
    unpopulated room to do this so that she can present the newbie with a
    full bag without spamming all over him.
    <p>
    Although <b>command</b> can be practically anything, I do not recommend
    coding another <b>MPAT</b> command as the command to do elsewhere. Not
    only does this not make any sense (why not go to the third location in the
    first place?) but also it's likely that your mob will never find its way
    back to the first location. Either that, or you'll crash the MUD.
   </dd>
   <p>
   <dt><b>MPMLOAD &nbsp; vnum</b></dt>
   <dd>
    This works like the Immortal command <b>LOAD MOB</b>. It will load a mobile
    with the specified vnum into your mob's room.
    Be careful with aggie mobs, you do not want to build a death trap for
    low levels. One example use for this is the bunny who loads another one
    of itself when killed, thus appearing to spring back to full life.
   </dd>
   <p>
   <dt><b>MPOLOAD &nbsp; vnum &nbsp; level</b></dt>
   <dd>
    This works like the Immortal command <b>LOAD OBJECT</b>. It will load an
    object with the specified vnum into your mob's inventory.
    Contrary to other documentation, the object is <em>NOT</em> loaded into the mob's
    inventory if it does not have a TAKE flag. Just like the Imm command LOAD OBJ,
    the command will dump the object on the floor in the mob's room.
    Popular uses are giving out quest items or keys.
   </dd>
   <p>
   <dt><b>MPPURGE &nbsp; argument</b></dt>
   <dd>
    This works like the Immortal command <b>PURGE</b>. If there is no <b>argument</b>,
    it will purge all objects and mobs from the room, except for your mob itself. 
    With an argument, it will purge whatever is named by the argument. 
    Given an argument of <b>$i</b> (which refers to itself, as explained later>, 
    it will even purge itself, but if this is not the last command in the mobprog 
    bad things will happen when the program tries to keep running without the mob 
    it's attached to. 
    <b>BEWARE:</b> MPPURGE does <em>not</em> check the <b>NOPURGE</b> flag on objects 
    or mobs. When it purges, it purges EVERYthing.
   </dd>
   <p>
   <dt><b>MPTRANSFER &nbsp; victim &nbsp; destination</b></dt>
   <dd>
    This command moves <b>victim(s)</b> to <b>destination</b>.
    The victim(s) may be mobs, mortal players or <b>ALL</b>.
    ALL specifies all characters in the same room with your mob.
    <b>destination</b> works as for <a HREF="#mpgoto">MPGOTO</a>.
    If you don't specify any destination, the victim will be
    transferred into your mob's room.
    <p>
    Your mob's victims do <em>not</em> receive a message about having been
    transferred, nor do they automatically LOOK in the new room. Thus, it
    is up to you to inform them of what happened (perhaps using 
    <a HREF="#mpecho">MPECHO</a> and/or MPFORCE ... LOOK),
    if you so choose.
   </dd>
  </dl>
  <p>
  This section would not be complete without... you guessed it, an <b>example</b>!
  <p>
  <table BORDER=1 CELLPADDING=15>
   <tr><td><b><code>
    >hitprcnt_prog 50~<br>
    sigh<br>
    mpecho Realizing $j is going to lose the fight, $I calls to Super Helga for help!<br>
    wave $n<br>
    mpecho A moment later...<br>
    mpechoaround $n $I disappears and $n is left fighting thin air.<br>
    mpechoat     $n $I disappears and you are left fighting thin air.<br>
    mpgoto helga<br>
    ~<br>
   </code></b></td></tr>
   <tr><td>
    This is a relatively simple MobProg. If the beggar is caught up in a fight
    and down to 50% of his HP, he sighs, announces his departure and cheats
    his way out of the fight by doing an MPGOTO Helga. Note the use of 
    MPECHOAROUND to give a message to bystanders, then MPECHOAT to give the
    specific message to his foe.
   </td></tr>
  </table> 
  <p>
  <hr>
  <p>
  As promised earlier, for those of you who want to know EVERYthing,
  here is
  <p>
  <h4 ALIGN="center"><a NAME="hardway">The Hard Way To Connect MobProgs to Mobs</a></h4>
  <p>
  Actually, after all the preceding, this will not seem so hard any more.
  Note once again that this practice is currently not in use at Dizzy MUD.
  <ul>
   <li>
    Collect your MobProgs into <b>groups</b> such that one or more
    groups of MobProgs can be attached to each mob that needs them.
    You cannot attach parts of groups, it's all or nothing. But you
    can give each mob more than one group of MobProgs.
   </li>
   <li>
    Write each group of MobProgs into a separate file (there may be
    a special directory or set of files designated for this purpose on 
    your MUD -- ask your Coders). Conventionally, each of the files
    containing MobProgs has an extension of <b>.MOB</b> or <b>.MP</b>
   </li>
   <li>
    In your <b>.ARE</b> (area) file, as the last section, start up a
    <b>#MOBPROGS</b> section. Follow this with lines of the form:<br>
    <table>
     <tr><td><b>M</b></td><td>mob-vnum</td><td>MobProg-filename</td></tr>
    </table>
    <p>
    Each of these lines names a mob that you want to attach a MobProg to,
    and names the file that contains that MobProg.
    <p>
    After all your <b>M</b> lines, code a line with only an <b>S</b> on
    it to end your <b>#MOBPROGS</b> section.
   </li>
  </ul>
  <p>
  In addition, if you have your MobProgs in files, you can code <b>in_file_progs</b>
  underneath your actual mobs to associate MobProg files with them. This allows
  you to connect several files to one mob. The syntax for these in_file_progs
  looks like any trigger prog:
  <p>
  <center><b>&gt;in_file_prog</b> &nbsp; filename<b>~</b></center>
  <p>
  <hr NOSHADE WIDTH="75%">
  Congratulations! your area file is
  finished at this point. <b>Do not forget the #$</b> at the end of
  your file to terminate your area file. The <b>#$</b> must come on a line by itself
  and be followed by at least one or more empty lines. Leaving off this file 
  termination or getting it wrong cause the MUD to crash at load time without even
  issuing an error message!
  <!-- BEGIN Navigator -->
  <HR NOSHADE>
  <table WIDTH="100%">
   <tr>
    <td ALIGN="left">
     <small>
      &lt;&lt; Back to 
      <a HREF="abspec.htm">
       #SPECIALS Section
      </a>
     </small>
    </td>
    <td ALIGN="right">
     <small><!-- End of the line --></small>
    </td>
   </tr>
  </table>
  <HR NOSHADE>
  <!-- END Navigator -->
  <table WIDTH="100%">
   <tr>
    <td>
     &nbsp;
    </td>
    <td ALIGN=right>
     <small>This page was last updated <font COLOR="#FF0000">Februuary 19, 1998</font>.</small>
    </td>
   </tr>
  </table>
 </body>
</html>

Site Stats

Snippets: 1791
Codebases: 571