Changes between Version 5 and Version 6 of Random_Map_Generator_Internals


Ignore:
Timestamp:
Apr 17, 2011, 12:17:18 AM (13 years ago)
Author:
historic_bruno
Comment:

Updated to match new map format

Legend:

Unmodified
Added
Removed
Modified
  • Random_Map_Generator_Internals

    v5 v6  
    55When 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.
    66
    7 The CMapGenerator provides a few things for the random map scripts. One is a global variable `g_MapSettings` which specifies all the map settings as created by game setup. CMapGenerator also exposes two JavaScript functions: `RMS.LoadLibrary(name)` and `RMS.ExportMap(data)`. `LoadLibrary` is used for choosing the API to which a random map script will have access. `ExportMap` is used to return generated map data from the scripts to the engine.
     7== Engine-script interface ==
     8
     9The CMapGenerator provides a minimal interface to the random map scripts. One is a global variable `g_MapSettings` which specifies all the map settings as created by game setup. CMapGenerator also exposes some JavaScript functions:
     10 * `RMS.LoadLibrary(name)` - load a library, choosing the API to which a random map script will have access, e.g. "rmgen".
     11 * `RMS.ExportMap(data)` - return generated map data from the scripts to the engine.
     12 * `RMS.SetProgress(percent)` - set the map generation progress percentage, so the loading screen progress bar can be updated. Percentage must be an integer 1-100.
     13 * `RMS.MaybeGC()` - possibly run the garbage collector.
    814
    915== Data format ==
     
    1521  "seaLevel": 20.0,
    1622  "textureNames": [ "medit_grass_field_a", ... ]
    17   "tileData": [ { "texIdx1" : 0x0001, "texIdx2" : 0xFFFF, "priority" : 0 }, ... ]
    18   "entities": [ { "id" : 100, "name" : "units/hele_support_female_citizen", "x" : 102.4, "y" : 64.8, "angle" : 0.86, "isActor" : false}, ... ]
     23  "tileData": [ { "idx" : 0x0001, "priority" : 0 }, ... ]
     24  "entities": [ { "id" : 100, "name" : "units/hele_support_female_citizen", "x" : 102.4, "z" : 64.8, "angle" : 0.86}, ... ]
    1925}
    2026}}}
     
    2329 * `seaLevel`: Float. This is the height of the sea, the value in the heightmap for which all lower terrain will be under water.
    2430 * `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).
    25  * `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.
     31 * `tileData`: Array of tile descriptor objects. Tile descriptors reference the terrain texture(s) for a given tile.
    2632 * `entities`: Array of entity objects. Entities specify something like a tree, unit, or building in the game.
    2733
    28 Tile descriptor format:
     34=== Tile descriptor format ===
    2935{{{
    3036{
    31   "texIdx1" : 8,
    32   "texIdx2" : 2,
     37  "idx" : 8,
    3338  "priority" : 0
    3439}
    3540}}}
    36  * `texIdx1`: Integer. Primary texture to be used (value is referenced from `textureNames` array).
    37  * `texIdx2`: Integer. Optional secondary texture to be used (value of 0xFFFF for none).
    38  * `priority`: Integer. Optional priority for texture blending (value of 0 is default). TODO: Explain how this works.
     41 * `idx`: Integer. Texture ID to be used (value is referenced from `textureNames` array).
     42 * `priority`: Integer. Optional priority for texture blending (value of 0 is default). Considering adjacent tiles, the texture with higher priority will be blended on top of the tiles with lower priorities.
    3943
    40 Entity format:
     44=== Entity format ===
    4145{{{
    4246  "id": 1034,
    4347  "name": "units/hele_support_female_citizen",
    4448  "x": 102.4,
    45   "y": 64.8,
    46   "angle": 0.86,
    47   "isActor": false
     49  "z": 64.8,
     50  "angle": 0.86
    4851}}}
    4952 * `id`: Integer. Unique ID of this entity, used by the engine to identify each instance.
    5053 * `name`: String. Template name of the entity, usually specifies faction and unit/building type for players, or special gaia templates.
    51  * `x`, `y`: Float. Position of the entity on the map (in tiles).
    52  * `angle`: Float. Rotation of the entity about y-axis.
    53  * `isActor`: Bool. This flags tells the map reader whether this entity is an actor or not.
     54 * `x`, `z`: Float. Position of the entity on the map (in XZ map coordinates; 4.0 map units = 1.0 tile unit).
     55 * `angle`: Float. Rotation of the entity about y-axis (vertical), in radians.
    5456
    5557CMapReader is responsible for parsing this data and creating the map, in a process very similar to that for scenarios.