abflags.htm

abflags.htm · 7.0 KB

From the archive ab.zip

Download the archive   « Back to the archive contents

<html>
 <head>
  <title>Dizzy Mud Area Builder's Guide - Flag Fields Explained</title>
 </head>
 <body BGCOLOR="#FFFFFF">
  <h3 ALIGN="center">Flag Fields Explained</h3>
  <hr NOSHADE>
  You were warned that area coding is a bit like computer programming. With flag fields,
  the similarity really takes hold. Computer geeks will feel at home with flag fields but
  other people will benefit from a word or three of explanation.
  <p>
  <b>Flags</b><br>
  A 'flag', in the computer world, is either lowered or raised. Nothing ever dies for good
  in a virtual world, hence there is no use for the concept of 'half-mast'. A raised flag
  indicates that something is true, or present, or available, or happening. It's the positive
  case. A lowered flag means false, not there, unavailable or not happening. An example of
  a condition which can be coded by a flag is: IS THIS ROOM NO-RECALL? For any given room,
  this question can be answered with a simple yes or no.
  <p>
  A room has many states that can be described with a yes/no flag, and a mob has even more.
  The programmers of the original MUDs realized that each such flag can be represented by
  a bit, and several such bits fit in one number. Thus, one (possibly large) number can
  contain many flags, possibly up to 32. Here's a brief excerpt from the Affect Flag Table, 
  indicating some of the affect flags used in Dizzy, their letter codes and numeric 
  equivalents:
  <p>
  <div ALIGN="center">
   <table BORDER="1">
    <caption ALIGN="top"><h4>Affect Flag Table (Excerpt)</h4></caption>
    <tr>
     <th>Name</th>
     <th>Letter Code</th>
     <th>(historic)<br>Numeric Code</th>
    </tr>
    <tr><td>AFF_BLIND</td><td>A</td><td>1</td></tr>
    <tr><td>AFF_INVISIBLE</td><td>B</td><td>2</td></tr>
    <tr><td>AFF_DETECT_EVIL</td><td>C</td><td>4</td></tr>
    <tr><td>AFF_DETECT_INVIS</td><td>D</td><td>8</td></tr>
    <tr><td>AFF_DETECT_MAGIC</td><td>E</td><td>16</td></tr>
    <tr><td COLSPAN=3 ALIGN="center">...</td>
    <tr><td>AFF_STEEL</td><td>Y</td><td>16777216</td></tr>
    <tr><td>AFF_DIVINEREGEN</td><td>Z</td><td> 33554432</td></tr>
    <tr><td COLSPAN=3 ALIGN="center">...</td>
    <tr><td>AFF_SLOW</td><td>d</td><td>536870912</td></tr>
    <tr><td>AFF_TALON</td><td>e</td><td>1073741824</td></tr>
   </table>
  </div>
  <p>
  <b>How it was done in the bad old days</b><br>
  Numbers were used to indicate which flags were 'raised'.
  A  mob affected by only DETECT_INVIS would have a 8 as a numeric code for its affect
  flags.
  To indicate more than one flag, people needed to haul out their calculators
  and add up the numeric values for the flags.
  A blind mob with Detect Evil would be coded as 1 + 4 = 5. Computer programs can break
  the 5 back down into 1 and 4 and regain the info about blindness and Detect Evil.
  If you wanted to code things from the end of the table, you had to manipulate
  numbers like 1073741824, and your calculator soon ran out of digits. Thus, in the olden days,
  many mobs ran around with very few flags on them. You may encounter areas coded for
  older MUDs using huge numbers in places where Dizzy uses letter codes.
  <p>
  <b>The Alphabet saves the Day</b><br>
  Realizing what a pain in the neck it is for humans to add up numbers, and worse, to
  'see' the flags coded into a given large number, the Creators of modern versions
  of ROM MUDs like Dizzy MUD thought up the idea of substituting <em>letters</em> for the
  numeric flags, and to let people just string them together instead of adding up
  values.
  <p>
  To code a mob that can see invisible, you code a <code><b>D</b></code>.<br>
  To code a blind mob with Detect Evil (yes, I realize it's a senseless example),
  you code <code><b>AC</b></code>.
  <p>
  Many things have a large set of flags, and updating an area may add even more.
  As a courtesy to the poor person who will have to read the flag fields in your
  areas, please arrange the letters in ascending alphabetical order.
  <p>
  There are a few fields with more flags in them than there are letters in the 
  alphabet! The programmers of DizzyMud extended flag fields by allowing coders
  to use lower case to code the flags beyond Z. Thus, <b>case is significant:
  If you see a lower case letter in a table, code a lower case letter!</b>
  <p>
  Lotus' Area Coding Guide suggests using double lower case letters to code
  those flags which have a single lower case letter in my tables, e.g.
  <code><b>dd</b></code> for SLOW. <b>Ignore other sources, do not use double
  lower case letters!</b> It turns out there is a bug in the software that reads
  the lowercase letters, and it produces the wrong results if you use double
  letters. Unfortunately, I can't fix the bug either, because some areas have been
  fixed to use the wrong double letter codes to achieve the right results. If I fix
  the bug, those areas will be wrong again.<br>
  This same bug also leads to <b>another problem:</b>
  If you have more than one of <em>any</em> letter, the effect will be something
  other than what you intended. Thus,<br>
  <b>Use any combination of letters you like, but <em>never</em> use the same 
  letter more than once in one field!</b>
  Arranging letters in alphabetical order (first the upper case letters ordered
  alphabetically, then the lowercase letters) will help you spot double letters
  immediately and allow you to eliminate the problem.
  <p>
  <h4>The Almighty Zero</h4>
  There are two reasons I mentioned numeric codes: 
  <ol>
   <li>
    you may encounter
    old area coding with number in it where Dizzy codes letters. While you may not
    want to analyze the numbers to figure out what bits are in there, at least you 
    will know why they are there. Incidentally, Dizzy will happily read numbers for
    flag fields although modern practice is to code letters.
   </li>
   <li>
    There is a special case: If you want to code <em>no</em> flags, it won't do to
    leave the field blank. All that would do is move the next field into the current
    one and your affect flags would be interpreted as act flags, or something 
    similarly chaotic. In any case, your area would not load. Instead, <b>
    to code <em>no</em> flags at all, code a <code>0</code> (zero). This is the 
    one case not handled by letter codes.</b>
   </li>
  </ol>
  <p>
  <b>Summary</b><br>
  To code a single flag into a flag field, find the letter code for that flag and
  stick it where the field goes in your code. To code several flags, find the
  appropriate letters and string them together into the field. Case is significant,
  use capitals where there are capitals in the table and vice versa!
  To code no flags, put a 0 (zero) there.
  <p>
  <a HREF="abmob.htm#actflags">Return to #MOBILES</a>
  <hr NOSHADE>
  <table WIDTH="100%">
   <tr>
    <td>
    </td>
    <td ALIGN=right>
     <small>This page was last updated <FONT COLOR="#FF0000">September 4, 1997</FONT>.</small>
    </td>
   </tr>
  </table>
 </body>
</html>

Site Stats

Snippets: 1791
Codebases: 571