Skip to content

Units and buildings

Defs: what a unit, a building or an upgrade level carries, where each one is built, and how the AI fields it.

A def is a unit, a building or an upgrade level, and every field it can carry is a field of the game's own unit definition. Here is a mod with its own art, a defended building, and a fourth level for the power plant line:

{
  "format": "steel-tide-mod",
  "v": 4,
  "id": "ironworks",
  "name": [
    "Ironworks",
    "铁工厂"
  ],
  "version": "1.0.0",
  "author": "you",
  "description": [
    "A hover tank, a bunker and a fusion plant.",
    "一辆悬浮坦克、一座碉堡和一座聚变电站。"
  ],
  "license": "CC-BY-4.0",
  "defs": [
    {
      "id": "ironworks-hover",
      "name": [
        "Skimmer Hover Tank",
        "掠行悬浮坦克"
      ],
      "desc": [
        "Fast, thin-skinned, rockets.",
        "快、皮薄、打火箭。"
      ],
      "kind": "unit",
      "domain": "ground",
      "tier": 2,
      "cost": 260,
      "hp": 320,
      "armor": "light",
      "speed": 110,
      "turnRate": 5,
      "radius": 9,
      "body": {
        "r": 10,
        "len": 10
      },
      "trail": "tire",
      "weapons": [
        {
          "id": "pods",
          "cls": "rocket",
          "dmg": 16,
          "reload": 2.2,
          "range": 4.5,
          "burst": 4,
          "burstDelay": 0.1,
          "splash": 10,
          "spread": 14
        }
      ],
      "producedBy": [
        "factory2",
        "factory3"
      ],
      "aiWeight": 1
    },
    {
      "id": "ironworks-bunker",
      "name": [
        "Bunker",
        "碉堡"
      ],
      "desc": [
        "A gun pit that takes a beating.",
        "扛打的火力点。"
      ],
      "kind": "building",
      "cost": 380,
      "hp": 1600,
      "fw": 2,
      "fh": 2,
      "power": -3,
      "vision": 8,
      "weapons": [
        {
          "id": "gun",
          "cls": "autocannon",
          "dmg": 22,
          "reload": 0.5,
          "range": 5,
          "turret": false,
          "targets": [
            "ground",
            "ship"
          ]
        }
      ]
    },
    {
      "id": "ironworks-fusion",
      "name": [
        "Fusion Plant",
        "聚变电站"
      ],
      "desc": [
        "The plant line's fourth level.",
        "发电厂线的第四级。"
      ],
      "extends": "power3",
      "upgradeOf": "power3",
      "cost": 2200,
      "hp": 2600,
      "power": 500,
      "upgradeCost": 1100,
      "upgradeTime": 60,
      "requires": [
        "radar",
        "reactor"
      ]
    }
  ],
  "sprites": [
    {
      "key": "u.ironworks-hover",
      "file": "sprites/u.ironworks-hover.png",
      "frames": 1,
      "rotated": true,
      "fw": 24,
      "fh": 26
    },
    {
      "key": "u.ironworks-bunker",
      "file": "sprites/u.ironworks-bunker.png",
      "frames": 1
    }
  ],
  "screenshots": [
    "screenshots/skimmers.png"
  ]
}

Units of measure

A tile is 32 world pixels. speed and projectile speed are world px/s; range, minRange, vision, sonar, stealth, detect, repairRange and interceptRange are tiles; radius, splash, spread and muzzleOffset are world px; every time is seconds. For scale, the Bison Battle Tank is cost 280, hp 620, speed 60, radius 10, with a cannon of dmg 60 every 1.8 s at range 4.6; the Recon Buggy is cost 60, hp 150, speed 120; a War Factory is 3×3 tiles, hp 1500, power −8.

