Fleet unit
A Fleet unit is a fleet-rebuild placeholder — a ship slot in a fleet that has been destroyed (or is scheduled to be replaced) and tracks the rebuild work. The fleet reconstitution system uses these to maintain fleet composition over time.
Inheritance: None — fleetunit is its own root datatype.
Properties
Section titled “Properties”| Property | Type | Description |
|---|---|---|
.exists | bool | Fleet unit exists |
.object | controllable | The actual ship for this unit (set after rebuild completes) |
.toplevelcommander | controllable | Fleet commander (the unit belongs to this fleet) |
.owner | faction | Fleet owner |
.macro | macro | Macro to reconstruct |
.loadout | loadout | Loadout to apply on rebuild |
.build | build | Active rebuild task (null if not yet building) |
Fleet-side accessors
Section titled “Fleet-side accessors”The fleet itself exposes its units via:
| Controllable property | Description |
|---|---|
.fleetunit | The fleet unit this object IS (if it’s a rebuild) |
.fleetunits | List of ALL fleet units for the fleet |
So Ship.fleetunit tells you the unit this ship is filling; Fleet.fleetunits tells you all unit slots.
Common patterns
Section titled “Common patterns””How many units of the fleet are missing"
Section titled “”How many units of the fleet are missing"”<set_value name="$Missing" exact="0"/>
<do_for_each name="$unit" in="$Fleet.fleetunits"> <do_if value="not @$unit.object"> <set_value name="$Missing" operation="add" exact="1"/> </do_if></do_for_each>
<write_to_logbook text="$Fleet.knownname + ' missing ' + $Missing + ' units'"/>"Trigger rebuild for a destroyed unit”
Section titled “"Trigger rebuild for a destroyed unit””There’s no public <rebuild_fleet_unit> action — the engine handles this when a class.ship with a .fleetunit reference is destroyed and .toplevelcommander is a fleet commander. The fleet-reconstitution MD framework (fleet_reconstitution.xml) drives this:
<!-- Vanilla framework checks every X seconds: --><do_for_each name="$unit" in="$Fleet.fleetunits"> <do_if value="not @$unit.object and not @$unit.build"> <!-- needs rebuild — find a shipyard via canbuildmacro/canbuildclass --> <!-- see Shipyard / Wharf --> </do_if></do_for_each>Common gotchas
Section titled “Common gotchas”- ⚠
.objectis null until rebuild completes. A fleet unit can exist without a physical ship. Always null-check. - ⚠
.buildis null until a rebuild starts. Without an active build, the unit is “lost and waiting for someone to reconstruct it”. - ⚠ Fleet units only exist for ships destroyed FROM a fleet. Random destroyed ships don’t get a fleet unit. The original ship must have been part of a fleet via
.fleet.commander. - ⚠
.macroand.loadoutare the rebuild target. Engine reconstitution uses these — don’t try to reassign mid-rebuild. - ⚠ Fleet reconstitution depends on
Shipyard.canbuildmacro/.canbuildclass. A fleet unit needing an XL won’t rebuild if no shipyard can build that XL class. See Shipyard.
Architectural context
Section titled “Architectural context”- Fleet reconstitution pipeline: Architectural overview Fleet reconstitution —
fleet_reconstitution.xmlchecks fleet composition, identifies missing units, finds compatible shipyards, dispatches builds. - Fleet vs subordinate distinction: Architectural overview Fleet structure — fleets have a
.fleet.commander; subordinates have a.commander. Fleet units exist only at the fleet level.
Related
Section titled “Related”- Ship — what fills fleet unit slots.
- Build —
.buildaccessor. - Macro —
.macroto rebuild. - Loadout —
.loadoutto apply. - Faction — fleet owner.
- Shipyard / Wharf — where rebuilds happen.