XML diff-patching aiscripts from another mod

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

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

azaghal
Posts: 393
Joined: Wed, 21. Mar 07, 13:19
xr

XML diff-patching aiscripts from another mod

Post by azaghal »

Hello all,

Is it possible to apply an XML diff-patch against aiscripts which are shipped by another extension (mod)?

After implementing a couple of smaller custom mods (a bit of a learning process) with some aiscripts, I ended-up looking whether I could hook-up some of my orders with notifications from the Report Current Status mod.

I wanted to keep my aiscripts mods independent from the Report Current Status mod, so I started to look into creating a separate integration mod that would patch my custom aiscripts in a similar way that the Report Current Status mod does it (it simply uses XML diff patching).

However, I seem to have hit a bit of a brick wall going down this path, and I'm trying to understand the limitations of the game engine. Namely, no matter what I did, I was not able to get the game engine to apply my patches. Here is the diff tidbit that I wrote to try things out:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<diff>
  <add sel="/aiscript/order/params">
    <param name="mycrap" type="bool" infinitevalue="true" default="false" text="My crap2" comment="Write to logbook"/>
  </add>
</diff>
This snippet, when placed under aiscripts/order.move.wait.xml successfully patches the vanilla script. However, trying to apply the same technique against aiscript shipped by my own extension results in something similar to:

Code: Select all

[=ERROR=] 7312.57 AI::AIDirector::LoadAIScript(): Ignoring root node 'diff' in XML file 'extensions\azaghal_vro_fixes\aiscripts\order.move.wait2.xml'.
Interesting enough, this also results in the following error when trying to run the /refreshai command:

Code: Select all

[=ERROR=] 7365.88 Errors found; AI scripts not refreshed
I've done a bunch of double-checking, and made sure to have correct dependency definitions on my "integration" mod (correct dependencies listed in the extensions game menu). In the above sample, I've merely copied the vanilla aiscripts/order.move.wait.xml, and updated the name/id within. Mainly because I was starting to think there might be something wrong with my own script.

I've even tried to ship my original extension as cat/dat thinking that perhaps game only allows patching of cat/dat-based extensions, but that did not seem to help either.

So, has anyone been in the similar situation? I haven't tried patching the md scripts yet to see if this is a general limitation perhaps, mind you - just the aiscripts.

Best regards,
Branko
User avatar
Dj_FRedy
Posts: 245
Joined: Mon, 27. Jun 11, 05:58
x4

Re: XML diff-patching aiscripts from another mod

Post by Dj_FRedy »

At first look it seems that the filename could be the cause of the error:

Code: Select all

..\order.move.wait2.xml
change the file name to: 'order.move.wait.xml'

Also make sure that 'dependency' is correctly set in the 'content.xml' file of your extension, negating 'optional':

Code: Select all

<!-- optional="true": No error if dependency missing/disabled. This is only used to define the loading order of extensions (dependencies are loaded first). -->
<dependency id="extension id to diff" version="100" optional="false" name="bla bla"/>
Let's see if we are lucky ...
"All my contributions to the Technical Support and Public Beta Feedback sections will be concise and to the point, no diatribes, that's what the other sections are for".
Thank you for your efforts.
azaghal
Posts: 393
Joined: Wed, 21. Mar 07, 13:19
xr

Re: XML diff-patching aiscripts from another mod

Post by azaghal »

Hey Dj_FRedy,

I was wondering if my example would cause some confusion :D

The order.move.wait2.xml is the correct name - in this particular case I described I was just experimenting by making a copy of an existing vanilla file (order.move.wait.xml) to see if maybe the issues was somehow related to my custom AI scripts (like maybe missing some utility/useful parameter/attribute etc).

Dependencies have been declared correctly, although I did not specify the particular version needed. Just as an example:

Code: Select all

  <dependency id="ReportCurrentStatus" optional="false" name="Mycu: Report current status"/>
  <dependency id="azaghal_deployment_orders" optional="false" name="azaghal: Deployment Orders"/>
  <dependency id="azaghal_faster_exploration" optional="false" name="azaghal: Faster Exploration"/>
  <dependency id="azaghal_redeploy_deployable" optional="false" name="azaghal: Redeploy Deployables"/>
And from what I can tell based on the extensions game menu - they got picked up correctly.

However... I just saw a post about the extensions/ subfolder mentioned in one of the threads (something about overriding other extensions), so maybe I just need to park my patches in correct directory... I'm about to give it a quick go to see if to works correctly.
azaghal
Posts: 393
Joined: Wed, 21. Mar 07, 13:19
xr

Re: XML diff-patching aiscripts from another mod

Post by azaghal »

Ah, damn... That did it... I was not aware of this particular tidbit... That also explains the extensions sub-directory I saw in a couple of extensions as I unpacked/installed them - I was wondering what the heck they were at that point :D

So... Just to avoid some of the confusion, the path I had for (one of) my original mod aiscripts was (relative to game's own top-level extensions sub-directory):

Code: Select all

azaghal_redeploy_deployables/aiscripts/order.redeploy.xml
And I tried to create the diff for it by placing the file into location:

Code: Select all

azaghal_vro_fixes/aiscripts/order.redeploy.xml
And this did not work... What I should have done was to put the file into location:

Code: Select all

azaghal_vro_fixes/extensions/azaghal_redeploy_deployables/aiscripts/order.redeploy.xml

Return to “X4: Foundations - Scripts and Modding”