Skip to content

Building

A building: it stands still, takes up its Size on the map (units walk around it), and belongs to a team. Workers put it up when it’s placed (see Worker.Builds); a Producer on it trains units, a Fighter makes it a tower, and Depot lets workers bring resources back to it.

Part of the Strategy module: Real-time strategy: factions, units that walk around obstacles and fight, workers that gather and build, buildings that train units, fog of war, the computer playing a side, the player’s controls and HUD, playing online team against team, and the Strategy template.

Works with: Producer (trains units); Health (so it can be destroyed); Fighter (makes it a tower)

Needed by: Producer

In a network game, it also sends values of its own besides its properties.

Each is listed as its key in the scene file and the MCP tools, then its kind of value, its default and what it does.

  • team: text = “Player”. The team it’s on: a Faction’s Team. (Names a team.) (Field: a name.)
  • size: [x, y] = [3,3]. The ground it covers, in world units; units walk around it. (Field: a vector.)
  • sight: a number = 7. How far it sees through the fog of war. (A distance: the Scene view draws it as a circle around the entity, with a handle to drag.) (Field: a number.)
  • cost: text = “150 Gold”. What it costs to build, e.g. “150 Gold, 50 Wood”. (Resources and how many of each, separated by commas, e.g. “150 Gold, 50 Wood”. The Inspector lists them a row each, the resource picked from the project’s and the count set.) (Field: its own editor: Counts.)
  • buildTime: a number = 10. Seconds a worker takes to put it up. (Field: a number.)
  • hotkey: text = null. The key that builds it, e.g. “B”. Empty uses its first letter. (Names a letter key; the Inspector picks from them and flags a name that isn’t one. Empty for none.) (Field: its own editor: Choice Of.)
  • supply: a whole number = 0. The supply it provides its team once it’s up: farms and houses. (Field: a number.)
  • depot: true or false = false. Whether workers bring gathered resources back here: a town hall. (Field: on or off.)
  • progress: a number = 1. How far along it is, from 0 (just placed) to 1 (finished). Buildings in a scene start finished. (Field: a number.)

Not saved with the scene; scripts read them, and entity_get shows them as live while the game plays.

  • isBuilt: true or false. True once it’s finished: only then does it train, take resources, provide supply or shoot.
  • rally: [x, y] or null. Where units it trains walk to. Right-click with it selected to set it.
  • rallyTarget: an entity: its name, id or path. A resource units it trains go and gather from, if the rally point was set on one.
  • isSelected: true or false. True while the player has it selected.

Scripts use it as Building: its methods, events and values that aren’t saved with the scene.