Pages

Unit modes

unit-modes.toml, which declares the abilities a player switches on and off, the build-menu buttons that switch them, and weapons a script holds back.

A unit can have modes: named abilities a player switches on and off, each with an energy upkeep and effects (design). A mod declares them in a unit-modes.toml file, when its units have abilities like Escalation's intel modes.

The worked example

The Shaper half of assets/compatibility/escalation-unit-modes.toml, as a unit-modes.toml at a mod's mounted root:

version = 1

[[mode]]
units = ["CORZIG", "ARMZIG"]
id = "max-intel"
caption = "Maximum Intel"
group = "intel"
upkeep_energy = 5000
effects = [ { activate = true }, { stat = "sight", op = "set", value = 2688 }, { script_on = "StartBuilding", script_off = "StopBuilding" } ]

[[mode]]
units = ["CORZIG", "ARMZIG"]
id = "commander-hack"
caption = "Commander Hack"
group = "intel"
upkeep_energy = 10000
effects = [ { borrow_sight = "*COMMANDER", owners = "enemy" }, { script_on = "StartBuilding", script_off = "StopBuilding" } ]

[[gadget]]
gui = "CORZIG1.GUI"
gadget = "xOMNI"
unit = "CORZIG"
mode = "max-intel"

[[weapon_requirement]]
units = ["CORCOM", "CORDECOM"]
weapon = 2              # the FBI's WeaponN, 1 to 3
script_flag = 4         # the static variable that unlocks it while nonzero
building = "CORTECH"    # what the player builds to set it, for the tooltip

Where the file comes from

A file at the mod's mounted root is used as it is; otherwise a unit-modes profile names a file in its mode_file field, and the game reads that file when the mounted mod has the profile's identity (Mod identity). The bundled taesc-intel-modes-v1 names escalation-unit-modes.toml, embedded from assets/compatibility/escalation-unit-modes.toml, for Escalation 10.2. A mode_file the engine does not embed is read from the mounted data.

A [[mode]] table

  • units: the unit types that have the mode, by FBI name. A unit has at most 8 modes.
  • id: the mode's name, which [[gadget]] tables refer to.
  • caption: what its switch shows when its page has no art of its own.
  • group: optional. At most one mode of a group is on: switching one on switches the others off.
  • upkeep_energy: energy per second while the mode is on. When the owner cannot pay, the mode stays on but its effects pause until energy returns.
  • effects, any of:
    • { activate = true }: the unit is switched on exactly while the mode is on, so its own sensors run only then, in every rule set. Such a unit has no plain ON/OFF order, and its own EnergyUse is not charged on top of the upkeep.
    • { stat = "...", op = "...", value = N }: a sensor value of the unit while the mode is on. stat is sight, radar, sonar, radar_jam or sonar_jam; op is set, add or mul. The type's value comes first, then adds, then multiplies, then the last set.
    • { borrow_sight = "*CATEGORY", owners = "..." }: the owner sees what every unit of that category sees, as their own line of sight. owners is enemy, allied or any.
    • { script_on = "Name", script_off = "Name" } (either or both): the unit's own scripts started when the mode turns on and off, for the ability's animation. A mode whose on script another active mode also runs is left alone, so switching between them keeps the animation going. Escalation's two intel modes run StartBuilding and StopBuilding, which turn the Shaper's dish and the Panopticon's arms.

A [[gadget]] table

A [[gadget]] table puts a mode's switch in a build menu: the button gadget on the page gui of the unit unit becomes a toggle for mode instead of something to build. A toggle never makes a unit, a frame or a queue entry. Escalation's xOMNI and xHACK buttons on the Shaper's and the Panopticon's pages are mapped this way, so those entries switch Maximum Intel and Commander Hack instead of building a token frame.

Modes change what units do, so they are a simulation rule: the file joins the compatibility plan, checkpoints and the sim hash, and it applies in both rule presets.

A [[weapon_requirement]] table

A [[weapon_requirement]] table records a weapon the unit's own script fires only while one of the script's flags is set (fields as commented in the example).

The script stays the rule: it still decides when the weapon aims. The game reads that flag on each unit's own script, so an attack order leaves the weapon out exactly while the script holds it back, and the unit closes to a gun that will fire. The weapon's order button carries a building mark naming the building while a selected unit's weapon is held back. A unit without a script, or a script without that variable, holds nothing back. A unit's weapon has at most one requirement. Escalation's commanders and decoy commanders are listed this way: their Starburst Missile waits on their upgraded flag (static 4), which their Detect sets while their side has a finished Upgrade Center (ARMTECH, CORTECH).

What goes wrong

A file that loads logs what it declared:

unit modes compatibility: native unit-modes.toml, <N> unit types, <N> gadgets

A malformed file (an unknown effect, a ninth mode for a unit) stops the match from loading, with a message that names the problem, for example:

mod compatibility: unit-modes.toml: mode[8]: unit CORZIG has more than 8 modes
mod compatibility: unit-modes.toml: mode[0].effects[1]: unknown effect {glow}
mod compatibility: profile my-modes-v1: mode_file 'my-modes.toml' is neither bundled nor in the mounted data

Next