[TUTORIAL] XML Patch Guide

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

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

Dev disco
Posts: 33
Joined: Wed, 2. Dec 20, 16:35

Re: [TUTORIAL] XML Patch Guide

Post by Dev disco » Wed, 17. Feb 21, 17:09

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: 259
Joined: Wed, 2. Dec 15, 13:15
x4

Re: [TUTORIAL] XML Patch Guide

Post by KrYcHokE » Thu, 18. Feb 21, 20:25

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 » Sat, 20. Feb 21, 16:24

Thanks!

User avatar
Xkuka
Posts: 207
Joined: Sun, 14. Mar 10, 19:25
x4

Re: [TUTORIAL] XML Patch Guide

Post by Xkuka » Fri, 31. Mar 23, 07:53

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: 761
Joined: Fri, 20. Jul 18, 23:20

Re: [TUTORIAL] XML Patch Guide

Post by user1679 » 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.

User avatar
Xkuka
Posts: 207
Joined: Sun, 14. Mar 10, 19:25
x4

Re: [TUTORIAL] XML Patch Guide

Post by Xkuka » Sun, 2. Apr 23, 23:55

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: 207
Joined: Sun, 14. Mar 10, 19:25
x4

Re: [TUTORIAL] XML Patch Guide

Post by Xkuka » Mon, 3. Apr 23, 00:42

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

Post Reply

Return to “X Rebirth - Scripts and Modding”