Trying to extend automine gate limits but it isn't working.

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

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

Post Reply
user1679
Posts: 761
Joined: Fri, 20. Jul 18, 23:20

Trying to extend automine gate limits but it isn't working.

Post by user1679 » Sun, 30. May 21, 08:58

I've been trying to extend the max gates allowed for automine but my script doesn't seem to do anything. There are no errors when loading, it just doesn't change from the default.

The files I've been working on are found in "aiscripts":

order.mining.routine.advanced.xml
order.mining.routine.expert.xml
order.mining.routine.xml

Here's an example of the DIFF that I created for the "advanced" one. The default formula is:

maxbuy = [([@this.ship.commander.tradenpc.skill.management, @this.ship.pilot.skill.piloting].max / 3) - 1, 0].max
mxasell = [@this.ship.commander.tradenpc.skill.management, @this.ship.pilot.skill.piloting].max / 3

so this is the patch file I created:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<diff>

    <replace sel="//aiscript/order[@id='MiningRoutine_Advanced']/params[@param='minbuy']">
        <param name="minbuy" default="[4, ((@this.ship.pilot.skill.piloting * 2) + 1)].max" type="number" text="{1041, 10056}" comment="Min gate distance to gather resources. Gathering range supported if $minsell and $maxsell are provided">
            <input_param name="startvalue" value="0"/>
            <input_param name="min" value="0"/>
            <input_param name="max" value="[4, ((@this.ship.pilot.skill.piloting * 2) + 1)].max" />
            <input_param name="step" value="1"/>
        </param>
    </replace>

    <replace sel="//aiscript/order[@id='MiningRoutine_Advanced']/params[@param='maxbuy']">
        <param name="maxbuy" default="[4, @this.ship.pilot.skill.piloting * 2].max" type="number" text="{1041, 10056}" comment="Max gate distance to gather resources. Gathering range supported if $minsell and $maxsell are provided">
            <input_param name="startvalue" value="0"/>
            <input_param name="min" value="0"/>
            <input_param name="max" value="[4, ((@this.ship.pilot.skill.piloting * 2) + 1)].max" />
            <input_param name="step" value="1"/>
        </param>
    </replace>

    <replace sel="//aiscript/order[@id='MiningRoutine_Advanced']/params[@param='minsell']">
        <param name="minsell" default="[4, ((@this.ship.pilot.skill.piloting * 2) + 1)].max" type="number" text="{1041, 10058}" comment="Min gate distance to sell resources. Sell range supported if $minsell and $maxsell are provided">
            <input_param name="startvalue" value="0"/>
            <input_param name="min" value="0"/>
            <input_param name="max" value="[4, ((@this.ship.pilot.skill.piloting * 2) + 1)].max" />
            <input_param name="step" value="1"/>
        </param>
    </replace>

    <replace sel="//aiscript/order[@id='MiningRoutine_Advanced']/params[@param='maxsell']">
        <param name="maxsell" default="[4, @this.ship.pilot.skill.piloting * 2].max" type="number" text="{1041, 10058}" comment="Max gate distance to sell resources. Sell range supported if $minsell and $maxsell are provided">
            <input_param name="startvalue" value="0"/>
            <input_param name="min" value="0"/>
            <input_param name="max" value="[4, ((@this.ship.pilot.skill.piloting * 2) + 1)].max" />
            <input_param name="step" value="1"/>
        </param>
    </replace>

</diff>
So when my pilot has a skill.piloting of 12 (3 stars), I would expect her to have a max gate range of 25 but she only has 7. I plan on tweaking the values once I know it's working.

Edit:

When I added a patch file for the EXPERT version I get this:

No matching node for path '//aiscript/order[@id='MiningRoutine_Expert']/params[@param='minbuy']' in patch file

but there is, it's almost identical to the Advanced file which doesn't produce any errors.

Berserk Knight
Posts: 398
Joined: Tue, 17. Dec 13, 01:34
x4

Re: Trying to extend automine gate limits but it isn't working.

Post by Berserk Knight » Sun, 30. May 21, 11:04

Path should be "/aiscript/order/params/param[@name='maxbuy']" instead.

It also should be throwing errors for advanced as well, but the game isn't 100% consistent on reporting errors.

DeadAirRT
Posts: 1008
Joined: Fri, 25. Jan 19, 03:26
x4

Re: Trying to extend automine gate limits but it isn't working.

Post by DeadAirRT » Sun, 30. May 21, 18:49

Here's an example from my code

