[HELP requested] Need help with AI jobs

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

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

Post Reply
Code501
Posts: 1
Joined: Wed, 8. May 24, 10:36
x4

[HELP requested] Need help with AI jobs

Post by Code501 » Wed, 8. May 24, 11:08

Hi all, I'm new to modding X4, but recently got an interest in it. So far I've been able to make 'new' ships and add them to the game. I can get all the blueprints, build them at shipyards and see related encyclopedia entries.

The mod I made is basically 'new' Xenon ships/equipment/equipmentmods that the player can build. I also wanted to get the AI to use them in some sort of invasion force. I made a md script to automatically add the blueprints to the player at game start and made sure the owner faction in wares.xml is set to xenon.

If I want the AI to use them instead of the regular jobs I need to make a Job xml accompanied by a Shipgroups xml and Ships xml, right? Only my scout patrol seems to be randomly spawning and I have no idea why. If I remove all the jobs only the standard Xenon miner seems to be spawning.
I've been looking at code from other mods and searched the internet to try and find an answer, but so far no luck. Any help would be greatly appreciated!

jobs.xml
Spoiler
Show

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<diff>
	<!-- Remove old jobs -->
	<!--
	<remove sel="/jobs/job[@id='xenon_free_miner_m_mineral']" />
	<remove sel="/jobs/job[@id='xenon_free_trader_m_energy']" />
	<remove sel="/jobs/job[@id='xenon_carrier_patrol_xl_border_cluster']" />
	<remove sel="/jobs/job[@id='xenon_carrier_patrol_xl_zone_defence']" />
	<remove sel="/jobs/job[@id='xenon_destroyer_patrol_xl_cluster']" />
	<remove sel="/jobs/job[@id='xenon_destroyer_patrol_xl_cluster_mission']" />
	<remove sel="/jobs/job[@id='xenon_destroyer_patrol_xl_defence']" />
	<remove sel="/jobs/job[@id='xenon_destroyer_patrol_xl_comp']" />
	<remove sel="/jobs/job[@id='xenon_destroyer_patrol_xl_comp_mission']" />
	<remove sel="/jobs/job[@id='xenon_fighter_patrol_s_zone']" />
	<remove sel="/jobs/job[@id='xenon_frigate_patrol_m_zone_everywhereelse']" />
	<remove sel="/jobs/job[@id='xenon_frigate_patrol_m_zone_everywhereelse_mission']" />
	<remove sel="/jobs/job[@id='xenon_scout_patrol_s']" />
	<remove sel="/jobs/job[@id='xenon_fighter_s_deepspace_single']" />
	<remove sel="/jobs/job[@id='xenon_fighter_s_deepspace_group']" />
	<remove sel="/jobs/job[@id='xenon_destroyer_escort_xl']" />
	<remove sel="/jobs/job[@id='xenon_frigate_escort_m']" />
	<remove sel="/jobs/job[@id='xenon_fighter_escort_s_frigate']" />
	<remove sel="/jobs/job[@id='xenon_fighter_escort_s_patrol']" />
	<remove sel="/jobs/job[@id='xenon_staticdefense_engineer_m']" />
	<remove sel="/jobs/job[@id='xenon_staticdefense_minelayer_s']" />
	-->
	<add sel="//jobs">
			<!-- CONCEPT: overextension. absolute limits are set in the galaxy quota - a faction will never build and deploy more than this number of this job.
          if a job's galaxy quota is set equal to the faction's starting number of the relevant space type,
            that leaves no space for expansion
            thus overextending immediately upon conquering more space.

          defining some point at which a faction overextends can be set by changing the galaxy quota of jobs
            relative to starting conditions,
            and relative to total number of spaces.
          for effectively no risk of overextension, set to total number of that space type in the galaxy.

          some additional complexity is available by keeping track of front line spaces vs border spaces vs internal spaces.

          At the moment, jobs are mostly set to have enough numbers to cover only the space that they start with, this coverage stretching as the faction expands.
          Jobs marked _exp can expand past the faction's starting territory, but only up to a point. These allow a faction to expand to a point largely defined here.
            Nature of reinforcement resulting from expansion is also largely defined by these jobs.
          Jobs marked _comp are capable of occupying a relatively small volume of space in numbers that are more significant than normal.
            These tend to resist compression, tending to concentrate as a faction contracts.

      Totals:
        Clusters: 47 (33)
        Sectors: 60 (44)
        Zones: 396 (162) -->
			
			<!-- JOB TAGS
			for patrol coord center (without invasions): commandeerable=true, military
			for invasions: commandeerable=true, factionlogic, military, 
			for economy factionlogic: factionlogic, freighter (miner, tug, trader)
			for expedition: expedition, military -->
		
		<!-- Xenon Non Combat M Freighter Jobs -->
		<job id="xenon_free_miner_x" name="{20204,1901}" startactive="true">
			<modifiers commandeerable="true"/>
			<orders>
				<order order="MiningRoutine" default="true">
					<param name="minbuy" value="0"/>
					<param name="maxbuy" value="2"/>
					<param name="minsell" value="0"/>
					<param name="maxsell" value="2"/>
				</order>
			</orders>
			<basket basket="minerals_xenon"/>
			<category faction="xenon" tags="[factionlogic, sx]" size="ship_m"/>
			<quota galaxy="56" cluster="8"/>
			<location class="galaxy" macro="xu_ep2_universe_macro" faction="xenon" relation="ally" comparison="ge" regionbasket="minerals_xenon"/>
			<environment buildatshipyard="false" gate="true"/>
			<ship>
				<select faction="xenon" tags="[sx, solid]" size="class.ship_m"/>
				<owner exact="xenon" overridenpc="true"/>
				<cargo>
					<wares>
						<fillpercent min="0" max="100" profile="inversebell"/>
					</wares>
				</cargo>
			</ship>
		</job>

		<job id="xenon_free_trader_x" name="{20204,4801}" startactive="true">
			<modifiers commandeerable="true"/>
			<orders>
				<order order="TradeRoutine" default="true">
					<param name="minbuy" value="0"/>
					<param name="maxbuy" value="2"/>
					<param name="minsell" value="0"/>
					<param name="maxsell" value="2"/>
				</order>
			</orders>
			<basket basket="energycells"/>
			<category faction="xenon" tags="[factionlogic, sx]" size="ship_m"/> <!-- freighter, trader -->
			<quota galaxy="42" cluster="6"/>
			<location class="galaxy" macro="xu_ep2_universe_macro" faction="xenon" relation="ally" comparison="ge"/>
			<environment buildatshipyard="false" gate="true"/>
			<ship>
				<!-- use miner ship for energy transport -->
				<select faction="xenon" tags="[sx, solid]" size="class.ship_m"/>
				<owner exact="xenon" overridenpc="true"/>
			</ship>
		</job>


		<!-- Invasion Forces -->
		<!-- Recon -->	
		<job id="xenon_scout_patrol_x" name="{20204,2801}" comment="few" startactive="true">
			<modifiers commandeerable="true"/>
			<orders>
				<order order="Recon" default="true"/>
			</orders>
			<category faction="xenon" tags="[factionlogic, tx]" size="ship_s"/>
			<quota galaxy="16" maxgalaxy="32" cluster="2"/>
			<location class="galaxy" macro="xu_ep2_universe_macro" faction="xenon" relation="self" comparison="lt" matchextension="false"/>
			<environment buildatshipyard="false" gate="true"/>
			<ship>
				<select faction="xenon" tags="[tx]" size="ship_s"/>
				<owner exact="xenon" overridenpc="true"/>
			</ship>
		</job>
		
		<!-- Destroyer Fleet -->
		<job id="xenon_light_invasionfleet_x" name="{20204,3801}" startactive="true">
			<modifiers commandeerable="true"/>
			<orders>
				<order order="Patrol" default="true">
					<param name="range" value="class.cluster"/>
				</order>
			</orders>
			<category faction="xenon" tags="[factionlogic, military, destx]" size="ship_xl"/>
			<quota galaxy="20" cluster="6"/>
			<location class="galaxy" macro="xu_ep2_universe_macro" /><!-- faction="xenon" relation="self" comparison="exact" -->
			<environment buildatshipyard="false" gate="true"/>			
			<!-- <encounters id="ship_enemy"/> -->
			<ship>
				<select faction="xenon" tags="[military, destx]" size="ship_xl"/>
				<owner exact="xenon" overridenpc="true"/>
			</ship>
			<subordinates>
				<subordinate job="xenon_frigate_escort_x"/>
				<subordinate job="xenon_fighter_escort_x"/>
				<subordinate job="xenon_frigate_escort_x"/>
				<subordinate job="xenon_fighter_escort_x"/>
			</subordinates>
		</job> 
		
		<!-- Carrier Fleet -->
		<job id="xenon_heavy_invasionfleet_x" name="{20204,3801}" startactive="true">
			<modifiers commandeerable="true"/>
			<orders>
				<order order="Patrol" default="true">
					<param name="range" value="class.cluster"/>
				</order>
			</orders>
			<category faction="xenon" tags="[factionlogic, military, carx]" size="ship_xl"/>
			<quota galaxy="20" cluster="6"/>
			<location class="galaxy" macro="xu_ep2_universe_macro" /><!-- faction="xenon" relation="self" comparison="exact" -->
			<environment buildatshipyard="false" gate="true"/>			
			<!-- <encounters id="ship_enemy"/> -->
			<ship>
				<select faction="xenon" tags="[military, carx]" size="ship_xl"/>
				<owner exact="xenon" overridenpc="true"/>
			</ship>
			<subordinates>
				<subordinate job="xenon_destroyer_escort_x"/>
				<subordinate job="xenon_frigate_escort_x"/>
				<subordinate job="xenon_fighter_escort_x"/>
				<subordinate job="xenon_destroyer_escort_x"/>
				<subordinate job="xenon_frigate_escort_x"/>
				<subordinate job="xenon_fighter_escort_x"/>
			</subordinates>
		</job> 
		
		<!-- Escorts -->
		<job id="xenon_fighter_escort_x" name="{20204,3401}" startactive="true">
			<orders>
				<order order="Escort" default="true">
					<param name="overrideformationskill" value="true"/>
				</order>
			</orders>
			<category faction="xenon" tags="[military, fx]" size="ship_s"/>
			<quota wing="8"/>
			<location class="galaxy" macro="xu_ep2_universe_macro"/>
			<environment buildatshipyard="false" gate="true"/>
			<modifiers subordinate="true"/>
			<ship>
				<select faction="xenon" tags="[military, fx]" size="ship_s"/>
				<owner exact="xenon" overridenpc="true"/>
			</ship>
		</job>
		
		<job id="xenon_frigate_escort_x" name="{20204,3401}" startactive="true">
			<orders>
				<order order="Escort" default="true">
					<param name="formation" value="formationshape.dartvertical"/>
					<param name="formationparam" value="2500m"/>
					<param name="overrideformationskill" value="true"/>
				</order>
			</orders>
			<category faction="xenon" tags="[military, frigx]" size="ship_m"/>
			<quota wing="6"/>
			<location class="galaxy" macro="xu_ep2_universe_macro"/>
			<environment buildatshipyard="false" gate="true"/>
			<modifiers subordinate="true"/>
			<ship>
				<select faction="xenon" tags="[military, frigx]" size="ship_m"/>
				<owner exact="xenon" overridenpc="true"/>
			</ship>
			<!--
			<subordinates>
				<subordinate job="xenon_fighter_escort_x"/>
			</subordinates>
			-->
		</job>
		
		<job id="xenon_destroyer_escort_x" name="{20204,3401}" startactive="true">
			<orders>
				<order order="Escort" default="true">
					<param name="formation" value="formationshape.invvshape"/>
					<param name="overrideformationskill" value="true"/>
				</order>
			</orders>
			<category faction="xenon" tags="[military, destx]" size="ship_xl"/>
			<quota wing="4"/>
			<location class="galaxy" macro="xu_ep2_universe_macro"/>
			<environment buildatshipyard="false" gate="true"/>
			<modifiers subordinate="true"/>
			<ship>
				<select faction="xenon" tags="[military, destx]" size="ship_xl"/>
				<owner exact="xenon" overridenpc="true"/>
			</ship>
			<!--
			<subordinates>
				<subordinate job="xenon_frigate_escort_x"/>
			</subordinates>
			-->
		</job>
	</add>