Where things are built

  • A unit joins the production list of the buildings in producedBy. Left out, it joins its domain's line from its tier up: a tier-2 ground unit appears at the level-2 and level-3 war factory, a tier-1 ship at every naval yard. With extends, it is built wherever the base is.
  • A building is placed by the units in builtBy, the engineer unless you say otherwise. A building with a produces list is a factory; a unit that names a plain building in producedBy turns it into one.
  • A unit with a produces list trains those units itself: a carrier, a mothership. Each one is launched beside it, wherever it has got to, and left standing there. Another unit of the mod may name it in producedBy; a unit of the game's own may not be made one.
  • An upgrade level is a building with upgradeOf: the named building gains an Upgrade button that turns it into this def, at upgradeCost over upgradeTime, and this def is never placed directly. A building has one next level, so upgradeOf may name a vanilla building at the end of its line (power3, factory3, extractor3, gatling, cannonturret2, samsite, interceptor2, radar, repairtower, reactor, nukesilo) or another def of your mod.
  • requires lists buildings that must stand before something can be built, the way Tier 3 needs the Radar Station.

The AI

AI opponents build a modded unit at its aiWeight, on the scale the vanilla roster is weighed on (a Bison is 3, a scout car 1), once its requires are met. Leave it out and they never build it. Buildings and upgrade levels are yours alone.

Reference

A def (defs[])

