[MOD] Mining/Trading Fleet ver0.03

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

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

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

[MOD] Mining/Trading Fleet ver0.03

Post by pesoda » Sat, 22. Dec 18, 01: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, 16:10, edited 2 times in total.

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

Re: [MOD] Mining/Trading Fleet

Post by Lakz » Sat, 22. Dec 18, 02: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, 02: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, 13:50
x4

Re: [MOD] Mining/Trading Fleet

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

YES, I need this so bad.

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

Re: [MOD] Mining/Trading Fleet

Post by jmattspartacus2 » Sat, 22. Dec 18, 06: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, 13:59

Re: [MOD] Mining/Trading Fleet

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

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

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

Re: [MOD] Mining/Trading Fleet

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

Thanks for comments.
Lakz wrote:
Sat, 22. Dec 18, 02: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, 02: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, 06:59
Can you post this to the nexus?
Next version will be posted to the nexus.

kspn
Posts: 75
Joined: Mon, 9. Jan 06, 10:59
x4

Re: [MOD] Mining/Trading Fleet

Post by kspn » Sat, 22. Dec 18, 11: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, 13:41

Re: [MOD] Mining/Trading Fleet

Post by deltaone » Sat, 22. Dec 18, 13: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, 03:51

Re: [MOD] Mining/Trading Fleet

Post by roflmao86 » Sat, 22. Dec 18, 15: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, 16:52, edited 1 time in total.

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

Re: [MOD] Mining/Trading Fleet

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

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

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

Re: [MOD] Mining/Trading Fleet

Post by deltaone » Sat, 22. Dec 18, 16: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, 13:41

Re: [MOD] Mining/Trading Fleet

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

Tyrant597 wrote:
Sat, 22. Dec 18, 02: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, 03:51

Re: [MOD] Mining/Trading Fleet

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

deltaone wrote:
Sat, 22. Dec 18, 16:28
Tyrant597 wrote:
Sat, 22. Dec 18, 02: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, 19:45
x4

Re: [MOD] Mining/Trading Fleet

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

kspn wrote:
Sat, 22. Dec 18, 11: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, 16: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, 15: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, 16:28
Tyrant597 wrote:
Sat, 22. Dec 18, 02: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.

TENGILL
Posts: 17
Joined: Thu, 22. Apr 04, 16:44
x4

Re: [MOD] Mining/Trading Fleet

Post by TENGILL » Sun, 23. Dec 18, 01:28

This mod looks great, +1 on adding it to NEXUS.
Please and thank you. :)

kspn
Posts: 75
Joined: Mon, 9. Jan 06, 10:59
x4

Re: [MOD] Mining/Trading Fleet

Post by kspn » Sun, 23. Dec 18, 05:32

I have the start of Wing Rename code.

Currently there is no check for the tag already existing in the Wings Name and my code assumes that you want to keep the existing wing name. An example output is Wing 1 Mining

Code: Select all

  <add sel="/aiscript/attention[1]/actions[1]/do_else[1]/do_else[1]" pos="after">
    <do_if value="($commander.subordinates.count == 1) and ($commander.defaultorder.id == 'TradeRoutine')">
      <debug_text text="'Set Wing name to %1 AutoTrade Count=%2'.[$commander.wing.name,$commander.subordinates.count]" />
      <set_object_wing_name object="$commander" name="'%1 AutoTrade'.[$commander.wing.name]" />
    </do_if>
    <do_elseif value="($commander.subordinates.count == 1) and ($commander.defaultorder.id == 'TaterTrade')">
      <debug_text text="'Set Wing name to %1 TaterTrade Count=%2'.[$commander.wing.name,$commander.subordinates.count]" />
      <set_object_wing_name object="$commander" name="'%1 TaterTrade'.[$commander.wing.name]" />
    </do_elseif>
    <do_elseif value="($commander.subordinates.count == 1) and ($commander.defaultorder.id == 'MiningRoutine')">
      <debug_text text="'Set Wing name to %1 Mining Count=%2'.[$commander.wing.name,$commander.subordinates.count]" />
      <set_object_wing_name object="$commander" name="'%1 Mining'.[$commander.wing.name]" />
    </do_elseif>
  </add>

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

Re: [MOD] Mining/Trading Fleet

Post by pesoda » Sun, 23. Dec 18, 09:19

Here, substitute_text function (see libraries/common.xsd) was added to your code for removing an overlapped tag.
"Rename Wings" seems to have worked. Thanks.
Original Post
Show

Code: Select all

  <add sel="/aiscript/attention[1]/actions[1]/do_else[1]/do_else[1]" pos="after">
    <!-- Add. Rename Wings.  Thanks to kspn at Mod Forum: https://forum.egosoft.com/viewtopic.php?f=181&t=410087&start=15#p4810686 -->
    <do_if value="($commander.subordinates.count gt 0)">
      <!-- Create tag -->
      <set_value name="$wing_tag" exact="''" />
      <do_if value="($commander.defaultorder.id == 'TradeRoutine')">
        <set_value name="$wing_tag" exact="'AutoTrade'" />
      </do_if>
      <do_elseif value="($commander.defaultorder.id == 'TaterTrade')">
        <set_value name="$wing_tag" exact="'TaterTrade'" />
      </do_elseif>
      <do_elseif value="($commander.defaultorder.id == 'MiningRoutine')">
        <set_value name="$wing_tag" exact="'Mining'" />
      </do_elseif>
      <debug_text text="'Set Wing name to %1 %2 Count=%3'.[$commander.wing.name,$wing_tag,$commander.subordinates.count]" />

      <!-- Rename wing-->
      <do_if value="$wing_tag != ''">
        <substitute_text source="$commander.wing.name" text="$org_name">
          <replace string="' %1'.[$wing_tag]" with="''" />
        </substitute_text>
        <set_object_wing_name object="$commander" name="'%1 %2'.[$org_name, $wing_tag]" />
        <debug_text text="'Wing name: %1'.[$commander.wing.name]" />
      </do_if>

    </do_if>
    <!--end-->
  </add>
