Skip to content

KeeperFX Map files format reference

rainlizard edited this page Jun 15, 2024 · 6 revisions

Levels in Dungeon Keeper are written in multiple files. Storing a map in more than one file makes it easier to modify the map, but also may lead to problems when copying it, renaming or sharing with other people. Knowledge of what specific files do, and how they look from inside is not crucial for the mapmaker. Mapmakers only need to know the file type of the level script (.TXT file), which is explained in the Dungeon Keeper Script Commands Reference.


Equivalent file types across map formats

KeeperFX can read maps in either KFX format or Classic format. The original Dungeon Keeper can only read maps in Classic format.

Classic KFX Description
apt aptfx Action Point file which defines location of action points that can be referenced by the script files.
clm clm Column file which determines the graphics for each subtile in the map.
dat dat Column Position Data file which determines the initial graphics at the start of the game.
dat Named map00xxx.lan.dat (where 'lan' is the language code), contains custom strings and translations.
inf inf Level Style file which specifies the landscape style/texture set used for the map (e.g. icy, ancient, etc).
lgt lgtfx Static Light file which provides extra fixed lighting effects in the map.
lif lof Level Info file, lif has only map number and name, while lof contains even more level metadata.
own own Ownership file which determines which player owns each subtile.
slb slb Slab file which determines the type of each map tile (e.g. earth, rock, room).
slx Map Style file which can set the tileset for individual slabs, overriding the .inf.
tng tngfx Thing file which is a list of objects/entities on the map such as items, creatures, traps, doors.
txt txt Level Script file which controls victory conditions, AI behavior, room/creature availability, triggered events, and more.
wib wib Wibble file which determines which subtiles have special distortion/animation effects.
wlb wlb Water Lava Block file specifying the type of liquid (water or lava) present on each tile.
Editor format Description
adi Adikted editor project file containing custom data used by the Adikted editor.
une Unearth editor project file containing custom data used by the Unearth editor.

Levels are stored in .\Levels\ directory on Dungeon Keeper CD. If you want to modify them and use the modified ones, you will have to copy all the levels to your Dungeon Keeper directory. See Mapmakers Installation Instructions for details.

Level 1 (the first level), consists of the following files:

map00001.apt
map00001.clm
map00001.dat
map00001.doc
map00001.eff
map00001.flg
map00001.inf
map00001.lgt
map00001.old
map00001.ori
map00001.own
map00001.slb
map00001.tmn
map00001.tng
map00001.txt
map00001.vsn
map00001.wib
map00001.wlb

Not all of these files are required to play the map. The crucial files are listed above. If you want to save disk space, or publish the map in Internet, you only require those files:

map00001.apt
map00001.clm
map00001.dat
map00001.inf
map00001.lgt
map00001.own
map00001.slb
map00001.tng
map00001.txt
map00001.wib
map00001.wlb

Rest of the files is not used by the game. Note that if you're using ADiKtEd to modify the map files, there may be another file in the list:

map00001.adi

This file isn't used by the game, only by ADiKtEd. If you're uploading level for end users, and the uploaded version won't be edited anymore, then you may skip this file.


Several of the Dungeon Keeper files are compressed with Rob Northern Compression (RNC). You can tell if a file is compressed, as the first three bytes will be 'R' 'N' 'C'. The fourth byte is a 1 (as distinct from '1').

There's a compressor/decompressor available to download in many places, for example on Syndicate Series Unofficial Fan Site. Source code in C is available too. There is also version of the decompression with graphical interface in DKTools package.


.


Each map is divided into 85x85 playing tiles, as seen on the map. Each tile is sub-divided into 3x3 subtiles - look at the game carefully, examining tiles, and trying to break them into subtiles, and you'll see what I mean. I'll use the terminology above extensively, be sure you understand what I mean.


  • Size: 2*85*85=14450
  • Required?: Yes.
  • Description: Determines type each tile is.
  • Format: 85 lines of 85 tiles, each having a two byte entry.
  • Notes: None.

The .SLB file is basically main file of every map. It contains information about map layout - says which subtile is places on which position. The file consist of a two-byte entry for every map tile.

Using .SLB file, the .CLM and .DAT files can be autogenerated.

The exact slabs can be found in terrain.cfg


  • Size: (85*3+1)*(85*3+1)=65536
  • Required?: Yes.
  • Description: Determine ownership of tiles.
  • Notes: I can't see why this is in subtile format when only one byte (or 3 bits, in fact) is needed per tile.

The file has one byte corresponding to every subtile on the map. It also defines the border subtiles, which are invisible. Border subtiles are: one at start and one at end of every column/row, so they are indexed 0 and 255.

