Attempting to make the AI Galaxy Trade

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

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

User avatar
SilverXarrow
Posts: 56
Joined: Thu, 29. May 14, 23:01
x4

Attempting to make the AI Galaxy Trade

Post by SilverXarrow »

I found a few places here on the forums suggesting I change this in the trade.ship.xml:

Code: Select all

<do_if value="this.ship.isclass.ship_l or this.ship.isclass.ship_xl">
          <set_value name="$range" exact="this.ship.cluster" />
        </do_if>
to:

Code: Select all

<do_if value="this.ship.isclass.ship_l or this.ship.isclass.ship_xl">
          <set_value name="$range" exact="this.ship.galaxy" />
        </do_if>


Yet the script doesnt seem to take any effect. any suggestions? I am completely new to X Rebirth modding as a whole.
Trying to fix X Rebirth....one trader at a time
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

we use diff files for changing existing stuff, not replacing them. see the Sticky [TUTORIAL] XML Patch Guide
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)
User avatar
SilverXarrow
Posts: 56
Joined: Thu, 29. May 14, 23:01
x4

Post by SilverXarrow »

I've given it a read through a few times already, but I still cant make out whether i copy the original contents of the trade.ship.xml into my own file and start editing?
Trying to fix X Rebirth....one trader at a time
User avatar
YorrickVander
Posts: 2774
Joined: Tue, 29. Oct 13, 21:59
x4

Post by YorrickVander »

A way to test making changes without patching (see theqmann's excellent guide here http://forum.egosoft.com/viewtopic.php?t=354310 is to use a directly edited xml file in the XR root dir.

1) keep the dir path intact
2) in steam > properties > general > Set Launch Options... add the command switch -prefersinglefiles

So in this case create a dir 'aiscripts' in your XR dir and copy the trade.ship.xml there, edit and run.

Another useful command switch to add is -debug all -logfile rebirth.log
which activates the debug log file in documents/egosoft/x rebirth/<some number>

You would be better off learning the patching method sooner rather than later as it has the added benefit of making changes to vanilla scripts a lot easier to track even if you do not plan on releasing a mod.
X Rebirth - A Sirius Cybernetics Corporation Product

Split irritate visiting pilot with strange vocal patterns.
User avatar
SilverXarrow
Posts: 56
Joined: Thu, 29. May 14, 23:01
x4

Post by SilverXarrow »

Thanks, I'll give it a shot!
Trying to fix X Rebirth....one trader at a time
User avatar
SilverXarrow
Posts: 56
Joined: Thu, 29. May 14, 23:01
x4

Post by SilverXarrow »

alright, I gave it a try but it doesn't seem to be working after 12 hours of running.

I currently have this as a patch:

Code: Select all

<diff>

<replace sel="aiscript/attention/actions/do_else/do_if[@value='this.ship.isclass.ship_l or this.ship.isclass.ship_xl']/set_value[@name='$range']/@range"> 
         <range = this.ship.galaxy/>
   </replace>

</diff>
what am I doing wrong?
Trying to fix X Rebirth....one trader at a time
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

here a correction:
<diff>
<replace sel="aiscript/attention/actions/do_else/do_if[@value='this.ship.isclass.ship_l or this.ship.isclass.ship_xl']/set_value[@name='$range']/@exact">player.galaxy</replace>
</diff>

1) you addressed the wrong Attribute -- there is no "range" attribute there, just one called "exact"
2) you tried to write an incorrect Value there, so it would thave looked like
<set_value name="$range" exact="<range = this.ship.galaxy/>" /> if 1 were correct (i think the Game wouldnt apply this because its breaking the syntax)

and here a shortened Version (not sure if it works since i didnt look in the related script, but i think it should):

<diff>
<replace sel="//do_if[@value='this.ship.isclass.ship_l or this.ship.isclass.ship_xl']/set_value[@name='$range']/@exact">player.galaxy</replace>
</diff>
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)
User avatar
YorrickVander
Posts: 2774
Joined: Tue, 29. Oct 13, 21:59
x4

Post by YorrickVander »

There's also a missing node 'do_if' between 'actions' + 'do_else' looking at the vanilla file.
X Rebirth - A Sirius Cybernetics Corporation Product

Split irritate visiting pilot with strange vocal patterns.
User avatar
SilverXarrow
Posts: 56
Joined: Thu, 29. May 14, 23:01
x4

Post by SilverXarrow »

Appreciate the quick response, I'll try it out and see what my results are. Thanks Uni!
Trying to fix X Rebirth....one trader at a time
User avatar
SilverXarrow
Posts: 56
Joined: Thu, 29. May 14, 23:01
x4

Post by SilverXarrow »

The debug is throwing an error upon loading into a game start:

Code: Select all

[=ERROR=] AI::AIDirector::ReInit(): Ignoring root node 'diff' in XML file 'extensions\Trader Fix\aiscripts\galaxy.trader.xml'.
Seems it doesnt like the 'diff' node too much

