[SCR] OK Traders v1.7.1 (04-12-14)

The place to discuss scripting and game modifications for X³: Terran Conflict and X³: Albion Prelude.

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

Warped
Posts: 23
Joined: Tue, 23. Jun 09, 12:47
x4

Post by Warped »

Geez I really stuffed up my last post, disregard.
Shimrod wrote: It sounds like there's some resupply mechanism at work there that might be laying in extra. Make sure any such settings on the ship itself are disabled.
I have set the 'Advanced Jumpdrive Configuration' to the folowwing:

autojump - no
min jump range - 0
resupply - 0

I think that's is want you mean?
Warped
Posts: 23
Joined: Tue, 23. Jun 09, 12:47
x4

Post by Warped »

ok, even with ships Advanced Jumpdrive Configuration set to yes, 0, 0 I am still seeing 1200 cells left in cargo after a delivery to out of sector npc.
Shimrod
Posts: 907
Joined: Tue, 18. Feb 03, 01:43
x4

Post by Shimrod »

My apologies I misread the code. It does not actually apply a 5% cargo space cap but rather applies a 5% floor, and 40% cap on jumpfuel. I'll edit my earlier post accordingly to avoid misleading more readers.

I spawned a mercury with an expanded cargobay of 4000 units, set 50 jumps on the homebase and enabled tracing. It does indeed load around 1200 energy, so what you're seeing is actually normal behaviour.

Code: Select all

[7047 9  Lib     Freight Transporter (Your Complex Hub α)] Get.Reserve.Jump.Energy: rc=1280
I agree there's scope for optimization to reduce amount of jumpfuel according to range of the outward destination. In the meantime if you check how many jump connections there are between your station and the worst case edge of the galaxy you'll probably find something like 15 or 20 jumps will actually do the job.

IIRC homebased traders do take advantage of excess fuel to buy goods on the way back after a sale if possible.

It's been suggested that traders could be set to prefer trading with player factories, I lack the free time for such a project in the near term though. However I may well be able to squeeze in the jumpfuel optimization; I already need to push out a fix for the Clear (all) button not working in the blacklist.
User avatar
Paddyy
Posts: 141
Joined: Sun, 12. Feb 06, 19:25
x3ap

Post by Paddyy »

Looks like the download link is down:
http://www.x1tp.com/root/index.php?opti ... 9&cid=1585
Shimrod
Posts: 907
Joined: Tue, 18. Feb 03, 01:43
x4

Post by Shimrod »

Shimrod
Posts: 907
Joined: Tue, 18. Feb 03, 01:43
x4

Post by Shimrod »

New version uploaded. The jump energy changes were non trivial. I've playtested for a couple of nights but keep an eye out for odd behaviour with jump energy.

1.6.2
- Fix a bug with the blacklist Clear button not working (1.6.1 regression)
- Prevent traders from selling Replicators
- Optimize the amount of jump energy for homebased traders based on current activity and reduce free trader energy stores by 20%
century
Posts: 15
Joined: Tue, 13. May 14, 10:33

Post by century »

hi there,


thanks for this great script.

i got 11 TS, and your stuff really improve my business , about millions in few hours ... i was poor , now i'm rich :) .....

all set to "Free Traders" , cauz i don't see what the "Eco trader" mean

sorry for my english :wink:

best regards
Fun-X
Posts: 184
Joined: Sun, 19. Jun 05, 06:34
x4

1.6.2 not so good

Post by Fun-X »

I installed 1.6.2 on top of 1.6.1 and started the game. The in game email confirmed it was "upgraded."

The station based traders would not keep any EC after selling some EC.

I reinstalled the 1.6.1 into the x3ap addon directory. I restarted the game. Again the in-game email confirmed it was "downgraded to 1.6.1"

Then it really lost its mind, and freighters were loosing their freight magically.

I then dis-installed everything. In game, used the removal tool from inside the OK Menu. Saved. I stopped the game. Then I re-installed 1.6.1. The in-game email said it was successfully installed.

1.6.1 seemed to work great after that.

I dunno, maybe 1.6.2 requires the in-game removal tool in order to work properly.

Any thoughts?
Shimrod
Posts: 907
Joined: Tue, 18. Feb 03, 01:43
x4

Post by Shimrod »

I've been away this week, sorry for delay.
"Eco trader"
It's short for 'economy boost'. In eco mode the trader prioritizes selling wares to stations that aren't producing due to ware shortages, rather than focusing only on best profit trades.
1.6.2 ... The station based traders would not keep any EC after selling some EC.
When unloading wares at the homebase in 1.6.2 traders also unload all jump energy (if the homebase uses energy). This is because the trader has no mission at this point, and so needs no energy cells.

When it selects its next mission it should then load a quanity of jump energy, particularly if the destination is in another sector. 1.6.2 is all about trying to optimize down the amount of energy the trader ships to make room for more traded wares.

If your trader has a jumpdrive, homebase has energy cells, is travelling outside of the home sector, and is NOT loading any jump energy from the homebase, then that may well be a bug.

