[MOD] Mining/Trading Fleet ver0.03

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

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

pesoda
Posts: 16
Joined: Thu, 13. Dec 18, 20:45
x4

[MOD] Mining/Trading Fleet ver0.03

Post by pesoda » Sat, 22. Dec 18, 02:19

This is a small patch that enables to organize Mining/Trading Fleets. Until today we have no choice but to manipulate ship orders by ship-by-ship clicking, but from today we can change default orders by a single action. It may allow us to adapt easily to cosmic situations together with a number of controllable ships.

Images
Overview / Rename Wings

Download ver0.03 (Dec 29, 2018) Copy the directory to “X4 Foundations/extensions” (create if needed).

Feature
  • Enable to organize Mining/Trading fleets by a single action.
    - Dynamic updating of order-properties (wares, distances, etc) when the commander docked at a station.
  • Rename Wings. (kspn’s-based) code
  • Compatibility with TaterTrade v3.1. (deltaone’s-based) code
How to use
  1. Set the commander ship to AutoMine or AutoTrade with wares and distances.
  2. Select miner or trader ships which the same job-type as the commander ship (but now a trader ship is unrestricted).
  3. Right click on the commander ship and assign them.
  4. Commander's default order and properties will be reflected to his subordinates.
  5. If you want to change the wares or distances immediately, back to 1) and reassign subordinates: i) assign all subs to other ship or station, ii) do “Remove all orders”, and iii) reassign them to the original commander.
Appendix
Reduce requirements of pilot skill for AutoMine, AutoTrade, Explore
https://www.mediafire.com/file/3d0hd6de ... bb_002.zip

* * *

Known problems or Future work (Jan 7, 2019)
  • Partially solved. Real-time updating of wares and distances. detail
  • In progress. Subordinates frequently take a coffee break (“Fly and Wait”) between tasks (eventually they return to work, so may not a problem). detail
    - According to the report, “Fly and Wait” may directs the commander’s position.
  • Subordinates can only have same default order as the commander. E.g. They cannot protect ships in the same wing.
    - For now, you can request unassigned ships or different wings to escort them.
    - I think one of the solutions is that adding assignment commands to the right click menu of ships. (Alternative idea is also welcome.)
  • Compatibility with many order mods.
    - In order to solve it fundamentally, the basal framework of this mod should be changed over from aiscripts to UI because the function for enumerating order-params is only provided to UI.
  • Exploring Fleet.
    - The problem of one-by-one clicking remains yet here. However, I think Exploring is more delicate issue than other. For example, the map visibility can be degraded according to the size of explored regions.
    - "Exploring Fleet" is suggesting a interesting subject that how to explore sectors automatically by multiple ships. Any idea?
Memo
In this try, aiscripts/lib.request.orders.xml was a key part to determine a default order because all existing orders are canceled by an assignment. You can find "Ship assigned to Ship” block that issues Escort, ProtectShip, and Follow orders at the rear of the file. The codes were inserted above that block. In addition, to refer to the value of order-params in aiscripts, "ship.order.$param_name" seems successfully worked (and "order" can be replaced with "defaultorder"). Feel free to modify this patch and share your edition.
Version history and Old file link
Show
ver0.03 Dec 29, 2018
New feature:
Compatibility with TaterTrade v3.1. (deltaone’s-based)
Rename Wings. (kspn’s-based)
Dynamic updating of order-properties (wares, distances, etc) when the commander docked at a station. (detail: topic)

ver0.02 Dec 22, 2018
https://www.mediafire.com/file/m438extk ... et_002.zip
Initial release.
Last edited by pesoda on Mon, 7. Jan 19, 17:10, edited 2 times in total.

Lakz
Posts: 127
Joined: Tue, 19. Feb 13, 05:20

Re: [MOD] Mining/Trading Fleet

Post by Lakz » Sat, 22. Dec 18, 03:28