Here is the list of proper values as C defines:

#define PLAYER0                0x00
#define PLAYER1                0x01
#define PLAYER2                0x02
#define PLAYER3                0x03
#define PLAYER_GOOD            0x04
#define PLAYER_UNSET           0x05

Note: All nine subtiles of every tile should be owned by the same player.


These files consists of number of entries followed by the list of entries. Every entry in such file has identical length.

For objects which are placed on map, entries contain coordinates where the object is. Those coordinates are always stored in same form:

  • For 2D coordinates: 4 unsigned bytes: sx tx sy ty
    The object is placed on a subtile (tx,ty) and its position within subtile is (sx,sy). These are horizontal and vertical positions, counting from 0. The values can be also interpreted as two 16-bit values (words). In that case, every word stores global position in the map coordinate system.
  • For 3D coordinates: 6 unsigned bytes: sx tx sy ty sz tz
    The object is placed on a cube (tx,ty,tz) and its position within cube is (sx,sy,sz). The values can be also interpreted as three 16-bit values (words). It's same as with 2D coordinates, only there's Z coord which is height. So, tz is the number of cubes above ground level (note there is usually one cube above ground level, forming a floor). There are up to eight cubes in total per subtile. The sz gives the height within the cube.

  • Size: 2+(21*number of entries)
  • Required?: Yes.
  • Description: List of "things" in the dungeon.
  • Format:
    • 2 bytes: Number of 21 byte entries
    • Each entry:
      • [0]: Location inner-subtile X
      • [1]: Location subtile X
      • [2]: Location inner-subtile Y
      • [3]: Location subtile Y
      • [4]: Location inner-subtile Z
      • [5]: Location subtile Z
      • [6]: Thing type
      • [7]: Thing subtype (eg creature race, trap type)
      • [8]: Owner
      • [9-20] 12 bytes: Type specific data

    Notes: A table of known values is below.

    Most of objects in Dungeon Keeper are things. These are all objects which generate graphics effects with bitmap (2D) images.

    Things can have various "types". Each thing type has different features. Here is a list of known types as C defines:

    #define THING_TYPE_NONE        0x00
    #define THING_TYPE_ITEM        0x01
    #define THING_TYPE_CREATURE    0x05
    #define THING_TYPE_ROOMEFFECT  0x07
    #define THING_TYPE_TRAP        0x08
    #define THING_TYPE_DOOR        0x09

    For every thing type, the meaning of some data is different:

    • Type 1=Item/decoration
      • 11-12: Sensitive tile; usually y*85+x (y and x being the tile co-ordinates, not subtile). Value -1 (0xffff) means none.
    • Type 5=Creature
      • 14: Level-1 (eg 0 for a level 1 creature, 9 for level 10)
    • Type 7=Room effect
    • Type 8=Trap
    • Type 9=Door
      • 13: Orientation. 0=door in N/S passage, 1=door in E/W passage
      • 14: Locks. 0=unlocked, 1=locked (note the spinning key above the door needs to be added as a .tng entry).

    Item/decoration subtype values (numbers are decimal):

    Num Item Num Item Num Item
    1 Barrel 46 Chicken spell 91 Increase level
    2 Torch 47 Destroy walls spell 92 Make safe
    3 Gold Chest (500) 48 Time bomb spell 93 Reveal hiddn world
    4 Temple statue 49 Hero gate 94 Boulder trap box
    5 Dungeon heart 50 Spinning key 2 95 Alarm trap box
    6 Gold Pot (250) 51 Armour 96 Poison gas trapbx
    7 Unlit torch 52 Gold Hoarde 1 97 Lightning trap bx
    8 Statue w/o flame 53 Gold Hoarde 2 98 Word of Pwr trpbx
    9 Growing Chicken 54 Gold Hoarde 3 99 Lava trap box
    10 Chicken 55 Gold Hoarde 4 100 Trap Dummy 2
    11 Hand of evil spell 56 Gold Hoarde 5 101 Trap Dummy 3
    12 Create imp spell 57 Wizard Lair 102 Trap Dummy 4
    13 Must obey spell 58 Barbarian Lair 103 Trap Dummy 5
    14 Slap spell 59 Archer Lair 104 Trap Dummy 6
    15 Sight of evil spell 60 Monk Lair 105 Trap Dummy 7
    16 Call to arms spell 61 Dwarfa Lair 106 Door Wood box
    17 Cave in spell 62 Knight Lair 107 Door Brace box
    18 Heal creature spell 63 Avatar Lair 108 Door Steel box
    19 Hold audience spell 64 Tunneller Lair 109 Door Magic box
    20 Lightning spell 65 Witch Lair 110 Workshop Item
    21 Speed creature spell 66 Giant Lair 111 Heart flame(red)
    22 Protect creatr spell 67 Fairy Lair 112 Disease
    23 Conceal creatr spell 68 Thief Lair 113 Scavenger eye
    24 Null1 69 Samurai Lair 114 Workshop machine
    25 Null2 70 Horny Lair 115 Guard Flag(red)
    26 Anvil 71 Skeleton Lair 116 Guard Flag(blue)
    27 Prison bar 72 Goblin Lair 117 Guard Flag(green)
    28 Candlestick 73 Dragon Lair 118 Guard Flag(yellow)
    29 Gravestone 74 Demonspawn Lair 119 Flagpost
    30 Horny Statue 75 Fly Lair 120 Heart flame(blue)
    31 Training post 76 Dark Mistress Lair 121 Heart flame(green)
    32 Torture spike 77 Sorceror Lair 122 Heart flame(yellw)
    33 Temple Spangle 78 Bile Demon Lair 123 Power Sight
    34 Potion1 79 Imp Lair 124 Power Lightning
    35 Potion2 80 Bug Lair 125 Torturer
    36 Potion3 81 Vampire Lair 126 Orc Lair
    37 Power hand 82 Spider Lair 127 Power Hand Gold
    38 Power hand grab 83 Hell Hound Lair 128 Spinning Coin
    39 Power hand whip 84 Ghost Lair 129 Statue 2
    40 Chicken stable 85 Tentacle Lair 130 Statue 3
    41 Chicken wobble 86 Reveal map 131 Statue 4
    42 Chicken crack 87 Resurrect creatre 132 Statue 5
    43 Gold (200) 88 Transfer creature 133 Statue 6
    44 Spinning key 89 Steal hero 134 Armageddon Spell
    45 Disease spell 90 Multiply creatres

    Creature subtype values (numbers are hexadecimal):

    Number (hex) Creature Number (hex) Creature
    1 Wizard 11 Dragon
    2 Barbarian 12 Demon spawn
    3 Archer 13 Fly
    4 Monk 14 Dark Mistress
    5 Dwarf 15 Warlock
    6 Knight 16 Bile demon
    7 Avatar 17 Imp
    8 Tunneller 18 Beetle
    9 Witch 19 Vampire
    a Giant 1a Spider
    b Fairy 1b Hell hound
    c Thief 1c Ghost
    d Samurai 1d Tentacle
    e Horned Reaper 1e Orc
    f Skeleton 1f Floating spirit
    10 Troll

    Room effect subtype values

    Number (hex) Effect
    2 Dripping water
    4 Dry ice

    Trap values

    Number (hex) Trap
    1 Boulder
    2 Alarm
    3 Poison gas
    4 Lightning
    5 Word of Power
    6 Lava

    Door subtype values

    Number (hex) Door
    1 Wooden
    2 Braced
    3 Iron
    4 Magic

    • Size: 4+8*(number of entries)
    • Required?: Yes.
    • Description: Gives location of action points for reference in script (.txt) files.
    • Format:
      • 4 bytes: Number of 8 byte entries.
      • Each entry:
        • [0]: Location inner-subtile X
        • [1]: Location subtile X
        • [2]: Location inner-subtile Y
        • [3]: Location subtile Y
        • [4-5] 2 bytes: Range
        • [6-7] 2 bytes: Action point number (points are usually in order, but they don't have to be).
    • Notes: None.

    This file defines action points. After the four-byte header, there comes a list of 8-byte action points.


    • Size:4+(20*number of entries)
    • Required?: Yes.
    • Description: Provides extra lighting.
    • Format:
      • 4 bytes: Number of 20 byte entries.
      • Each entry:
        • [0-1] 2 bytes: Range
        • [2]: Light intensity
        • [3-9] 7 bytes: Unknown
        • [10]: Location inner-subtile X
        • [11]: Location subtile X
        • [12]: Location inner-subtile Y
        • [13]: Location subtile Y
        • [14]: Location inner-subtile Z
        • [15]: Location subtile Z
        • [16-17] 2 bytes: Unknown.
        • [18-19] 2 bytes: Always -1 (0xffff).

    The LGT file defines lights which, unlike torches, cannot be destroyed. It should be put in centre of large rooms and on lava.

    3.4 Extended thing .TNGFX files

    • Required?: For KeeperFX features.
    • Description: A more powerful alternative to TNG files.
    • Format: Toml text file
    TODO

    3.5 Extended static light .LGTFX files

    • Required?: For KeeperFX features.
    • Description: A more powerful alternative to LGT files.
    • Format: Toml text file
    TODO

    3.6 Extended action point .APTFX files

    • Size: 4+4+(AptEntrySize*Number of APT entries)
    • Required?: For KeeperFX features.
    • Description: A more powerful alternative to APT files.
    • Format: Toml text file
    TODO

    .


    Graphic on every subtile can be called column. Every column consists of textured cubes, put one on another. Typically, the tall columns (like rock, gems, earth...) are built using 5 cubes and a base block (which is the lowest cube).


    • Size: 1
    • Required?: Yes.
    • Description: Specifies the landscape style, or in other words, texture file number (making the dungeon icy, for instance).
    • Format: Always 1 byte, which is a 0 for all but the following maps:
      • 01 for maps 13, 14, 15, 16, 17, 104
      • 02 for maps 9, 10
      • 03 for maps 19, 20
    • Notes: There are more textures available in Deeper Dungeons.

    The single byte defines texture number. Short description of available textures:

    Number Texture
    1 Standard texture
    Used in most of original campaign maps.
    2 Ancient texture
    This one has brighter walls than the first. Walls have Aztec drawings on these testures.
    3 Winter texture
    Walls with snow and ice drawings representing snow drops.
    4 Snake Key texture
    Walls with key of life and snake. The wall brick is brown in this texture, not red like on standard one.
    5 Stone Face texture
    Rough walls with red eyed face on. The walls are bright on this texture, nearly yellow.
    6 Big Breasts texture
    The woman reliefs on these textures have bigger breasts than standard.
    7 Rough Ancient texture
    Texture with ancient relief theme and rougher earth.
    8 Skull Relief texture
    On this texture walls are brighter than standard, and reliefs are representing skulls of various size.

    • Size: 49160
    • Required?: Yes.
    • Description:Along with the .dat file, this determines the graphics for the level. Each entry gives the data for a subtile.
    • Format:
      • 8 bytes: Number of 24 byte entries (always 2048).
      • Each entry:
        • 24 bytes:
        • 0-1: Use - Counter of the column uses for non-permanent columns; For permanent colums, this value has an offset.
        • 2: Byte with bitfields:
          • Bit 0: Permanent - if set, the column is never overwritten
          • Bits 1-3: Lintel (unknown)
          • Bits 4-7: Height - in subtiles; proper values are 0..7
  • 3-4: Solidmask - appears to be a bitmask for which of the cubes are non-zero, with the lowest cube being represented by the least significant bit.
  • 5-6: BaseTexture - determines the very lowest level (below the lowest cube). This number refers to a texture directly, and not to a cube This entry is mostly useful for water, lava, and hatcheries.
  • 7: Orientation (always 0)
  • 8-23: Cubes - there are 8 cubes, each having a 2 byte entry. The first cube usually forms the floor, etc, up to the ceiling.
  • Notes: .dat entries are pointers into this file.
  • cubes can be found in cubes.cfg

    In the original levels (and Unded ones, IIRC), only used subtiles have non-zero .clm entries. Adikted generates a standard .clm file, as this is much easier and has very few drawbacks as far as I can see. The table below gives (most of!) the values I know about. I haven't been particularly rigorous generating this table, but I'll add to it when I find some time. I've taken this entirely from my own source code (which in turn took most values from observations of original DK levels). Some cubes are used in several places; I've usually only put one use below. In the future, I hope to be able to show a picture of what each cube looks like (only one face is used, it's just rotated).


    • Size: 2*(85*3+1)*(85*3+1)=131072
    • Required?: Yes.
    • Description: Determines the graphics at the start of the game. When new areas are dug out or rooms are changed, computer automatically generates different graphics for these areas, but otherwise everything is in this file.
    • Format: Subtile map format, with 2 bytes per entry.
    • Notes: None.

    The file has two bytes corresponding to every subtile on the map. It also defines the border subtiles, which are invisible. Border subtiles are: one at start and one at end of every column/row, so they are indexed 0 and 255.

    If you treat the value for a subtile as a signed integer, and take the absolute value (or rather, just reverse the sign - I've never seen a positive one), you get the entry number in the .clm file.

    How visibility is calculated:
    At the start of the game, a square is visible to a player if either it is owned by them or it is possible to reach that square from the dungeon heart without going through walls.


    • Size: 65536
    • Required?: Yes.
    • Description: Determines which subtiles are animated.
    • Format: Subtile map with single byte entries. Each byte is 00, 01, or 02:
      • 00: Display the subtile without any change
      • 01: Skew the subtile slightly (default)
      • 02: Animate the subtile
    • Notes: Don't think individual subtiles can be animated... putting one animated subtile in a load of non-animated ones makes no difference.

    The file has one byte corresponding to every subtile on the map. It also defines the border subtiles, which are invisible. Border subtiles are: one at start and one at end of every column/row, so they are indexed 0 and 255.


    • Size: 85*85=7225
    • Required?: No.
    • Description: Determines type of liquid each tile is.
    • Format: 85 lines of 85 tiles, each having one byte entry.
    • Notes: None.

    Water and Lava Block files are used to mark where on the map the water and lava is located. Normally, liquid blocks are defined in SLB file. But if you will put a bridge over the water or lava, the information about what it really was is stored here.


    • Size: 85*85=7225
    • Required?: No.
    • Description: Determines type of mapstyle each tile is.
    • Format: 85 lines of 85 tiles, each having one byte entry.
    • Notes: Fx specific

    contains the tileset used for individual slabs, overwrites what's in the .INF, same data but 1 byte for each slab instead of for whole map



    • Size: Varies.
    • Required?: Yes.
    • Description: Level script which determines victory conditions, enemy keepers actions, training mode, etc.
    • Format: Text file.
    • Notes: Description of the language can be found in
    • Script Commands Reference.

    This is a pretty simple scripting language. There are no loops or jumps, and condition testing is very basic. There are only three statement forms - conditions, commands, and condition terminators. Conditions are naturally nested, but that's about as complicated as it gets.

    Each line contains a single instruction. Whitespace in the form of spaces and tabs is ignored. Comments begin with REM. All unconditional commands (ie ones outside any condition statements) are executed at the beginning of the game, then ignored. All conditions are checked at regular intervals.


    • Size: Varies.
    • Required?: No.
    • Description: More advanced script
    • Format: Text file.
    • Notes: KeeperFx specific.

    This is a more advanced scripting language and supports all stuff a full programing language harder to use, but also more powerfull then the .txt scripts both can be used together on the same map the specific dialect used by keeperFx is luau about wich more info can be found here https://luau-lang.org/ wich is based on lua 5.1 for wich documentation can be found here http://www.lua.org/manual/5.1/manual.html currently in early stages, documentation coming when more mature


    contains the map number (bit redundant given that this is already in the filename) followed by a semicolon and then the name of the map


    this is an FX specific alternative for the lif file which can contain more info then just the mapname

    • NAME_TEXT: the name of the level
    • NAME_ID: translatable id of the level name which can overwrite NAME_TEXT in the language of the game
    • ENSIGN_POS: position of the flag on the overview map
    • ENSIGN_ZOOM
    • PLAYERS: number of player the map supports for multiplayer maps
    • OPTIONS: currently ony option is TUTORIAL to change the ensign to one with a T
    • SPEECH: the speech before and after the map for campaigns
    • LAND_VIEW
    • KIND SINGLE MULTI BONUS EXTRA FREE
    • AUTHOR
    • DESCRIPTION
    • DATE
    • MAPSIZE: size of the map in tiles, default is 85 85

    These are files specific to 1 editor and cannot be used by the game or any other editor. Using these file, these generally contain stuff not stored in the other files but that the editor needs to make sense of it such as Custom Columns.


    This is a text file which contains ADiKtEd script for levels which were edited using ADiKtEd. The script stores commands which are specific to ADiKtEd and cannot be used by the game or any other editor. Using this file, ADiKtEd can support some special functions, which were originally not supported by the game, such as Graffiti or Custom Columns.


    For unearth this is a binary file


    • Size: 131072
    • Required?: Probably - doesn't exist for map 80.
    • Description: Unknown.
    • Format: Subtile map with 2 byte entries. High byte of each entry is 0.
    • Notes: No idea what it does yet. On first map, seems to be very similar to the slab file (when you've changed the format and key) but the path to the North/North West of the dungeon heart is in the wrong place. All rooms seem to have a distinguishing byte or so in the bottom right corner. Could this be an old slab format?

    .


    Documentation creator: Tomasz Lis

    Used information provided by: Jon Skeet


    Version 1.1

    • Added more content; still much to do
    • Fixed .WLB explanation
    • Added position format explanation in object list files

    Version 1.0

    • First reference, by Tomasz Lis
    • Used materials from Jon Skeet's webpage

    1. Dungeon Keeper Mapmaker's Documentation
    2. Dungeon Keeper Script Commands Reference

    Clone this wiki locally