High Ground: Tactics Battle Maps with Cover, Ramps and Chokepoints
README.md
battleMapsKit — tactics battle maps with high ground, cover and chokepoints
Battle maps for turn-based grid tactics games. Eight hand-designed, fair (point-mirrored) boards with raised ground reached by ramps or stairs, half and full cover, and chokepoints — bridges over rivers, a one-plank-wide bridge with slow flank fords, gates in walls, knife-edge ridges, rope bridges over a chasm, a hilltop monastery — each dressable as seven different places, plus a seeded map generator that makes as many more fair boards as you want. One call gives you the map data; one more draws it as a painted diorama on every peer.
Version 1.1.0 (require("battleMapsKit.api").VERSION). This package was called battleMaps up to 1.0.3; it is the same published asset under a new name (see Upgrading from battleMaps).
- Map data stays tacticsKit-compatible (
cols,rows,cellSize,coverwithkind/q/r/rot/prop,spawns,objective), plusheights,blocked,bridges,fords,chokepoints. - Switching place or layout is one change:
BM.get(layout, setting). - Seeded generator:
BM.generate({ seed, setting, cols, rows, levels, chokepoint })— same seed, same map on every peer; every answer passesBM.checkandBM.isMirrored. - Runtime builder: draws the board from a module or component in play, deterministic, so every peer sees the same board.
quality = "low"for phones and tablets. - Helpers: the movement rule,
reach,path(optionally weighted: fords cost 2),check(validation), lighting suggestions. - No dependencies.
Quick start
local BM = require("battleMapsKit.api")
local map = BM.get("bridge", "snowPass") -- a fresh map table
assert(BM.check(map)) -- valid: walkable, fair, cover placed legally
local holder = entity.spawn("board", { temporary = true })
local board = BM.build(holder, map, { quality = "high" }) -- draw it here
BM.applyLighting(holder, "snowPass") -- optional: the setting's sky, sun and fog
print(map.name, #map.cover, board.cellTop(6, 5)) -- "Old Bridge (Snowy Mountain Pass)" 20 0
board.setCoverAlive(3, false) -- piece 3 is blown up: hidden, rubble shown
-- a generated board: same options, same map on every peer
local gen = BM.generate({ seed = 42, setting = "monastery", chokepoint = "bridge", rows = 13 })
print(gen.name) -- "Narrow Bridge Crossing #42 (Ruined Hill Monastery)"
Or with no code: add the BattleMap component (battleMapsKit.BattleMap) to an entity and pick layout and setting in its fields (layout = "generated" with seed, chokepoint, levels, cols, rows for a generated board; picker = true shows buttons to cycle them; defines = "myMaps" for a layout or setting of your own; ref:board() and ref:map() read back what it drew).
Layouts x settings
Every layout works in every setting (56 maps, all checked by the test suite).
| layout | name | size | levels | chokepoints |
|---|---|---|---|---|
bridge | Old Bridge | 14 x 12 | 0-2 | Old Bridge (2 wide, objective), North and South Footbridges |
gate | Broken Gate | 14 x 12 | 0-2 | West Gate, East Gate, North Breach, South Breach into a walled courtyard |
terraces | Terraced Hill | 14 x 14 | 0-3 | West and East Summit Stairs to the summit objective |
twinHills | Twin Hills | 14 x 12 | 0-2 | North and South Ridge (1-wide), West and East Saddle Ramps |
crossroads | Market Crossroads | 16 x 12 | 0-2 | four 1-cell stall gaps into the market square, two canal bridges |
canyon | Spire Canyon | 16 x 12 | 0-2 | West and East Rope Bridges to the spire, North and South Pass |
monastery | Hill Monastery | 14 x 14 | 0-3 | a central hill: garden stairs to the cloister terrace, stairs to the bell tower ring, one stair a side to the summit objective |
narrowBridge | Narrow Bridge | 14 x 13 | 0-2 | Narrow Bridge: a 4-long, 1-wide bridge over a deep river, the only quick crossing (objective); North and South Fords at the far flanks are slow (cost 2) and open |
All have 6 spawns a side (west and east), an objective zone, ramps or stairs to every raised area, and 20-26 cover pieces mixing half and full cover. On narrowBridge the shortest walk between the armies goes over the bridge, one cell wide: BM.path crosses on its deck cells and the test suite checks it.
| setting | place | ramps | props | cover props (half / full) | light |
|---|---|---|---|---|---|
ruins | Jungle Ruins | stone stairs | 11 | broken column, rubble heap, offering urns, fallen column, altar slab, crouching jaguar statue / crumbling temple wall, standing column, toppled idol head, serpent stele, vine-choked archway | warm afternoon |
snowPass | Snowy Mountain Pass | packed-snow ramps | 12 | ice boulder, spruce stump, broken sled, frozen supply sled, snowy log pile, frozen ore cart, avalanche debris / snowbank wall, stone cairn, ice spire, frozen icefall, prayer-flag windbreak | pink dawn |
riverVillage | River Village | timber stairs | 11 | haystack, village well, cider barrels, hand cart, woodpile lean-to, pump and water trough / dry-stone wall, market crate stack, thatched cottage, awning market stall, stone dovecote | bright noon |
forest | Misty Forest | dirt ramps | 11 | mossy boulder, mushroom stump, bramble thicket, fallen log, fern bank, woodcutter's stack / log palisade, split giant trunk, mossy outcrop, upturned root wall, hunters' blind | misty morning |
desert | Desert Oasis | sandstone stairs | 11 | clay pots, draped trade crates, half-buried rock, caravan wagon, camel saddle packs, sandstone cistern / mudbrick wall, sandstone hoodoo, layered mesa rock, broken obelisk, nomad tent | golden sunset |
outpost | Frontier Outpost (sci-fi) | hazard-striped metal ramps | 11 | cargo crates, fuel drums, jersey barriers, supply lockers, knocked-out sentry turret / barrier panels, antenna pylon, coolant tank, fusion generator, crashed drop pod, hard-light shield emitter | night, floodlamps |
monastery | Ruined Hill Monastery | limestone stairs | 11 | leaning headstones, fallen bronze bell, cloister wellhead, monks' beehives, terraced herb bed, abbot's sarcophagus / cloister wall, broken cloister arch, bell tower stump, wayside shrine, cypress planter | lilac storm-light, mid-afternoon |
Every prop of every setting is placed somewhere by the shipped layouts (the prop rotation continues from one layout to the next; the test suite checks it). The monastery surround has cypresses, olive trees, lavender and roofless chapel ruins; its raised ground is paved in limestone flags.
The seeded generator
local map = BM.generate({
seed = 42, -- number or string; same options = same map on every peer
setting = "forest", -- any setting id (default "ruins")
cols = 14, rows = 13, -- 12-20 (even) x 10-16 (default 14 x 12)
levels = 2, -- highest ground, 1-3 (default 2)
chokepoint = "bridge", -- "bridge" | "gate" | "pass" | "random" (default: picked from the seed)
cover = 12, -- optional: west-side cover pieces to place (default 10-13)
fords = true, -- bridge only: flank fords on an odd row count (default true)
chasm = nil, -- bridge only: true = a chasm, false = a river, nil = seed decides (30% chasm)
})
- bridge: a river (or chasm) down the middle. On an odd row count one central bridge, one cell wide, is the only quick crossing, with slow fords at the far flanks; on an even count two 1-wide bridges. Terraced hills on each bank.
- gate: a walled courtyard on a mound; a stair gate in each side wall (and sometimes a breach), a dais on top when
levels >= 2. - pass: a rock ridge down the middle cut by a narrow pass (one cell on an odd row count); the ridge tops are reached by ramps from shoulders.
The answer is a map in the same format as BM.get, plus seed, chokepoint and generated (the options used); its id is gen_<chokepoint>_<seed>_<cols>x<rows>_<setting> and layout is "generated". It is point-mirrored, has raised ground reached by ramps or stairs, half and full cover (more of it near the chokepoints), six spawns a side and an objective at the chokepoint; it always passes BM.check and BM.isMirrored (a candidate that fails is thrown away and the next attempt tried; the suite checks 600 seeds across sizes, levels and chokepoints). Only a seeded generator decides it, so peers that pass the same options draw the same board.
The map data format
BM.get(layoutId, settingId) returns a new table each call:
| field | meaning |
|---|---|
id | "<layout>_<setting>" |
name, blurb | display name and an evocative one-liner |
layout, setting, layoutName, settingName | where it came from |
cols, rows | grid size; cells are q = 0..cols-1, r = 0..rows-1 |
cellSize | 2 (metres) |
levelHeight | 1.0 (metres per level) |
holdTurns | 3 |
maxLevel | highest level on the map |
heights | heights[r+1][q+1]: an integer is flat ground at that level; X.5 is a ramp / stairs cell between level X and X+1 |
blocked | { {q=,r=}, ... } impassable but see-through cells (water or chasm); their height reads 0 |
water, chasm | the blocked cells split by what they are |
bridges | { {q=,r=}, ... } walkable deck cells drawn over water or a chasm |
fords | { {q=,r=}, ... } walkable shallow water at level 0 with stepping stones; BM.moveCost answers 2 for them |
cover | { kind, q, r, rot, prop, variant, scale, yaw }; kind is tacticsKit's: wall (1 cell, full), wall2/wall3 (2/3 cells along +q, full), block (2x2, full), low (1 cell, half), low2 (2 cells along +q, half). rot n turns the footprint 90° n times, (dq,dr) -> (-dr,dq) per step (the same as tacticsKit Maps.cells). prop is the setting's prop id. Full cover is about 1.6 m, half about 0.8 m. |
spawns | { west = 6 x {q,r}, east = 6 x {q,r} } as a two-entry list; entry i of each side are mirror twins |
objective | { cells = { {q,r}, ... } } |
chokepoints | { {q=, r=, name="Old Bridge", kind=?}, ... } (kind is "bridge", "ford", "gate" or "pass" where the layout says) |
The movement rule
Two orthogonally adjacent cells connect when neither is blocked and |h1 − h2| ≤ 0.5. So a ramp cell (X.5) links level X and level X+1, and a step of 1 or more is a cliff. Cover is not part of the rule (your game decides whether units pass through it); reach and path treat cover cells as solid unless ignoreCover = true. Entering a ford costs 2 movement points (BM.moveCost); reach and path count steps unless weighted = true, when they count movement points.
API (require("battleMapsKit.api"))
| call | does |
|---|---|
BM.SETTINGS, BM.LAYOUTS | id lists |
BM.get(layout, setting) | a fresh map definition |
BM.generate(opts) | a seeded, generated map (above) |
BM.all() | every { layout, setting } pair |
BM.check(map) -> ok, err | on the board, no cover on cover / spawns / ramps / blocked / objective cells, every ramp joins its two levels, every spawn walks to the objective and the enemy spawns, every open cell (every raised area) reachable |
BM.isMirrored(map) -> ok, err | point-mirror fairness check (heights, blocked cells, fords, cover heights, spawn counts) |
BM.heightAt(map,q,r), BM.isRamp, BM.isBlocked, BM.isBridge, BM.isFord, BM.onBoard, BM.surfaceY | queries |
BM.canStep(map,q1,r1,q2,r2) | the movement rule |
BM.moveCost(map,q,r) | movement points to enter a cell: 2 for a ford, else 1 |
BM.reach(map,q,r,{maxSteps,ignoreCover,occupied,weighted}) -> {["q,r"]=cost} | flood fill |
BM.path(map,aq,ar,bq,br,{ignoreCover,weighted}) -> {{q,r},...}? | shortest (or cheapest) walk |
BM.rampDir(map,q,r) -> dq,dr | which way a ramp climbs |
BM.cells(cover), BM.FOOTPRINTS, BM.FULL | cover footprints |
BM.propsFor(setting, kind), BM.setting(id), BM.layout(id) | catalogue |
BM.defineLayout(id, def), BM.defineSetting(id, def, base?) | add your own (see the layouts module README for the half-grid format) |
BM.expand(def, id, setting, propSeed?) | expand a half-grid layout table into a map without registering it |
BM.lightingFor(setting) | { timeOfDay, sunColor, sunIntensity, fogColor, fogDensity, ambient, sunDirection, zenith, horizon, lamps } |
BM.applyLighting(parent, setting, opts) -> { root, destroy } | spawns that sky, sun, ambient and fog (opts fog = false, ambientScale) |
BM.build(parent, map, opts) -> handle | draws the board (below) |
BM.build(parent, map, opts)
opts: cellToLocal = function(q, r) -> (x, z) (default x = (q-(cols-1)/2)*cellSize, z = (r-(rows-1)/2)*cellSize, any affine grid works), quality = "high" | "low", drawCover = true | false, temporary = true (default) , y (base height), name.
The handle: root (entity), cover = { [coverIndex] = entity } (each piece its own entity standing on its cell top), setCoverAlive(i, alive) (hides a destroyed piece and shows rubble), isCoverAlive(i), cellTop(q, r) -> local y, cellCenter(q, r) -> x, y, z, stats (triangles, terrainDraws, lights), destroy().
What it draws: cell tops at heights * levelHeight (grass, snow, sand, flagstones or deck plates per setting, with a faint checker so the grid reads), cliff faces with strata and a ground lip, ramps or stairs climbing toward the higher neighbour, water with lily pads / ice floes or a deep chasm under blocked cells (rivers and rifts run on off the board), fords as shallow water over a pebble bed with stepping stones, bridges (stone, timber, metal, or rope over a chasm), the cover props, and a surround of the setting's land (trees, ruins, cottages, palms, domes, lamps, cypresses and chapel ruins...) cut out as a diorama plinth. Terrain is a few merged, vertex-coloured meshes (about 2-6 draws); a high-quality board is about 17-30k triangles and builds in under 0.2 s; low drops ground detail, most scenery and extra lights.
Multiplayer: build is deterministic from the map data, so give every peer the same layout/setting (or the same generator options) — the BattleMap component's fields sync; for a layout or setting of your own set its defines field to the module that defines it, so every peer requires it — and each draws the same board locally with temporary entities.
What is in the package
| part | what |
|---|---|
battleMapsKit.api | the API above |
battleMapsKit.layouts | the eight layouts as data |
battleMapsKit.settings | the seven settings: palettes, materials, props, scatter, lighting |
battleMapsKit.props | every cover prop and scenery piece, modelled in code |
battleMapsKit.generate | the seeded map generator behind BM.generate |
battleMapsKit.board | the runtime builder and the lighting helper |
battleMapsKit.geo | flat-shaded vertex-coloured mesh builder |
battleMapsKit.BattleMap component | a board on an entity, with an optional layout/setting picker and generated boards |
battleMapsKit test suite | 17 tests: all 56 maps valid and fair, every prop used, the narrow bridge, the monastery, 600 generated maps valid, fair and deterministic, rule, helpers, component, runtime build |
| guides | "How to add battle maps with high ground, cover and chokepoints to a tactics game" (with the map generator), "Example: build a snowy mountain pass skirmish map with a bridge chokepoint" |
Using it with tacticsKit
The map tables carry every field tacticsKit's Maps.define reads. Cover prop ids name battleMapsKit props, so draw the board with BM.build(..., { cellToLocal = <your grid's cell centre> }) and keep tacticsKit's own cover drawing off, or pass drawCover = false and let your game draw cover. When a blast destroys half cover, call board.setCoverAlive(i, false). Fords are ordinary walkable level-0 cells to tacticsKit; charge BM.moveCost if your game counts movement points.
Upgrading from battleMaps
1.1.0 renames the package from battleMaps to battleMapsKit. It is the same ZeroMind asset (same guid), so updating the install brings the new name. Change your requires and component names:
| before (1.0.x) | now (1.1.0) |
|---|---|
require("battleMaps.api") | require("battleMapsKit.api") |
require("battleMaps.layouts") / .settings / .props / .board / .geo | require("battleMapsKit.layouts") / .settings / .props / .board / .geo |
component battleMaps.BattleMap | battleMapsKit.BattleMap ("BattleMap" still works where the name is unambiguous) |
The API, the map data format and every existing layout and setting are unchanged; existing maps keep their shape, spawns and cover cells (some pieces are now dressed with one of the new props).
Changelog
- 1.1.0 — renamed
battleMaps->battleMapsKit(same asset). Newmonasterysetting (Ruined Hill Monastery: limestone cloister ruins, cypresses, lilac storm-light) andmonasterylayout (Hill Monastery: a central hill reached by stairs). NewnarrowBridgelayout: a one-cell-wide bridge as the main crossing with slow flank fords. Fords (fin the half-grid,map.fords,BM.isFord,BM.moveCost, weightedreach/path). Seeded generatorBM.generate(bridge / gate / pass chokepoints) andlayout = "generated"on theBattleMapcomponent. 27 new cover props: every setting has 10+ props, each placed by the layouts.BM.expand. Test suite 11 -> 17 tests. - 1.0.3 — text only: corrects what 1.0.2 said about custom layouts without
defines. On a freshly opened engine arequireat the top of a scene build runs after the component's first draw, so the board logsunknown layoutonce and then appears; it is not left empty.definesremoves that warning, and is needed when nothing else requires the module. - 1.0.2 —
BattleMapgets adefinesfield (the module defining your own layouts or settings, required by the component on every peer before it draws);:board()and:map()are now real methods on the component ref; the example guide makes its scene playerless so Play works, and usesdefines. - 1.0.1 — first full release: docs, guides, test suite and demo; same API as 1.0.0.
- 1.0.0 — first release: 6 layouts x 6 settings, movement rule and helpers,
check, runtime diorama builder with low quality, per-piece cover entities with destroyed state, lighting suggestions and helper,BattleMapcomponent, test suite, two guides.