Skip to content

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.

PropertyTypeDescription
.existsboolFleet unit exists
.objectcontrollableThe actual ship for this unit (set after rebuild completes)
.toplevelcommandercontrollableFleet commander (the unit belongs to this fleet)
.ownerfactionFleet owner
.macromacroMacro to reconstruct
.loadoutloadoutLoadout to apply on rebuild
.buildbuildActive rebuild task (null if not yet building)

The fleet itself exposes its units via:

Controllable propertyDescription
.fleetunitThe fleet unit this object IS (if it’s a rebuild)
.fleetunitsList 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.

”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'"/>

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>
  • .object is null until rebuild completes. A fleet unit can exist without a physical ship. Always null-check.
  • .build is 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.
  • .macro and .loadout are 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.
  • Fleet reconstitution pipeline: Architectural overview Fleet reconstitutionfleet_reconstitution.xml checks 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.