War3map.w3e - Terrain
This is the tileset file. It contains all the data about the tilesets of the map. Let’s say the map is divided into squares called “tiles”. Each tile has 4 corners. In 3D, we define surfaces using points and in this case tiles are defined by their corners. I call one tile corner a “tilepoint”. So if you want a 256x256 map, you’ll have 257x257 tilepoints. That’s also why a tile texture is defined by each of its four tilepoints. A tile can be half dirt, one quarter grass and one quarter rock for example. The first tilepoint defined in the file stands for the lower left corner of the map when looking from the top, then it goes row by row. Tilesets are the group of textures used for the ground.
Format
Here is the file format:
char[4] magic_number int32 format_version char main_tileset int32 uses_custom_tileset int32 ground_tilesets char[4][a] ground_tileset_ids int32 cliff_tilesets char[4][b] cliff_tilesets_ids int32 width int32 height float horizontal_offset float vertical_offset
Then width * height tilepoints, each 7 bytes long:
int16 ground_height int16 water_height + boundary_flag 4bits flags 4bits ground_texture 5bits ground_variation 3bits cliff_variation 4bits cliff_texture 4bits layer_height
Explanation
char[4] magic_number
The constant string “W3E!” at the start of the war3map.w3e file used to identify it.
int32 format_version
The version. Seems to always be 11? Needs more investigation
char main_tileset
This is the main tileset for the map. Each tileset has an .mpq in the game mpqs which contains some specific textures for this tileset like water or cliff textures. It can be one of the following:
- A Ashenvale
- B Barrens
- C Felwood
- D Dungeon
- F Lordaeron Fall
- G Underground
- L Lordaeron Summer
- N Northrend
- Q Village Fall
- V Village
- W Lordaeron Winter
- X Dalaran
- Y Cityscape
- Z Sunken Ruins
- I Icecrown
- J Dalaran Ruins
- O Outland
- K Black Citadel
int32 uses_custom_tileset
Indicates whether this map uses a combination of textures from different tilesets or a predefined one from the list above.
(1 = custom tileset, 0 = no custom tileset)
int32 ground_tilesets
Indicates how many ground textures there are. There is no maximum except that a tilepoint only allocates 4 bits and thus can save only 16 different values and so only the first 16 tilesets are usable.
char[a][4] ground_tileset_ids
A list of strings of size 4. Example: “Ldrt” stands for “Lordaeron Summer Dirt”
Refer to “TerrainArt.slk” located in War3.mpq or War3x.mpq for more details.
int32 cliff_tilesets
Indicates how many cliff textures there are. There is no maximum except that a tilepoint only allocates 4 bits and thus can save only 16 different values and so only the first 16 cliffs are usable.
Note that while the tilepoints allocate 4 bits for which cliff_tilesets_ids to use, the value 15 is reserved for an unknown. This means that while y