v0.32 Zone converter and generator from Diku-Circle to Aber-Dirt
Authored by Steven Lucas a.k.a. "Crimefighter", written in Perl v5.004.p1

Any re-release, modification, or redistribution of this code must credit me as being the original author, or something very bad could happen as did to others who have fallen for engaging in such activity. ;) I also should be informed and mailed copies of any such modifications, repairs or improvements made to "smlucas@flashmail.com" of which will be posted on "The COMPLETE Abermud List" website at "http://abermud.tripod.com". Monetary donations are also welcome.

ATTENTION: Please read through this whole documentation before sending me questions. Please make sure it's ZGEN that's at fault and not the zone file you're using. If you do find a real bug, send me the zone set that exposed it and where it blew up at, this is a work in progress and not all bugs are found very easily.

These files should be included with this archive: zgen.pl, zgen.ini, zgen.txt, 190.mob, 190.wld, 190.obj, 190.zon, 190.shp, building.txt and version.txt, and a set of zgen.ini files with the extensions of .idt, .drt, .dyt, .cdt, and .pdt in place of .ini. To use any of these just rename your current .ini to .old and copy the one you want to use (don't rename, you'll get your files mixed up or copied over that way!) If you're missing any one of these files, then I need to put them back in! Previously I thought that sample zone I included had no known author. Well I think I should correct that by including this description:

The file elven.tar.gz is a new area, complete with shops, of an elven forest. It should contain the following files: 190.mob 190.obj 190.shp 190.wld 190.zon This area has a reception area and guilds... It can be used in place of the major town or as another one.

Please enjoy,

Gbetz@gargamel.asms.state.k12.al.us

I have not been contacted by anyone about their zones being converted over, so I'm not concerned about this oversight.

Purpose

I wrote this program simply to increase the variety of Aber zones (albeit the hack-n-slash kind) and I wanted an easy way to duplicate a diku zone into Aber format. The first zone I have ever written was called Bal Harbor, and it was based on the zone of the same name on certain Diku muds. Although I didn't have the actual zone file, I proceeded to adapt the zone from scratch, keeping most of the mobiles, but using new room descriptions. Problem was, the thing took forever to do--mainly due to a lack of creativity but also due to size, it ended up being 180k long! The specials took a few weeks to write, but I didn't know how to write those until it was much later after initial release--about two years (you know what they say, you want it done, you gotta do it yourself!) There was at the time, a zone that had been converted to Aber format, and that is the "Rome" zone (distributed in the C-Dirt codebase).

Just about everything in the zone was duplicated, although that individual who made it probably had to do it all by hand and certainly not with a tool like this program. Previously, I've heard rumors that someone was planning to make such a conversion program, but it never materialized. I fortunately am employed, but have many periods of lulls and time to kill at work. I do all my programming on UNIX, and I have to learn Perl on the fly, so I've decided to write this program in Perl during my lull time.

On the side, a few of the newer Abermuds have attempted to make themselves more and more like Diku muds while maintaining the core features of the Aber code. Most Aber zones are aimed for low to mid-level players, but high-level players that are practically armed battletanks usually have no such high-level zone aimed for them. Diku zones on average are aimed at high to highest-level players, and the low-to-mid level players are left out--most mobiles can kill someone with just one blow. These "Aberku's" have the old standard zones with many mobiles being not much of a challenge. So this converter will make those tough zones into a format recognizable by Aber servers, and give mud owners a source of new zones while the rest of us continue making our original zones and quests. Coders however, can attempt customizing the finished conversions into quests by adding catch functions/specials. This program currently does not generate specials, and probably won't for a long while.

Basic Instruction