Save this xml-file to "extensions/mining_trading_fleet/aiscripts/".
]https://www.mediafire.com/file/mdlbsk3q ... orders.xml

Edit:
Fixed: Tag remains when the default order changed.
Image: https://i.imgur.com/o1nqeRN.png

Code: Select all

  <add sel="/aiscript/attention[1]/actions[1]/do_else[1]/do_else[1]" pos="after">
    <!-- Add. Rename Wings.  Thanks to kspn at Mod Forum: https://forum.egosoft.com/viewtopic.php?f=181&t=410087&start=15#p4810686 -->
    <do_if value="($commander.subordinates.count gt 0)">
      <!-- Prepare tags. ** Should be used dictionary **  -->
      <set_value name="$mtf_orders" exact="['TradeRoutine', 'TaterTrade', 'MiningRoutine']" />
      <set_value name="$mtf_tags" exact="[  'AutoTrade',    'TaterTrade', 'Mining']" />

      <!-- Create tag -->
      <set_value name="$wing_tag" exact="''" />
      <substitute_text source="$commander.wing.name" text="$org_name">
        <replace string="' %1'.[$mtf_tags.{1}]" with="''" />
      </substitute_text>
      <debug_text text="'mtf_orders.count=%1'.[$mtf_orders.count]" />
      <do_all exact="$mtf_orders.count" counter="$i">
        <!-- Remove existing tag -->
        <substitute_text text="$org_name">
          <replace string="' %1'.[$mtf_tags.{$i}]" with="''" />
        </substitute_text>

        <!-- Rename Wing -->
        <do_if value="($commander.defaultorder.id == $mtf_orders.{$i})">
          <set_value name="$wing_tag" exact="' %1'.[$mtf_tags.{$i}]" />
        </do_if>
      </do_all>
      <set_object_wing_name object="$commander" name="'%1%2'.[$org_name, $wing_tag]" />
      <debug_text text="'Set Wing name to %1 Count=%2'.[$commander.wing.name,$commander.subordinates.count]" />
    </do_if>
    <!--end-->
  </add>
Save this xml-file to "extensions/mining_trading_fleet/aiscripts/".
http://www.mediafire.com/file/w6lzeydpb ... orders.xml
Last edited by pesoda on Sun, 23. Dec 18, 12:35, edited 1 time in total.

kspn
Posts: 75
Joined: Mon, 9. Jan 06, 10:59
x4

Re: [MOD] Mining/Trading Fleet

Post by kspn » Sun, 23. Dec 18, 09:46

Awesome :)

I have added the update to my game.

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

Re: [MOD] Mining/Trading Fleet

Post by pesoda » Tue, 25. Dec 18, 01:21

MTF ver0.03 is in progress.
If you want to test an experimental version, see bottom.

Attempt to realize real-time updating of wares/distances.

1) Introduction: Passing by reference of $warebasket. Passing by value of $maxbuy/$maxsell.
Firstly, author isn’t a programmer, but as a basic knowledge of programming, a list structure will basically be passed by reference of list[0] and the program uses not a real value (e.g. “name=spaceweed, price=500”) but a reference (e.g. 0x12345) for accessing to the list. Therefore, when the commander’s “warebasket” is passed to subordinates, their references are shared and wares-lists will synchronize. That’s the reason why updating wares-lists is easier.
However, “maxbuy” is an integer and is passed its copy. It means that the program must execute to copy of “maxbuy” every time when commander’s “maxbuy” is changed. Because the only function to set param one-by-one was prepared, I couldn't implement shallow-copy of whole order-params even though create params-list. An alternative way was necessary.

2) Method A: Using EventHandler.
I tried to hook the moment which the commander’s default-order-param is changed. (About hooking. For example, imagine Paint Tools, your click event is hooked and detected as “pos.x=250 [px], pos.y=600 [px], mouse_button=Left” by OS and that info is processed by Paint Tool to display your drawing activity.) However, no valid functions (prefix: event_) exist for that purpose and event_object_order_param_edited was inappropriate, too. Maybe the valid function will be found in the menu-UI, inside of lua codes.
In conclusion, the perfect real-time updating of wares/distances should be realized as the one of the Lua-UI mod.
Sample code is available. Put it to the aiscripts directory and add <handler ref=“FleetDefaultOrderChangedHandler” /> within <interrupts> block of an order script.
https://www.mediafire.com/file/e081aw5i ... detail.xml

3) Method B: Inject copy-params code into docking script.
Copy-params code was injected to order.dock that frequently be executed. It seems to work fine.

I would like to share it, but I have no time to check the scripts completely work. So, this is an unstable version. And feel free to modify/fix and reupload.

ver0.03 experimental
https://www.mediafire.com/file/y9dms5eu ... 3_exp3.zip

New feature: deltaone’s compatibility patch for TaterTrade (v3.1).
New feature: kspn’s-based Rename Wings.
New feature: Dynamic updating of subordinates’ order-properties (wares, distances, etc) when the commander docked at a station.

Edit:
Fixed: Only AutoTrade ships were updated their distance.
File was reuploaded.
Captions were added to this text.
Last edited by pesoda on Wed, 26. Dec 18, 15:24, edited 2 times in total.

Post Reply

Return to “X4: Foundations - Scripts and Modding”