Adding Map Overlays


 

 

 

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:

 

 

 

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_WATERTERRAIN_GRASSTERRAIN_SNOWTERRAIN_SWAMPTERRAIN_LAVATERRAIN_DESERTTERRAIN_DIRTTERRAIN_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: