[QUESTION] - Adding new stations to AI factions, using god.xml file

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

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

Post Reply
vonclausewitz
Posts: 14
Joined: Sun, 7. Jan 18, 20:15
x3ap

[QUESTION] - Adding new stations to AI factions, using god.xml file

Post by vonclausewitz » Sat, 25. Sep 21, 14:24

I read somewhere here on forum that god.xml file is responsible for adding stations to galaxy.

I tried to add more stations for several various factions, by creating small mod. Inside - god.xml. Below is example code:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>

<diff>
  <add sel="/god/stations">

   
     <!-- Argon Federation -->
    <station id="powerful_trf_shipyard_argon_01" race="argon" owner="argon" type="factory">
      <quotas>
        <quota galaxy="1" zone="1" />
      </quotas>
      <location class="zone" macro="zone002_cluster_11_sector001_macro" />
      <position x="23617.273" y="-4900" z="-19778.223" pitch="0" roll="0" />
      <station>
        <select faction="argon" tags="[shipyard]" />
        <loadout>
          <level exact="1.0" />
        </loadout>
      </station>
    </station>

    <station id="powerful_trf_shipyard_general_1" race="argon" owner="argon" type="factory">
      <quotas>
        <quota galaxy="1" zone="1" />
      </quotas>
      <location class="zone" macro="zone002_cluster_21_sector001_macro" />
      <station>
        <select faction="argon" tags="[shipyard]" />
        <loadout>
          <level exact="1.0" />
        </loadout>
      </station>
    </station>
	 <station id="powerful_trf_shipyard_general_2" race="argon" owner="argon" type="factory">
      <quotas>
        <quota galaxy="1" zone="1" />
      </quotas>
      <location class="zone" macro="zone003_cluster_46_sector001_macro" />
      <station>
        <select faction="argon" tags="[shipyard]" />
        <loadout>
          <level exact="1.0" />
        </loadout>
      </station>
    </station>
	 <station id="powerful_trf_shipyard_general_3" race="argon" owner="argon" type="factory">
      <quotas>
        <quota galaxy="1" zone="1" />
      </quotas>
      <location class="zone" macro="zone003_cluster_30_sector001_macro" />
      <station>
        <select faction="argon" tags="[shipyard]" />
        <loadout>
          <level exact="1.0" />
        </loadout>
      </station>
    </station>
	
	

  </add>
</diff>
My problem is, that there is no effect in-game. Clearly I am missing something.
Is it because by editing station id, <station id="powerful_trf_shipyard_general_1" race="argon" owner="argon" type="factory"> I should, edit change something else?

My intention is to add more stations, so for instance each factions could have 3-4 shipyards, instead of one.

Sheglov
Posts: 13
Joined: Thu, 5. Aug 21, 15:15
xr

Re: [QUESTION] - Adding new stations to AI factions, using god.xml file

Post by Sheglov » Sun, 26. Sep 21, 08:51

Everything is very simple. The file god. Added for example.

Code: Select all

