Skip to content

Economy and building

For creatorsAdd-on 2.2.2+

You build a two-base map where workers mine crystals, raise buildings and train new units. It builds on units and orders and combat.

▶ Play the base map

  • Select workers and right-click crystals to gather.
  • B, then a building’s key, to build: C Command HQ, D supply depot, R barracks, F factory. Click the ground to place it.
  • Select a building and press a unit’s key to train it: W worker, T trooper, K hover tank.
  • With a building selected, right-click to set its rally point. On crystals, new workers start gathering there.
  • The orders of tutorial 16 still apply.

Each side starts with a Command HQ, six workers and 100 crystals, with eight crystal nodes behind the HQ. The red side does nothing yet: the next tutorial gives it a computer player.

  1. Start from your map. Keep the ground, the rock and the camera from tutorial 15. Add two scene tags: rts.crystals = 100,100 (each team’s starting crystals) and rts.cap = 400 (the most units and buildings the map holds).

  2. Add the worker and the buildings to the unit table. A building is a unit that never moves: give it building: 1, a footprint in cells (foot) and a speed of 0. Copy the rows in The economy table below into data/units.json.

  3. Model them. Model a worker and the four buildings, and name them as the table’s model column says: Model_Worker, Model_HQ, Model_Depot, Model_Barracks, Model_Factory.

  4. Place the crystals. Model a crystal node and copy it eight times behind each base. Give each one Add Component ▸ Shooter & Strategy ▸ Crystal Node. Its rts.resource is the crystals it holds (500).

  5. Start each side. In data/start.json, give each team one hq and six worker rows near its crystals.

  6. Update the help lines. Change the HUD lines to the building and training keys.

  7. Press ▶ Play. Box-select your workers, right-click the crystals, then press B and D and click a clear spot. A worker walks over and a depot rises.

Row cost supply buildTime Notes
worker 50 1 8 s gather: 5 crystals a trip after mineTime: 2 s of mining
trooper 50 1 10 s
hover tank 150 3 20 s
Command HQ 400 60 s foot: "4,4", provides: 10 supply, produces: worker, dropoff: 1 (takes deliveries)
supply depot 100 20 s foot: "2,2", provides: 8 supply
barracks 150 30 s foot: "3,3", produces: trooper
factory 200 40 s foot: "3,3", produces: tank, requires: barracks

Give every row a hotkey (the key that builds or trains it) and an hp and sight, as in tutorial 16.

  • Buildings are units. They have a team, health and sight. You can select them, and enemies can target and destroy them. Their footprint is solid, so units walk round them, even one placed across a path. Armies fight units first, then buildings.
  • The worker’s round. A worker walks to a node, mines for two seconds, carries five crystals to the nearest finished HQ, and goes back. A node shrinks as it is mined and disappears when empty; its workers move on to the nearest node with crystals left. Workers on the job pass through each other, so a mining line never jams.
  • Building. The worker walks to the site, and the building is placed and paid for when it arrives. If the ground is no longer clear, or the crystals are gone, nothing is built and nothing is spent. The site rises from a pad in its team’s colour, and its health grows with the work, so a site under fire is fragile.
  • Training. A building queues up to five units. Cost and supply are charged when you queue. The unit appears beside the building when its time is up and walks to the rally point.
  • Supply. Finished buildings provide supply, up to 100. Living units and queued units use it.
  • Nothing is lost on a refusal. An order that can’t happen (rock, too few crystals, no barracks yet, full supply, a full queue) is refused at no cost.
  • The resource bar shows your crystals and supply.
  • Select workers and the card shows a button per building, with its cost and key. A button you can’t use yet is greyed; hover it for the reason, such as needs barracks.
  • Select one finished building and the card shows a button per unit it trains, its queue with the first unit’s progress, and its rally point.
  • Placing. A ghost of the building follows the cursor, snapped to the grid. It is green where every cell is free and you can afford it, and red where not. A click on red places nothing. The nearest selected worker takes the job.
Tag Values What it does
rts.crystals 100,100 Each team’s starting crystals
rts.cap default 400 The most units and buildings the map holds, including those trained later
rts.resource crystals, default 500 On a crystal node: what it holds

Next: a game against the computer.