fieldtyperequireddefaultmeaning
extensions{ capability: configuration }Configuration keyed by a required engine capability (format 3)
isHQbooleanbuildings onlya headquarters: holds territory and production slots, follows the ordinary HQ loss and sale rules; format 2
ididyesunique across every mod and the vanilla roster; prefix a generic word with your mod's id
nametextyesas the HUD shows it
desctext""the tooltip line
extendsida vanilla def id (or an earlier def of this mod) to copy, then override field by field; inherits its art and where it is built
kindunit | buildingyesa unit or a building (required unless `extends` says)
domainground | ship | air | amphibiousunits onlygroundwhere it moves; a submarine is a `ship` with `underwater`, and an `amphibious` hull drives and swims (a ship target afloat, a ground one ashore)
tierinteger 1–31the factory level it appears at, and the badge
costnumber 0–99999yesmetal
buildTimenumber 0–3600cost ÷ 14seconds at full power
popinteger 0–501 for a unit, 0 for a buildingpopulation it counts for
hpnumber 1–100000000yeshit points; standard capacity is limited to 1000000, large to 100000000
armorlight | medium | heavy | ship | sub | air | structureby domainthe armour class weapons are multiplied against
impactMaterialarmor | earth | concreteconcrete for structure armor, armor otherwiseprojectile-impact sound material; does not change damage. Both ordinary and heavy impacts use the matching recorded family
directionalArmor{ front, side, rear }units onlyground hull direct-hit multipliers `{front, side, rear}`, each 0–10; 90° front/rear arcs and 90° on each side. Arc fire, collateral blasts, mines and fire ignore facing. Enables slow reversing for short moves behind the hull
speednumber 0–1000units only60world px/s (a tile is 32)
turnRatenumber 0–50units only3.5rad/s
visionnumber 0–648sight, in tiles; rounded to the nearest whole tile when activated
radiusnumber 1–2009, or the footprintcollision radius, world px, and the *combat* yardstick: range, splash and hits are measured to it
body{ r, len }units onlythe circle of `radius`the room the hull takes up when units push each other apart, world px: `r` its half-width, `len` its length less the two round ends. A long hull is what a circle cannot say. A ship whose beam (`r` twice) is over a tile (32) needs that many tiles of water abeam, rounded up: it never enters a channel narrower than itself
weaponsweapon[][]the weapons (see below); an empty list is unarmed
fwinteger 1–8buildings only2footprint width, tiles
fhinteger 1–8buildings only2footprint height, tiles
producedByid[]units onlythe line for its domain, from its tier upthe buildings whose production list it joins (vanilla or this mod's), or units of this mod that train it (a carrier)
producesid[]a factory: the units it builds. On a unit, a carrier or a mothership that trains them itself: each is launched beside it, wherever it has got to
builtByid[]buildings only["engineer"]the builder units that may place it
buildsid[]units onlya builder unit: the buildings it can construct
buildRatenumber 0–10000units onlya builder unit: hp of work per second
reachnumber 0–256units onlya builder unit: how far past a target's radius it works from, world px (the engineer's 46 when unset; the engineer boat's 64)
powernumber -10000–10000−pop for a unit, 0 for a buildingpositive produces, negative draws; every unit draws its population
metalRatenumber 0–1000metal per second: an extractor, or a unit that earns (a supply ship)
needsDepositbooleanbuildings onlymust stand on a deposit
offshorebooleanbuildings onlystands in open water on its own legs: every footprint tile sea, no shore needed; with needsDeposit, an ore field at sea, which only a builder on the water (the engineer boat) can reach
wallbooleanbuildings onlya wall: one tile that joins its neighbours of the same def (its sheet is sixteen frames, one per set of neighbours: north 1, east 2, south 4, west 8), the last thing a gun shoots at, untouched by a pulse, and it falls without a charge
repairRangenumber 0–64a repair aura, tiles; a unit repairs ground and naval units, a building also repairs aircraft and buildings
repairAirRangenumber 0–64repairRangerepair reach for aircraft, tiles; does not change which targets the source can repair
repairNavalRangenumber 0–64repairRangerepair reach for ships, submarines and swimming amphibians, tiles
repairRatenumber 0–10000hp per second per target
repairTargetsinteger 1–50targets served at once
upgradeOfidbuildings onlythe building this is the next level of; that one gains the upgrade button
upgradeCostnumber 0–99999buildings onlycost − the source's costwith `upgradeOf`: the upgrade's price
upgradeTimenumber 0–3600buildings onlybuildTimewith `upgradeOf`: seconds
requiresid[]building ids that must stand before it can be built, or tech node ids that must be researched (`suicideDrones`, `activeProtection`…)
nukeCapacityinteger 0–10a launcher: warheads it holds
nukeCostnumber 0–99999a launcher: metal per warhead
nukeTimenumber 0–3600a launcher: seconds per warhead
armsAtBasenumber 0–64units onlya launcher: fabricates its warheads only within this many tiles of one of its own bases of its kind (a naval yard for a hull, an airbase for an aircraft; and, an `underwater` one, only on the surface), and holds the work otherwise (the Kraken's and the Wraith's 4)
rearmTimenumber 0.1–60015seconds to fill every gun that carries `ammo` from empty, at a base of its kind
hatchnumber 0–30a launcher: seconds its doors take to open before the warhead leaves, and to close after; none fires on the spot
antiWarheadbooleanits anti-air may fire on a nuclear warhead without a veteran's rank
interceptRangenumber 0–64point defence: reach in tiles
interceptMaginteger 1–200point defence: rounds ready
interceptReloadnumber 0.05–600point defence: seconds per round replaced
interceptMuzzleOffsetnumber 0–200point defence: launcher length, world px
transportCapinteger 1–50units onlya transport: hold, in cargo weight
transportMaxWeightnumber 0–50units onlytransportCapa transport: maximum cargo weight of one passenger
cargoReachnumber 0.5–4units only1a transport: how far its load and unload distances stretch, as a multiple of the default (the landing craft's 1.1, the Moray's 1.5); on a ship it widens the ground its ramp reaches too
landsForCargobooleanunits onlya cargo plane that touches down to load
cargoWeightnumber 0–50units onlypophow much of a hold it takes
underwaterbooleanunits onlya submarine: seen only by sonar
sonarnumber 0–64units onlysonar range, tiles
stealthnumber 0–64units onlyseen only within this many tiles of an enemy
detectnumber 0–64reveals stealth within this many tiles
radarbooleansees by radio: the sight circle ignores weather and the hour, and drops to 7 tiles when short of power
remoteVisionbooleanunits onlyremote camera feed: hostile jamming blocks its sight within the field
jamRangenumber 0–64buildings onlyelectronic-warfare radius in tiles; requires full power, reveals its location, blocks hostile radar and remote vision, never visual sight or sonar
hoversbooleanunits onlyan aircraft that hovers instead of orbiting
kamikazebooleanunits onlythe unit is its own round: it never picks a target, and its one weapon flies it into what it is ordered at (the Hornet)
lowFlyingbooleanunits onlyan aircraft at treetop height: machine guns and autocannons that fire on the ground reach it too (the helicopters and the Hornet)
limitinteger 1–200units onlyat most this many a faction at once, alive and queued together (the Hornet's 10)
altitudenumber 0–64units only12an aircraft's drawn height, px
fireOnMovebooleanunits onlykeeps shooting on a plain move
burnMultnumber 0–4units only1what fire on the ground does to it, as a multiplier (the Drake's 0.5)
trailtread | tire | wake | noneunits onlyby domainthe mark it leaves, and the sound of it: treads and tyres are heard rolling; `none` for a unit on foot or a hovercraft, which neither cuts a rut nor is heard as an engine
shadowbooleantruethe shadow the game casts for it: a unit's hull and turret silhouettes, a step to the south-east on the ground, further off in the air; a building's gun's, on its roof; `false` when the art brings its own, or none is wanted (a submarine casts none)
spritestringthis mod's u.<id> sheet, else the base's artthe body's atlas key: one of this mod's sheets, or a vanilla key to borrow its art
turretSpritestringthis mod's tur.<id> sheet, else the base's (when its art is kept)the rotating part's key, if any
turretMountsmount[]one, where the body sheet's `mount` puts it (else the pivot); the base's, when its art is keptthe rings its turret stands on and fires from, up to 8: a hull with several guns names one each (a battleship's A, B and X), every one drawn with the one `turretSprite` and trained on the one target, as far round as its own arc goes (see below)
decalsdecal[]the base's, when its art is keptpictures laid on the hull and the turret besides their own sheets (see below), up to 12
abilitysprint | afterburner | smoke | incendiary | barrage | countermeasures | damageControl | emergencyRepairunits onlythe base'sits one active ability, a vanilla one by id (`sprint`, `smoke`, `countermeasures`…): the same click, clock and unlock as on the game's own units
aliasesstring[]other names the console's `give` accepts
aiWeightnumber 0–10units only0how readily the AI builds it: a Bison is 3, a scout car 1; 0 never
rulesrule[]its behaviour: rules that turn it into another form, spawn, heal, pay, buff or blow up, on an event, a condition, a clock or a button (see Behaviour), up to 24; never inherited through `extends`
shield{ hp, regen, delay }an energy shield, `{ hp, regen, delay }`: it takes harm before the hull does, and recharges `regen` a second once unhurt for `delay` seconds
regennumber 0–10000hit points a second it mends itself by
untargetablebooleannothing on the other side may pick it as a target or be ordered to attack it; a blast still reaches it (a disguise, a decoy)
wing{ unit, count, rebuild, sortie, rearm, range }units onlya carrier: planes of this mod it keeps aboard, `{ unit, count, rebuild, sortie, rearm, range }`, sent out at what it fights, taken back to rearm and made again when lost; never the player's to order (see Behaviour); never inherited through `extends`

Defaults with no extends: a unit is domain: "ground", tier: 1, pop: 1, speed: 60, turnRate: 3.5, vision: 8, radius: 9, armour by domain (ground medium, ship ship, air air), a tread trail on land (trail: "none" for a unit on foot, which is then not heard rolling either) and a wake at sea; a building is fw: 2, fh: 2, armor: "structure", power: 0, pop: 0. buildTime is cost ÷ 14 seconds.

Last edited