xsd-lookup
Version:
Multi-schema XSD lookup utility
868 lines (821 loc) • 134 kB
text/xml
<?xml version="1.0" encoding="utf-8"?>
<mdscript name="FactionLogic" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="md.xsd">
<cues>
<!--Cue to be signalled to inform the faction manager of something
The first element in the parameter list must be the faction e.g. param = [$Faction, 'attacked', $Victim]-->
<cue name="FactionSignalled" instantiate="true">
<conditions>
<event_cue_signalled/>
</conditions>
</cue>
<cue name="Generate_Global_Report" instantiate="true">
<conditions>
<event_cue_signalled/>
</conditions>
<actions>
<debug_text text="player.age + ' - GENERATING GLOBAL FACTION LOGIC REPORT'" context="false"/>
<set_value name="$Factions" exact="global.$FactionManagers.keys.list"/>
<do_all exact="$Factions.count" counter="$i">
<signal_cue_instantly cue="FactionSignalled" param="[$Factions.{$i}, 'Generate Report']"/>
</do_all>
<remove_value name="$Factions"/>
</actions>
<force name="Generate Faction Logic Report"/>
</cue>
<!--
####################
MANAGER INSTANCES
####################-->
<cue name="FactionLogicManagers" mapeditor="false" version="3">
<conditions>
<event_cue_signalled cue="md.Setup.Start" />
<check_value value="player.galaxy.macro.ismacro.{macro.xu_ep2_universe_macro}"/>
</conditions>
<actions>
<set_value name="md.$DefaultShipStrengthTable" exact="table[
{class.ship_xl} = 23,
{class.ship_l} = 11,
{class.ship_m} = 3,
{class.ship_s} = 1]"/>
<set_value name="md.$DefaultSubordinateStrengthTable" exact="table[
{class.ship_xl} = 21,
{class.ship_l} = 9,
{class.ship_m} = 3,
{class.ship_s} = 1]"/>
</actions>
<patch sinceversion="2" state="complete">
<set_value name="md.$DefaultShipStrengthTable" exact="table[
{class.ship_xl} = 23,
{class.ship_l} = 11,
{class.ship_m} = 3,
{class.ship_s} = 1]"/>
<set_value name="md.$DefaultSubordinateStrengthTable" exact="table[
{class.ship_xl} = 21,
{class.ship_l} = 9,
{class.ship_m} = 3,
{class.ship_s} = 1]"/>
</patch>
<patch sinceversion="3">
<do_if value="not md.$Patch_RiggedAsteroidLists?">
<set_value name="md.$Patch_RiggedAsteroidLists" exact="[]"/>
</do_if>
</patch>
<cues>
<cue name="ArgonFactionLogic">
<cues>
<cue name="ArgonFactionLogic_Manager" ref="Manager">
<param name="Faction" value="faction.argon"/>
<param name="BaseAggressionLevel" value="moodlevel.normal"/>
<param name="BaseAvariceLevel" value="moodlevel.high"/>
<param name="BaseLawfulness" value="0.8"/>
<param name="PreferredHQSpaceMacro" value="macro.cluster_14_macro" comment="Argon Prime"/>
<param name="PreferredHQTypes" value="['shipbuilding', 'equipmentdock', 'tradestation']"/>
<param name="SatelliteNetworkGoal" value="20"/>
<param name="LasertowerNetworkGoal" value="5"/>
<param name="MinefieldGoalPerSector" value="1" comment="[MGPS * Sectors, 12].min is the maximum amount of Minefields for this faction"/>
<param name="DebugChance" value="0"/>
<param name="DebugChance2" value="0"/>
</cue>
</cues>
</cue>
<cue name="AntigoneFactionLogic">
<cues>
<cue name="AntigoneFactionLogic_Manager" ref="Manager">
<param name="Faction" value="faction.antigone"/>
<param name="BaseAggressionLevel" value="moodlevel.normal"/>
<param name="BaseAvariceLevel" value="moodlevel.high"/>
<param name="BaseLawfulness" value="0.4"/>
<param name="PreferredHQSpaceMacro" value="macro.cluster_28_macro" comment="Antigone Memorial"/>
<param name="PreferredHQTypes" value="['equipmentdock', 'shipbuilding', 'tradestation']"/>
<param name="SatelliteNetworkGoal" value="7"/>
<param name="LasertowerNetworkGoal" value="3"/>
<param name="MinefieldGoalPerSector" value="1" comment="[MGPS * Sectors, 12].min is the maximum amount of Minefields for this faction"/>
<param name="DebugChance" value="0"/>
<param name="DebugChance2" value="0"/>
</cue>
</cues>
</cue>
<cue name="HatikvahFreeLeagueFactionLogic">
<cues>
<cue name="HatikvahFreeLeagueFactionLogic_Manager" ref="Manager">
<param name="Faction" value="faction.hatikvah" />
<param name="BaseAggressionLevel" value="moodlevel.low"/>
<param name="BaseAvariceLevel" value="moodlevel.normal"/>
<param name="BaseLawfulness" value="0.4"/>
<param name="PreferredHQSpaceMacro" value="macro.cluster_29_sector001_macro" comment="Hatikvah's Choice"/>
<param name="PreferredHQTypes" value="['tradestation', 'piratebase', 'equipmentdock']"/>
<param name="SatelliteNetworkGoal" value="2"/>
<param name="MinefieldGoalPerSector" value="2" comment="[MGPS * Sectors, 12].min is the maximum amount of Minefields for this faction"/>
<param name="DebugChance" value="0"/>
<param name="DebugChance2" value="0"/>
</cue>
</cues>
</cue>
<cue name="TeladiComapanyFactionLogic">
<cues>
<cue name="TeladiCompanyFactionLogic_Manager" ref="Manager">
<param name="Faction" value="faction.teladi"/>
<param name="BaseAggressionLevel" value="moodlevel.low"/>
<param name="BaseAvariceLevel" value="moodlevel.veryhigh"/>
<param name="BaseLawfulness" value="0.2"/>
<param name="PreferredHQSpaceMacro" value="macro.cluster_15_macro" comment="Ianamus Zura"/>
<param name="PreferredHQTypes" value="[macro.landmarks_tel_tradestation_01_macro, 'tradestation', 'equipmentdock', 'shipbuilding']"/>
<param name="SatelliteNetworkGoal" value="17"/>
<param name="LasertowerNetworkGoal" value="3"/>
<param name="MinefieldGoalPerSector" value="0" comment="[MGPS * Sectors, 12].min is the maximum amount of Minefields for this faction"/>
<param name="DebugChance" value="0"/>
<param name="DebugChance2" value="0"/>
</cue>
</cues>
</cue>
<cue name="MinistryOfFinanceFactionLogic">
<cues>
<cue name="MinistryOfFinanceFactionLogic_Manager" ref="Manager">
<param name="Faction" value="faction.ministry"/>
<param name="BaseAggressionLevel" value="moodlevel.low"/>
<param name="BaseAvariceLevel" value="moodlevel.veryhigh"/>
<param name="BaseLawfulness" value="0.1"/>
<param name="PreferredHQSpaceMacro" value="macro.cluster_34_macro" comment="Profit Centre Alpha"/>
<param name="PreferredHQTypes" value="['equipmentdock', 'shipbuilding']"/>
<param name="SatelliteNetworkGoal" value="2"/>
<param name="LasertowerNetworkGoal" value="3"/>
<param name="MinefieldGoalPerSector" value="2" comment="[MGPS * Sectors, 12].min is the maximum amount of Minefields for this faction"/>
<param name="DebugChance" value="0"/>
<param name="DebugChance2" value="0"/>
</cue>
</cues>
</cue>
<cue name="ScalePlatePactFactionLogic">
<cues>
<cue name="ScalePlatePactFactionLogic_Manager" ref="Manager">
<param name="Faction" value="faction.scaleplate"/>
<param name="BaseAggressionLevel" value="moodlevel.normal"/>
<param name="BaseAvariceLevel" value="moodlevel.veryhigh"/>
<param name="BaseLawfulness" value="0.1"/>
<param name="PreferredHQSpaceMacro" value="macro.cluster_42_macro" comment="Nopileos' Legacy"/>
<param name="PreferredHQTypes" value="['equipmentdock', 'piratebase']"/>
<param name="SatelliteNetworkGoal" value="8"/>
<param name="MinefieldGoalPerSector" value="2" comment="[MGPS * Sectors, 12].min is the maximum amount of Minefields for this faction"/>
<param name="DebugChance" value="0"/>
<param name="DebugChance2" value="0"/>
</cue>
</cues>
</cue>
<cue name="GodrealmOfTheParanidFactionLogic">
<cues>
<cue name="GodrealmOfTheParanidFactionLogic_Manager" ref="Manager">
<param name="Faction" value="faction.paranid"/>
<param name="BaseAggressionLevel" value="moodlevel.high"/>
<param name="BaseAvariceLevel" value="moodlevel.normal"/>
<param name="BaseLawfulness" value="1.0"/>
<param name="PreferredHQSpaceMacro" value="macro.cluster_18_macro" comment="Trinity Sanctum"/>
<param name="PreferredHQTypes" value="['shipbuilding', 'equipmentdock', 'tradestation']"/>
<param name="SatelliteNetworkGoal" value="5"/>
<param name="LasertowerNetworkGoal" value="5"/>
<param name="MinefieldGoalPerSector" value="1" comment="[MGPS * Sectors, 12].min is the maximum amount of Minefields for this faction"/>
<param name="DebugChance" value="0"/>
<param name="DebugChance2" value="0"/>
</cue>
</cues>
</cue>
<cue name="HolyOrderFactionLogic">
<cues>
<cue name="HolyOrderFactionLogicFactionLogic_Manager" ref="Manager">
<param name="Faction" value="faction.holyorder"/>
<param name="BaseAggressionLevel" value="moodlevel.high"/>
<param name="BaseAvariceLevel" value="moodlevel.normal"/>
<param name="BaseLawfulness" value="0.6"/>
<param name="PreferredHQSpaceMacro" value="macro.cluster_24_macro" comment="Holy Vision"/>
<param name="PreferredHQTypes" value="['shipbuilding', 'equipmentdock', 'tradestation']"/>
<param name="SatelliteNetworkGoal" value="4"/>
<param name="LasertowerNetworkGoal" value="4"/>
<param name="MinefieldGoalPerSector" value="2" comment="[MGPS * Sectors, 12].min is the maximum amount of Minefields for this faction"/>
<param name="DebugChance" value="0"/>
<param name="DebugChance2" value="0"/>
</cue>
</cues>
</cue>
<cue name="AllianceOfTheWordFactionLogic">
<cues>
<cue name="AllianceOfTheWordFactionLogic_Manager" ref="Manager">
<param name="Faction" value="faction.alliance"/>
<param name="BaseAggressionLevel" value="moodlevel.normal"/>
<param name="BaseAvariceLevel" value="moodlevel.normal"/>
<param name="BaseLawfulness" value="1.0"/>
<param name="PreferredHQSpaceMacro" value="macro.cluster_23_macro" comment="Sacred Relic"/>
<param name="PreferredHQTypes" value="['shipbuilding', 'equipmentdock']"/>
<param name="SatelliteNetworkGoal" value="3"/>
<param name="LasertowerNetworkGoal" value="1"/>
<param name="DebugChance" value="0"/>
<param name="DebugChance2" value="0"/>
</cue>
</cues>
</cue>
<cue name="XenonFactionLogic">
<cues>
<cue name="XenonFactionLogic_Manager" ref="Manager">
<param name="Faction" value="faction.xenon"/>
<param name="BaseAggressionLevel" value="moodlevel.veryhigh"/>
<param name="BaseAvariceLevel" value="moodlevel.low"/>
<param name="BaseLawfulness" value="1.0"/>
<param name="HasMissions" value="false"/>
<param name="SatelliteNetworkGoal" value="0"/>
<param name="MinefieldGoalPerSector" value="1" comment="[MGPS * Sectors, 12].min is the maximum amount of Minefields for this faction"/>
<param name="DebugChance" value="0"/>
<param name="DebugChance2" value="0"/>
</cue>
<!--Xenon-Kha'ak Existential Crisis-->
<cue name="XenonFactionLogic_KhaakCrisis" ref="md.Crisis_Xenon_Khaak_Combo.Start">
<param name="DebugChance" value="0"/>
</cue>
</cues>
</cue>
<cue name="BuccaneersFactionLogic">
<cues>
<cue name="BuccaneersFactionLogic_Manager" ref="Manager">
<param name="Faction" value="faction.buccaneers"/>
<param name="BaseAggressionLevel" value="moodlevel.high"/>
<param name="BaseAvariceLevel" value="moodlevel.low"/>
<param name="BaseLawfulness" value="0.1"/>
<param name="EconManagerActive" value="false"/>
<param name="PreferredHQSpaceMacro" value="macro.cluster_04_macro"/>
<param name="PreferredHQTypes" value="[]" comment="Appended to from the Paranid story"/>
<param name="SatelliteNetworkGoal" value="2"/>
<param name="LasertowerNetworkGoal" value="2"/>
<param name="MinefieldGoalPerSector" value="7" comment="[MGPS * Sectors, 12].min is the maximum amount of Minefields for this faction"/>
<param name="DebugChance" value="0"/>
<param name="DebugChance2" value="0"/>
</cue>
</cues>
</cue>
<cue name="TrinityFactionLogic">
<conditions>
<event_cue_signalled/>
</conditions>
<actions>
<!--debug_text text="'Starting Trinity factionlogic'"/-->
</actions>
<cues>
<cue name="TrinityFactionLogic_Manager" ref="Manager">
<param name="Faction" value="faction.trinity"/>
<param name="ConsumedFactions" value="[faction.paranid, faction.holyorder]"/>
<param name="BaseAggressionLevel" value="moodlevel.high"/>
<param name="BaseAvariceLevel" value="moodlevel.normal"/>
<param name="BaseLawfulness" value="0.8"/>
<param name="PreferredHQSpaceMacro" value="macro.cluster_11_macro"/>
<param name="PreferredHQTypes" value="['defencestation', 'shipbuilding', 'equipmentdock']"/>
<param name="SatelliteNetworkGoal" value="5"/>
<param name="LasertowerNetworkGoal" value="5"/>
<param name="MinefieldGoalPerSector" value="1" comment="[MGPS * Sectors, 12].min is the maximum amount of Minefields for this faction"/>
<param name="DebugChance" value="0"/>
<param name="DebugChance2" value="0"/>
</cue>
</cues>
</cue>
</cues>
</cue>
<!--
- Invade sector
- Defend sector
- Expand to area
- Enforce anti-smuggler laws
- Request job trade ships
- -->
<!--
####################
MANAGER
####################-->
<library name="Manager" namespace="this" version="15">
<params>
<param name="Faction" comment="The faction to be managed"/>
<param name="ConsumedFactions" default="[]" comment="Inactive factions considered to be a part of $Faction. Used to take their old goals or economic actions into account with the new faction."/>
<param name="BaseAggressionLevel" default="moodlevel.normal" comment="Base level the faction will normalize at"/>
<param name="BaseAvariceLevel" default="moodlevel.normal" comment="Base level the faction will normalize at"/>
<param name="BaseLawfulness" default="0.5"/>
<param name="Volatility" default="0.5" comment="The strength of mood shifts"/>
<param name="HasMissions" default="true" comment="Faction spawns missions"/>
<param name="EconManagerActive" default="true" comment="Start the economy manager analysis as active"/>
<param name="ExpeditionEnemies" default="[]" comment="List of factions to launch long distance expedition 'invasions' against"/>
<param name="SatelliteNetworkGoal" default="0"/>
<param name="LasertowerNetworkGoal" default="0"/>
<param name="LasertowerGateChance" default="0"/>
<param name="MinefieldGoalPerSector" default="0" comment="Note that this requires minelayer-jobs to be defined"/>
<param name="PreferredHQSpaceMacro" default="null" comment="When specifying a PreferredHQ, either specify both PreferredHQSpaceMacro and PreferredHQTypes, or neither"/>
<param name="PreferredHQTypes" default="[]" comment="List of types by priority. Can be a station macro or strings 'shipbuilding', 'equipmentdock', 'tradestation', 'defencestation', 'piratebase' or 'any'"/>
<!--TODO @Owen lists to define prefered spaces for other major stations?-->
<param name="ExcludedSectorMacros" default="[]" comment="List of sector macros for this faction to attempt to ignore. Not an enforced rule for all game systems and the list may be edited through the game."/>
<param name="EconomicallyExcludedSectorMacros" default="[]" comment="List of sector macros for this faction to ignore economically."/>
<param name="PeriodicCallback" default="null" comment="callback cue"/>
<param name="DebugChance" default="0"/>
<param name="DebugChance2" default="0"/>
</params>
<actions>
<set_faction_mood faction="$Faction" type="aggression" level="$BaseAggressionLevel"/>
<set_faction_mood faction="$Faction" type="avarice" level="$BaseAvariceLevel"/>
<set_value name="$Goals" exact="[]"/>
<set_value name="$Crises" exact="[]"/>
<!-- $Intel == [[$TargetSpace, $Recon_NumObjects, $Recon_LastUpdate], etc] -->
<set_value name="$Intel" exact="[]"/>
<!-- $DistressCalls == [$Faction, [$ObjectID, $ForceDifferential, [$Sector, $ShipPosition], player.age, [$Priority, $State]], [$ObjectID, $ForceDifferential, [$Sector, $ShipPosition], player.age, [$Priority, $State]], etc] -->
<set_value name="$DistressCalls" exact="[]"/>
<set_value name="$MilitaryStrengthList" exact="[]"/>
<create_group groupname="$Shipyards"/>
<create_group groupname="$FactionSatellites"/>
<create_list name="$FactionMinefields"/>
<create_list name="$FactionLasertowers"/>
<create_group groupname="$PlayerLasertowers" comment="lasertowers from player-missions"/>
<create_group groupname="$ClaimedSectors"/>
<set_value name="$ExcludedSectors" exact="[]"/>
<do_if value="$ExcludedSectorMacros.count">
<find_sector name="$ExcludedSectors" macro="$ExcludedSectorMacros" multiple="true"/>
</do_if>
<set_value name="$EconomicallyExcludedSectors" exact="[]"/>
<do_if value="$EconomicallyExcludedSectorMacros.count">
<find_sector name="$EconomicallyExcludedSectors" macro="$EconomicallyExcludedSectorMacros" multiple="true"/>
</do_if>
<set_value name="$NextJobRedeployTime" exact="player.age + 1h"/>
<!--Add faction manager cue to the global variable-->
<do_if value="not global.$FactionManagers?">
<set_value name="global.$FactionManagers" exact="table[]"/>
</do_if>
<set_value name="global.$FactionManagers.{$Faction}" exact="namespace"/>
<debug_text text="$Faction + ' trying to register with the Patrol Coordination Service.'" chance="$DebugChance"/>
<signal_cue_instantly cue="md.FactionGoal_PatrolCoordinationService.Register_Factions" param="namespace" comment="'namespace' is the manager-cue"/>
<signal_cue_instantly cue="md.FactionGoal_Plunder.Register_Factions" param="namespace"/>
</actions>
<patch sinceversion="2">
<create_group groupname="$PlayerLasertowers"/>
</patch>
<patch sinceversion="3">
<set_value name="$MinefieldGoalPerSector" exact="0"/>
<do_if value="($Faction == faction.teladi) or ($Faction == faction.alliance)">
</do_if>
<do_elseif value="($Faction == faction.ministry) or ($Faction == faction.scaleplate) or ($Faction == faction.holyorder)">
<set_value name="$MinefieldGoalPerSector" exact="2"/>
</do_elseif>
<do_else>
<set_value name="$MinefieldGoalPerSector" exact="1"/>
</do_else>
</patch>
<patch sinceversion="4">
<!-- removed unused faction.tempest from FactionDB -->
<do_if value="@$Enemies.count">
<do_for_each name="$enemy" in="$Enemies" counter="$_i" reverse="true">
<do_if value="not $enemy">
<debug_text text="'PATCH: removing %s from $Enemies. (should be null)'.[$Enemies.{$_i}]" filter="savegame"/>
<remove_value name="$Enemies.{$_i}"/>
</do_if>
</do_for_each>
</do_if>
</patch>
<patch sinceversion="5">
<signal_cue cue="CreateNewFactionRepresentative"/>
<set_value name="$HQNecessary" exact="$Faction.isactive"/>
<do_if value="$Faction == faction.argon">
<set_value name="$PreferredHQSpaceMacro" exact="macro.cluster_14_macro" comment="Argon Prime"/>
<set_value name="$PreferredHQTypes" exact="['shipbuilding', 'equipmentdock', 'tradestation']"/>
</do_if>
<do_elseif value="$Faction == faction.antigone">
<set_value name="$PreferredHQSpaceMacro" exact="macro.cluster_28_macro" comment="Antigone Memorial"/>
<set_value name="$PreferredHQTypes" exact="['equipmentdock', 'shipbuilding', 'tradestation']"/>
</do_elseif>
<do_elseif value="$Faction == faction.hatikvah">
<set_value name="$PreferredHQSpaceMacro" exact="macro.cluster_29_sector001_macro" comment="Hatikvah's Choice"/>
<set_value name="$PreferredHQTypes" exact="['tradestation', 'piratebase', 'equipmentdock']"/>
</do_elseif>
<do_elseif value="$Faction == faction.paranid">
<set_value name="$PreferredHQSpaceMacro" exact="macro.cluster_18_macro" comment="Trinity Sanctum"/>
<set_value name="$PreferredHQTypes" exact="['shipbuilding', 'equipmentdock', 'tradestation']"/>
</do_elseif>
<do_elseif value="$Faction == faction.holyorder">
<set_value name="$PreferredHQSpaceMacro" exact="macro.cluster_24_macro" comment="Holy Vision"/>
<set_value name="$PreferredHQTypes" exact="['shipbuilding', 'equipmentdock', 'tradestation']"/>
</do_elseif>
<do_elseif value="$Faction == faction.alliance">
<set_value name="$PreferredHQSpaceMacro" exact="macro.cluster_23_macro" comment="Sacred Relic"/>
<set_value name="$PreferredHQTypes" exact="['shipbuilding', 'equipmentdock']"/>
</do_elseif>
<do_elseif value="$Faction == faction.teladi">
<set_value name="$PreferredHQSpaceMacro" exact="macro.cluster_15_macro" comment="Ianamus Zura"/>
<set_value name="$PreferredHQTypes" exact="[macro.landmarks_tel_tradestation_01_macro, 'tradestation', 'equipmentdock', 'shipbuilding']"/>
</do_elseif>
<do_elseif value="$Faction == faction.ministry">
<set_value name="$PreferredHQSpaceMacro" exact="macro.cluster_34_macro" comment="Profit Centre Alpha"/>
<set_value name="$PreferredHQTypes" exact="['equipmentdock', 'shipbuilding']"/>
</do_elseif>
<do_elseif value="$Faction == faction.scaleplate">
<set_value name="$PreferredHQSpaceMacro" exact="macro.cluster_42_macro" comment="Nopileos' Legacy"/>
<set_value name="$PreferredHQTypes" exact="['equipmentdock', 'piratebase']"/>
</do_elseif>
<do_elseif value="not @$PreferredHQSpaceMacro">
<set_value name="$PreferredHQSpaceMacro" exact="null"/>
</do_elseif>
</patch>
<patch sinceversion="6">
<set_value name="$ExcludedSectorMacros" exact="null"/>
</patch>
<patch sinceversion="7">
<set_value name="$ExpeditionEnemies" exact="[]"/>
</patch>
<patch sinceversion="8">
<set_value name="$DoPatchPatrolCoordination" exact="true"/>
</patch>
<patch sinceversion="9">
<do_if value="not $ExcludedSectorMacros">
<set_value name="$ExcludedSectorMacros" exact="[]"/>
</do_if>
<do_if value="not $ExcludedSectors?">
<set_value name="$ExcludedSectors" exact="[]"/>
</do_if>
</patch>
<patch sinceversion="10">
<set_value name="$LasertowerGateChance" exact="0"/>
</patch>
<patch sinceversion="11">
<set_value name="$EconomicallyExcludedSectors" exact="[]"/>
</patch>
<patch sinceversion="13">
<set_value name="$Crises" exact="[]"/>
</patch>
<patch sinceversion="14">
<set_value name="$NextJobRedeployTime" exact="[player.age, 1h].max"/>
</patch>
<patch sinceversion="15">
<set_value name="$EconManagerActive" exact="$Faction != faction.buccaneers"/>
</patch>
<cues>
<cue name="PATCH_ReregisterForPatrolCoordination" onfail="cancel">
<conditions>
<check_value value="@$DoPatchPatrolCoordination"/>
</conditions>
<delay exact="1s"/>
<actions>
<!--Patching out invalid distress calls may have removed this faction from the patrol coordination master list. Attempt to re-add-->
<signal_cue_instantly cue="md.FactionGoal_PatrolCoordinationService.Register_Factions" param="namespace" comment="'namespace' is the manager-cue"/>
<remove_value name="$DoPatchPatrolCoordination"/>
</actions>
</cue>
<cue name="Trigger_Report" instantiate="true" comment="Cue added here for convenience. Signal for faction report.">
<conditions>
<event_cue_signalled/>
</conditions>
<actions>
<signal_cue_instantly cue="md.FactionLogic.FactionSignalled" param="[$Faction, 'Generate Report']"/>
</actions>
</cue>
<!--Libraries-->
<cue name="Econ_Manager" ref="md.FactionLogic_Economy.Econ_Manager">
<param name="FactionManagerCue" value="Manager"/>
<param name="Faction" value="$Faction"/>
<param name="ConsumedFactions" value="$ConsumedFactions"/>
<param name="DebugChance" value="$DebugChance"/>
</cue>
<cue name="Ship_Construction_Manager" ref="md.Job_Helper.Manager">
<param name="FactionManagerCue" value="Manager"/>
<param name="Faction" value="$Faction"/>
<!--<param name="Ref_Shipyards" value="$Shipyards"/>-->
<param name="DebugChance" value="0"/>
</cue>
<cue name="Maintain_Stations" ref="md.FactionLogic_Stations.Manage_Stations">
<param name="FactionManagerCue" value="Manager"/>
<param name="Faction" value="$Faction"/>
<param name="DebugChance" value="0"/>
</cue>
<cue name="StaticDefenseManager" ref="md.FactionLogic_StaticDefense.StaticDefenseManager">
<param name="FactionManagerCue" value="Manager"/>
<param name="Faction" value="$Faction"/>
<param name="DebugChance" value="0" />
</cue>
<cue name="Cleanup_Faction_Headquarters" comment="reset it to a state where Find_Faction_Headquarters will find a new HQ">
<conditions>
<event_cue_signalled/>
</conditions>
<actions>
<do_if value="$Faction.representative.exists">
<debug_text text="'Removing representative %s for faction %s'.[$Faction.representative, $Faction]" chance="0"/>
<set_value name="this.$rep" exact="$Faction.representative"/>
<remove_representative faction="$Faction" />
<debug_text text="'After removing, representative %s for faction %s'.[$Faction.representative, $Faction]" chance="0"/>
<do_if value="@this.$rep.room.iswalkable">
<signal_objects object="this.$rep" param="'npc_despawn'"/>
</do_if>
<do_else>
<remove_actor_from_room actor="this.$rep" destroy="true"/>
</do_else>
</do_if>
<do_if value="$Faction.headquarters.exists">
<debug_text text="'Removing HQ %s for faction %s'.[$Faction.headquarters, $Faction]" chance="0"/>
<set_faction_headquarters faction="$Faction" station="$Faction.headquarters" headquarters="false" comment="Undo it being the HQ"/>
</do_if>
<remove_value name="md.$FactionData.{$Faction}.$Headquarters"/>
<remove_value name="md.$FactionData.{$Faction}.$Representative" comment="can't set it to null, just remove it"/>
<reset_cue cue="Cleanup_Faction_Headquarters"/>
</actions>
</cue>
<cue name="Find_Faction_Headquarters" version="5">
<actions>
<set_value name="$HQNecessary" exact="$Faction.isactive"/>
<!--Even wrecked HQs are valid-->
<set_value name="$HQ" exact="$Faction.headquarters"/>
<do_if value="$HQ.exists">
<debug_text text="$Faction + ' already has headquarters ' + $HQ" chance="$DebugChance"/>
</do_if>
<do_elseif value="not $HQNecessary">
<debug_text text="$Faction + ' does not need a HQ'" chance="$DebugChance"/>
</do_elseif>
<do_else>
<!-- Preferred Faction HQ location and type depends on the faction -->
<debug_text text="'Finding Faction HQ for ' + $Faction" chance="$DebugChance" />
<set_value name="$PreferredSpace" exact="null"/>
<do_if value="$PreferredHQSpaceMacro">
<find_cluster name="$PreferredSpace" macro="$PreferredHQSpaceMacro"/>
<do_if value="not $PreferredSpace">
<find_sector name="$PreferredSpace" macro="$PreferredHQSpaceMacro"/>
</do_if>
</do_if>
<do_if value="$PreferredSpace and $PreferredHQTypes.count">
<!--2 passes. First with $PreferredSpace(based on $PreferredHQSpaceMacro), second for the whole galaxy-->
<set_value name="$SearchSpace" exact="$PreferredSpace"/>
<do_all exact="2">
<do_all exact="$PreferredHQTypes.count" counter="$i">
<debug_text text="'Attempting to find a suitable HQ for faction ' + $Faction.knownname + ' in space ' + $SearchSpace.knownname + ' of type ' + $PreferredHQTypes.{$i}" chance="$DebugChance"/>
<do_if value="typeof $PreferredHQTypes.{$i} == datatype.macro">
<find_station_by_true_owner name="$HQ" space="$SearchSpace" faction="$Faction" macro="$PreferredHQTypes.{$i}" />
</do_if>
<do_elseif value="$PreferredHQTypes.{$i} == 'shipbuilding'">
<find_station_by_true_owner name="$HQ" space="$SearchSpace" faction="$Faction" canbuildships="true" comment="shipyard or wharf"/>
</do_elseif>
<do_elseif value="$PreferredHQTypes.{$i} == 'equipmentdock'">
<find_station_by_true_owner name="$HQ" space="$SearchSpace" faction="$Faction" equipmentdock="true" comment="equipment dock" />
</do_elseif>
<do_elseif value="$PreferredHQTypes.{$i} == 'tradestation'">
<find_station_by_true_owner name="$HQ" space="$SearchSpace" faction="$Faction" tradestation="true" />
</do_elseif>
<do_elseif value="$PreferredHQTypes.{$i} == 'defencestation'">
<find_station_by_true_owner name="$HQ" space="$SearchSpace" faction="$Faction" defencestation="true" />
</do_elseif>
<do_elseif value="$PreferredHQTypes.{$i} == 'piratebase'">
<find_station_by_true_owner name="$HQ" space="$SearchSpace" faction="$Faction" piratebase="true" />
</do_elseif>
<do_elseif value="$PreferredHQTypes.{$i} == 'any'">
<find_station_by_true_owner name="$HQ" space="$SearchSpace" faction="$Faction" />
</do_elseif>
<do_if value="$HQ">
<break/>
</do_if>
</do_all>
<do_if value="$HQ">
<break/>
</do_if>
<do_else>
<set_value name="$SearchSpace" exact="player.galaxy"/>
</do_else>
</do_all>
<do_if value="$HQ">
<debug_text text="$Faction + ' HQ set to ' + $HQ.knownname + ' ' + $HQ + ' in ' + $HQ.sector.knownname + ', ' + $HQ.cluster.knownname" chance="$DebugChance" />
<set_value name="md.$FactionData.{$Faction}.$Headquarters" exact="$HQ" />
<set_faction_headquarters faction="$Faction" station="$HQ"/>
<signal_cue cue="CreateNewFactionRepresentative" />
</do_if>
<do_else>
<debug_text text="'No suitable location for ' + $Faction.name + ' HQ found!'" filter="error" />
</do_else>
</do_if>
<do_else>
<set_value name="$HQNecessary" exact="false" />
<debug_text text="'Faction is ' + $Faction.name + ' - no Faction HQ is required'" chance="$DebugChance" />
</do_else>
<remove_value name="$PreferredSpace"/>
</do_else>
</actions>
<cues>
<cue name="CheckHQStatus" checkinterval="5min">
<conditions>
<!--parent.time so the conditions don't pass as soon as the parent completes with no HQ-->
<check_value value="$HQNecessary and player.age gt (parent.time + 1s) and not $Faction.headquarters.exists"/>
</conditions>
<actions>
<debug_text text="$Faction + ' does not have a HQ. Attempt to find a new one.'" chance="$DebugChance"/>
<reset_cue cue="Find_Faction_Headquarters"/>
</actions>
</cue>
<cue name="CheckHQStatus_FactionActivated">
<conditions>
<event_faction_activated faction="$Faction"/>
<check_value value="$HQNecessary and player.age gt (parent.time + 1s) and not $Faction.headquarters.exists"/>
</conditions>
<actions>
<debug_text text="$Faction + ' active. Attempt to find a HQ.'" chance="$DebugChance"/>
<reset_cue cue="Find_Faction_Headquarters"/>
</actions>
</cue>
</cues>
</cue>
<cue name="PeriodicCallback_Check" checkinterval="5min" instantiate="true">
<actions>
<do_if value="@$PeriodicCallback">
<set_value name="$Table" exact="table[$caller = this, $hqnecessary = $HQNecessary, $hq = $HQ, $PreferredHQSpaceMacro = $PreferredHQSpaceMacro, $preferredhqtypes = $PreferredHQTypes]"/>
<signal_cue_instantly cue="$PeriodicCallback" param="$Table"/>
</do_if>
<!--do_if value="this.$hqrelocate?">
<signal_cue cue="RelocateHQ"/>
<remove_value name="this.$hqrelocate"/>
</do_if-->
</actions>
</cue>
<cue name="RelocateHQ">
<conditions>
<event_cue_signalled/>
</conditions>
<actions>
<debug_text text="'Relocating HQ (preferredhqspace=%s preferedhqtypes=%s)'.[$PreferredHQSpaceMacro, $PreferredHQTypes]" chance="0"/>
<signal_cue cue="Cleanup_Faction_Headquarters"/>
<reset_cue cue="Find_Faction_Headquarters"/>
</actions>
</cue>
<cue name="FactionRepresentativeKilled_Check" checkinterval="1s" version="2">
<conditions>
<check_value value="md.$FactionData.{$Faction}.$Representative?" />
<check_value value="md.$FactionData.{$Faction}.$Representative"/>
</conditions>
<patch sinceversion="2" state="waiting">
<!-- patch missing factionrep definition in characters.xml in 3.10HF1, cue is waiting because it failed to create it previously" -->
<!-- We need to specifically patch faction.court, but can't directly access that, so use a different way to narrow it down to 'relevant' factions -->
<do_if value="(md.$FactionData.{$Faction}.$Headquarters?) and (md.$FactionData.{$Faction}.$Headquarters.isoperational) and (not md.$FactionData.{$Faction}.$Representative?)">
<signal_cue cue="CreateNewFactionRepresentative"/>
</do_if>
</patch>
<cues>
<cue name="FactionRepresentativeKilled">
<conditions>
<event_object_destroyed object="md.$FactionData.{$Faction}.$Representative" />
</conditions>
<actions>
<debug_text text="'Representative for ' + $Faction.name + ', ' + event.object.name + ' ({' + event.object + '}), has been killed'" chance="$DebugChance" />
<set_value name="md.$FactionData.{$Faction}.$Representative" exact="null" />
</actions>
</cue>
<cue name="CheckRepresentativeStatus" checkinterval="3min">
<conditions>
<check_value value="(md.$FactionData.{$Faction}.$Headquarters.isoperational) and (not md.$FactionData.{$Faction}.$Representative.exists)"/>
</conditions>
<actions>
<signal_cue cue="CreateNewFactionRepresentative" />
</actions>
</cue>
</cues>
</cue>
<!-- Create Faction Representative NPCs (at gamestart or when last representative was killed) -->
<cue name="CreateNewFactionRepresentative" instantiate="true">
<conditions>
<event_cue_signalled />
</conditions>
<actions>
<debug_text text="'Check if a new faction representative for ' + $Faction.name + ' is needed'" chance="$DebugChance" />
<do_if value="not $Faction.representative">
<debug_text text="'No faction representative exists for ' + $Faction.name" chance="$DebugChance" />
<do_if value="@md.$FactionData.{$Faction}.$Headquarters.isoperational">
<create_representative_actor name="$Representative" station="md.$FactionData.{$Faction}.$Headquarters" faction="$Faction" />
<do_if value="$Representative">
<debug_text text="'Created ' + $Representative.name + ' ({' + $Representative + '}) as representive of ' + $Faction.name + ' on ' + md.$FactionData.{$Faction}.$Headquarters.knownname + ' ({' + md.$FactionData.{$Faction}.$Headquarters + '}) in ' + md.$FactionData.{$Faction}.$Headquarters.sector.knownname + ', ' + md.$FactionData.{$Faction}.$Headquarters.cluster.knownname" chance="$DebugChance" />
<set_value name="md.$FactionData.{$Faction}.$Representative" exact="$Representative" />
<do_if value="FactionRepresentativeKilled_Check.state" exact="cuestate.complete">
<reset_cue cue="FactionRepresentativeKilled_Check" />
</do_if>
<signal_cue_instantly cue="md.NPC_FactionRepresentative.FactionRepresentativeCreated" param="$Representative" />
</do_if>
<do_else>
<debug_text text="'Failed to create representative of ' + $Faction.name + ' on ' + md.$FactionData.{$Faction}.$Headquarters.knownname + ' ({' + md.$FactionData.{$Faction}.$Headquarters + '}) in ' + md.$FactionData.{$Faction}.$Headquarters.sector.knownname + ', ' + md.$FactionData.{$Faction}.$Headquarters.cluster.knownname" filter="error" />
</do_else>
</do_if>
<do_else>
<debug_text text="'There is no Faction HQ on which to generate the Faction Representative for ' + $Faction.name" filter="error" />
</do_else>
</do_if>
</actions>
</cue>
<!--Delay a random amount so not all factions evaluate at the same time-->
<cue name="Manager_Delay">
<delay min="0s" max="3s"/>
<cues>
<cue name="EvaluateGoals_Wait">
<conditions>
<event_cue_completed cue="Manager_Delay"/>
</conditions>
<cues>
<!--Loop over all potential goals, evaluate their weight and attempt to activate one-->
<cue name="EvaluateGoals" checkinterval="30s" instantiate="true">
<actions>
<include_actions ref="UpdateData"/>
<!--Goals to trigger, regardless of other evaluation scores-->
<set_value name="$PriorityGoals" exact="[]"/>
<!--Goals to be selected for triggering, based on evaluation scores-->
<set_value name="$EvaluatedGoals" exact="[]"/>
<do_all exact="global.$FactionGoals.count" counter="$i">
<do_if value="global.$FactionGoals.{$i}.$EvaluationCue">
<!--Run the actions of the goals evaluation cue. If successful, data will be added to $EvaluatedGoals-->
<include_actions ref="global.$FactionGoals.{$i}.$EvaluationCue"/>
</do_if>
</do_all>
<do_all exact="$PriorityGoals.count" counter="$i">
<debug_text text="player.age + ': %1 is attempting to run priority goal %2 with params: %3'.[$Faction, $PriorityGoals.{$i}.$TriggerCue.$Name, $PriorityGoals.{$i}]" chance="$DebugChance"/>
<signal_cue_instantly cue="$PriorityGoals.{$i}.$TriggerCue" param="$PriorityGoals.{$i}"/>
</do_all>
<!--Evaluate goals and choose which ONE can be activated in this iteration-->
<do_if value="$EvaluatedGoals.count">
<set_value name="$TotalWeight" exact="0.0"/>
<do_all exact="$EvaluatedGoals.count" counter="$i">
<set_value name="$TotalWeight" exact="$EvaluatedGoals.{$i}.$Weight" operation="add"/>
</do_all>
<set_value name="$TargetWeight" min="0.0" max="$TotalWeight"/>
<set_value name="$CurrentWeight" exact="0.0"/>
<do_all exact="$EvaluatedGoals.count" counter="$i">
<!--CurrentGoal = [Weight, TriggerCue, TargetSpace, [NumReconObjects, time], param1, param2, e.t.c]-->
<set_value name="$CurrentGoal" exact="$EvaluatedGoals.{$i}"/>
<set_value name="$CurrentWeight" exact="$CurrentGoal.$Weight" operation="add"/>
<do_if value="$TargetWeight le $CurrentWeight or $i == $EvaluatedGoals.count">
<debug_text text="player.age + ': %1 is attempting to run goal %2 with weight %3 and params: %4'.[$Faction, $CurrentGoal.$TriggerCue.$Name, $CurrentGoal.$Weight, $CurrentGoal]" chance="$DebugChance"/>
<signal_cue_instantly cue="$CurrentGoal.$TriggerCue" param="$CurrentGoal"/>
<break/>
</do_if>
</do_all>
</do_if>
</actions>
</cue>
</cues>
</cue>
<cue name="SectorLost" instantiate="true">
<conditions>
<event_object_changed_owner group="$ClaimedSectors" previous="$Faction"/>
</conditions>
<actions>
<!--Sector which was owned by the faction has either been lost or contested.-->
<set_value name="this.$Sector" exact="event.object"/>
<debug_text text="'Faction ' + $Faction + ' has lost ownership of sector ' + this.$Sector + ' ' + this.$Sector.knownname" chance="$DebugChance"/>
<!--Remove any space tags that the faction may have set for its previous situation-->
<include_actions ref="SectorNoLongerBorder"/>
</actions>
</cue>
<cue name="SectorContested" instantiate="true">
<conditions>
<event_object_changed_contested_state group="$ClaimedSectors" contested="true"/>
</conditions>
<actions>
<!--Sector which was owned by the faction has either been lost or contested.-->
<set_value name="this.$Sector" exact="event.object"/>
<debug_text text="'Faction ' + $Faction + ' is having its ownership of sector ' + this.$Sector + ' ' + this.$Sector.knownname + ' contested'" chance="$DebugChance"/>
<!--Remove any space tags that the faction may have set for its previous situation-->
<include_actions ref="SectorNoLongerBorder" comment="Contested sectors are not considered 'border'"/>
</actions>
</cue>
<!--this.$Sector must be set-->
<library name="SectorNoLongerBorder">
<actions>
<debug_text text="this.$Sector + ' ' + this.$Sector.knownname + ' is no longer considered border for ' + $Faction" chance="if $DebugChance == 100 and this.$Sector.haslocationtag.border then 100 else 0"/>
<remove_space_location_tag space="this.$Sector" tag="tag.border"/>
</actions>
</library>
<library name="UpdateData">
<actions>
<set_value name="$Clusters" exact="[]"/>
<set_value name="$Zones" exact="[]"/>
<!--Populate $ClaimedSectors will all owned and contested sectors of this faction-->
<clear_group group="$ClaimedSectors"/>
<find_sector name="$Sectors" owner="$Faction" multiple="true"/>
<add_to_group groupname="$ClaimedSectors" list="$Sectors"/>
<find_sector groupname="$ClaimedSectors" contestedby="$Faction"/>
<do_for_each name="$Loop_Sector" in="$Sectors">
<do_if value="not $Clusters.indexof.{$Loop_Sector.cluster}">
<append_to_list name="$Clusters" exact="$Loop_Sector.cluster"/>
</do_if>
</do_for_each>
<find_zone name="$Zones" space="$Sectors" normalzone="true" multiple="true" />
<set_value name="$AdjacentSectors" exact="[]"/>
<set_value name="this.$ExcludedSectors" exact="$Sectors.clone"/>
<do_if value="$ExcludedSectors.count">
<append_list_elements name="this.$ExcludedSectors" other="$ExcludedSectors"/>
</do_if>
<!--Find gates in owned sectors which lead to unowned sectors and list those sectors as adjacent. Flag owned sectors bordering enemies as border.-->
<do_for_each name="$OwnSector" in="$Sectors">
<find_gate name="$JumpGates" space="$OwnSector" active="true" multiple="true"/>
<find_highway_entry_gate name="$JumpGates" space="$OwnSector" superhighwaygate="true" append="true" multiple="true"/>
<set_value name="this.$BorderingEnemy" exact="false"/>
<do_for_each name="$JumpGate" in="$JumpGates">
<debug_text text="'gate ' + $OwnSector.knownname + ' dest ' + $JumpGate.destination.sector + ' ' + $JumpGate.destination.sector.knownname" chance="$DebugChance"/>
<set_value name="this.$GateDestination" exact="@$JumpGate.destination.sector"/>
<do_if value="this.$GateDestination and this.$ExcludedSectors.indexof.{this.$GateDestination} == 0">
<debug_text text="$Faction + ' is checking ' + this.$GateDestination.knownname + ' ' + this.$GateDestination + ' from ' + $OwnSector.knownname" chance="$DebugChance"/>
<do_if value="$AdjacentSectors.indexof.{this.$GateDestination} == 0 and this.$GateDestination.owner != $Faction">
<append_to_list name="$AdjacentSectors" exact="this.$GateDestination"/>
</do_if>
<do_if value="not this.$BorderingEnemy">
<!--Check if the sector of our jumpgate is fully in our control but the gate destination leads to a sector owned or contested by an enemy-->
<do_if value="this.$GateDestination.iscontested">
<do_for_each name="$ContestingFaction" in="this.$GateDestination.contestingfactions">
<do_if value="$Faction.hasrelation.enemy.{$ContestingFaction}">
<set_value name="this.$BorderingEnemy" exact="true"/>
<break/>
</do_if>
</do_for_each>
</do_if>
<do_elseif value="$Faction.hasrelation.enemy.{this.$GateDestination.owner}">