Flag Fields Explained


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.

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:

Affect Flag Table (Excerpt)

Name Letter Code (historic)
Numeric Code
AFF_BLINDA1
AFF_INVISIBLEB2
AFF_DETECT_EVILC4
AFF_DETECT_INVISD8
AFF_DETECT_MAGICE16
...
AFF_STEELY16777216
AFF_DIVINEREGENZ 33554432
...
AFF_SLOWd536870912
AFF_TALONe1073741824

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.

The Almighty Zero

There are two reasons I mentioned numeric codes:
  1. 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.
  2. There is a special case: If you want to code no 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, to code no flags at all, code a 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.

Return to #MOBILES


  This page was last updated May 15, 2001