[TUTORIAL] XML Patch Guide

The place to discuss scripting and game modifications for X Rebirth.

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

user1679
Posts: 981
Joined: Fri, 20. Jul 18, 23:20

Re: [TUTORIAL] XML Patch Guide

Post by user1679 »

Clownmug wrote: Thu, 20. Aug 20, 14:06
user1679 wrote: Thu, 20. Aug 20, 05:04 How would I patch an MD script from another mod?

For example, I use the mod Rise of the Ossian Raider and usually set it to difficulty Normal or Hard. Since this defaults to "very easy", how would I patch the MD script instead of having to package the whole 300 Mb mod into a separate version? Would I use a DIFF patching method or could I package my modified \md\ror_setup.xml into a 'sub_01.cat' (I don't know what sub cats are)?

The line I'm interested in changing is:

Code: Select all

<mdscript xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="Ror_setup" xsi:noNamespaceSchemaLocation="md.xsd">
	<cues>	
		<cue name="Ror_Setup_root" version="3">
			<conditions>
			<!--	<event_cue_signalled cue="md.Setup.GameStart"/> -->
				<event_player_created/>
			</conditions>
			<delay exact="10s"/>
			<actions>
			<set_value name="global.$RorSetting.$Difficulty" exact="0" comment="Very Easy - No Invasions"/>
and I want to create two patches that can be enabled as mods that change it to:

Code: Select all

<set_value name="global.$RorSetting.$Difficulty" exact="2" comment="Normal - Invasions"/>

Code: Select all

<set_value name="global.$RorSetting.$Difficulty" exact="3" comment="Hard - Invasions"/>
I don't think you need to patch their file since the difficulty is set as a global variable, it should be accessible from other mdscripts.

If you do need to make a patch though, you would have to create an extensions folder within your own mod, then put the file being patched from the other mod in there.

Example: your_mod\extensions\ror\md\ror_setup.xml
I made my own basic gamestart where I start at an Argon wharf with the cheapest ship and no money. I was thinking I could add this 'extensions' folder to that but is there anything I need to do to tell the game to prioritize the load order?

Thanks!
Clownmug
Posts: 418
Joined: Wed, 11. Dec 13, 02:39
x4

Re: [TUTORIAL] XML Patch Guide

Post by Clownmug »

user1679 wrote: Fri, 21. Aug 20, 08:58
Clownmug wrote: Thu, 20. Aug 20, 14:06
user1679 wrote: Thu, 20. Aug 20, 05:04
I don't think you need to patch their file since the difficulty is set as a global variable, it should be accessible from other mdscripts.

If you do need to make a patch though, you would have to create an extensions folder within your own mod, then put the file being patched from the other mod in there.

Example: your_mod\extensions\ror\md\ror_setup.xml
I made my own basic gamestart where I start at an Argon wharf with the cheapest ship and no money. I was thinking I could add this 'extensions' folder to that but is there anything I need to do to tell the game to prioritize the load order?

Thanks!
In the your mod's content.xml file you can add a dependency for the Rise of the Ossian Raider mod.

Something like this:

Code: Select all

<?xml version="1.0" encoding="utf-8" ?>
<content id="example_id" name="Example" description="Example Description" version="100">
  <dependency id="ws_1705279348" optional="true" name="Rise of the Ossian Raider" />
</content>
user1679
Posts: 981
Joined: Fri, 20. Jul 18, 23:20

Re: [TUTORIAL] XML Patch Guide

Post by user1679 »

Clownmug wrote: Fri, 21. Aug 20, 14:02
user1679 wrote: Fri, 21. Aug 20, 08:58
Clownmug wrote: Thu, 20. Aug 20, 14:06

I don't think you need to patch their file since the difficulty is set as a global variable, it should be accessible from other mdscripts.

If you do need to make a patch though, you would have to create an extensions folder within your own mod, then put the file being patched from the other mod in there.

Example: your_mod\extensions\ror\md\ror_setup.xml
I made my own basic gamestart where I start at an Argon wharf with the cheapest ship and no money. I was thinking I could add this 'extensions' folder to that but is there anything I need to do to tell the game to prioritize the load order?

Thanks!
In the your mod's content.xml file you can add a dependency for the Rise of the Ossian Raider mod.

Something like this:

Code: Select all

<?xml version="1.0" encoding="utf-8" ?>
<content id="example_id" name="Example" description="Example Description" version="100">
  <dependency id="ws_1705279348" optional="true" name="Rise of the Ossian Raider" />
</content>
Thank you.
BigGreenThugs
Posts: 89
Joined: Thu, 26. Mar 20, 16:50
x4

Re: [TUTORIAL] XML Patch Guide

Post by BigGreenThugs »

how do I make this:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<root>
  <bar>
    <foo a="1" b="taco elephant rocket spade shoe"/>
  </bar>
</root>
into this:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<root>
  <bar>
    <foo a="1" b="taco elephant bicycle rocket spade shoe"/>
  </bar>
</root>
EDIT: My apologies if this question seems obtuse. I read the entire thread and did not see this specific example. Maybe it was covered by a different example but I didn't find anything close enough for me to feel comfortable. What I'd really like to do is add mining to the types of weapons that can be mounted on a small ship. The Theseus can do this already and I'd like have that capability on more than one ship. This makes early money in game more easily obtained if you choose to mine crystals as it then allows you to destroy the asteroids for unstable crystals, lodestones, and spacefly eggs.

For example: The Callisto is cheap, has 2 weapon mount points, and even if ARG/ANT hates you you can get one from ALI. What you can't do is mount a mining laser. so how do I make:

Code: Select all

<connection name="con_weapon_005" tags="weapon small standard missile platformcollision symmetry symmetry_right symmetry_top ">
into

Code: Select all

<connection name="con_weapon_005" tags="weapon small standard mining missile platformcollision symmetry symmetry_right symmetry_top ">
BigGreenThugs
Posts: 89
Joined: Thu, 26. Mar 20, 16:50
x4

Re: [TUTORIAL] XML Patch Guide

Post by BigGreenThugs »

My question was answered in the unofficial discord by UniTrader. The answer is quoted below. All Credit to UniTrader.

@BigGreenThugs you can only replace the full content of an attribute

Code: Select all

<replace sel="//connection[@name='con_weapon_005']/@tags">weapon small standard mining missile platformcollision symmetry symmetry_right symmetry_top</replace>
Dev disco
Posts: 33
Joined: Wed, 2. Dec 20, 16:35

Re: [TUTORIAL] XML Patch Guide

Post by Dev disco »

I think this should go here.... if not I will make a separate post.

I want to add a bit more variety to the pirate spawns. I am good friends with all the 'normal' factions, and I am a bit fed up capping yet another Rahanas hybrid or Sahanar.
So I decided to try my hand on modding. I figured out that I need shipgroups.xml, and used this code:

Code: Select all

	
<replace sel="/groups/group[@name='sov_trader_l_grp']"> 	
	  <group name="sov_trader_l_grp">
		<select macro="units_size_l_kit_container_02_macro" weight="20"/> 
		<select macro="units_size_l_kit_bulk_01_macro" weight="20"/>
		<select macro="units_size_l_kit_energy_01_macro" weight="20"/>
		<select macro="units_size_l_kit_liquid_01_macro" weight="20"/>
		<select macro="units_size_l_silicon_collector_macro" weight="10"/>
		<select macro="units_size_l_hydrogen_collector_macro" weight="10"/>	
	</group>
</replace>   
This works fine, just like the other groups that came with the original game.
However, I can't get those bloody Atlas Pirates to be a bit more inclusive in their taste in ships.

Code: Select all

 <replace sel="/groups/group[@name='atl_trader_l_grp']"> 	
	  <group name="atl_trader_l_grp">
		<select macro="units_size_l_kit_container_02_macro" weight="20"/> 
		<select macro="units_size_l_kit_bulk_01_macro" weight="20"/>
		<select macro="units_size_l_kit_energy_01_macro" weight="20"/>
		<select macro="units_size_l_kit_liquid_01_macro" weight="20"/>
		<select macro="units_size_l_te_kit_bulk_03_macro" weight="5"/>
		<select macro="units_size_l_te_kit_container_03_macro" weight="5"/>		
		<select macro="units_size_l_te_kit_energy_03_macro" weight="5"/>		
		<select macro="units_size_l_te_kit_liquid_03_macro" weight="5"/>		
	  </group>
</replace> 
This doesn't do a thing, and I bet because the official extensions are giving me the finger.
I thought that I was the one in charge here, at least that's what I hear all the time...
How do I solve this?

PS1 Would this be the 'group' that spawns these endless Phoenixes:

Code: Select all

sel="/groups/group[@name='te_destroyer_light_grp']"> 
PS2 Is there a way to figure out which Albatros (vanilla or xl) belongs to which macro?
User avatar
KrYcHokE
Posts: 263
Joined: Wed, 2. Dec 15, 13:15
x4

Re: [TUTORIAL] XML Patch Guide

Post by KrYcHokE »

Your extension should have dependency to dlc
Dev disco
Posts: 33
Joined: Wed, 2. Dec 20, 16:35

Re: [TUTORIAL] XML Patch Guide

Post by Dev disco »

Thanks!
User avatar
Xkuka
Posts: 245
Joined: Sun, 14. Mar 10, 19:25
x4

Re: [TUTORIAL] XML Patch Guide

Post by Xkuka »

So according to what i have experienced and what i read, and please correct me if necessary,

1) A file without <diff> is handled as "merge", and from painful trial and error, you cant combine merging with patching <- This should be right on the top of the first post, it confused me why some mods do "merge" and others "diff" patches and has cost me quite some time.

