Created Xenon ships not attacking

The place to discuss scripting and game modifications for X4: Foundations.

Moderators: Scripting / Modding Moderators, Moderators for English X Forum

Phiolin
Posts: 158
Joined: Wed, 26. May 04, 08:49
x4

Created Xenon ships not attacking

Post by Phiolin »

I looked into a way of creating a couple of Xenon destroyers to save one of their sectors using below code from an md cue:

Code: Select all

          <actions>
            <find_zone name="$ship_zone" space="player.galaxy" multiple="false" required="true">
              <match_any>
                <match macro="macro.tzoneCluster_112_Sector002SHCon5_GateZone_macro" />
              </match_any>
            </find_zone>
            <find_sector name="$Sector_SavageSpur_2" macro="macro.Cluster_112_Sector002_macro"/>
            <find_station_by_true_owner name="$DefenceStations" faction="faction.xenon" planneddefencestation="true" plannedshipyard="false" plannedwharf="false" plannedequipmentdock="false" plannedtradestation="false" space="$Sector_SavageSpur_2" checkoperational="false" multiple="true"/>
            <do_all exact="$DefenceStations.count" counter="$i" reverse="true">
              <create_ship name="$ship" macro="ship_xen_xl_destroyer_01_a_macro" zone="$ship_zone" commandeerable="true">
                <owner exact="faction.xenon" overridenpc="true"/>
                <loadout ref="scenario_combat_xen_destroyer"/>
                <pilot>
                  <select faction="faction.xenon" tags="tag.commander"/>
                </pilot>
                <people>
                  <fillpercent exact="100"/>
                </people>
                <safepos object="$DefenceStations.{$i}" max="10km"/>
              </create_ship>
              <create_order id="'ProtectStation'" object="$ship" immediate="true">
                <param name="station" value="$DefenceStations.{$i}"/>
              </create_order>

              <create_ship name="$ship" macro="ship_xen_xl_destroyer_01_a_macro" zone="$ship_zone" commandeerable="true">
                <owner exact="faction.xenon" overridenpc="true"/>
                <loadout ref="scenario_combat_xen_destroyer"/>
                <pilot>
                  <select faction="faction.xenon" tags="tag.commander"/>
                </pilot>
                <people>
                  <fillpercent exact="100"/>
                </people>
                <safepos object="$DefenceStations.{$i}" max="10km"/>
              </create_ship>
              <create_order id="'ProtectStation'" object="$ship" immediate="true">
                <param name="station" value="$DefenceStations.{$i}"/>
              </create_order>
              <create_ship name="$ship" macro="ship_xen_xl_destroyer_01_a_macro" zone="$ship_zone" commandeerable="true">
                <owner exact="faction.xenon" overridenpc="true"/>
                <loadout ref="scenario_combat_xen_destroyer"/>
                <pilot>
                  <select faction="faction.xenon" tags="tag.commander"/>
                </pilot>
                <people>
                  <fillpercent exact="100"/>
                </people>
                <safepos object="$DefenceStations.{$i}" max="10km"/>
              </create_ship>
              <create_order id="'ProtectStation'" object="$ship" immediate="true">
                <param name="station" value="$DefenceStations.{$i}"/>
              </create_order>

              <create_ship name="$ship" macro="ship_xen_xl_destroyer_01_a_macro" zone="$ship_zone" commandeerable="true">
                <owner exact="faction.xenon" overridenpc="true"/>
                <loadout ref="scenario_combat_xen_destroyer"/>
                <pilot>
                  <select faction="faction.xenon" tags="tag.commander"/>
                </pilot>
                <people>
                  <fillpercent exact="100"/>
                </people>
                <safepos object="$DefenceStations.{$i}" max="10km"/>
              </create_ship>
              <create_order id="'ProtectStation'" object="$ship" immediate="true">
                <param name="station" value="$DefenceStations.{$i}"/>
              </create_order>

              <create_object name="$TargetSatellite" macro="[macro.eq_arg_satellite_02_macro].random" owner="faction.player" sector="$Sector_SavageSpur_2">
                <safepos max="25km" object="$DefenceStations.{$i}"/>
              </create_object>
            </do_all>
            <remove_value name="$TargetSatellite" />
            <remove_value name="$DefenceStations" />
            <remove_value name="$ship" />
            <remove_value name="$ship_zone" />
            <remove_value name="$Sector_SavageSpur_2" />
          </actions>
The ships are spawning in just fine around the defense stations in Savage Spur II, however they just idle there and don't attack/retaliate against any enemies.
There's a Terran task force shooting at one of the stations, but it is completely ignored even by the destroyers spawning right next to the Terrans. The K's even get hit and don't seem to be interested in it at all.

I'm certainly missing something - why are the destroyers not fullfilling the ProtectStation order and are even not shooting back at their enemies at all? Is there anything else I need to add to make them aggressive?

Edit: Seems like ships don't inherit the faction relations. Setting some relations helps to bring out the guns, i.e.:

Code: Select all

              
              <create_ship name="$ship" macro="ship_xen_xl_destroyer_01_a_macro" zone="$ship_zone" commandeerable="true">
                <owner exact="faction.xenon" overridenpc="true"/>
                <loadout ref="scenario_combat_xen_destroyer"/>
                <pilot>
                  <select faction="faction.xenon" tags="tag.commander"/>
                </pilot>
                <people>
                  <fillpercent exact="100"/>
                </people>
                <safepos object="$DefenceStations.{$i}" max="10km"/>
              </create_ship>
              <create_order id="'ProtectStation'" object="$ship" immediate="true">
                <param name="station" value="$DefenceStations.{$i}"/>
              </create_order>              
              <set_relation_boost object="$ship" faction="faction.terran" silent="true" decay="0.00000001" value="-0.7"/>
              <set_relation_boost object="$ship" faction="faction.argon" silent="true" decay="0.00000001" value="-0.7"/>
              <set_relation_boost object="$ship" faction="faction.antigone" silent="true" decay="0.00000001" value="-0.7"/>
              <set_relation_boost object="$ship" faction="faction.pioneers" silent="true" decay="0.00000001" value="-0.7"/>
DeadAirRT
Posts: 1124
Joined: Fri, 25. Jan 19, 03:26
x4

Re: Created Xenon ships not attacking

Post by DeadAirRT »

Pretty sure you have to designate the order as default
Phiolin
Posts: 158
Joined: Wed, 26. May 04, 08:49
x4

Re: Created Xenon ships not attacking

Post by Phiolin »

It actually helped to add the set_relation_boost to make the K's attack the surrounding fighters. I would have expected that spawning ships with faction.xenon should be enough for them to inherit faction relations, but they were just sitting there taking hits from the Terrans without shooting back. After adding the set_relation_boost to make them more hostile towards the Terrans, they fired back immediately as I would expect.
So for what I was trying to do, which was really just preventing that sector to be taken over by the Terrans, this was a good enough fix.
Meanwhile it seems the faction logic has commandeered the ships elsewhere, so that seems to be in order now.

Return to “X4: Foundations - Scripts and Modding”