Introduction

Pressing Tab in the game opens the hub, and its first page is the map: a plan of the floor you are on, your position and the way you face, the icons of doors, terminals and pickups, and where your objectives are. The game's own levels each come with their map drawn. A level you make has none - until you give it one.

Utilities → Generate Map Assets makes the map from your level's walk mesh: it finds the floors, draws each one in the game's map style, writes the movies the hub shows into the level's own UI folder, and sets the map anchor, a floor change per floor and every map item's floor in your level's script. Launch the level through OpenCAGE and the map is there.

How the Tab Map Works

The hub (DATA/UI/HUB.GFX) loads the map page (HUB_MAP.GFX), and the map page loads one small movie per floor - in the game's levels DATA/UI/MAPS/<floor>.GFX, named after the floor's map keyframe (Tech_Hub_1, Sci_Hub_2 ...). A floor movie holds the floor's plan as vector outlines and a startmarker_mc: the point every position on the map is measured from.

The Map Anchor

A level has one MapAnchor, triggered as the level starts. It lists the level's floors (keyframe to keyframe5, six at most) and says how the world lies on the map:

  • world_pos - linked to a PositionMarker: the world point drawn at the floor movie's start marker.
  • map_north - the world direction drawn as up (default 0,0,1).
  • map_scale - how big the level is drawn. At 1, one map screen (960 × 540) covers 240 m across and 140 m up and down; the game's levels use 0.72 to 2.7.

A world point lands on the floor movie at the start marker plus (-dot(P - W, B) × scale / 240 × 960, -dot(P - W, N) × scale / 140 × 540), with N north and B = (-N.z, 0, N.x): with north (0,0,1), +x is right and +z is up. The player's arrow, the map items and the objective markers all go through this, so the floor plans must be drawn with the same numbers - which is why the generator draws them and sets the anchor together.

Floors

The map opens on the floor the player is on. The game's levels say which that is with Map_Floor_Change entities (floor_name = one of the anchor's keyframes) fired by PlayerTriggerBoxes covering each deck. In the map, the player can also flip to another floor.

Map Items and Objectives

The icons on the map come from MapItem entities inside the game's composites - doors (locked, unlocked, powered down), hacking and rewire panels, save points, terminals, ladders, containers, weapons, tools and keycards. A map item is only drawn on the floor whose keyframe equals its map_keyframe, which each placed instance sets (the composite passes it down to its MapItem). An item with the wrong map_keyframe shows on another floor, or on none.

Objective markers come from SetSubObjective's target_position (and its objective_type: a point or a small, medium or large area). They are shown on whichever floor is open, at their position.

Borrowed Keyframes

The game only opens a map for a keyframe on its own list (in its global item database), so a level can't name new ones. The generator borrows the game's: RnD_HzdLab_1 for the first floor, then RnD_HzdLab_2, And_Lab_0, And_Lab_1, And_Lab_2, And_Lab_3. Only your level shows its map under them - the game's levels keep their own maps. RnD_HzdLab_1 is also what every map item starts with, so ground floor items need nothing.

Generating the Map

Save and Build your level once first (the map is drawn from its walk mesh), then open Utilities → Generate Map Assets.

  1. The floors it found are listed with the heights they split at and the keyframe each borrows. Name them as the map should say (LOWER DECK, MEDICAL ...), and move their heights if a floor has taken too much or too little; Add Floor and Remove Floor change how many there are. The heights split the walkable area at Above and Up to, and each part goes on the floor above whatever it covers (see Finding the Floors).
  2. Set Map scale (0 picks one so most of the level fits a map screen) and the Map name shown over the map (your level's name by default).
  3. Add Labels if you want room names on the map: one per line, name, x, z (a world position), and the floor's name after them when the name belongs on an upper floor. They are drawn in capitals, as the game's maps are.
  4. Press Preview and pick a floor: it is drawn as the map page shows it, the white frame one map screen.
  5. Press Generate. The files are written, the script changes are one step on the undo history, and a second Generate replaces the first.
  6. Save the level.

Finding the Floors

Only what the player can walk to is drawn: the biggest connected part of the walk mesh, following its links (ladders and drops included). The tops of furniture, roofs and sealed-off islands are left out, and so is the alien's vent network (the walk mesh's backstage area and the links into it, which only the alien uses). The floor heights are where most of that area is, at least 2.4 m apart and each with at least 5% of it; each takes the heights up to halfway to the next.