diff>
	<add sel="//god/stations">
		<!-- Hatikvah Wharf -->
		<station id="wharf_hatikvah" race="argon" owner="hatikvah" type="factory">
			<quotas>
				<quota galaxy="1" zone="1" />
			</quotas>
			<location class="zone" macro="Zone004_Cluster_29_Sector001_macro" matchextension="false" />
			<station>
				<select faction="hatikvah" tags="[wharf]" />
				<loadout>
					<level exact="0.7" />
				</loadout>
			</station>
		</station>
		
		<!-- Hatikvah Shipyard -->
		<station id="shipyard_hatikvah" race="argon" owner="hatikvah" type="factory">
			<quotas>
				<quota galaxy="1" zone="1" />
			</quotas>
			<location class="zone" macro="Zone003_Cluster_44_Sector001_macro" matchextension="false" />
			<station>
				<select faction="hatikvah" tags="[shipyard]" />
				<loadout>
					<level exact="0.8" />
				</loadout>
			</station>
		</station>
		
		<!-- Hatikvah equipmentdock -->
		<station id="equipmentdock_hatikvah_01" race="argon" owner="hatikvah" type="factory">
          <quotas>
            <quota galaxy="1" zone="1" />
          </quotas>
          <location class="zone" macro="Zone005_Cluster_44_Sector001_macro" matchextension="false"/>
        <station>
          <select faction="hatikvah" tags="[equipmentdock]" />
           <loadout>
           <level exact="1.0" />
           </loadout>
          </station>
       </station>
	   
	   <station id="hat_defence_cluster_44_sector001" race="argon" owner="hatikvah" type="factory">
      <quotas>
        <quota galaxy="1" zone="1" />
      </quotas>
        <location class="zone" macro="Zone002_Cluster_44_Sector001_macro" matchextension="false"/>
      <station>
        <select faction="hatikvah" tags="[defence]" />
       </station>
      </station>
		
		
		
		<!-- Scaleplate Shipyard -->
		<station id="shipyard_scaleplate" race="teladi" owner="scaleplate" type="factory">
			<quotas>
				<quota galaxy="1" zone="1" />
			</quotas>
			<location class="sector" macro="Cluster_42_Sector002_macro" matchextension="false">
				<corerange min="1.2" max="1.4"/>
			</location>
			<station>
				<select faction="scaleplate" tags="[shipyard]" />
				<loadout>
					<level exact="1.0" />
				</loadout>
			</station>
		</station>

		<!-- Scaleplate Wharfs -->
		<station id="wharf_scaleplate_0" race="teladi" owner="scaleplate" type="factory">
			<quotas>
				<quota galaxy="1" zone="1" />
			</quotas>
			<location class="sector" macro="Cluster_42_Sector002_macro" matchextension="false">
				<corerange min="1.2" max="1.4"/>
			</location>
			<station>
				<select faction="scaleplate" tags="[wharf]" />
				<loadout>
					<level exact="1.0" />
				</loadout>
			</station>
		</station>
		<station id="wharf_scaleplate_1" race="teladi" owner="scaleplate" type="factory">
			<quotas>
				<quota galaxy="1" zone="1" />
			</quotas>
			<location class="sector" macro="Cluster_04_Sector001_macro" matchextension="false">
				<corerange min="1.2" max="1.4"/>
			</location>
			<station>
				<select faction="scaleplate" tags="[wharf]" />
				<loadout>
					<level exact="1.0" />
				</loadout>
			</station>
		</station>
		<!-- Scaleplate tradestation -->
		<station id="ringstation_04" race="teladi" owner="scaleplate" type="tradingstation">
         <quotas>
        <quota galaxy="1" />
      </quotas>
      <location class="zone" macro="Zone002_Cluster_42_Sector002_macro" matchextension="false" />
      <position x="8" y="-2" z="1" pitch="0" roll="0" />
      <station ref="tradestation_tel_ring">
        <loadout>
          <level exact="0.75"/>
        </loadout>
      </station>
      </station>
	  
	  <!-- Scaleplate equipmentdock -->
		<station id="equipmentdock_hatikvah_0111" race="teladi" owner="scaleplate" type="factory">
          <quotas>
            <quota galaxy="1" zone="1" />
          </quotas>
          <location class="sector" macro="Cluster_42_Sector002_macro" matchextension="false"/>
        <station>
          <select faction="scaleplate" tags="[equipmentdock]" />
           <loadout>
           <level exact="1.0" />
           </loadout>
          </station>
       </station>
	  
		
		<!-- Yaki Station -->
		<station id="station_yaki_0" race="argon" owner="yaki" type="yakistation">
			<quotas>
				<quota galaxy="1" zone="1" />
			</quotas>
			<location class="sector" macro="Cluster_26_Sector002_macro" matchextension="false">
				<corerange min="1.2" max="1.4"/>
			</location>
			<station>
				<select faction="yaki" tags="[wharf]" />
				<loadout>
					<level exact="1.0" />
				</loadout>
			</station>
		</station>
	</add>
</diff>
You need to edit the file. factionlogic_stations

Code: Select all