2) /edit: I had trouble removing stuff, i got it working now. Don't know exactly why it did not work before.

3) Might be not fitting to this topic entirely, but i am curious if some of the patching could be avoided by creating "redirections". Like if i replace an item and my item has a different ID, but the original ID is called by other files, would there be a way to link the old ID to my new one instead of patching every file?

4) Are there operators that can be used? Any source where i can look for?
***Never not modified***
Specs: I9 9900k, 32GB DDR4, ASUS RTX2060 12GB, Sys drive: 1TB Nvme SSD, Games drive: 1TB Nvme SSD, Win10 pro 21H2
user1679
Posts: 981
Joined: Fri, 20. Jul 18, 23:20

Re: [TUTORIAL] XML Patch Guide

Post by user1679 »

I think it would also make things easier if there was a load order that users could assign to mods like Mod Organizer uses for Skyrim. That way if I have two mods that make a bunch of changes with some of them overlapping, I can easily tell the game to load MOD A before MOD B without having to edit the XML files and add a bunch of dependencies.
User avatar
Xkuka
Posts: 245
Joined: Sun, 14. Mar 10, 19:25
x4

Re: [TUTORIAL] XML Patch Guide

Post by Xkuka »

user1679 wrote: Sat, 1. Apr 23, 09:53 I think it would also make things easier if there was a load order that users could assign to mods like Mod Organizer uses for Skyrim. That way if I have two mods that make a bunch of changes with some of them overlapping, I can easily tell the game to load MOD A before MOD B without having to edit the XML files and add a bunch of dependencies.
I think dependencies might have the disadvantage that a user has to add a line of text to a file, but it is much easier actually just to worry about a dependency instead to organize a long list of mods. I wish i could use the dependency in some other games too, where mods have patches to make mods compatible. Its a hell of a mess sorting that out with load order, and would be much more reliable on a dependency basis.

