While debugging why my trading station subordinates seemingly are idling (to the point of making and debugging a WIP mod), I noticed a major problem with this mod:
Let's say I have constructed a wharf and have a configured tradestation. This wharf naturally wants a budget to buy wares. If I somehow forget to supply some money to the wharf, then the trade will never happen. This is OK if it happens only once, but since this is a wharf, it is asking for wares at max price, and so it will still show up in the trade logic as "best trade deal". This causes tradestation subordinates (and even other NPC ships) to try to trade with the wharf again and again, while actually doing nothing because I really forgot about the wharf and the wharf cannot actually buy anything.
I guess this is a very strong reason why EgoSoft decided against the idea of this mod even though it is good in theory. There aren't any obvious direct solution to this, some planning will be required.
Yes, starting from some version player stations no longer put up buy offers with respect to its actual budget (probably in response to complaints about budget being meaningless for internal trade in vanilla). And this is causing problem with this mod since trade search usually does not check for fund availability (i.e. assuming buy offers are generated with budget in mind).
After thinking about this for a while, I think this problem can be solved.
We should first agree that station subordinates only use AutoTrade (ignore all other modded options), so any other "unsupported" modded trading behavior will be treated as "player initiated" and so the player pays the bill.
Then, have a look at aiscripts/order.trade.find.commander.xml and aiscripts/order.trade.find.free.xml ; the key is the $loctradevalue. If you can modify $loctradevalue (eg look at my other mod Fully Loaded https://www.nexusmods.com/x4foundations/mods/1462 ) then you can influence the behavior of the actual AutoTrade script (eg I made Fully Loaded to make traders avoid unused cargo space during their trade runs).
For maximum compatibility with other mods you should do something like this: patch to add the following line: $loctradevalue = $loctradevalue * (clamped trade amount / original trade amount) Using my example once again, if I forgot to transfer funds to the wharf, now when finding trades, the clamped trade amount becomes 0, so loctradevalue becomes 0. In effect, the buy offer sinks to the bottom of the list, and AutoTrade can find another best offer. With this, logistics can continue, and the wharf will no longer block AutoTrade.
Works great and haven't had any issues so far (about 20 hours active). I am glad you uploaded this mod as I really didn't understand, why EGO cut this (economics 101) feature tbh.
Finally I am able to see, how profitable my stations are, even if they almost solely supply my own stations!
For trades explicitly issued by player through UI, no money is transferred (I would like to make it also transfer money, but do not want to mess with the UI lua scripts.)
Maybe you could have a little correspondence with "kuertee" as he managed to implement a lot via his groundwork mod: kuertee's UI Extension
7 comments
Let's say I have constructed a wharf and have a configured tradestation. This wharf naturally wants a budget to buy wares. If I somehow forget to supply some money to the wharf, then the trade will never happen. This is OK if it happens only once, but since this is a wharf, it is asking for wares at max price, and so it will still show up in the trade logic as "best trade deal". This causes tradestation subordinates (and even other NPC ships) to try to trade with the wharf again and again, while actually doing nothing because I really forgot about the wharf and the wharf cannot actually buy anything.
I guess this is a very strong reason why EgoSoft decided against the idea of this mod even though it is good in theory. There aren't any obvious direct solution to this, some planning will be required.
We should first agree that station subordinates only use AutoTrade (ignore all other modded options), so any other "unsupported" modded trading behavior will be treated as "player initiated" and so the player pays the bill.
Then, have a look at aiscripts/order.trade.find.commander.xml and aiscripts/order.trade.find.free.xml ; the key is the $loctradevalue. If you can modify $loctradevalue (eg look at my other mod Fully Loaded https://www.nexusmods.com/x4foundations/mods/1462 ) then you can influence the behavior of the actual AutoTrade script (eg I made Fully Loaded to make traders avoid unused cargo space during their trade runs).
For maximum compatibility with other mods you should do something like this:
patch to add the following line:
Using my example once again, if I forgot to transfer funds to the wharf, now when finding trades, the clamped trade amount becomes 0, so loctradevalue becomes 0. In effect, the buy offer sinks to the bottom of the list, and AutoTrade can find another best offer. With this, logistics can continue, and the wharf will no longer block AutoTrade.$loctradevalue = $loctradevalue * (clamped trade amount / original trade amount)
Works great and haven't had any issues so far (about 20 hours active).
I am glad you uploaded this mod as I really didn't understand, why EGO cut this (economics 101) feature tbh.
Finally I am able to see, how profitable my stations are, even if they almost solely supply my own stations!
Maybe you could have a little correspondence with "kuertee" as he managed to implement a lot via his groundwork mod: kuertee's UI Extension
Anyway...
Thanks for this and
Have a great one!