I can see this being very useful. You should try to make it compatible with non vanilla traders (TaterTrader, or Euclid's). Also, it'd be great to have updates on ware/distance changes sent to the whole wing rather than manually removing/adding ships :P

Thanks!

Tyrant597
Posts: 299
Joined: Wed, 9. Apr 08, 05:52
x4

Re: [MOD] Mining/Trading Fleet

Post by Tyrant597 » Sat, 22. Dec 18, 03:33

2) Subordinates frequently take a coffee break (“Fly and Wait”) between tasks (eventually they return to work, so may not a problem).
Haven't looked at your code yet, but trader wait time between trades is based off of pilot skill, and you seem to be using very low level pilots in that screen. =P
You don't talks about X:Rebirth...
X4 Mods: Collect Inventory Wares Stations Supply Build Storage Mass Move Marines

rjtwins
Posts: 20
Joined: Wed, 3. Nov 10, 14:50
x4

Re: [MOD] Mining/Trading Fleet

Post by rjtwins » Sat, 22. Dec 18, 03:48

YES, I need this so bad.

jmattspartacus2
Posts: 73
Joined: Wed, 5. Dec 18, 08:04

Re: [MOD] Mining/Trading Fleet

Post by jmattspartacus2 » Sat, 22. Dec 18, 07:59

Can you post this to the nexus? It's free to use and you can show it off and it's fairly easy to manage and update things there.

verl1
Posts: 9
Joined: Fri, 7. Dec 18, 14:59

Re: [MOD] Mining/Trading Fleet

Post by verl1 » Sat, 22. Dec 18, 08:21

Thanks so much! i've waited for this one!

pesoda
Posts: 16
Joined: Thu, 13. Dec 18, 20:45
x4

Re: [MOD] Mining/Trading Fleet

Post by pesoda » Sat, 22. Dec 18, 11:06

Thanks for comments.
Lakz wrote:
Sat, 22. Dec 18, 03:28
You should try to make it compatible with non vanilla traders (TaterTrader, or Euclid's). Also, it'd be great to have updates on ware/distance changes sent to the whole wing rather than manually removing/adding ship
It's not so difficult to create a compatible patch by hand if only for a few MODs. I'm searching a way to enumerate order-params.
About updating wares/distances, what I concerned is a nest of wings, namely commander of commander. Probably, only lowest level ships should be controlled their wares/distances by their direct commander.

Tyrant597 wrote:
Sat, 22. Dec 18, 03:33
2) Subordinates frequently take a coffee break (“Fly and Wait”) between tasks (eventually they return to work, so may not a problem).
Haven't looked at your code yet, but trader wait time between trades is based off of pilot skill, and you seem to be using very low level pilots in that screen. =P
Maybe it's correct. Thanks.

jmattspartacus2 wrote:
Sat, 22. Dec 18, 07:59
Can you post this to the nexus?
Next version will be posted to the nexus.

kspn
Posts: 69
Joined: Mon, 9. Jan 06, 11:59
x4

Re: [MOD] Mining/Trading Fleet

Post by kspn » Sat, 22. Dec 18, 12:32

This is great, this is one of the things that I wanted :D

That should help to clean up my Ship list.

I am assuming that the changes with the 1.5 patch with AutoTrade being restricted at 3* Pilots are adhered to?

deltaone
Posts: 3
Joined: Sat, 22. Dec 18, 14:41

Re: [MOD] Mining/Trading Fleet

Post by deltaone » Sat, 22. Dec 18, 14:47

