Skip to content

Defensible

A Defensible is the X4 engine abstract class for objects that defend themselves — has shields, turrets, weapons, can be boarded, has loadouts. Inherits from Controllable and is parent of Container (stations) and Ship (mobile).

Inheritance: object → controllable → defensible. Subclass: Container (most stations), Ship (mobile combat entities).

Critical for boarding mechanics:

PropertyTypeDescription
.iscapturablebooleanCan this be captured (signalleak S/M or boarding L+)? Also: S-ship pilot won’t eject if false.
.isalertlevel.<level>booleanAt alert level (red/yellow/green). Note: Turrets deactivate on green.
.boardingoperationoperationCurrent boarding operation this object is part of
.boardingoperationslistInbound boarding operations to defend against
.boardingbehaviourboardingbehaviourBoarding behaviour assigned for current operation
.boardingmarines.countintegerTotal marines assigned for boarding
.boardingmarines.combinedskillintegerCombined marine skill 0-100
.boardingmarines.{$level}.countintegerMarines at specific tier
.allmarinesdispatchedbooleanAll marines dispatched?
.boardingresistanceintegerTotal boarding resistance
.baseboardingresistanceintegerBase resistance defined for object
.boardingstrengthintegerBoarding strength of marines + officer

All defensive surface components share the same property pattern:

Property patternTypeDescription
.shields.numslots / .turrets.numslots / .weapons.numslotsintegerNumber of slots
.<X>.<state>.countintegerCount filtered by state (all/construction/operational/wreck)
.<X>.<state>.listlistList filtered by state
.<X>.<state>.indexof.{$component}integerIndex of $component (1-based)
.<X>.<state>.randomshieldgenerator/turret/weaponRandom component

Where <X> is shields, turrets, or weapons.

PropertyTypeDescription
.constructionsequenceconstructionsequenceCurrent construction sequence
.hasstagedconstructionbooleanCurrent/planned construction is staged
.hasfutureconstructionstagebooleanHas future stages?
.planmodule.{$constructionplanentryid}moduleModule from construction plan entry
.requiresconstructionvessel.{constructionsequence}booleanConstruction sequence needs construction vessel

The loadout system controls equipment generation:

PropertyTypeDescription
.loadoutlevelfloatLoadout level used to generate this object
.rawloadoutlevelfloatWithout fallback to parameters.xml
.minloadoutlevelfloatMinimum allowed (e.g. lowerbound in job definition)
.loadoutvariationfloatLoadout variation range
.moduleloadoutlevelfloatModule loadout level (station)
.rawmoduleloadoutlevelfloatWithout fallback
.moduleloadoutvariationfloatModule variation

Plus quantity + quality variants:

Property patternDescription
.loadoutquantity.level / .variationQuantity overrides
.rawloadoutquantity.level / .variationWithout fallback (check -1)
.loadoutquality.level / .variationQuality overrides
.rawloadoutquality.level / .variationWithout fallback (check -1)
.moduleloadoutquantity.level / .variationModule quantity (station)
.moduleloadoutquality.level / .variationModule quality (station)
.rawmoduleloadout...Without fallback variants

The “raw” variants must be checked against -1 before use (signal that no override is in effect).

PropertyTypeDescription
.defencedronemodedronemodeCurrent defence drone mode
<set_value name="$turrets" exact="$ship.turrets.operational.list"/>
<do_for_each name="$turret" in="$turrets">
<write_to_logbook text="$turret.name"/>
</do_for_each>
<do_if value="$ship.iscapturable">
<!-- can be captured -->
</do_if>

"Check if boarding operation is in progress"

Section titled “"Check if boarding operation is in progress"”
<do_if value="$ship.boardingoperation?">
<write_to_logbook text="'Boarding active!'"/>
</do_if>
<set_value name="$shields" exact="$station.shields.all.list"/>
<set_alert_level object="$ship" level="alertlevel.red"/>
  • Turrets DEACTIVATE on alert level green. Ships with green alert don’t fight back.
  • .iscapturable controls multiple things at once: signalleak capture (S/M) AND boarding capture (L+) AND S-ship pilot eject behavior.
  • The shield/turret/weapon state parameter is mandatory<X>.list without state is invalid. Use .all.list, .operational.list, etc.
  • Raw loadout properties may return -1 — meaning “no override”. Check if $ship.rawloadoutlevel != -1 before using.
  • .boardingoperations (plural) is for DEFENDING side.boardingoperation (singular) is the operation this object is in (attacking or defending).
  • Construction stages are managed via container subclass — defensible exposes the read API but not write.
object
└── controllable
└── defensible ← this class
├── container (stations)
│ └── station (concrete)
└── ship (concrete mobile)
ActionPurpose
<set_alert_level>Set object’s alert level
<initiate_boarding>Begin a boarding operation
<cancel_boarding>Abort boarding operation
<generate_loadout>Generate a loadout (uses loadoutlevel, etc.)
<apply_loadout>Apply a generated loadout
<evaluate_ammo_storage>Evaluate ammo storage state
<add_ammo>Add ammo to ammostorage (for deployables)

Defensible adds defense mechanics on top of Controllable. Most modders interact with it via ship.shields / station.turrets / boarding mechanics. The loadout properties are critical for procedurally-generated content.