What you will need to run this program is a current version of the Perl compiler for whichever operating system you have. Preferably in some flavor of UNIX, since this program was tested to work on SCO UNIX. I've run ZGEN on Red Hat Linux and made this latest version using ActivePerl 5.8 in Windows 2000. Perl is obtained through "http://www.perl.com/CPAN". The zones themselves will end up running on a UNIX system, since about all the MUDs run on UNIX machines. Then you obviously need a diku zone file that's in Circle 3 format. You can probably find a few on some FTP or MUD resource webpage that specializes in archive distribution (try "ftp://ftp.game.org/pub/mud/" or "http://www.game.org/ftpsite/" for starters--that's where I got my test zones). There are formats for other kinds of Dikus, more complex in hybrids of GAMMA or Merc, older versions of Circle, and whatever else is out there.

The zone file will likely have an extension of '.tar' or '.gz' which is the compressed form of '.tar'. For '.gz', you need a program that will unzip a '.gz' file, like uncompress in UNIX or if you're using Windows, a program like WinZip. Once the '.gz' is unzipped to a '.tar' file, you have to use the tar program to break it up into regular files, or else use WinZip for Windows machines and FTP the untarred files over to the UNIX directory. This document however, won't provide a how-to on uncompress, tar, or WinZip--there are man pages and help files for those programs in UNIX and WinZip themselves respectively.

Once you have unzipped or untarred the archive zone file you should have a set of five files with the extensions '.wld', '.mob', '.obj', '.zon', and '.shp'. The '.zon' file assigns all the locations for mobiles and loads items, weapons and armor either on mobiles, in containers, or just on the floor. This actually was the trickier part of the programming, as I had to figure out how to insert the "Location =" values when there's multiple copies of each mobile and object somewhere in the zone--and some assignment are to things that aren't in the zone file AT ALL! Thankfully my engine only assigns what it needs when it asks for it, what it doesn't use is left over and all is well. Essentially you have the task of generating multiple copies of each and tagging them with an extension like '_1', '_2', '_3' and so on. This file had to be parsed first, and all the locations were stuck in an array to be searched and plucked as each mobile or object came along. If a mobile or object did not have a location assigned to it in the .zon file, the default is set at "limbo@limbo".

The second file processed, .wld, is the set of all rooms and their descriptions, along with all DOORS and a few NoGet objects thrown in for scenery. The third, '.obj' is processed next for all the rest of the objects, weapons, and armor. The fourth, '.mob' is processed to populate the zone with mobiles. In Dikus, ALL things in the zone is assigned a number, so everything is going to have something like MOB3245 and OBJ4534.

This unfortunately will be where you'll need to step through the output zone file and do many search/replaces--unless you can live with the current names. The '.shp' file, if there is one, contains data for shops in the zone, where you buy and sell stuff. Most abers don't have such things, and if they do it's basically a Wal-Mart like store so this file is not supported.

All four of the necessary files also need to have the same name like myzone.*, if one or more have a different name you'll need to rename the files. If for some reason one or more of these files are missing, some parts of the zone won't be generated. If you've only got the .zon file, NONE of the zone will be generated and you'll get an error. When the program sees if the files are there, you get to name the resultant zone--which will be used in all location names. To start the converter program type:

perl zgen.pl

If you get a warning at the start concerning your version of perl, it means you have an order version of the language. If you continue to run zgen from this point and it abends with an error message, then you will likely need to upgrade your perl. If you get a successful run under an older Perl, then I will lower the version requirement. If you run the program with the -w tag you will definitely get a lot of warnings, but it still works doesn't it?

You will need to input the input zone set name, and the output zone name, then the program just does the rest. For the file I included for demo purposes, the input zone set name is called "190" and the output zone name I used was "elven". As the program is running, a lot of debugging messages will print to show where it is at on whichever file it's reading. If it were to stop somewhere, these status notes will tell you where it got hung-up or just plain voiced its disapproval of what it read. If there's mistakes in the diku zonefile, you will have to fix the mistakes, and you will need the "CircleMUD Builders Manual" which I included (breaking copyright law or not) with ZGEN to assist in proper formatting and syntax. IMPORTANT: Please remove any blank lines from a '.zon' file, the program won't handle them, and they should be replaced by a "*" if they must stay. Deviations from the syntax will just cause you misery--I know...the demo file I included as a demo had several. String compares will now ignore the extra spaces, unlike previous versions where it will accept "D2 " as well as "D2". Take note: the terminator in diku files is the tilde "~", as opposed to the carat "^" in dirt.

After Zone Generation

When it has finished you should read through the generated zone to make sure everything looks okay, as it's likely you'll see some oddball things in it. First and foremost, a couple of exits in the zone could be to rooms that don't exist, which probably are to other zones on a DikuMUD that you don't have--you will have to remove or substitute an exit (especially when you open the zone to runners!) Secondly, check each "door" to see if they are named correctly and have another "door" associated with it. If not, either add the missing door yourself or remove all fields that make it a door and turn it into just scenery for the room. You can have a one-way door if you want, but you still have to link it to another object, and not assign an exit to it.

There is probably no need to alter the base values of stuff, the numbers were determined by dividing the cost of renting an item in an inn on a Diku by ten. If I had used the cost of buying an item, the points earned would have been excessive (no guarantees you won't get an excessive value anyway). Since Dikus do not define a size value (except for containers), I made it equal to the weight value. Damage on Dikus are determined by dice--how many dice and how many sides on each--so I multiplied them together to get a max.

Armor is computed on a scale of -10 to +10 (for mobiles, not items), +10 being equivalent to zero armor for abers, and -10 for whatever your max armor is--conversion is subtracting 10 from the value, and multiplying the result by -2. For flags, it is possible to generate something with two or more of the same flag...you'll just have to delete the duplicates. Another thing, stuff inside containers will only appear in the first copy, as there's no easy way to track all containers made so far and where something should go and how many--ZGEN is to help speed conversions, not make all zones perfect! Some other values on stuff or mobiles may not be to your liking, so change 'em! After polishing your newly generated zone and you'll be ready to stick in into your mud.

Now, I realize there's more than one flavor of Aber-Dirt out there, and there's different flags for different muds representing the same thing (or NONE!) So, we have created a zgen.ini file to assist in customizing. For example, mobiles that fear holy items may have their flag called FearHoly on one mud, and Cross on another. To pick one over the other, you can go into your editor and change which name is supposed to be used. Just before generation, the program reads the zgen.ini file and uses the flag names specified so the matching up the diku flags with the aber flags can take place. If there's a diku flag that aber doesn't support, leave the according line blank. I will describe in the next section which flag goes where.

zgen.ini Flags

This will be the ascribed format for the zgen.ini file, the defaults are the ones I supply to you myself. If you want to use something different, like the names of the flags on YOUR mud, copy zgen.ini to zgen.old (for backup in case you botch it) and use an editor to change the values. These values when played around with, can assist in tailoring a zone to the kind of zone it is, dense rainforest, dry desert, or an unstable earthquake area. And each line must be there or blank because the zgen will be looking for an exact number of values or else blow up with an error. Oddly enough, since each brand of Aber has a completely different way of handling wear flags, line 2 has become the unofficial mud brand identifier. Any line can be blank, but the codebase preference section must have values defined. You CAN use more than one value on a line, e.g. the Wear flag for hands has LeftHand and RightHand together. Anything you eat or drink of course has to have the Oflag Food with it, such as Booze, Potion, or Poison. You can't use comments in the INI file, since it will interpret them as a flag value. Here, line by line is what each line corresponds to:

Line # FlagName       Usage
------ -------------- -----------------------------------------------------
---Codebase Preferences---
1     Spell Flags  Use 0-Mflags, 1-Eflags, 2-NO flags.  I-Dirt & C-Dirt use
                     1, others use 0.  (Current just one flag generates)
2     Wear Flags   Use 0-Wflags, 1-Oflags, 2-Aflags, 3-NO flags, 4-pDirt.  
                     I-Dirt use 3, C-Dirt use 2, Dyrt use 1, Dirt 3.1.2 use 0
                     Use a 4 to create a pDirt formatted zone.
3     Speed        Pick a number from 1-99, default is 5.  All mobs get
                     this speed unless flagged SENTINEL for zero.
4     Aggression   If set, all mobs get a certain aggression value from
                     1-100, default is 25.
5     Visibility   If set, mob starts invis to some people, pick a number
                     from 1-100000, default 10.  This will also apply to
                     any objects defined as invis.
6     WIMPY        If they should flee, pick a number from 1-25.  Default
                     is 25, if you don't have fleeing mobs, put it in!
7     exits.h      If needed, enter a 1.  If not, leave blank.
8     %zone        If needed, enter a 1.  If not, leave blank.
9     Latitude     If needed, enter the number you need.  If not, leave blank.
10    Rainfall     If needed, enter the number you need.  If not, leave blank.
11    Attitude     If needed, enter a list of 8 numbers, separated by a space,
                     each for the room types below for city, field, forest,
                     hills, mountain, water_swim, underwater, flying, & 
                     desert.  Enter an X for each value to leave undefined.  
                     Or leave the whole line blank to not use Attitude.
12    Direction    If you do not want objects created that represent directions
      Description    enter a 1 on this line.  Otherwise leave blank.

---Lflag Preferences---
13    NOTRACK      Default NoSnoop, tracking or tracing stops here?
14    GODROOM      Obviously for the master user, but you ought to let
                     regular wizards come in here at will.
(The following effects kind of weather experienced, modify as you see fit.)
15    INDOORS      Default blank, unless you need something special in
                     these rooms, like Earthquake, Party, Hot/Cold...
16    CITY         Default Outdoors.  Pick that or Seasons, TempExtreme,
17    FIELD        Default Outdoors.  Hot, Cold, or Hot & Cold.
18    FOREST       Default Seasons.  C-Dirt can use RAINFOREST.
19    HILLS        Default Seasons.  
20    MOUNTAIN     Default Outdoors & Cold.
21    WATER_SWIM   Default OnWater, but you might add Outdoors to it.
                     (Lumped together with WATER_NOSWIM)
22    UNDERWATER   Most use UnderWater, some use InWater.
23    FLYING       If you have sky rooms, use its name or else flag it 
                     for powers only or wizards only.
24    DESERT       Default TempExtreme.
25    MAX          Default NegRegen.  Was to take move points off faster.

---Mflag Preferences---
26    STAY_ZONE      Mobs stay in their zone, default is blank.
27    AGGR_EVIL      Default blank, else good mobs attack evil players.
28    AGGR_GOOD      Default FearHoly, evil mobs attack good players.
29    AGGR_NEUTRAL   Not used, mobs attack 'fence sitters'.
30    MEMORY         Called REVENGE on Abers.  Mobiles strike back if they
                       find the bum who attacked them.  Leave blank if you
                       don't have this flag.
31    HELPER         Not used, mobs come aid other mobs in trouble.
32    NOCHARM        Not used, stops you from getting a mob to follow you
                       around and order it around.
33    NOBLIND        Blind spell won't work on this mob, default blank!
34    DETECT_ALIGN   Not used, mob reacts to someone's alignment.
35    DETECT_INVIS   Not used, mob sees invis people.
36    DETECT_MAGIC   Not used, mob reacts to magical stuff.
37    SENSE_LIFE     Not used, mob finds hidden people.
38    WATERWALK      Default Aquatic.  Mobs stay in water only.
39    SANCTUARY      Not used, mob takes half damage.
40    CURSE          Mob is cursed, or curses people, default CanCurse.
41    PROTECT_EVIL   Not used, evil can't kill it.
42    PROTECT_GOOD   Not used, good can't kill it.
43    NOTRACK        Default NoTrace, can't track or trace this mobile.
44    HIDE           Not used, mob is hid.
45    FLYING         Default Flyer, mob can fly into the sky or over water.

---Oflag Preferences---
46    SCROLL         Special will need to be made if set.  Default Magical.
47    WAND           Special will need to be made if set.  Default Magical.
48    STAFF          Special will need to be made if set.  Default Magical.
49    POTION         Default FOOD.  C-Dirt can use POTION instead.
50    BOAT           Self explanatory, if you don't have this, leave blank.
51    HUM            Makes a humming noise, default blank.
52    NODONATE       Default blank, some muds have the donate command, this
                       would be used to prevent donating an item.
53    MAGIC          Default magical, probably has a special with it.
54    NODROP         Default CURSED, can't be dropped or given away, food
                       heals half the normal value, explodes in pit.
55    BLESSED        Item is blessed, food heals 1.5 times normal value.
56    ANTI_GOOD      Good guys can't have it, default CURSED also!
57    ANTI_EVIL      Bad guys can't have it, default is HOLY, or rename it
                       CROSS for those who fear it.
58    ANTI_NEUTRAL   Not used.  Fence sitters can't have it.
59    ANTI_MAGE      Mages can't have it, default blank.
60    ANTI_CLERIC    Clerics can't have it, default blank.
61    ANTI_THIEF     Thieves can't have it, default blank.
62    ANTI_WARRIOR   Warriors can't have it, default blank.
63    BOOZE          Either Booze or Alcohol.  Default BOOZE.
64    POISON         Drinking this will make you ill.  Default Poison.
65    SCUBAGEAR      Allows you to breathe underwater, default Breathe.
66    WINGS          Allows you to fly, default blank.
      
---Wflag Preferences---
(Note:  If Wflags isn't used, but is used in Oflags or Aflags, change 'em.)
67    WEAR_FINGER    Item can be worn on the fingers.  Default FINGER.
68    WEAR_NECK      Item can be worn around the neck.  Default NECK.
69    WEAR_BODY      Item can be worn on the body.  Default TORSO.
70    WEAR_HEAD      Item can be worn on the head.  Default HEAD.
71    WEAR_LEGS      Item can be worn on the legs.  Default LEGS.
72    WEAR_FEET      Item can be worn on the feet.  Default FEET.
73    WEAR_HANDS     Item can be worn on the hands.  Default is both
                       LeftHand & RightHand.
74    WEAR_ARMS      Item can be worn on the arms.  Default Arms.
75    WEAR_SHIELD    Item can be used as a shield.  Default Shield.
76    WEAR_ABOUT     Item can be worn about the body.  Default BACK.
77    WEAR_WAIST     Item can be worn around the waist.  Default WAIST.
78    WEAR_WRIST     Item can be worn around the wrist.  Default WRIST.

---Sflag Preferences---
79    BLIND          Mob is blind, default is blind. (This is an Mflag 
			     under pDirt)

Most of the basic flags fortunately are the same for all muds. For Lflags, the type of room and terrain of the room were lumped together since only OnWater and UnderWater were relevant. In-the-sky type rooms are not implemented anywhere, for the time being anyway.

Concerning lines 45-48, if you want those to do something, you will have to hardcode a special with them. Appendix A of "Building.txt" lists the spells associated with the codes used to make the item. 

Since everything is by number, and this isn't a database program (and it would have been MUCH easier to do a database dump than this, but too many people don't have access to a decent database package like dBase, FoxPro, Access, Superbase, etc., then again too many got screwed over with an OS that didn't provide ANY decent text editor) most everything in the zone has names like MOB13464, OBJ13564, etc. These are their identifiers, and are different from Pname and Altname.

Programming Issues or Why'd You Write It Like THAT?

If you've read the code, you may have wondered why the heck did I not use an array to store the INI values? Except for the process to load the variables, I wanted to keep each INI value straight with a descriptive name like $blind instead of $flag[24] and possibly getting the numbers mixed up and a goofy looking resultant parse. Add to the mix that I've been inserting more flags in between the existing ones and then you have to modify several lines of code to put in the new subscripts...just too much trouble for a "quick" addition. It is possible that the author of the diku zone you are trying to convert made some typos themselves. It is relevant to read through the diku zone and verify that it is in the proper format with the correct values on the correct lines. This program does a limited check of the format on the fly, in so far as seeing if a correct number of values were read in on certain lines. If it thinks it found an improper number of values, it stops right there and gives you an error.

Why is everything given mob#### and obj####? (Rooms are zonename####, but many zones are done like that anyway.) If is wasn't for the locations file and the fact that Diku format required that type of numbering, I could have had an easier time assigning legit names to those things. Now if Dikus had done regular names for its assignments at the start there wouldn't have been a problem. (Incidently, Aber 4s used this same type of numbering before Dirt came along, thus Merc and ROM are practically the "Dirt" of Dikumuds...) But, if you've got that decent text editor (Win95 Wordpad.exe will do the job) you can do several find/replace operations, e.g. for mob19007 which is the elf named Quintor, you find mob19007 and replace it with Quintor...which takes care of every instance of Quintor (those being duplicates tagged with _1, _2, etc.) and any objects that he's holding. Now, those diku zones I've brought over so far I've just kept the numbering convention as is so that players reading the code will have to spend more time trying to cheat. For those debugging the specials files that I write, you shouldn't have to change any MOB_ELVEN_MOB19007s since I check to make sure which one I mean to use.

Where are the case/switch statements? Perl doesn't have such a thing! And the ones shown in that "Camel Book" Programming Perl just weren't understandable to me, so I used if-elsif-else constructs so I could be able to read them and not confuse myself. I could change the structure to something else later but I'm sticking with this, cause the other methods just look weird.

Despite what the author of the book said, you CAN'T put calling subs just anywhere. If you try it you could get a "Malformed prototype" error on compile time. Good thing I can cut and paste so I could relocate them to workable locations.

About all the searches were done with brute force search methods, especially with the letter compares and the assignment of locations. The assignment of locations are sorted with quick sort after generation, then a deletion set in a brute-force method is used to pass out the values to mobiles, doors, and objects on the fly. These three lists could have been made into two-dimensional arrays, but problem is that thing removed entries if requested but left the locations undefined and open for reuse instead of shrinking the size of the array--that would not do.


Additional Flags not supported in Circle 3.0

The following are flags not supported in Circle 3.0, but were found in other diku-type zones like Ghenna, most notably Gamma and AnnoyMUD. Most of these aren't implemented in any aber-based mud, and it is unlikely that they will, or else someone will use these things presented to try putting them in the game. The big problem with Gamma and AnnoyMUD is the same flag types are contradicting the standard or each other, thus a zone that works on one mud will not the same on another. It should be noted that letters for bitvectors aren't used in those breeds. I include these so ZGEN won't reject them like in previous versions, a couple items in there were a sort of a welcome addition:

Room Flags:



4096 m Pet Shop

8192 n No Recall -- We'll make this lflag CantSummon

16384 o Bank

32768 p Push north--means you're drug north after so many seconds

65536 q Push east

131072 r Push south

262144 s Push west

524288 t push up

1048976 u push down



Sector Type:



9 unused

10 Desert -- this one would get TempExtreme

11 UnderWater (same as 8, interesting to find 8 was skipped on the other!)

12 Max, meaning spend the maximum amount of move points in here. This

will be given NegRegen.



Door Flags



4 Pass Door proof, mobiles can't just pass thru it like it weren't there.

8 Hidden Door, you'd need a special to find such a door, cause it's given

the Destroyed flag.

16 Keyword Reference, meaning either you have to reference the door by its

name to pass through it or you can open it by name but not by direction

name--not clear to me. I guess maybe this is to go beyond the standard

6 exits by using the GO command (with diagonals this becomes 10).

Since you open doors by name and not direction, this is moot. Using GO

to go through a door by name and not direction isn't implemented by any

Aber that I know of.



Mobile Action Flags:



262144 s unused

524288 t Shops will raise prices on those over level 10

1048576 u Shops will raise prices on those over level 20

2097152 v Shops will raise prices on those over level 30

4194304 w unused

8388608 x Mobile stayed in a certain type of terrain

16777216 y Practices Avian skills (This is one of AnnoyMUD's differing

flags, other types were using already taken #'s. Have no

other possible names for this flag as of yet.)

33554432 z NoHassle -- no one can kill this mob, except using the

runesword and even then that thing has to attack it.



Mobile Affection Flags (These differ from Circle):



262144 s Dodging or Charmed

524288 t Sneak or Flying

1048576 u Hidden or Mobiles Walk Thru closed doors (like ghosts?)

2097152 v Afraid or infected with the Plague

4194304 w Charmed or Using InfraVision

8388608 x Following someone



Object Types:



24 unused

25 unused

26 Pill

27 Aquatic (Scuba Gear or such)

28 Fly (Wings or such)

29 Quiver (A container for like arrows for a bow)

30 Throw (Item that can be thrown at someone)

31 unused

32 unused

33 Portal (to another dimension?)



Object Extra Flags:



131072 r unused

262144 s Enter objects (people can get inside them)

524288 t Boat

1048576 u Invisible item



Wear Flags:



32768 p Throwing item or it's two-handed.



The "B" field for objects...no information is known, only that it's there and takes one argument with it. Discovered in the Ghenna zone.

All the flag sets run through z or 33554432 for all those muds that have used every possible flag, but are set as undefined.