Code: Select all

    <!--add. TaterTrade -->
    <!-- TODO: Introduce criteria for trader -->
    <do_elseif value="($commander.defaultorder.id == 'TaterTrade')">
    <!-- and ($object.primarypurpose == purpose.mine)"> -->
      <debug_to_file name="MTFleet" text="'ship %1(%2) assigned to ship %3. It is Fleet-Trader commanded by %3'.[$object.knownname, $object, $commander.knownname]" chance="$debugchance" />
      <create_order object="$object" id="'TaterTrade'" default="true">
        <param name="warebasket" value="$commander.defaultorder.$warebasket" />

		<param name="home" value="$commander.defaultorder.$home" />
		<param name="returnhome" value="$commander.defaultorder.$returnhome" />		
		<param name="discount" value="$commander.defaultorder.$discount" />
		<param name="discount2" value="$commander.defaultorder.$discount2" />
		<param name="bypass" value="$commander.defaultorder.$bypass" />
		
        <param name="minbuy" value="$commander.defaultorder.$minbuy" type="number" advanced="true" text="{1041, 10066}" comment="Min gate distance to buy. Buy range supported if $minbuy and $maxbuy are provided">
          <input_param name="max" value="@$commander.pilot.skill.management, @this.ship.pilot.skill.piloting].max * 2"/>
        </param>
        <param name="maxbuy" value="$commander.defaultorder.$maxbuy" type="number" text="{1041, 10054}" comment="Max gate distance to gather resources. Gathering range supported if $minsell and $maxsell are provided">
          <input_param name="max" value="@$commander.pilot.skill.management, @this.ship.pilot.skill.piloting].max * 2"/>
        </param>
        <param name="minsell" value="$commander.defaultorder.$minsell" type="number" advanced="true" text="{1041, 10068}" comment="Min gate distance to sell. Sell range supported if $minsell and $maxsell are provided">
          <input_param name="max" value="@$commander.pilot.skill.management, @this.ship.pilot.skill.piloting].max * 2"/>
        </param>
        <param name="maxsell" value="$commander.defaultorder.$maxsell" type="number" advanced="true" text="{1041, 10057}" comment="Max gate distance to sell resources. Sell range supported if $minsell and $maxsell are provided">
          <input_param name="max" value="@$commander.pilot.skill.management, @this.ship.pilot.skill.piloting].max * 2"/>
        </param>
      </create_order>
    </do_elseif>
    <!--end-->	
For TaterTrader, parameters copied ok, but one question, how to initialize ship default order ?

trade script have this section (i think its called when press apply button)

Code: Select all

  <init>
    <set_value name="$object" exact="this.assignedcontrolled" />
    <debug_to_file name="this.ship.knownname" directory="'TaterTrader'" text="'Starting Log File'" output="false" append="false" />

    <set_order_syncpoint_reached order="this.ship.order"/>
  </init>

roflmao86
Posts: 3
Joined: Thu, 13. Dec 18, 04:51

Re: [MOD] Mining/Trading Fleet

Post by roflmao86 » Sat, 22. Dec 18, 16:28

hi, for the problem of waiting time during action there is a fix mod https://www.nexusmods.com/x4foundations/mods/84

or you can just put the code in your mod ^^
aiscripts
<diff>
<replace sel="//attention/actions/run_script">
<run_script name="'move.idle'">
<param name="Min" value="5s"/>
<param name="Max" value="5s"/>

</run_script>
</replace>
</diff>

you can set a max value at 1-5mn and reduce it based on the skill level ^^
Last edited by roflmao86 on Sat, 22. Dec 18, 17:52, edited 1 time in total.

User avatar
DogyAUT
Posts: 43
Joined: Sat, 19. Jan 13, 20:29
x4

Re: [MOD] Mining/Trading Fleet

Post by DogyAUT » Sat, 22. Dec 18, 16:32

If this would work with TaterTrade it would be perfect :D

deltaone
Posts: 3
Joined: Sat, 22. Dec 18, 14:41

Re: [MOD] Mining/Trading Fleet

Post by deltaone » Sat, 22. Dec 18, 17:22

TaterTrade compability fix solved, final block:

Code: Select all

    <!--add. TaterTrade -->
    <!-- TODO: Introduce criteria for trader -->
    <do_elseif value="($commander.defaultorder.id == 'TaterTrade')">
    <!-- and ($object.primarypurpose == purpose.mine)"> -->
      <debug_to_file name="MTFleet" text="'ship %1(%2) assigned to ship %3. It is Fleet-Trader commanded by %3'.[$object.knownname, $object, $commander.knownname]" chance="$debugchance" />
      <create_order object="$object" id="'TaterTrade'" default="true">
        <param name="warebasket" value="$commander.defaultorder.$warebasket" />

		<param name="home" value="$commander.defaultorder.$home" />
		<param name="returnhome" value="$commander.defaultorder.$returnhome" />		
		<param name="discount" value="$commander.defaultorder.$discount" />
		<param name="discount2" value="$commander.defaultorder.$discount2" />
		<param name="bypass" value="$commander.defaultorder.$bypass" />
		
        <param name="minbuy" value="$commander.defaultorder.$minbuy" type="number" advanced="true" text="{1041, 10066}" comment="Min gate distance to buy. Buy range supported if $minbuy and $maxbuy are provided">
          <input_param name="max" value="@$commander.pilot.skill.management, @this.ship.pilot.skill.piloting].max * 2"/>
        </param>
        <param name="maxbuy" value="$commander.defaultorder.$maxbuy" type="number" text="{1041, 10054}" comment="Max gate distance to gather resources. Gathering range supported if $minsell and $maxsell are provided">
          <input_param name="max" value="@$commander.pilot.skill.management, @this.ship.pilot.skill.piloting].max * 2"/>
        </param>
        <param name="minsell" value="$commander.defaultorder.$minsell" type="number" advanced="true" text="{1041, 10068}" comment="Min gate distance to sell. Sell range supported if $minsell and $maxsell are provided">
          <input_param name="max" value="@$commander.pilot.skill.management, @this.ship.pilot.skill.piloting].max * 2"/>
        </param>
        <param name="maxsell" value="$commander.defaultorder.$maxsell" type="number" advanced="true" text="{1041, 10057}" comment="Max gate distance to sell resources. Sell range supported if $minsell and $maxsell are provided">
          <input_param name="max" value="@$commander.pilot.skill.management, @this.ship.pilot.skill.piloting].max * 2"/>
        </param>
      </create_order>
	  <set_order_syncpoint_reached order="$object.order"/>
    </do_elseif>
    <!--end-->	

deltaone
Posts: 3
Joined: Sat, 22. Dec 18, 14:41

Re: [MOD] Mining/Trading Fleet

Post by deltaone » Sat, 22. Dec 18, 17:28

Tyrant597 wrote:
Sat, 22. Dec 18, 03:33
2) Subordinates frequently take a coffee break (“Fly and Wait”) between tasks (eventually they return to work, so may not a problem).
Haven't looked at your code yet, but trader wait time between trades is based off of pilot skill, and you seem to be using very low level pilots in that screen. =P
Think these order come from default commander behavior and these need patching, but where ? ;)

roflmao86
Posts: 3
Joined: Thu, 13. Dec 18, 04:51

Re: [MOD] Mining/Trading Fleet

Post by roflmao86 » Sat, 22. Dec 18, 19:30