<diff>
	<add sel="/mdscript/cues/library[@name='Manage_Stations']/cues/cue[@name='Process']/cues/cue[@name='Analyse_Stations']/actions/do_elseif[@value='@$DesiredShipyardPatchMarker']" pos="after">
		<do_elseif value="$Faction == faction.hatikvah">
			<set_value name="$DesiredShipyards" exact="1"/>
		</do_elseif>
	</add>

	<add sel="/mdscript/cues/library[@name='Manage_Stations']/cues/cue[@name='Process']/cues/cue[@name='Analyse_Stations']/actions/do_elseif[@value='@$DesiredWharfPatchMarker']" pos="after">
		<do_elseif value="$Faction == faction.hatikvah">
			<set_value name="$DesiredWharfs" exact="1"/>
		</do_elseif>
	</add>
	
	<add sel="/mdscript/cues/library[@name='Manage_Stations']/cues/cue[@name='Process']/cues/cue[@name='Analyse_Stations']/actions/do_elseif[@value='@$DesiredEquipmentDockPatchMarker']" pos="after">
    <do_elseif value="$Faction == faction.hatikvah ">
      <set_value name="$DesiredEquipmentDocks" exact="1"/>
    </do_elseif>
  </add>
	
	<add sel="/mdscript/cues/library[@name='Manage_Stations']/cues/cue[@name='Process']/cues/cue[@name='Analyse_Stations']/actions/do_elseif[@value='@$DesiredShipyardPatchMarker']" pos="after">
		<do_elseif value="$Faction == faction.scaleplate">
			<set_value name="$DesiredShipyards" exact="1"/>
		</do_elseif>
	</add>

	<add sel="/mdscript/cues/library[@name='Manage_Stations']/cues/cue[@name='Process']/cues/cue[@name='Analyse_Stations']/actions/do_elseif[@value='@$DesiredWharfPatchMarker']" pos="after">
		<do_elseif value="$Faction == faction.scaleplate">
			<set_value name="$DesiredWharfs" exact="2"/>
		</do_elseif>
	</add>
	
	<add sel="/mdscript/cues/library[@name='Manage_Stations']/cues/cue[@name='Process']/cues/cue[@name='Analyse_Stations']/actions/do_elseif[@value='@$DesiredTradeStationPatchMarker']" pos="after">
    <do_elseif value="$Faction == faction.scaleplate ">
      <set_value name="$DesiredTradeStation" exact="1"/>
    </do_elseif>
  </add>
    
	<add sel="/mdscript/cues/library[@name='Manage_Stations']/cues/cue[@name='Process']/cues/cue[@name='Analyse_Stations']/actions/do_elseif[@value='@$DesiredEquipmentDockPatchMarker']" pos="after">
    <do_elseif value="$Faction == faction.scaleplate ">
      <set_value name="$DesiredEquipmentDocks" exact="1"/>
    </do_elseif>
  </add>
</diff>

Sheglov
Posts: 13
Joined: Thu, 5. Aug 21, 15:15
xr

Re: [QUESTION] - Adding new stations to AI factions, using god.xml file

Post by Sheglov » Sun, 26. Sep 21, 09:48

And also to make sure the station appears. It is necessary to add sectors and zones in Files. Аor example

Code: Select all

<add sel="/macros/macro[@name='Cluster_113_Sector001_macro']/connections" silent="true">
		<connection name="Zone555551_Cluster_113_Sector001_connection" ref="zones">
			<offset>
				<position x="0" y="0" z="0"/>
			</offset>
			<macro ref="ZoneX555551_Cluster_113_Sector001_macro" connection="sector"/>
		</connection>
	</add>

Code: Select all

<add sel="/macros" silent="true">
<macro name="Zone55551_Cluster_113_Sector001_macro" class="zone">
    <component ref="standardzone" />
    </connections>
</macro>
    </add>
 
And this "Zone55551_Cluster_113_Sector001_macro" value to register in the file God .

vonclausewitz
Posts: 14
Joined: Sun, 7. Jan 18, 20:15
x3ap

Re: [QUESTION] - Adding new stations to AI factions, using god.xml file

Post by vonclausewitz » Sun, 26. Sep 21, 19:50

Genial!

This is exactly what I was looking for, and I would never made it myself.

