Create civilian fleets to help manage your traders and miners.
Civilian Fleets: that's how simple it is! (the above screenshot was taken in X4 Foundations v2.6 with this mod active)
NOTE: this mod is now archived; see CLOSING.md
in the repo for more details, such as:
Without the help from the community, this mod will not be available in other languages.
You should check the Nexus page for more details, but, if you want to form/join a civilian fleet:
This mod also supports the following civilian default behaviors from other mods as part of the built-in features:
For mod makers, other mods can be made compatible to Civilian Fleets; more information below.
Due to the way Civilian Fleets work, it cannot automatically detect other aiscript files that should also be used.
To make Civilian Fleets use your custom aiscript, do the following:
Civilian Fleets will need the following, so prepare them first:
Create a Mission Director file in /md
, then do the following:
For example:
<?xml version="1.0" encoding="utf-8" ?>
<mdscript name="External_CivilianFleetCompat" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="md.xsd">
<cues>
<!-- Example cue using the existing Sanity Miners compatibility code -->
<cue name="RegisterFleetNames" instantiate="true">
<conditions>
<event_cue_signalled cue="md.V1024_CivilianFleets.CivilianFleets_SettingUp" />
</conditions>
<!-- Delay a bit to let the original cue complete its actions -->
<delay exact="1s" />
<actions>
<!-- [$aiscriptId, $fleetNameString] -->
<append_to_list name="global.$civFleet_CmdTagPairs" exact="['Sanity_SectorAutoMine', {221024, 2001}]" />
</actions>
</cue>
</cues>
</mdscript>
Sometimes, some parameters of your aiscript become meaningless when ships start working uner a fleet. This means that you must tell us how fleet members should receive the aiscript parameters.
Create the Mission Director patch-file /extensions/v1024_civilian_fleets/md/civilianfleets_signals.xml
, then do the following:
For example, if you are adding a is-mining aiscript:
<?xml version="1.0" encoding="utf-8" ?>
<diff>s
<add sel="/mdscript/cues/cue[@name='Signal_SyncOrders_MimicryExtension']/actions/do_if[@value='($fromShip.primarypurpose == purpose.mine) and ($toShip.primarypurpose == purpose.mine)']/do_else[1]" pos="before" comment="For is-mining aiscript">
<do_elseif value="$fromShip_DefaultOrder.id == 'YourOrderID'">
<create_order object="$toShip" id="'YourOrderID'" default="true">
<param name="exampleparam" value="$fromShip_DefaultOrder.$exampleparam" />
</create_order>
</do_elseif>
</add>
</diff>
For example, if you are adding a non-mining aiscript:
<?xml version="1.0" encoding="utf-8" ?>
<diff>
<add sel="/mdscript/cues/cue[@name='Signal_SyncOrders_MimicryExtension']/actions/do_else[1]" pos="before" comment="For non-mining aiscript">
<do_elseif value="$fromShip_DefaultOrder.id == 'YourOrderID'">
<create_order object="$toShip" id="'YourOrderID'" default="true">
<param name="exampleparam" value="$fromShip_DefaultOrder.$exampleparam" />
</create_order>
</do_elseif>
</add>
</diff>
We should test that the patch works.
You can launch the game and assign ships to others using the Mimic
menu, and you should see that your new fleet subordinates are not using the Mimic
command, but your actual custom aiscript command instead.
If that is the case, then congratulations! You have successfully made your custom aiscript compatible with Civilian Fleets. Your mod users will now also enjoy the benefits of the Civilian Fleets mod, e.g. persistent fleet orders.
This serves as an important reminder to never skip steps, respect legacy methods, and never make breaking updates without auto-fixes.