X4: Foundations

X4: Foundations

Mules and Warehouses v4
Showing 1-9 of 9 entries
Update: 17 Jun, 2019 @ 5:06pm

v4.0 : Two new Mules just arrived into the family : the TravelMule and the DistriMule !
One handles selling from your warehouses to NPCs, the other equalising wares between your warehouses.
Keep in mind they are still newborns. Be gentle with them and report any strange behavior.

New : from now on, all Mules will stay docked between trades !
No more useless docking-undocking.
I had to replace all the contents of orders.base.xml to do it, which may cause compatibility issues with other mods :
Any mods that alters that same file and comes before alphabetically, will see their changes overwritten.
Any mod that comes after alphabetically will overwrite my change.
If that happens, let me know, compatibility can be arranged !

Various fixes to the StationMule, including :
Rewrite of the 'Make Target Warehouse' option, so that it doen't use buy and sell offers anymore, but lists of products and tradewares instead. Translation : some bugs fixed.
Logic to forbid a StationMule from ever trading between two warehouses.

Update: 14 Jun, 2019 @ 8:19pm

v3.5 : Complete rewrite of trade logic.
I realized that sorting trades only work on amount and volume, and sometimes not even that, because the variables behind have some strange behaviors, and some are not calculated correctly (like stocklevel).

So I wrote my own logic to choose which need to prioritize :
When "Seller priority" is activated for a trade, I still use volume to sort, that works well with sell offers.
But, when it is not activated, and in every case of in-cluster trade, I now sort wares according to how empty the storage is in %, which I calculate myself from reserved storage and amount of ware in cargo.
Check the description for details. I'm really happy about this, I was already trying to get this behavior back when X4 was in v1.4...

I changed the rules for low-cargo trades, to always allow a low-cargo trade when it is to supply the last few units of a ware used to build a station, or station drones.

I made a small but important change : now, when selling wares to one of your stations, Mules will not consider the quantity of wares the station can buy (variable amount) but instead the quantity it would buy if it had the budget (variable desiredamount). Not only does it solve a number of vanilla bugs and annoyances, it allows the delivery of wares to stations with no money !
It is very important for your warehouses : now, you can prevent a warehouse from ever buying wares from a NPC by setting the station budget to 1 credit. The 'amounts' of every buy offer on this station will be 0, so no regular trader will ever sell to the station. But Mules will... Then you can allow your warehouse to trade with other factions, which will mean to sell to other factions only !
Your warehouse will start to earn money from these sales, but as soon as the budget goes above 2x what you gave initially, they will transfer the excess to you. So the station budget will stay at 2 credits, and you will get all the money from the sales quickly in your own account.

The mod is now named Mules and Warehouses. It is more concise, and it has a swanky acronym : MaW !
I can tell you're all really excited about that last one.

Update: 13 Jun, 2019 @ 9:04am

v3.32 : Improvements to in-cluster trade logic :

Now, Mules will consider the needs of shipyards and factories at the same time.
Since shipyards generally have larger storage capacity, their buy offers are larger, and they should still get priority.
But once their needs are smaller, your mules will deliver to your factories as well, without waiting for your shipyard to be full first. The needs of station construction still have absolute priority, and the 'needs' of warehouses always come last.

Improved logic when a factory needs a ware, but produces it as well.
Now, the Mules will not bypass the volume of the buy offer set by the manager in that specific case, which is usually zero for a good reason : the factory can supply itself.

Update: 12 Jun, 2019 @ 5:36pm

v3.31 : Fixed small typo in v3.3 that prevented cluster-wide trade from delivering to regular stations.

Update: 12 Jun, 2019 @ 4:41pm

v3.3 : Restored the feature of the 3.1 update, lost in v3.2
Other small fixes and code reorganisation following v3.2

New : the Mules will now deliver wares to a station even if the amount of that ware requested by the manager is zero, as long as the station still actually has reserved storage for that ware.
This solves a number of vanilla bugs caused by strange manager behavior.

Update: 12 Jun, 2019 @ 11:02am

v3.2 : Fixes to some logic that could allow trades with zero quantity.
Fix for an issue that prevented in-cluster trade to 'see' all player trades properly.
Fix for 'Create Trade' option in cases when warehouse stops buying because stores are full : will no longer try to add these wares at every run.

Updated choice of trade partner when trading in-cluster :
Mules will now sell to your construction sites, then if no valid trade to your shipyards, then to your factories, then your warehouses. They will as usual choose the offer with the largest volume first.
They will buy from your factories first, then your warehouses.

Mules now handle having extra cargo, like when a Sale cancels after they already bought the wares, or if you assign them to Mule duty while their cargo is not empty. They will sell it anywhere in the Source station's cluster before resuming regular Mule duties. If it cannot sell the ware, it will idle.

Other back-end optimisations of the code, the script is back at 300 lines in all. Easier debug and better performances

Update: 9 Jun, 2019 @ 8:39pm

v3.1 : Small fix : Mules now always allow the trade of energy cells when trading with station build storages.

Update: 8 Jun, 2019 @ 6:07pm

v3.0 : Added ability to create Warehouses and Trade Stations !

Also added new default behavior : now, when idling (no trade between Source and Target), the Mules default to trade in the whole cluster of the Source station, only between player objects.
Mules supply station build storages first, then all your stations.

Update: 8 Jun, 2019 @ 2:00pm

v2.0 : First upload to the workshop.
All previous changes documented in the Egosoft thread for the original StationMule.