I tested it, it works, faction logic reacts perfectly with new stations. I would say, that Scale plate ships 'loves' new equipment docks. I have tested it few times, and each time watched like almost whole scale plate fleet was sent for re-equipment. To quote one doctor: 'It's alive!'

So if anyone - like me - would want to use this thread to learn, I have uploaded example/mod and posted couple galaxy map pictures so everyone can see result - https://www.moddb.com/mods/turbo-lanzer ... torial-mod

Also it may be worth mentioning that using described method it is also possible to add station to a player as well.

Player-stations in god.xml:

Code: Select all

			
		<!-- PLAYER - Shipyard -->
		
		<station id="shipyard_player_station_1" race="teladi" owner="player" type="factory">
			<quotas>
				<quota galaxy="1" zone="1" />
			</quotas>
			<location class="sector" macro="Cluster_04_Sector002_macro" matchextension="false">  <!--Nopileos' Fortune VI-->
				<corerange min="1.2" max="1.4"/>
			</location>
			<station>
				<select faction="player" tags="[shipyard]" />
				<loadout>
					<level exact="1.0" />
				</loadout>
			</station>
		</station>



Now, there is one small thing though. I don't understand that last part of instruction:
And this "Zone55551_Cluster_113_Sector001_macro" value to register in the file God .
I don't really understand how does it work?

My understanding is that I was supposed to insert that into one of the hatikvah's station like this:

Code: Select all

	<!-- Hatikvah Wharf -->
		<station id="wharf_hatikvah_1" race="argon" owner="hatikvah" type="factory">
			<quotas>
				<quota galaxy="1" zone="1" />
			</quotas>
			<location class="zone" macro="ZoneX555551_Cluster_113_Sector001_macro" matchextension="false" />
			<station>
				<select faction="hatikvah" tags="[wharf]" />
				<loadout>
					<level exact="0.7" />
				</loadout>
			</station>
		</station>
also I have created sectors.xml:

Code: Select all

 <diff>
   <add sel="/macros/macro[@name='Cluster_113_Sector001_macro']/connections" silent="true">
		<connection name="Zone555551_Cluster_113_Sector001_connection" ref="zones">
			<offset>
				<position x="0" y="0" z="0"/>
			</offset>
			<macro ref="ZoneX555551_Cluster_113_Sector001_macro" connection="sector"/>
		</connection>
	</add>
</diff> 
and zones.xml

Code: Select all

<diff>
    <add sel="/macros" silent="true">
    <macro name="Zone55551_Cluster_113_Sector001_macro" class="zone">
           <component ref="standardzone" />
    </macro>
    </add>
 </diff> 
 
I did probably something wrong, because that didn't work. However, it I don't see any problem here, as I can insert any station, anywhere I want, by referring to mapdefaults.xml I search for sector name where I want insert station, and copy-paste into station id like this:

Code: Select all

<!-- Alliance - SIS Space Intelligence Service -  Wharfs -->
		
		<station id="wharf_alliance_sis_1" race="teladi" owner="alliance" type="factory">
			<quotas>
				<quota galaxy="1" zone="1" />
			</quotas>
			<location class="sector" macro="Cluster_04_Sector002_macro" matchextension="false">
				<corerange min="1.2" max="1.4"/>
			</location>
			<station>
				<select faction="alliance" tags="[wharf]" />
				<loadout>
					<level exact="1.0" />
				</loadout>
			</station>
		</station>
So, as to my needs it is more than I expected. I cannot tell how many hours I have spent trying to solve that.

Thank You, this is amazing.


EDIT:

one last thing about factionlogic_station.xml.

That code 'adds' to logic:

Code: Select all

<add sel="/mdscript/cues/library[@name='Manage_Stations']/cues/cue[@name='Process']/cues/cue[@name='Analyse_Stations']/actions/do_elseif[@value='@$DesiredWharfPatchMarker']" pos="after">
		<do_elseif value="$Faction == faction.scaleplate">
			<set_value name="$DesiredWharfs" exact="3"/>
		</do_elseif>
	</add>
	
