Log inGet started
World

Field Command: RTS Selection, Formations, Fog of War and AI Opponents Kit

Merged

rtsKit 1.0.22: workers construct barracks and town halls (player + computer)

#1
Author
claude-code @ auraAgent
Opened
Nov 3, 2026
From
contrib-01m6gx5t
Into
main
Merged
Nov 10, 2026

Why: the kit had no way to build anything during a match. Both guides place the town hall AND the barracks up front with FC.structure, and nothing in rtsKit, productionKit or buildPlaceKit lets a worker construct a building. A skirmish that starts the classic way (a town hall and a few workers, build your barracks) could not be made with the kit. This adds construction as a first-class worker order, for players and computer opponents, following the kit's host-authoritative design.

What changed:

  • production.module: ROLES gain cost/buildTime/depth/hotkey/glyph (barracks 150g+100w, 25 s of work; town hall 350g+150w, 45 s). New P.buildable(), P.setBuild(role, {cost, buildTime}), and the host-side P.build(sim, team, cmd, ctx). P.build checks the sender's workers, a clear spot in bounds (sim:canPlace) and the cost (all-or-nothing Bank.debit, refunded if the building cannot be placed). It then places the real productionKit building sunk below ground as a site and orders the workers to build it. trainerOf and P.train refuse unfinished buildings (code underConstruction).
  • sim.module: a new 'build' order (workers walk to the edge and each add their own work, so two build twice as fast; others ignore it). Also: Sim:canPlace(radius, x, z, bounds), Sim:clearFootprint(s), structures carry constructing/buildTime/progress, unfinished drop-offs take no deliveries, unfinished buildings see less, and a 'built' event fires. A worker taken off gathering resumes it when the building is up.
  • Match.component: a synced 'sites' line (entity id -> 0..1). The host handles op 'build' through Production.build and raises each unfinished building out of the ground as work adds up. addStructureFrom restores progress from 'sites' after host migration.
  • Structure.component: constructing and buildTime fields.
  • net.module: Net.clean keeps 'role' and 'yaw'.
  • ai.module: a 'build' branch in the commander tree. It lays a barracks by the base, facing the enemy, at the first clear spot, when it has none and can pay; keeps two workers on any unfinished building; and saves for the barracks before training more workers. AI:siteFor, AI:build and AI:afford can be swapped out via opts.build/opts.afford for tests.
  • Commander.component: B / T hotkeys and command-card buttons for workers; a green/red placement ghost; Shift keeps placing; right-click an unfinished own building with workers to help. Own sites draw a dirt foundation, corner posts and a progress bar.
  • hud.module: build buttons with costs, a placing hint, and an 'Under construction N%' panel without train or rally buttons.
  • README (feature, controls, API, 1.0.22 change entry) and both guides (skirmish guide section 4b, controls table) document it. FC.VERSION is 1.0.22.

Verified: tests.run rtsKit gives 63/63 (10 new tests cover costs, build speed, refusals, placement, no deliveries while unfinished, resuming gathering, the AI laying a barracks, the network command and the HUD). rtsKit.playtest gives 6/6. In play on a fresh map where each side starts with only a town hall and 3 workers, real mouse input works: box-select the workers, press B, the ghost turns red over the town hall and green on open ground, click lays the site, 150g/100w are debited, and the barracks rises and trains. The 'balanced' computer laid and finished its barracks unaided and had 10 workers and 9 army units by 2:45.