</diff>
shipgroups.xml
Spoiler
Show

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<diff>
	<add sel="//groups">
			<!-- Non Combat Ships -->
			<group name="xen_miner_m_x">
				<select macro="ship_xen_m_miner_10_a_macro" weight="100"/>
			</group>
			
			<!-- Combat Ships -->
			<group name="xen_scout_s_x">
				<select macro="ship_xen_s_scout_10_a_macro" weight="100"/>
			</group>
			
			<group name="xen_fighter_s_x">
				<select macro="ship_xen_s_fighter_10_a_macro" weight="100"/>
				<select macro="ship_xen_s_fighter_20_a_macro" weight="100"/>
			</group>
			
			<group name="xen_fighter_m_x">
				<select macro="ship_xen_m_fighter_10_a_macro" weight="100"/>
			</group>
			
			<group name="xen_destroyer_xl_x">
				<select macro="ship_xen_xl_destroyer_10_a_macro" weight="100"/>
			</group>
			
			<group name="xen_carrier_xl_x">
				<select macro="ship_xen_xl_carrier_10_a_macro" weight="100"/>
			</group>
	</add>
</diff> 
ships.xml
Spoiler
Show

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<diff>
	<add sel="//ships">
			<!-- Non Combat Ships -->
			<ship id="xenon_miner_mx" group="xen_miner_m_x" capturable="false">
				<category tags="[sx, solid]" faction="[xenon]" size="ship_m"/>
				<pilot>
					<select faction="xenon" tags="traderpilot"/>
				</pilot>
				<drop ref="ship_small_xenon"/>
				<equipmentmods>
					<weapon ware="mod_weapon_xenonblueprints_surfaceelement"/>
					<engine ware="mod_engine_xenonblueprints" />
					<ship ware="mod_ship_xenonblueprints" />
					<shield ware="mod_shield_xenonblueprints" />
				</equipmentmods>
			</ship>
			
			<!-- Combat Ships -->
			<ship id="xenon_scout_sx" group="xen_scout_s_x" capturable="false">
				<category tags="[military, tx, mission]" faction="[xenon]" size="ship_s"/>
				<pilot>
					<select faction="xenon" tags="fighterpilot"/>
				</pilot>
				<drop ref="ship_small_xenon"/>
				<equipmentmods>
					<weapon ware="mod_weapon_xenonblueprints_surfaceelement"/>
					<engine ware="mod_engine_xenonblueprints" />
					<ship ware="mod_ship_xenonblueprints" />
					<shield ware="mod_shield_xenonblueprints" />
				</equipmentmods>
			</ship>
			
			<ship id="xenon_fighter_sx" group="xen_fighter_s_x" capturable="false">
				<category tags="[military, fx, mission]" faction="[xenon]" size="ship_s"/>
				<pilot>
					<select faction="xenon" tags="fighterpilot"/>
				</pilot>
				<drop ref="ship_small_xenon"/>
				<equipmentmods>
					<weapon ware="mod_weapon_xenonblueprints_surfaceelement"/>
					<engine ware="mod_engine_xenonblueprints" />
					<ship ware="mod_ship_xenonblueprints" />
					<shield ware="mod_shield_xenonblueprints" />
				</equipmentmods>
			</ship>
  
			<ship id="xenon_frigate_mx" group="xen_fighter_m_x" capturable="false">
				<category tags="[military, frigx, mission]" faction="[xenon]" size="ship_m"/>
				<pilot>
					<select faction="xenon" tags="fighterpilot"/>
				</pilot>
				<drop ref="ship_small_xenon"/>
				<equipmentmods>
					<weapon ware="mod_weapon_xenonblueprints_surfaceelement"/>
					<engine ware="mod_engine_xenonblueprints" />
					<ship ware="mod_ship_xenonblueprints" />
					<shield ware="mod_shield_xenonblueprints" />
				</equipmentmods>
			</ship>
  
			<ship id="xenon_destroyer_xlx" group="xen_destroyer_xl_x" capturable="false">
				<category tags="[military, destx, mission]" faction="[xenon]" size="ship_xl"/>
				<pilot>
					<select faction="xenon" tags="fighterpilot"/>
				</pilot>
				<drop ref="ship_large_xenon"/>
				<equipmentmods>
					<weapon ware="mod_weapon_xenonblueprints_surfaceelement"/>
					<engine ware="mod_engine_xenonblueprints" />
					<ship ware="mod_ship_xenonblueprints" />
					<shield ware="mod_shield_xenonblueprints" />
				</equipmentmods>
			</ship>
  
			<ship id="xenon_carrier_xlx" group="xen_carrier_xl_x" capturable="false">
				<category tags="[military, carx, mission]" faction="[xenon]" size="ship_xl"/>
				<pilot>
					<select faction="xenon" tags="fighterpilot"/>
				</pilot>
				<drop ref="ship_large_xenon"/>
				<equipmentmods>
					<weapon ware="mod_weapon_xenonblueprints_surfaceelement"/>
					<engine ware="mod_engine_xenonblueprints" />
					<ship ware="mod_ship_xenonblueprints" />
					<shield ware="mod_shield_xenonblueprints" />
				</equipmentmods>
			</ship>
	</add>
</diff> 

Post Reply

Return to “X4: Foundations - Scripts and Modding”