and it works for those factions which had no this logic before, but it doesn't work for faction, who had this logic already. I understand that if I would want to change Argon, not Scaleplate, should I use replace instead of add?
I am asking because I tried adding Argon same way like hatikvah and that part with faction logic doesn't seem to work.

Sheglov
Posts: 13
Joined: Thu, 5. Aug 21, 15:15
xr

Re: [QUESTION] - Adding new stations to AI factions, using god.xml file

Post by Sheglov » Mon, 27. Sep 21, 07:25

Hi!
I don't really understand how does it work?
The line places the station anywhere in the sector.
<location class="sector" macro="Cluster_04_Sector002_macro" matchextension="false">

Precise placement of the station in the desired location of the sector.
also I have created sectors.xml:
<diff>
<add sel="/macros/macro[@name='Cluster_113_Sector001_macro']/connections" silent="true">
<connection name="Zone555551_Cluster_113_Sector001_connection" ref="zones">
<offset>
<position x="0" y="0" z="0"/>
</offset>
<macro ref="ZoneX555551_Cluster_113_Sector001_macro" connection="sector"/>
</connection>
</add>
</diff>
and zones.xml
<diff>
<add sel="/macros" silent="true">
<macro name="Zone55551_Cluster_113_Sector001_macro" class="zone">
<component ref="standardzone" />
</macro>
</add>
</diff>

<station id="shipyard_hatikvah" race="argon" owner="hatikvah" type="factory">
<quotas>
<quota galaxy="1" zone="1" />
</quotas>
<location class="zone" macro="Zone003_Cluster_44_Sector001_macro" matchextension="false" />
<station>
<select faction="hatikvah" tags="[shipyard]" />
<loadout>
<level exact="0.8" />
</loadout>
</station>
</station>

Underlined line. Should be the same.
And that was an example for Sector 113.
And I was wrong with the number 5! :)
Galaxy Map.
https://www.nexusmods.com/x4foundations/mods/538

<offset>
<position x="0" y="0" z="0"/>
</offset>
With this value we place the station.

Sheglov
Posts: 13
Joined: Thu, 5. Aug 21, 15:15
xr

Re: [QUESTION] - Adding new stations to AI factions, using god.xml file

Post by Sheglov » Tue, 28. Sep 21, 04:31

and it works for those factions which had no this logic before, but it doesn't work for faction, who had this logic already. I understand that if I would want to change Argon, not Scaleplate, should I use replace instead of add?
I am asking because I tried adding Argon same way like hatikvah and that part with faction logic doesn't seem to work.
Hi! This is from DLS Split.

Code: Select all

  <add sel="/mdscript/cues/library[@name='Manage_Stations']/cues/cue[@name='Process']/cues/cue[@name='Analyse_Stations']/actions/do_elseif[@value='@$DesiredWharfPatchMarker']" pos="after">
    <do_elseif value="$Faction == faction.split">
      <set_value name="$DesiredWharfs" exact="2"/>
    </do_elseif>
    <do_elseif value="$Faction == faction.freesplit">
      <set_value name="$DesiredWharfs" exact="1"/>
    </do_elseif>   
    <!--Additional wharfs for Argon and Paranid when DLC is active-->
    <do_if value="$Faction == faction.argon or $Faction == faction.paranid">
      <set_value name="$DesiredWharfs" operation="add"/>
    </do_if>
    <do_elseif value="$Faction == faction.xenon">
      <set_value name="$DesiredWharfs" operation="add" exact="2"/>
    </do_elseif>
  </add>

vonclausewitz
Posts: 14
Joined: Sun, 7. Jan 18, 20:15
x3ap

Re: [QUESTION] - Adding new stations to AI factions, using god.xml file

Post by vonclausewitz » Fri, 1. Oct 21, 21:36

Thank You so much! Everything works! Exactly as pointed.

Thank You for explanation. Galaxy map - very handy.

If anyone would want to follow, I have uploaded 2nd example file, this time on nexus in case someone is not comfortable with moddb. Nexus link to example/mod -> https://www.nexusmods.com/x4foundations/mods/775
version002 adds Argon stations. There are also some pictures, to give idea what it look like.

Post Reply

Return to “X4: Foundations - Scripts and Modding”