The heights split the walkable area into parts, and each part goes on a floor by its shape. A level part (a deck, a mezzanine, a storey) goes on its heights' floor - or, if it lies 2 m or more over another part across enough of it, on the floor above that one. A sloping or uneven part (a hillside, a ramp, rough ground) goes on the lowest floor beside it, never higher than its heights' floor, and so does a small level patch that covers nothing (a step, a crate top). So ground at any height stays on the ground floor, and a mezzanine inside a hall goes upstairs with the rest of the upper floor. A floor nothing ends up on is left out. Map items go on the floor of the walk mesh they stand on.

Each floor is drawn from its walk mesh: filled in, small holes (furniture, pillars) closed, grown out to about where the walls are, traced, and squared to its walls - edges close to the walls' directions made exactly parallel to them, small steps and notches straightened and cut corners made square, so the outlines are straight lines - in the game's teal plan with a hairline outline, with the floor above it drawn faintly, so you can see where the next level is.

What It Writes

Into the level's UI folder (DATA/ENV/<level>/UI):

  • HUB.GFX - the game's own hub, from your install, loading its map page from the level's files. It is one of the level's own UI movies.
  • FILES/HUB_MAP.GFX - the game's own map page, loading its floors from the level's files and showing your map and floor names.
  • FILES/<KEYFRAME>.GFX - one movie per floor.

Launching the level through OpenCAGE puts the movies in the level's UI/FILES folder into UI.PAK as OpenCAGE's own entries (DATA/UI/LV/...) along with the level's own UI movies, and takes them out again when the game closes - as it does the movies themselves. The Mod Manager looks past them, and they travel with the level.

Into the root composite, on a flowgraph page called Map: MapAssets_Anchor and MapAssets_AnchorPos, MapAssets_Start (a ThinkOnce that triggers the anchor), and per floor MapAssets_Floor_N (a Map_Floor_Change) fired by MapAssets_FloorBox_N_M (PlayerTriggerBoxes covering the floor in 20 m squares - in game a bigger box doesn't fire everywhere inside it - each from the floor's lowest walkable height there to its highest; where two floors share a square they split its height between them, in smaller squares where they need to, so no box reaches into another floor). And every map item's map_keyframe, set to the floor it stands on. A map item inside a composite placed on more than one floor shares one setting, so each placement gets its own through an alias in the root composite (named MapAssets_ and the item's name).

Level Check

Level Check finds map items on the wrong floor: a map item whose map_keyframe is not the floor it stands on, by the level's map anchor and its floor boxes - one you placed after generating the map, say. Its fix sets the item's map_keyframe (per placement, by an alias, when its composite is placed on more than one floor); generating the map again sets them all.

Testing in Game

Launch the level with Launch Game and press Tab: the map opens on your floor, centred on your arrow. Walk onto another floor and it opens there (a debug teleport far across the level may not switch it - walking does); in the map, the floor key flips between floors. Your objectives' markers sit where their target positions are. A level started any other way (from Steam, say) has the game's own hub and no map.

For AI Assistants

An AI assistant connected to OpenCAGE makes the map with generate_map_assets (floors as {name, from, to}, scale, map_name, labels as {text, x, z, floor}; dry_run returns the floors, keyframes, anchor, files and map items without changing anything) and checks the map items with check_map_items. check_level and fix_level_check report and fix the Level Check finding above.