I'll try and repro this the next time I have a window to play the game. Another way forward is to send me logging for analysis:
1. Select this trader as the logging target
2. Move trader to homebase, don't start OK Trade yet
3. Enable level 9 logging - be sure the trader is selected as logging target or log will be spammed by all traders
4. Start OK Trade on the trader
5. Wait until the trader selects a trade mission and heads out
6. Capture the log at this point (C:\Users\<User>\Documents\Egosoft\X3AP\log09055.txt)
7. Examine or PM me the log
reinstalled the 1.6.1...freighters were loosing their freight magically.
I've no insight into this. OK will load/unload at homebase or buy/sell outside of it. If wares disappear I'd expect them to have been unloaded at the homebase or sold to another station.

Downgrade without uninstall can potentially result in instability, it's not a case that's worth investing my time in supporting. That said I don't recall having made breaking changes in 1.6.2.

I think logging would be the way forward here too, if we can compare OK's decision making to real actions that occurred. E.g.went to homebase, wares still appear in cargo, undocks from homebase, wares have all disappeared) -> enable logging before it docks at homebase, and collect the log after confirming wares disappear from cargo.
Aeshi
Posts: 156
Joined: Sun, 11. Sep 11, 14:26
x3tc

Post by Aeshi »

Two small questions I'd like to ask:

A) Is there any way to make the "Blacklist" feature a "don't go to this Sector" one rather than a "don't go to stations in this sector" one? I've had at least 2 OK Traders who insisted on flying into Xenon Sectors.

B) Is there any way to give a "Free OK Trader" a homebase? I'd like to assign them to my HQ, that way they'd send & take money from the HQ's reserves, not mine.
Shimrod
Posts: 907
Joined: Tue, 18. Feb 03, 01:43
x4

Post by Shimrod »

A) Is there any way to make the "Blacklist" feature a "don't go to this Sector" one rather than a "don't go to stations in this sector" one? I've had at least 2 OK Traders who insisted on flying into Xenon Sectors.
It's probably doable but not currently implemented. OK uses standard Egosoft scripts to move the ship and these don't support a blacklist.

If sector connectivity data can be determined via APIs then it should be possible to do some sort of spanning tree algorithm to determine shortest path while taking into account blacklists.

Not a high priority relative to other desired features and I'm not playing X at the moment.
B) Is there any way to give a "Free OK Trader" a homebase? I'd like to assign them to my HQ, that way they'd send & take money from the HQ's reserves, not mine.
No, the scripts have hardcoded assumptions that a homebase means it's a station trader and vice versa. If the homebase changes while the scripts are running they should bail out on a sanity check. Unlikely to ever change.
1.6.2 ... The station based traders would not keep any EC after selling some EC.
Can anyone corroborate problems with 1.6.2 in their game?
agentanorexia
Posts: 2
Joined: Wed, 28. May 14, 19:20

Post by agentanorexia »

I'm newish to x3 and started a new game. I got enough cash to buy a second trade ship with about 1 mil left over. I sent him on his way, and walked away for a bit. Came back to find the trader had bankrupted me down to 3k credits and was trading one banshee missile over and over. I guess he was buying engine upgrades or something? I couldn't really tell and it wasn't obvious from the ship info screen whether that's what he did or not. Perhaps the traders should check whether there are enough credits to both buy the next level of upgrade plus the cost of a full load, otherwise they just trade?

On another note, roughly how many credits will it take to upgrade everything such that he just trades?
Shimrod
Posts: 907
Joined: Tue, 18. Feb 03, 01:43
x4

Post by Shimrod »

Equipping can be disabled via the menu. This is the default config:

Code: Select all

346   | $Equip.Config [ $Config.Equip.Lasers ] = 0 
347   | $Equip.Config [ $Config.Equip.Shields ] = 1 
348   | $Equip.Config [ $Config.Equip.Missiles ] = 0 
349   | $Equip.Config [ $Config.Equip.Drones ] = 1 
350   | $Equip.Config [ $Config.Equip.DockingComputer ] = 1 
351   | $Equip.Config [ $Config.Equip.Jumpdrive ] = 1 
352   | $Equip.Config [ $Config.Equip.Triplex ] = 1 
353   | $Equip.Config [ $Config.Equip.Rudder ] = 1 
354   | $Equip.Config [ $Config.Equip.CargoLifeSupport ] = 1 
355   | $Equip.Config [ $Config.Equip.Duplex ] = 1 
The price is whatever the wares cost. Shields are the most expensive item in vanilla, cost of upgrades and tunings probably a few hundred k altogether. XRM inflates the cost of every ware to epic proportions however. I'd recommend disabling auto equipping if strapped for cash.

The trader simply checks it can buy 1 unit of desired ware at the max possible price of the ware. One option I'd consider would be to set a floor amount in player funds which auto equipping and repairing will not go below. It may be some time before I'm likely to release any updates though unless bugs are found.
agentanorexia
Posts: 2
Joined: Wed, 28. May 14, 19:20