Code: Select all

  <replace sel="/aiscript/order[@id='MiningRoutine_Advanced'][@name='{1041, 591}']/params/param[@name='maxbuy']/@default">[([@this.ship.commander.tradenpc.skill.management, @this.ship.commander.pilot.skill.management, @this.ship.pilot.skill.piloting].max)-5,4].max</replace>
  <replace sel="/aiscript/order[@id='MiningRoutine_Advanced'][@name='{1041, 591}']/params/param[@name='maxbuy']/input_param[@name='max'][@value='[([@this.ship.commander.tradenpc.skill.management, @this.ship.pilot.skill.piloting].max / 3) - 1, 0].max']/@value">[([@this.ship.commander.tradenpc.skill.management, @this.ship.commander.pilot.skill.management, @this.ship.pilot.skill.piloting].max)-5,4].max</replace>
  <replace sel="/aiscript/order[@id='MiningRoutine_Advanced'][@name='{1041, 591}']/params/param[@name='maxsell']/@default">[([@this.ship.commander.tradenpc.skill.management, @this.ship.commander.pilot.skill.management, @this.ship.pilot.skill.piloting].max)-5,4].max</replace>
  <replace sel="/aiscript/order[@id='MiningRoutine_Advanced'][@name='{1041, 591}']/params/param[@name='maxsell']/input_param[@name='max'][@value='[@this.ship.commander.tradenpc.skill.management, @this.ship.pilot.skill.piloting].max / 3']/@value">[([@this.ship.commander.tradenpc.skill.management, @this.ship.commander.pilot.skill.management, @this.ship.pilot.skill.piloting].max)-5,4].max</replace>

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

Re: Trying to extend automine gate limits but it isn't working.

Post by user1679 » Sun, 30. May 21, 20:33

Berserk Knight wrote:
Sun, 30. May 21, 11:04
Path should be "/aiscript/order/params/param[@name='maxbuy']" instead.

It also should be throwing errors for advanced as well, but the game isn't 100% consistent on reporting errors.
Thanks for that!
DeadAirRT wrote:
Sun, 30. May 21, 18:49
Here's an example from my code
Thank you.

Is that from one of your published mods? Currently Is that part of your DeadAir Gate Overhaul? I have your "Tweaks" mod but I was reluctant to
use the gate overhaul because it also increases the amount of fleets and I already use FOCW, so I didn't know how much of a load it would be
on my CPU.

DeadAirRT
Posts: 1008
Joined: Fri, 25. Jan 19, 03:26
x4

Re: Trying to extend automine gate limits but it isn't working.

Post by DeadAirRT » Mon, 31. May 21, 01:40

Gate overhaul is discontinued. That change is part of my ai tweaks already so you could just fiddle with the numbers in there

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

Re: Trying to extend automine gate limits but it isn't working.

Post by user1679 » Mon, 31. May 21, 03:27

DeadAirRT wrote:
Mon, 31. May 21, 01:40
Gate overhaul is discontinued. That change is part of my ai tweaks already so you could just fiddle with the numbers in there
Ok, thanks. I don't want to go crazy big with numbers but right now I have two full M gas miners that have been "searching for trades" for
several hours and I've got their gates set to max (4).

I wish there was a way I could transfer their cargo to a hauler or just tell them to release it back into space. Apparently nobody has a use
for hydrogen in my universe.

Also, am I correct to assume that if I want to use your AI tweaks but also my own mod that changes the gate distance, I would
need to set your mod as a dependency so mine is loaded after it?

DeadAirRT
Posts: 1008
Joined: Fri, 25. Jan 19, 03:26
x4

Re: Trying to extend automine gate limits but it isn't working.

Post by DeadAirRT » Mon, 31. May 21, 04:34

You could use a dependency or folder name after to ensure load order.

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

Re: Trying to extend automine gate limits but it isn't working.

Post by user1679 » Mon, 31. May 21, 07:11

DeadAirRT wrote:
Mon, 31. May 21, 04:34
You could use a dependency or folder name after to ensure load order.
I'm not entirely sure either of these are working. I tried your ai tweaks alone, my mod alone and my mod with yours as a dependency and no matter what I put in the formula, my 3-star pilot only gets 5 gates.

I even tried this:

Code: Select all

[([@this.ship.commander.tradenpc.skill.management, @this.ship.commander.pilot.skill.management, @this.ship.commander.pilot.skill.piloting, @this.ship.pilot.skill.piloting].max)-5,50].max
That should give all pilots a max gate distance of 50 because that's more than even a 5-star pilot would get. But my 3-star pilot still only gets 5 gates.

What I really want is a 1-star pilot to get 5 and every additional star gives +2 so 7,9,11,13. Since stars are point based (I think 15 is 3 stars?), the formula is easy enough but it doesn't change in game.

DeadAirRT
Posts: 1008
Joined: Fri, 25. Jan 19, 03:26
x4

Re: Trying to extend automine gate limits but it isn't working.

Post by DeadAirRT » Mon, 31. May 21, 08:02

What files did you change? If it's not working, it means you missed something somewhere, have a conflict, or a syntax error possibly

arshiba
Posts: 48
Joined: Thu, 1. Jul 04, 15:30
x4

Re: Trying to extend automine gate limits but it isn't working.

Post by arshiba » Mon, 31. May 21, 16:02

Take into account that all "MiningRoutine_<any>" scripts are wrappers for "MiningRoutine" script.
And there is a sanity check here that starts on the next line and so on.