EDIT: After searching the issue, I found that this is Rebirth's way of not loading the diff as a replacement file! (Ironically enough, posted by Yorrick :P)
Trying to fix X Rebirth....one trader at a time
User avatar
SilverXarrow
Posts: 56
Joined: Thu, 29. May 14, 23:01
x4

Post by SilverXarrow »

After a few hours of eye balling the Albion-DeVries gate, no freighters jumped through. I am at a loss on what to try next.
Trying to fix X Rebirth....one trader at a time
User avatar
YorrickVander
Posts: 2774
Joined: Tue, 29. Oct 13, 21:59
x4

Post by YorrickVander »

This worked when I tried it some time ago, but that was around patch 1.17 or 1.19... Will have a look tomorrow and see what I can see. I assume you are working off a non plot game and/or the jump gates are unlocked?
X Rebirth - A Sirius Cybernetics Corporation Product

Split irritate visiting pilot with strange vocal patterns.
User avatar
YorrickVander
Posts: 2774
Joined: Tue, 29. Oct 13, 21:59
x4

Post by YorrickVander »

It occurs to me, there are 2 entries for the range in trade.ship.xml - in the interrupt sub cue + in the main one that I had modded previously. Perhaps try modding both directly and testing with -prefersinglefiles?

edit : The interrupt subcue is not something I recall from the older xml i worked with. If you're diff file only catches the first instance this may be whats missing.
X Rebirth - A Sirius Cybernetics Corporation Product

Split irritate visiting pilot with strange vocal patterns.
User avatar
SilverXarrow
Posts: 56
Joined: Thu, 29. May 14, 23:01
x4

Post by SilverXarrow »

I am testing with the 'Free Play' Start. So I havent done the plot on this save, but I figured that if I can traverse the gates without the plot, the AI could, correct?
in the interrupt sub cue + in the main one that I had modded previously
I actually didnt notice the subcue, I'll try it and see what happens
Trying to fix X Rebirth....one trader at a time
User avatar
YorrickVander
Posts: 2774
Joined: Tue, 29. Oct 13, 21:59
x4

Post by YorrickVander »

Yeah in non plot start all gates are open
X Rebirth - A Sirius Cybernetics Corporation Product

Split irritate visiting pilot with strange vocal patterns.
User avatar
SilverXarrow
Posts: 56
Joined: Thu, 29. May 14, 23:01
x4

Post by SilverXarrow »

Alright, so I got that hammered out, cheers.

now, the only interrupts I see being referred to in trade.ship.xml is this:

Code: Select all

<interrupts>
    <handler ref="AttackHandler" />
    <handler ref="ScannedHandler" />
  </interrupts>
Could you guide me to the interrupt subcue you are referring to?
Trying to fix X Rebirth....one trader at a time
User avatar
YorrickVander
Posts: 2774
Joined: Tue, 29. Oct 13, 21:59
x4

Post by YorrickVander »

Thats the one :) it also contains an if l or xl ship range = cluster. I haven't tried this, just telling you a possibility.
X Rebirth - A Sirius Cybernetics Corporation Product

Split irritate visiting pilot with strange vocal patterns.
User avatar
SilverXarrow
Posts: 56
Joined: Thu, 29. May 14, 23:01
x4

Post by SilverXarrow »

honestly, I cant find the reference too it, unless this is it:

Code: Select all

<do_if value="$range" exact="'zone'">
        <set_value name="$range" exact="this.ship.zone" />
      </do_if>
      <do_elseif value="$range" exact="'sector'">
        <set_value name="$range" exact="this.ship.sector" />
      </do_elseif>
      <do_elseif value="$range" exact="'cluster'">
        <set_value name="$range" exact="this.ship.cluster" />
      </do_elseif>
      <do_else>
        <do_if value="this.ship.isclass.ship_l or this.ship.isclass.ship_xl">
          <set_value name="$range" exact="this.ship.cluster" />
        </do_if>
        <do_else>
          <set_value name="$range" exact="this.ship.sector" />
		</do_else>
      </do_else>
Trying to fix X Rebirth....one trader at a time
User avatar
YorrickVander
Posts: 2774
Joined: Tue, 29. Oct 13, 21:59
x4

Post by YorrickVander »

uh well yes, thats it.... the same test that is performed lower down the file to set the ships range....
X Rebirth - A Sirius Cybernetics Corporation Product

Split irritate visiting pilot with strange vocal patterns.
User avatar
SilverXarrow
Posts: 56
Joined: Thu, 29. May 14, 23:01
x4

Post by SilverXarrow »

All the trade ships are now idle with "Command: None" as their current command.

This is what I'm getting from the Debug:

Code: Select all

[=ERROR=] Error on AI director import: Invalid blocking action index 7 for context trade.ship on entity 0x252D
Trying to fix X Rebirth....one trader at a time

Return to “X Rebirth - Scripts and Modding”