Flags
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.
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:
Name | Letter Code | (historic) Numeric Code |
---|---|---|
AFF_BLIND | A | 1 |
AFF_INVISIBLE | B | 2 |
AFF_DETECT_EVIL | C | 4 |
AFF_DETECT_INVIS | D | 8 |
AFF_DETECT_MAGIC | E | 16 |
... | ||
AFF_STEEL | Y | 16777216 |
AFF_DIVINEREGEN | Z | 33554432 |
... | ||
AFF_SLOW | d | 536870912 |
AFF_TALON | e | 1073741824 |
How it was done in the bad old days
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.
The Alphabet saves the Day
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 letters for the
numeric flags, and to let people just string them together instead of adding up
values.
To code a mob that can see invisible, you code a D
.
To code a blind mob with Detect Evil (yes, I realize it's a senseless example),
you code AC
.
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.
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, case is significant: If you see a lower case letter in a table, code a lower case letter!
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.
dd
for SLOW. Ignore other sources, do not use double
lower case letters! 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.
This same bug also leads to another problem:
If you have more than one of any letter, the effect will be something
other than what you intended. Thus,
Use any combination of letters you like, but never use the same
letter more than once in one field!
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.
0
(zero). This is the
one case not handled by letter codes.
Summary
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.
This page was last updated May 15, 2001. |