Playing Random Maps
Random maps can now be played through the game setup, by choosing Random from the Match Type dropdown. See the Gameplay Manual for more details.
Guide to Random Map Scripting
Random map scripts are placed in the maps/random/ directory (see mod layout). In addition to the script itself, there is also an associated JSON data file. This file is loaded by game setup to recognize a new random map, and it includes various settings, see defining the map for details.
A random map script should first load any libraries it will need. Libraries are stored in the game data directories under maps/random/libraryName/. When a library is loaded, all scripts in that directory are parsed and their code made available to the random map script. They are loaded through the function call RMS.LoadLibrary(libraryName). Currently there is only one library available, rmgen - in the future there may be others or you can create your own.
Initialize the library
The next step is to initialize the library. This may vary, but for rmgen, you would call InitMap().
Save the results
The random map script should end with a call to RMS.ExportMap(data), which returns all the map data back to the engine. In rmgen this is abstracted by a call to ExportMap(). For the exact format of the data see Random Map Generator Internals.
Note: The export map function does a coordinate conversion from the 2D used in the rmgen libs to 3D for the engine. You should only use it once, only after the map is fully generated.
Design Tips and Conventions
- Place terrain over an area rather than a tile. Most times placing tiles only looks unnatural. In addition remember terrain from the same biome fits better to each other than tiles from different biomes.
- In a player's starting area, not many obstructions should be placed within a radius of 20 tiles, so the player has space to build a base there. Large clumps of trees can be problematic. Especially avoid placing very uneven terrain and water there. Remember that Iberians get walls as a civilization bonus which are placed by default with their starting entities and have roughly a radius of 20 tiles.
- A player's starting buildings should be rotated uniformly to face the player's initial camera view. A rotation of about -PI/4 on the Y-axis is standard. Starting units should be grouped together neatly.
- Placed entities (especially trees) shouldn't obstruct the player's initial view of their units and structures.
- Don't place entities outside the reachable map area (That causes problems with AIs).
- Match the aesthetics of hand-crafted scenarios as much as possible.
Here's a list of libraries currently included with the map generator: