Using Advanced Edit
From OPU Wiki
In the OP2Mapper there is a little button on the map toolbar that many people probably won't notice. This is the Advanced Edit button, and looks like a pencil writing in a grid. This handy tool, if used correctly, can be a major aid in people designing new tiles or entire tilesets. This article will explain what it can do and what its applications are.
| Table of contents |
What exactly is a map?
A terrain map in most RTS games, is simply just a list of X-Y coordinates (called "tiles") on a game "map" and what type of terrain exists at each tile - sand, grass, water, mountains, etc. This type is usually some sort of numeric reference to the actual thing that describes the tile, in most games that "thing" is a small bitmap of the terrain. Some games might also include extra information with each tile, such as elevation, whether units can pass through it, etc.
In most games the entire possible set of tile bitmaps is known as a tileset. Most games use one tileset per map. For example, snow maps might load a single tileset called "Snow," which contains bitmaps for snow tiles. However, tiles like grass generally aren't available, because the grass colored bitmaps might reside in a different tileset called "Grass."
One way to represent a reference between a number in a map and an image in a tileset is through "indexing." What this means, is that the separate images in a tileset are laid out in a specific order and assigned a number. For example the first tile in a tileset might be assigned the number 1, the 2nd tile be assigned 2, etc. This way the numeric entries in the map tell the game to look for the image in the tileset assigned to that number. This is a fairly efficient and fast way to number the images in a tileset.
However, it doesn't work quite the same way in Outpost 2, which is explained next.
Why are OP2 maps different?
Outpost 2 handles tilesets a lot differently than most games. In Outpost 2, it's possible for a map file to load more than one tileset for it's images. The reason this creates a problem for "indexing" is because other games only have a single tileset per map. When the number (or "index") is used in the map, it can only refer to a single tile - the tile in the tileset with that unique number. However, in OP2, each tileset has its own set of index numbers for the contained bitmaps. So if you made the tile at position (1,1) equal to index 20, which tile 20 would it be if the map had multiple tilesets? The 20th tile in the first tileset? Or the 20th tile in the second tileset? Or something else?
Introducing Mappings
Well, the OP2 developers came up with a way to fix this. They designed the map file format so instead of the index numbers in the X-Y coordinate data referring directly to a tile in a single tileset, the numbers refer to entries in a list called the "Mapping Table." This table is part of the map file.
This mapping table contains a bunch of entries, much like a tileset does in most games. However, this table doesn't contain the images. The mapping table contains the information necessary to completely locate a specific tile in a specific tileset. It does this by assigning each tileset an ID number, as well as assigning each tile an ID number. So for example, for X-Y position (1,1) on the map, it might have an index number of 15. This tells the game to go look at the 15th entry in the mapping table, which is where the tileset ID, and the tile ID within that tileset are stored. Each entry in the mapping table is called a Mapping Index, or just mapping for short.
This should help describe how the game locates a specific tile in a tileset. This is necessary, because the official maps reference 13 tilesets!
So you should understand, that the X-Y information on the map DOES NOT directly reference a tileset ID and tile ID. It contains a number which tells the game what position in the mapping table holds a specific tile. This implies that to use a certain tile in a tileset on a map, an entry in the mapping table must be created for it.
Animations
However, there's more to the mapping table than just the tileset ID and tile ID. In OP2, it's also possible to have an animated tile. The frames in an animation in OP2 are stored as consecutive tile images in the tileset. The mapping table contains information, in addition to the tileset and starting tile ID, the number of frames in the animation, and the time delay (or cycle delay) between each frame of the animation. This system is used in the official maps to create the lava images. Each different "tile" of lava animation is a unique entry in the mapping table, with the extra data in the mapping table to tell the game how many frames the animation has.
You can use this animation support to create dynamic-looking maps and tilesets, with things such as waves in water, avalanches, etc.
Limitations of the Mapping Table / Why do we need an Advanced Editor?
The Mapping Table can only hold 2048 entries. So this places a limit on the maximum number of tiles that a single map may use. (The official maps contain 2012 mappings, so that only gives you 36 more mappings to use). So, we need a way to manipulate mappings and tilesets, to better utilize the limited amount of mappings available. This comes in the Advanced Editor in OP2Mapper.
The Advanced Editor allows you to:
- Add or remove tilesets from a map
- Create new mappings within a map
- Modify mappings, to make them reference a different tileset, tile, or to create or remove an animation
- View the structure of the mapping table and see what tilesets and tiles exist in a map
So now I'll explain how the Advanced Editor is used.
Using the Advanced Editor
To access the Advanced Editor, click the Advanced Edit button in the map window for the map you wish to edit on.
A "Loading..." message will appear briefly as it loads. Shortly after, the Advanced Edit screen will appear.
The editor can be divided into two parts: the left side which lists all the tilesets and mappings, and the right side which lets you see info and edit the selected item from the left.
There are also Add and Remove buttons at the bottom. The Add button allows you to add new tilesets into the map, either by adding a new tileset entry or by replacing an existing one.
Editing Existing Mappings
You can edit existing mappings to make them point to a different tileset and tile ID, or to add or remove animations. Some uses include making better utilization of mappings, for example several mappings that reference the same time could be changed to reference different tiles, or animations could be removed to make room for static tiles.
To do this, simply open the tree up and click the mapping which you want to change. A preview of what the mapping "does" in the game is shown, and fields are given for you to edit it. Simply edit the desired values then click the Save button.
Animations are created by setting the Number of Frames and the Delay to non zero values. (Note that the Number of Frames is really the number of frames after the first tile, for example a non animated tile will have a 0 zero, meaning there are 0 "extra" frames after the first one). The delay is specified in game ticks. (Approximately 10 ticks per second. Experiment to see what really happens)
(Note on animations: The only current way to place an animation on the map is to create a unique mapping for a static tile (this tile must only have ONE static mapping), draw the tile onto the map (it will use that mapping), then reenter the Advanced Editor and set that mapping to an animated tile. The animation will not animate on the map itself, but it will animate in game).
Adding Tilesets
New tilesets can be introduced into your map through the Add button at the bottom of the dialog. Pressing Add will pop up a menu to let you select how you want to add a new tileset. You can add a new tileset without affecting any existing sets, or you can replace an existing one. (The tileset being replaced and the new tileset must have the same number of tiles)
To do this click the appropriate option. In the case of replacing an existing one, highlight the one you wish to replace before clicking the Replace Existing option. A dialog will then pop up asking for the name of the tileset. Do not add .bmp at the end, this is handled automatically by the Mapper and OP2 itself. If you are adding a new tileset it will then ask if you want to create initial mappings. This is highly recommended if you wish to use most or all of the tiles in the map, because creating mappings manually is tedious. (Just be sure that the total number of tiles doesn't exceed 2048 by using this operation).
The tileset is then added to the list and you can use it from the editing tools like you would any other tileset.
When you replace a tileset in advanced edit, eg well0001 to grnwld01 the grnwld01 bmp must be in the outpost 2 directory when you do this edit. The well0001 bmp would be in the maps.vol as normal.
Adding Mappings
New mappings can be created manually as well, for creating animations, or if you only use a few tiles from a certain tileset. To do this, click on the Add button and select Mapping. A new one will be created in the tree, grouped under the first tileset. Edit its properties to change the mapping.
Closing
To exit the Advanced Editor, click the Close button on the dialog. The changes will take effect immediately.
Warnings and Hints
Changes made in the Advanced Editor cannot be undone, except by closing and reopening the map file without saving. There is no "undo" for the Advanced Editor, because it's a tool primarily for tileset developers and people who need to tweak the mapping table.
Also, at this time mappings cannot be deleted. Create mappings sparingly.
Some hints on keeping the number of entries in the mapping table lower:
- Avoid making multiple mappings to the same time (with the only exception being different mappings for still tiles and for animations).
- Avoid creating mappings that you won't absolutely need, since you can't easily remove them later. Judge whether you need a mapping, and only then go ahead and add it.
- If you are only using a few tiles from a tileset with many tiles, answer No to the question asking whether you want to create mappings, and then add the few mappings manually.
Mappings are a limited resource in an OP2 map, so that's why an Advanced Editor is needed, to control the usage of them, and to do specialized edits like animations, etc. However, it's also a powerful tool with the ability to easily damage your map if used incorrectly. Keep that in mind at all times.