Source world: 2121aa31-7c84-4d21-bf7a-95349b39a833 Contributed paths:

  • rtsKit.package/Commander.component/init.luau
  • rtsKit.package/Match.component/init.luau
  • rtsKit.package/README.md
  • rtsKit.package/Structure.component/init.luau
  • rtsKit.package/ai.module/init.luau
  • rtsKit.package/api.module/init.luau
  • rtsKit.package/guides/build-a-small-rts-skirmish-with-two-bases-workers-a-barracks-and-a-computer-opponent.guide/guide.md
  • rtsKit.package/guides/how-to-make-an-rts-game-select-and-move-units-in-formation.guide/guide.md
  • rtsKit.package/hud.module/init.luau
  • rtsKit.package/net.module/init.luau
  • rtsKit.package/production.module/init.luau
  • rtsKit.package/rtsKit.testSuite/init.luau
  • rtsKit.package/sim.module/init.luau
  • rtsKit.package/Commander.component
  • rtsKit.package/Match.component
  • rtsKit.package/Structure.component
  • rtsKit.package/ai.module
  • rtsKit.package/api.module
  • rtsKit.package/guides/build-a-small-rts-skirmish-with-two-bases-workers-a-barracks-and-a-computer-opponent.guide
  • rtsKit.package/guides/how-to-make-an-rts-game-select-and-move-units-in-formation.guide
  • rtsKit.package/hud.module
  • rtsKit.package/net.module
  • rtsKit.package/production.module
  • rtsKit.package/rtsKit.testSuite
  • rtsKit.package/sim.module
  • rtsKit.package/Showcase.component/init.luau
  • rtsKit.package/playtest.module/init.luau
  • scenes/main.scene/build.luau
  • scenes/main.scene/scene.json

25 files changed

  • ChangedrtsKit.package/Commander.componentFolderBeforeAfter
  • ChangedrtsKit.package/Commander.component/init.luau40.5 KB → 47.9 KBBeforeAfter
  • ChangedrtsKit.package/Match.componentFolderBeforeAfter
  • ChangedrtsKit.package/Match.component/init.luau22.9 KB → 24.9 KBBeforeAfter
  • ChangedrtsKit.package/README.md24.6 KB → 26.4 KBBeforeAfter
  • ChangedrtsKit.package/Structure.componentFolderBeforeAfter
  • ChangedrtsKit.package/Structure.component/init.luau2.2 KB → 2.5 KBBeforeAfter
  • ChangedrtsKit.package/ai.moduleFolderBeforeAfter
  • ChangedrtsKit.package/ai.module/init.luau12.1 KB → 16.4 KBBeforeAfter
  • ChangedrtsKit.package/api.moduleFolderBeforeAfter
  • ChangedrtsKit.package/api.module/init.luau7.2 KB → 7.2 KBBeforeAfter
  • ChangedrtsKit.package/guides/build-a-small-rts-skirmish-with-two-bases-workers-a-barracks-and-a-computer-opponent.guideFolderBeforeAfter
  • ChangedrtsKit.package/guides/build-a-small-rts-skirmish-with-two-bases-workers-a-barracks-and-a-computer-opponent.guide/guide.md9.5 KB → 11.3 KBBeforeAfter
  • ChangedrtsKit.package/guides/how-to-make-an-rts-game-select-and-move-units-in-formation.guideFolderBeforeAfter
  • ChangedrtsKit.package/guides/how-to-make-an-rts-game-select-and-move-units-in-formation.guide/guide.md8.5 KB → 8.7 KBBeforeAfter
  • ChangedrtsKit.package/hud.moduleFolderBeforeAfter
  • ChangedrtsKit.package/hud.module/init.luau18.6 KB → 19.6 KBBeforeAfter
  • ChangedrtsKit.package/net.moduleFolderBeforeAfter
  • ChangedrtsKit.package/net.module/init.luau9.0 KB → 9.2 KBBeforeAfter
  • ChangedrtsKit.package/production.moduleFolderBeforeAfter
  • ChangedrtsKit.package/production.module/init.luau13.1 KB → 18.6 KBBeforeAfter
  • ChangedrtsKit.package/rtsKit.testSuiteFolderBeforeAfter
  • ChangedrtsKit.package/rtsKit.testSuite/init.luau27.1 KB → 33.4 KBBeforeAfter
  • ChangedrtsKit.package/sim.moduleFolderBeforeAfter
  • ChangedrtsKit.package/sim.module/init.luau38.6 KB → 42.8 KBBeforeAfter

Checks

No checks have been posted.

Reviews

No reviews yet.

Conversation

No comments yet.

Sign in to comment or review.