Post by agentanorexia »

Got it, yeah I'm in xrm, though wasn't last time I played. I'll check out the menu and disable gearing up until I build up some sizable cash.

Thanks!
Fun-X
Posts: 184
Joined: Sun, 19. Jun 05, 06:34
x4

Post by Fun-X »

1.6.2 ... The station based traders would not keep any EC after selling some EC.
Can anyone corroborate problems with 1.6.2 in their game?
I tried 1.6.2 on a new game from scratch, and it seems to be working now. I am guessing that the upgrade from 1.6.1 to 1.6.2 caused some temporary insanity.

If nobody else had an issue, then I guess we don't need to worry about it.
Shauwn205
Posts: 5
Joined: Mon, 2. Jul 12, 09:06

Post by Shauwn205 »

Hey what's up, I love you script. I hated micromanaging CLS, CAG, PTP, RFI, and all the other three-letter-combinations you can imagine, but OK Trader really allows you to focus on what you want to focus on without loosing all your pretty hair due to frustration. Great, great, great work! However, I've only started out with 1.6.2 since I just recently picked up the game again and had the same issues as Fun-X, I think. Restarting the game didn't fix the problem either, however.
My free traders were therefore happily jumping from sector to sector gaining me lotsa digits, but hometraders always got stuck at wherever they want to sell the products of their homestation since they sold all their energy cells as well. Therefore, they slowly fly to the next solar power plant or whatever is closest and than jump back home. I make a profit, but ever so slowly. I didn't want to go back to CAG since, well, I just can't get along with pilots who are actually constantly japping at you about their salary, inability to use jumpdrives etc. so I had a look at your script.

In 'glen.trade.ok.lib' I've found the line under

Code: Select all

1342 * Get.Reserved.Amount:

1384 * Fuel
1385 if $Ware == {Energy Cells}
1386 $rc = [THIS]-> call script 'glen.trade.ok.lib' : Func=$Lib.Get.Reserve.Jump.Energy Arg1=null Arg2=null Arg3=null Arg4=null Arg5=null Arg6=null
1387 break
1388 end
Therefore I change the first Argument to $Home.Sector :

Code: Select all

1386 $rc = [THIS]-> call script 'glen.trade.ok.lib' : Func=$Lib.Get.Reserve.Jump.Energy Arg1=$Home.Sector Arg2=null Arg3=null Arg4=null Arg5=null Arg6=null
This fixed it for me, Hometraders were now jumping from Profit to home and back. I'm not sure if Energy Cells are being used efficiently now, I Think you were trying to optimize that with the last update, but I'm just happy it's working for me. Also, I haven't seen anybody else complain so it might be a problem only I am encountering but if there is somebody else out there with the same problem, well, this should make it work.
Shimrod
Posts: 907
Joined: Tue, 18. Feb 03, 01:43
x4

Post by Shimrod »

That's the right area of code, in terms of how OK determines how much jump energy to retain from sale, but the change looks like a placebo as Get.Reserve.Jump.Energy (line 297) doesn't reference $Arg1.

Prior to 1.6.2 that function would retain an amount simply proportional to homebase max jumps, whereas 1.6.2 aims to trim it down to a minimum based on the ship's current mission.

It'd be useful to see level 9 logging from the trader when it sells off its energy without retaining any jumpfuel.
Shauwn205
Posts: 5
Joined: Mon, 2. Jul 12, 09:06

Post by Shauwn205 »

I might change it back and turn debug-logging on just to see if that might help you figure out where the problem is located. The thing that confuses me is that only I am experiencing this kind of bug and noone else. I'd be surprised if it interfered with any other script in any way since all of those have their seperate - umm - "area" in which they operate, right?
I'm gonna do that later, though, since I've been procrastinating the last few days by not studying for my orals tomorrow x( .
Also, I have second to none experience in X³ scripting whatsoever so even finding a placebo and putting it in and the whole thing working is a huge success for me :lol:
Shimrod
Posts: 907
Joined: Tue, 18. Feb 03, 01:43
x4

Post by Shimrod »

I'll have a go at reproducing it after work too. One thing that could make a difference is whether the trader has a docking computer.

Scripts are isolated from each other in that assigning a variable in one script won't affect a variable with the same name in another script (unless the variable were deliberately exported as a global variable, or attached to a game object), but all scripts do operate on the same game state and objects and ultimately they could interfere with each other.

But I think a 1.6.2 bug is far more likely since that patch is all about messing with jump energy.

Edit: think I found the bug, testing a fix this evening.
Shimrod
Posts: 907
Joined: Tue, 18. Feb 03, 01:43
x4

Post by Shimrod »

1.6.3 uploaded.

1.6.3
- Add a blacklist menu option for adding all sectors belonging to a selected race
- Fix a bug where homebased traders would sell all their jumpfuel before returning home after a sale (1.6.2 regression)

Return to “X³: Terran Conflict / Albion Prelude - Scripts and Modding”