Tile masks
Overlays take up many tiles. They can be single tiles, like heroes, or they can be complicated shapes, like mountain ranges. Some of these tiles block the hero. And, for interactive objects like mines or windmills, usually only 1 or 2 tiles is the "main" tile where the hero can actually interact.
These different kinds of tiles are represented by the tile masks. A tile mask is an 8x6 grid of 1s and 0s, saying which tiles of an overlay have certain attributes. Each overlay has 6 tile masks.
To see these masks in action, simply open the editor and turn on "Show Grid." When you place a map object, you'll see e . For example, here's one of the largest overlays, the Warlock castle.

You can see four kinds of highlighted cells:
- Black denotes the shadow cells. These cells are passable to the hero, and may overlap other objects. They may even extend off the edge of the map.
- Green denotes the "covered non-obstructed" tiles. These tiles are passable to the hero and map overlap other objects, but may not be placed off the edge of the map.
- Brown denotes the "normal" intersected tiles. They are not passable to the hero. Whether they can overlap other objects is complicated, and we haven't yet figured out all the details.
- And finally, orange denotes the interaction point(s). This is considered the "main" cell of the overlay, and is usually where the hero actually interacts with the object. This is also the tile where you can edit the object with the Cell Details tool.
As an example of these ideas in actions, here is the minimum island that you can place the Warlock castle on.

In the XML, all tile masks are represented by an 8x6 grid of 1's and 0's. For example:
<tiles>
00000000
00000100
00011111
00011111
00011111
00000000
</tiles>
Valid Terrains
The map format allows an overlay to specify what kinds of terrain it may be placed on. The data format allows an overlay to be placed on/forbidden on any subset of terrain types. However, in the actual data, all overlays are one of the following types: can only be placed on water, can only be placed on land, can be placed on any terrain.
Note that this concept only exists in the map editor; it is perfectly possible to hex-edit a map to make a town appear on water, and then visit it via boat. One user has demonstrated this: thread.
Here's an example of making an overlay placeable on any terrain except water:
<overlay ....>
....
<validTerrain>
TERRAIN_GRASS
</validTerrain>
<validTerrain>
TERRAIN_SNOW
</validTerrain>
<validTerrain>
TERRAIN_SWAMP
</validTerrain>
<validTerrain>
TERRAIN_LAVA
</validTerrain>
<validTerrain>
TERRAIN_DESERT
</validTerrain>
<validTerrain>
TERRAIN_DIRT
</validTerrain>
<validTerrain>
TERRAIN_WASTELAND
</validTerrain>
<validTerrain>
TERRAIN_SAND
</validTerrain>
...
</overlay>
The valid values of validTerrain are TERRAIN_WATER, TERRAIN_GRASS, TERRAIN_SNOW, TERRAIN_SWAMP, TERRAIN_LAVA, TERRAIN_DESERT, TERRAIN_DIRT, TERRAIN_WASTELAND, and TERRAIN_SAND. These correspond to the indices 0-8.
Note that the original overlay data actually contains bits for an additional three types of land terrain, indexed 9, 10, and 11. We inspected the map editor code and determined they don't do anything, so we deliberately dropped them from the map data.
Special Treatment of Map Objects
There is code throughout the map editor that gives special treatment to certain object types, and sometimes even to specific overlay indices. Here is an incomplete list:
- Towns, heroes, signs, events, sphinxes, and spell scrolls all have extra information associated with them called the "map extra," which can be edited using the Cell Details tool. The code for initializing these is in the PlaceOverlay function. See the reverse-engineered code.
- Castles/towns are actually 4 overlays: the castle/town itself, the two flags, and the terrain-specific mound they sit on. These will all be given the same "overlay link," so that they will be deleted as a unit with the Erase tool. The code for placing these extra overlays is in PlaceOverlay.
- There is a special exception that Alchemist Labs cannot be placed on the top row of the map. The code that handles this is in ValidOverlayPlacement.
Comments (0)
You don't have permission to comment on this page.