Code: Select all

      <set_value name="$maxrange" exact="[@this.assignedcontrolled.commander.tradenpc.skill.management, @this.skill.piloting].max / 3"/>

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

Re: Trying to extend automine gate limits but it isn't working.

Post by user1679 » Tue, 1. Jun 21, 00:22

DeadAirRT wrote:
Mon, 31. May 21, 08:02
What files did you change? If it's not working, it means you missed something somewhere, have a conflict, or a syntax error possibly

I changed all three of the files I listed above.
arshiba wrote:
Mon, 31. May 21, 16:02
Take into account that all "MiningRoutine_<any>" scripts are wrappers for "MiningRoutine" script.
And there is a sanity check here that starts on the next line and so on.

Code: Select all

      <set_value name="$maxrange" exact="[@this.assignedcontrolled.commander.tradenpc.skill.management, @this.skill.piloting].max / 3"/>
But that shouldn't change the UI slider limit which uses minsell and maxsell, which is what I'm not seeing change in my UI.
I know it's because "piloting" skill has a numeric value associated with it and at certain values you gain another star,
but I can't find documentation as to how many "points" = 1 star.

Code: Select all

      <do_if value="$maxsell gt $maxrange">
        <set_value name="$maxsell" exact="$maxrange"/>
        <do_if value="@$thisorder.exists">
          <edit_order_param order="this.assignedcontrolled.order" param="'maxsell'" value="$maxsell"/>
        </do_if>
      </do_if>
I agree though that this maxrange also needs to be edited. This block would effectively ignore the slider value because it's using
a different formula to determine "max"

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

Re: Trying to extend automine gate limits but it isn't working.

Post by user1679 » Tue, 1. Jun 21, 00:54

Ok, so I managed to get it to work by changing the maxrange value and adding an optional dependency so my mod loads after deadairtweaks. Not sure why that had any effect on the slider display but whatever.

So there's just two small things left:

1. What are the numeric vales behind each star (1 star pilot = 5, 2 star pilot = 8, etc)? I'm still not getting the steps I want so my formula needs tweaking
2. How do I select the "maxrange" value for my replace statement? Right now the best I could do is to select the INIT block and replace the whole thing with only the one line changed

And a bit off-topic, what do you do with a miner that's full but there are no buyers? I don't have my own station yet and I can't see any way to get them to jetison their
cargo so I can switch what they're mining.


Thanks everyone for your help so far.

arshiba
Posts: 48
Joined: Thu, 1. Jul 04, 15:30
x4

Re: Trying to extend automine gate limits but it isn't working.

Post by arshiba » Tue, 1. Jun 21, 06:46

user1679 wrote:
Tue, 1. Jun 21, 00:54
1. What are the numeric vales behind each star (1 star pilot = 5, 2 star pilot = 8, etc)?
Individual skill range 0..15, 3 points = 1 star. Combined skill range 0..100, 20 points = 1 star.
user1679 wrote:
Tue, 1. Jun 21, 00:54
2. How do I select the "maxrange" value for my replace statement?

Code: Select all

<replace sel="/aiscript[@name='order.mining.routine']/init//set_value[@name='$maxrange']/@exact">XXX</replace>
user1679 wrote:
Tue, 1. Jun 21, 00:54
I can't see any way to get them to jetison their cargo
The simplest way is to enable the NPC workaround for the player.

Code: Select all

<replace sel="/aiscript[@name='order.mining.routine']/attention[@min='unknown']/actions/do_elseif[@value='this.assignedcontrolled.cargo.count']/do_if[@value='not this.isplayerowned']/@value">true</replace>

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

Re: Trying to extend automine gate limits but it isn't working.

Post by user1679 » Tue, 1. Jun 21, 07:30

arshiba wrote:
Tue, 1. Jun 21, 06:46
user1679 wrote:
Tue, 1. Jun 21, 00:54
1. What are the numeric vales behind each star (1 star pilot = 5, 2 star pilot = 8, etc)?
Individual skill range 0..15, 3 points = 1 star. Combined skill range 0..100, 20 points = 1 star.
user1679 wrote:
Tue, 1. Jun 21, 00:54
2. How do I select the "maxrange" value for my replace statement?

Code: Select all

<replace sel="/aiscript[@name='order.mining.routine']/init//set_value[@name='$maxrange']/@exact">XXX</replace>
user1679 wrote:
Tue, 1. Jun 21, 00:54
I can't see any way to get them to jetison their cargo
The simplest way is to enable the NPC workaround for the player.

Code: Select all

<replace sel="/aiscript[@name='order.mining.routine']/attention[@min='unknown']/actions/do_elseif[@value='this.assignedcontrolled.cargo.count']/do_if[@value='not this.isplayerowned']/@value">true</replace>
Thanks, very useful.

I actually just realized you can drag the cargo slider on the ship info screen and click "drop" and the ship will drop boxes of Methane (or whatever) in space.

Post Reply

Return to “X4: Foundations - Scripts and Modding”