5 | | When loading a scenario, the CMapReader class simply reads an XML file (with map settings, list of entities, and other textual data) together with a binary file called a PMP (which specifies height map and terrain textures). For a random map, there is obviously no predefined map to read. Instead, the engine uses a new CMapGenerator class. The CMapGenerator needs the name of a random map script and some settings, such as number of players and their civs. These are selected during game setup. |
| 5 | When loading a scenario, the CMapReader class simply reads an XML file (with map settings, list of entities, and other textual data) together with a binary file called a PMP (which specifies height map and terrain textures). For a random map, there is obviously no predefined map data to load. Instead, the engine uses a new CMapGenerator class. The CMapGenerator needs the name of a random map script and some settings, such as number of players and their civs. These are selected during game setup. |
23 | | * `textureNames`: Flat array of strings. This is the terrain textures used. They must be in the order in which they were defined (as they are referenced by tile data). |
24 | | * `tileData`: Flat array of tile descriptors. Tile descriptors reference the terrain textures for a given tile and an optional priority for blending. The array must be arranged in patches, there are 16 tiles per patch. |
25 | | * `entities`: Flat array of entities. |
| 23 | * `textureNames`: Array of strings. This is the terrain textures used. They must be in the order in which they were defined (as they are referenced by tile data). |
| 24 | * `tileData`: Array of tile descriptor objects. Tile descriptors reference the terrain texture(s) for a given tile. The array must be arranged in patches; there are 16 tiles per patch. |
| 25 | * `entities`: Array of entity objects. Entities specify something like a tree, unit, or building in the game. |
| 26 | |
| 27 | Tile descriptor format: |
| 28 | {{{ |
| 29 | { |
| 30 | "texIdx1" : 8, |
| 31 | "texIdx2" : 2, |
| 32 | "priority" : 0 |
| 33 | } |
| 34 | }}} |
| 35 | * `texIdx1`: Integer. Primary texture to be used (value is referenced from `textureNames` array). |
| 36 | * `texIdx2`: Integer. Optional secondary texture to be used (value of 0xFFFF for none). |
| 37 | * `priority`: Integer. Optional priority for texture blending (value of 0 is default). TODO: Explain how this works. |
| 38 | |
| 39 | Entity format: |
| 40 | {{{ |
| 41 | "id": 1034, |
| 42 | "name": "units/hele_support_female_citizen", |
| 43 | "x": 102.4, |
| 44 | "y": 64.8, |
| 45 | "angle": 0.86, |
| 46 | "isActor": false |
| 47 | }}} |
| 48 | * `id`: Integer. Unique ID of this entity, used by the engine to identify each instance. |
| 49 | * `name`: String. Template name of the entity, usually specifies faction and unit/building type for players, or special gaia templates. |
| 50 | * `x`, `y`: Float. Position of the entity on the map (in tiles). |
| 51 | * `angle`: Float. Rotation of the entity about y-axis. |
| 52 | * `isActor`: Bool. This flags tells the map reader whether this entity is an actor or not. |