Taking the "easy" way often makes it actually more difficult in other aspects.
***Never not modified***
Specs: I9 9900k, 32GB DDR4, ASUS RTX2060 12GB, Sys drive: 1TB Nvme SSD, Games drive: 1TB Nvme SSD, Win10 pro 21H2
User avatar
Xkuka
Posts: 245
Joined: Sun, 14. Mar 10, 19:25
x4

Re: [TUTORIAL] XML Patch Guide

Post by Xkuka »

So i figured out pretty reliably what needs to be considered when using a <remove> patch.
Its actually quite simple. You cant change the hirarchy in a tree by removing nodes or attributes, at least one child node of a type must remain in that specific tree. If there are duplicates in the same sub tree, all but one child nodes can be removed.
But you can replace a parent node, without adding the same content.

For example:

Code: Select all

<root>
     <foo>    <-- the foo node is unique it cant be removed, it can be replaced with different content
        <bar id="1" a="1" b="2">    <-- the bar nodes aren't unique, they can be removed, but not all, one bar node must remain
        </bar>
        <bar id="2" a="3" b= "4">   <-- an attribute can't be removed, only replaced
        </bar>
        <bar1> <-- the bar1 node is unique, it must be replaced
              <value a="1"/>      <-- same as with the bar nodes, as long as one exist you can remove as many as you want
              <value a="2"/>
        </bar>
     </foo>
</root>
***Never not modified***
Specs: I9 9900k, 32GB DDR4, ASUS RTX2060 12GB, Sys drive: 1TB Nvme SSD, Games drive: 1TB Nvme SSD, Win10 pro 21H2
User avatar
eventus
Posts: 126
Joined: Sat, 3. Apr 04, 15:16
x4

Re: [TUTORIAL] XML Patch Guide

Post by eventus »

Hello together,

I strugle now quite some time so I want to ask this "simple" question.

Can I change a XML file with diff and put there an add with proper selection command and
following replacement commands, which use the added node?

I don't see why it should not work, but I cant get it working and XPath is verified correct.
I also tried Unitraders info and put the add command in one line (it's short).

Thanks and BRs
Eventus
Goethe:
Erfahrung ist eine nützliche Sache. Leider macht man sie immer erst kurz nachdem man sie braucht.
----------------------------------------------
X2 - Epic fun :D
X Rebirth - Epic fail start, skipped as not playable plot for months :doh:
X4 Foundation - Fail start :doh: finally good :thumb_up: :goner:
Post Reply

Return to “X Rebirth - Scripts and Modding”