deltaone wrote:
Sat, 22. Dec 18, 17:28
Tyrant597 wrote:
Sat, 22. Dec 18, 03:33
2) Subordinates frequently take a coffee break (“Fly and Wait”) between tasks (eventually they return to work, so may not a problem).
Haven't looked at your code yet, but trader wait time between trades is based off of pilot skill, and you seem to be using very low level pilots in that screen. =P
Think these order come from default commander behavior and these need patching, but where ? ;)
see my post of the waiting time order script "move.idle"^^(it's not the better name for this mod but it is what are you talking no ?) https://www.nexusmods.com/x4foundations/mods/84

pesoda
Posts: 16
Joined: Thu, 13. Dec 18, 20:45
x4

Re: [MOD] Mining/Trading Fleet

Post by pesoda » Sat, 22. Dec 18, 20:47

kspn wrote:
Sat, 22. Dec 18, 12:32
I am assuming that the changes with the 1.5 patch with AutoTrade being restricted at 3* Pilots are adhered to?
It seems the 3-star skill restriction is ignored in this mod.

deltaone wrote:
Sat, 22. Dec 18, 17:22
TaterTrade compability fix solved, final block:

Code: Select all

    <!--add. TaterTrade -->
    <!-- TODO: Introduce criteria for trader -->
    <do_elseif value="($commander.defaultorder.id == 'TaterTrade')">
    <!-- and ($object.primarypurpose == purpose.mine)"> -->
      <debug_to_file name="MTFleet" text="'ship %1(%2) assigned to ship %3. It is Fleet-Trader commanded by %3'.[$object.knownname, $object, $commander.knownname]" chance="$debugchance" />
      <create_order object="$object" id="'TaterTrade'" default="true">
        <param name="warebasket" value="$commander.defaultorder.$warebasket" />

		<param name="home" value="$commander.defaultorder.$home" />
		<param name="returnhome" value="$commander.defaultorder.$returnhome" />		
		<param name="discount" value="$commander.defaultorder.$discount" />
		<param name="discount2" value="$commander.defaultorder.$discount2" />
		<param name="bypass" value="$commander.defaultorder.$bypass" />
		
        <param name="minbuy" value="$commander.defaultorder.$minbuy" type="number" advanced="true" text="{1041, 10066}" comment="Min gate distance to buy. Buy range supported if $minbuy and $maxbuy are provided">
          <input_param name="max" value="@$commander.pilot.skill.management, @this.ship.pilot.skill.piloting].max * 2"/>
        </param>
        <param name="maxbuy" value="$commander.defaultorder.$maxbuy" type="number" text="{1041, 10054}" comment="Max gate distance to gather resources. Gathering range supported if $minsell and $maxsell are provided">
          <input_param name="max" value="@$commander.pilot.skill.management, @this.ship.pilot.skill.piloting].max * 2"/>
        </param>
        <param name="minsell" value="$commander.defaultorder.$minsell" type="number" advanced="true" text="{1041, 10068}" comment="Min gate distance to sell. Sell range supported if $minsell and $maxsell are provided">
          <input_param name="max" value="@$commander.pilot.skill.management, @this.ship.pilot.skill.piloting].max * 2"/>
        </param>
        <param name="maxsell" value="$commander.defaultorder.$maxsell" type="number" advanced="true" text="{1041, 10057}" comment="Max gate distance to sell resources. Sell range supported if $minsell and $maxsell are provided">
          <input_param name="max" value="@$commander.pilot.skill.management, @this.ship.pilot.skill.piloting].max * 2"/>
        </param>
      </create_order>
	  <set_order_syncpoint_reached order="$object.order"/>
    </do_elseif>
    <!--end-->	
Good work. Thanks for your efforts.
The xml-file that including TaterTrade compatible fix was uploaded here. Save this to "extensions/mining_trading_fleet/aiscripts/".
https://www.mediafire.com/file/jzk1aymw ... orders.xml

roflmao86 wrote:
Sat, 22. Dec 18, 16:28
hi, for the problem of waiting time during action there is a fix mod https://www.nexusmods.com/x4foundations/mods/84
Thanks. It's helpful information about "move.idle".
deltaone wrote:
Sat, 22. Dec 18, 17:28
Tyrant597 wrote:
Sat, 22. Dec 18, 03:33
2) Subordinates frequently take a coffee break (“Fly and Wait”) between tasks (eventually they return to work, so may not a problem).
Haven't looked at your code yet, but trader wait time between trades is based off of pilot skill, and you seem to be using very low level pilots in that screen. =P
Think these order come from default commander behavior and these need patching, but where ? ;)
Changing parameters of "move.idle" can be effective. However, In other hand, subordinates executes "Fly and Wait", probably by using "move.generic" or "MoveGeneric". If think simply, the place will be found in infinite routine, aiscripts/order.mining.routine.xml, order.trade.routine.xml, and sciripts that they call. I think this info won't help you, but I can only say that now. Good luck.

Post Reply

Return to “X4: Foundations - Scripts and Modding”