[MOD] Auto Trader (v1.1 Dec 15 2015)

The place to discuss scripting and game modifications for X Rebirth.

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

Post Reply
User avatar
euclid
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 13289
Joined: Sun, 15. Feb 04, 20:12
x4

[MOD] Auto Trader (v1.1 Dec 15 2015)

Post by euclid » Mon, 6. Jan 14, 02:41

AutoTrader Ver.1.1:

V1.1: Added type for trade reservation (change of script command format in X Rebirth 4.0)

DOWNLOAD

  • I. Requirements:
    You need a ship with universal storage capacity. To start the AutoMiner the ship needs at least 10 Scooper and 10 surface drones.


    II. How to start:
    • 1) Fly to a zone which sector has enough trade opportunities because the initial range of an AutoTrader will be this sector.
      2) Add the ship to your squad and wait until it has arrived.
      3) Select the ship either via property or zone map or simply target it if in visual range.
      4) Engage and disengage the autopilot (default: hit shift-A twice) to trigger a custom conversation "Auto Trade"
      5) Select "AutoTrade" and then one of the trade options "Sector Trader", "Sector Station Trader", "Sector Miner" or "Sector Station Miner" (see I. Requirements).
      6) Remove the ship from your squad.
    III. Promotion
    The total profit of an Auto trader unlocks an optional promotion. A corresponding message (including status details) is send to the player's logbook. To promote an auto trader just trigger the menu (see II.,4)) and select the Cluster or Galaxy trader option. Except the benefit of a wider range a promoted auto trader will work slightly faster and deals in higher ranked wares. However, his fee also increases slightly.

    IV. Relocation
    It is easy to move an auto trader to another sector or cluster. Just follow the steps 1) to 6) in II. above.

    V. Warnings:
    • 1) Be careful where you start what type of AutoTrader! Any station miner or station trader will exclusively trade between player-owned stations only within his range (initially the current sector). For the station miner ensure that you own at least one station in that sector and that this station need resources available in this sector. For the station trader you need at least two stations in that sector which production and resources are mutually dependent (one produces the resource of the other).

      2) Be careful how many traders you promote to Cluster or even Galaxy range. A Galaxy Auto Trader will search the entire galaxy for most profitable deals and hence the list he has to check will become very long. If you run too many Galaxy Traders there will be significant lag spikes when they search for trades.
    VI. Installation
    As usual extract the entire AutoTrader folder to your extensions folder.


    VII.Deinstallation
    Add all your auto traders to your squad to stop the scripts. Then save your game and exit. Remove the folder AutoTrader from your extensions folder. Start the game, load the saved game and find other jobs for the former auto traders.


    VIII. Compatibility
    As all my mods also this mod does not use or alter any vanilla files for the ultimate compatibility. However, it does use but uses several global and local (on the captain) variables and also adds some inventory items and an account to the captain. [bPlease do not change these! [/b]

    IX. CopyRight
    I allow everyone to use this mod in parts or entirely for your own mod. Change or modify it as you like but, please, do not publish your mod of this mod at the Nexus (as some did already :-( ). I will maintain my mods there and do not wish any conflict.
Question & Answers

Q: I've started the Station Trader and now he is following me around. What is wrong?
A: If you start a Station Trader or Station Miner in a sector where you do not own any stations then he will send you a corresponding message (check you logbook) and will follow you.

Q: I do own several stations in the sector where I have started the Station Miner but he is following me. Is this a bug?
A: No bug. The Station Miner and the Sector Miner will check initially and regularly the amount of scooper and surface drones. If there are not 10 of each then he send a message and follow you around. Lead him to a ship Yard and buy the missing collector drones. The lead him back to the sector wher he is suppose to work, hail the captain and select "resume autotrade" either the Station Miner or Sector Miner.

Q: I have a Cluster Station Trader running but now I've changed my mind and want him to serve not only my stations but trade with NPC stations, too. How can I do that?
A: Just follow steps II. 2) to 6).
Q: I have observed my Station miner for some time and he is collecting and the drones do show "in Use" but there are no drones flying about. What is wrong?
A: Nothing, similar as with the autotrader's cargo lifters the mod do not launch the collector drones for collection. The entire collection is 'simulated'. So there is also no need for a ship to have a mining laser.

Q: My Rahanas energy freighter does not have the auto trader option, why?
A: The AutoTrader will only work with ship that have universal storage. However, if you insist of having an energy-only auto trader running then please feel free to mod my mod ;-)

Q: Could you recommend a good station setup for the Station Trader?
A: There are many good setups. An Engergy Array is always good to have because ecells are needed by every station. Similar with food rations, so a Foodstuff Supply in addition is a good setup. But also, for example, a Metalworks Yard and an Arms Tech Fab because the refined metals produced in the Metalworks are needed as a resource in the Arms Tech Fab to produce reinforced metal plating.

Q: My auto trader is not moving and hasn't send any report for some time.
A: Trigger the menu (see II. steps 3) & 4)) and see if the option "Show profit" appears. If so feel free to click it for a status update in your logbook. Probably your trader has not found any deals in his range.

Q: I did hail him but there is no such show profit option. What is wrong?
A: The only way that can happen is if your pilot has received another command. Either you have assigned him to a new superior or added him to your squad or issued any other order. But no panic, you can restart him (see II. above).

Q: No, that didn't work either. What now?
A: Kick him from your squad, add him again and if you still do not get the option then send me your zipped saved game please :-)

Q: What about fuel?
A: No worries, the pilot covers for the fuel cost via his commision charge. (Technically: they do not use fuel for jumping). If they have fuel initially it will be used for jumping.

Q: I've accidentially added him to my squad and now he's just following me. Is all lost?
A: Nope, all is cool. Just restart him (see II. above).

Q: I keep getting reputation gains with faction I never met but nothing increases. Is this brocken?
A: No, not broken, it's intended. Every trade partner's faction will be known to you, too, and With each trade you gain a very small reputation with the trader faction. It is so small that it requires many runs to "see" a reputation gain.

Q: LOL ! I've never been in Omicron Lyrae but in the map some sectors and zones are "known" to me. Is that right?
A: Do you remember the feature in X3 where you could set a fast ship to follow the Goner U.F.O.? It would eventually map out for you the entire universe :D The auto trader has the same feature: if an area is known to them it is also known to you.

Q: I watched my auto trader during trades but where are the cargo lifter?
A: This mod does not use cargo lifters for load wares. The auto trader's ship has secretly been upgraded and equipped with a transporter beam ;-)

Q: What would you consider as an optimum ship setup for an auto trader?
A: Use a Titurel (go captue one :p) with a high-skilled engineer and a defence officer (command set on defend), fully equipped ammo, 75 welder drones and 75 interceptor Mk2, no fuel.


Cheers Euclid
Last edited by euclid on Thu, 17. Mar 16, 23:11, edited 25 times in total.
"In any special doctrine of nature there can be only as much proper science as there is mathematics therein.”
- Immanuel Kant (1724-1804), Metaphysical Foundations of the Science of Nature, 4:470, 1786

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Re: [MOD] Auto Trader

Post by UniTrader » Mon, 6. Jan 14, 02:57

euclid wrote:The reason is that the current script system lacks of global variables as we know them from the "old" SE. Hence it's tricky to 'safe' data if a script, that has defined them, is cancelled. My solution is to use the pilot's inventory (yes, NPCs have one ;-) ) which I use to safe the auto trader's level. I've also added an account to the pilot and set a maximum budget to save the profit.
Global Variables exist and are far easier to use than in the old SE :roll: ;) (probably its too simple, i didnt find it at first, too ^^)
global.$variable <-use this like any variable you would use in the Script. no need to explicitly read/write them.

additionally you also have local Variables on Entities:
this.$variable (acces to $variable on the Entity, probably the Pilot/Captain in your case)

PS i think may find this code snippet useful when you want to use this Script on other Ships with limited Cargo (it filters a list with all availabele wares so only the transportable, legal ones are left):

Code: Select all

      <!-- list of all wares for iteration - i wish i could get this one dynamically.. (or simply only the compatible wares..) -->
      <run_script name="'lib.ut.get.unreachable.values'" result="$allwares">
        <param name="value" value="'allwares'"/>
      </run_script>
      <create_list name="$basket" exact="0"/>
      <do_all exact="$allwares.count" counter="$i">
        <!-- we want only transportable Goods -->
        <do_if value="this.ship.cargo.{$allwares.{$i}}.max">
          <!-- we dont want to trade Fuel (re-charging is done seperately)-->
          <do_if value="$allwares.{$i} != ware.fuelcells">
            <!-- dont include illegal Wares (ToDo: finer check needed; for now i only ignore globally Illegal Wares -->
            <do_if value="not $allwares.{$i}.illegal">
                <append_to_list name="$basket" exact="$allwares.{$i}"/>
            </do_if>
          </do_if>
        </do_if>
      </do_all>
      <remove_value name="$allwares"/>
      <show_notification caption="'Warebasket'" details="$basket" queued="true" chance="$debugoutputchance"/>
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

User avatar
werewolves?
Posts: 1166
Joined: Tue, 31. Jan 12, 00:58
x4

Post by werewolves? » Mon, 6. Jan 14, 03:12

you guys are rad.

User avatar
Tanvaras
Posts: 170
Joined: Thu, 27. Nov 03, 10:45
x4

Post by Tanvaras » Mon, 6. Jan 14, 03:56

In the words of Monty Burns "Excellent!!!!"

Thank gawd for modders :)

Cheers

User avatar
YorrickVander
Posts: 2689
Joined: Tue, 29. Oct 13, 21:59
x4

Post by YorrickVander » Mon, 6. Jan 14, 06:04

Euclid, above and beyond mate. Great job.
X Rebirth - A Sirius Cybernetics Corporation Product

Split irritate visiting pilot with strange vocal patterns.

iforgotmysocks
Posts: 1244
Joined: Fri, 8. Nov 13, 22:35
x4

Post by iforgotmysocks » Mon, 6. Jan 14, 09:25

Pretty nice!

PS: md scripts aren't macros. You don't need to add them to any index file. ^^
Only macros and components.

User avatar
euclid
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 13289
Joined: Sun, 15. Feb 04, 20:12
x4

Re: [MOD] Auto Trader

Post by euclid » Mon, 6. Jan 14, 13:12

UniTrader wrote: .......
global.$variable <-use this like any variable you would use in the Script. no need to explicitly read/write them.

additionally you also have local Variables on Entities:
this.$variable (acces to $variable on the Entity, probably the Pilot/Captain in your case)
.......
iforgotmysocks wrote: ........
PS: md scripts aren't macros. You don't need to add them to any index file. ^^
Only macros and components.
Thanks to both of you :-)

Cheers Euclid
"In any special doctrine of nature there can be only as much proper science as there is mathematics therein.”
- Immanuel Kant (1724-1804), Metaphysical Foundations of the Science of Nature, 4:470, 1786

User avatar
YorrickVander
Posts: 2689
Joined: Tue, 29. Oct 13, 21:59
x4

Post by YorrickVander » Mon, 6. Jan 14, 13:41

Been trying out the trader today, works very well :) May I pop in a request for something similar for mining vessels? Perhaps with similar skill upgrades to sell local, cluster or galactic and at some stage learn to favour player offers over npc?

I am btw seeing a lot of these errors in my log though the trader is till making money regardless:

[General] ======================================
[=ERROR=] Error in AI script autotrade on entity 0x17795F: Property lookup failed: $buyoffers.{353}.unitprice
* Expression: $Maxprofit lt $Amount * ($buyoffers.{$i}.unitprice - $selloffers.{$j}.unitprice) and player.money gt 2 * $Amount * $selloffers.{$j}.unitprice
[General] ======================================
[General] ======================================
[=ERROR=] Error in AI script autotrade on entity 0x17795F: Property lookup failed: $buyoffers.{353}.ware
* Expression: [this.ship.cargo.{$buyoffers.{$i}.ware}.free, $buyoffers.{$i}.amount, $selloffers.{$j}.amount].min
[General] ======================================
X Rebirth - A Sirius Cybernetics Corporation Product

Split irritate visiting pilot with strange vocal patterns.

User avatar
euclid
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 13289
Joined: Sun, 15. Feb 04, 20:12
x4

Post by euclid » Mon, 6. Jan 14, 16:25

YorrickVander wrote: ...................*snip*.................
[=ERROR=] Error in AI script autotrade on entity 0x17795F: Property lookup failed: $buyoffers.{353}.unitprice
* Expression: $Maxprofit lt $Amount * ($buyoffers.{$i}.unitprice - $selloffers.{$j}.unitprice) and player.money gt 2 * $Amount * $selloffers.{$j}.unitprice
...................*snip*................
Hm .....353 buy offers :O .... that should not happen. One reason the cluster and galaxy trader have a restricted shopping list. For example if you search for all trades in the entire galaxy then the returned list is so long that the algorithm, to find the optimum deal, takes too much time to execute so that some (or at least one) of the trade offers has been reserved by someone else and, since the list entries are passed by reference, there is no way to hold the data.

May I ask what trader caused that (sector/cluster/galaxy) and in which sector does he work?

Cheers Euclid
"In any special doctrine of nature there can be only as much proper science as there is mathematics therein.”
- Immanuel Kant (1724-1804), Metaphysical Foundations of the Science of Nature, 4:470, 1786

User avatar
YorrickVander
Posts: 2689
Joined: Tue, 29. Oct 13, 21:59
x4

Post by YorrickVander » Mon, 6. Jan 14, 18:07

It's a scaldis started as sector trader in ascendancy. Just before end of log (a few hours afk to see how it went) I upgraded to cluster trader.

Full log from that session if helpful :
https://docs.google.com/file/d/0BzGfezj ... RWRlU/edit

Edit : I should add that my TradeThing (on Nexus) mod is also installed to make the npc traders do their thing too.
X Rebirth - A Sirius Cybernetics Corporation Product

Split irritate visiting pilot with strange vocal patterns.

fiby
Posts: 98
Joined: Mon, 29. Jan 07, 00:22
x4

Post by fiby » Mon, 6. Jan 14, 18:18

Finally a mod that I've been waiting for! Thanks for taking the time to design and implement it. Just one question do I still need to look for the offers myself around the galaxy or does the ship have access to that information already?

Keep up the good work!

toepick
Posts: 103
Joined: Wed, 29. Feb 12, 16:57
x4

Post by toepick » Mon, 6. Jan 14, 21:17

yep..this is awesome!! seems to be working great.. have 4 running each sector of Albion atm..as soon as last one reaches level two I will 'promote' each one.

this is almost too easy (and fast lol) Not that I am complaining at all.. is it feasible to allow them to work their cargo normally (without the transporter beam). Or was that necessary to get the mod to work properly?

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader » Mon, 6. Jan 14, 21:58

toepick wrote:yep..this is awesome!! seems to be working great.. have 4 running each sector of Albion atm..as soon as last one reaches level two I will 'promote' each one.

this is almost too easy (and fast lol) Not that I am complaining at all.. is it feasible to allow them to work their cargo normally (without the transporter beam). Or was that necessary to get the mod to work properly?
not necesary, but perhapsn easier since you dont have to do the docking procedure etc. first.. (i am currently working on something similiar and thats where i am a bit lost since the Vanilla Scripts for that are very extensive)
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

User avatar
euclid
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 13289
Joined: Sun, 15. Feb 04, 20:12
x4

Post by euclid » Mon, 6. Jan 14, 22:33

@YorrickVander: Thanks for the debug log. It seems something is heavily interfering with the mod because even the initial cue check shows an error (see your debug). Also you got loads of patch complaints there. I know many people ignore these but you never know for sure what they might do.

Best advise I can offer is to test the mod with a new game not using any other mods you have running atm..



@fiby: You have probably found out yourself by now that you don't need to do anything. Once started the auto(nomous) trader will do it's job until the end of days ;-)



@toepick: No, not necessary but, as Unitrader said already, the game scripts for cargo transfer via drones is tricky:
Your ship needs to find a docking spot risking to get blocked by others and may lose the trade reservation resulting in long queues and a full cargo hold. The cargo lifters have to be available. Ok, your freighter has some but NPC ships or station may not. Again resulting in waiting queues.
This is why I've decided not to code that. Besides, who is actually watching the trader to dock and then send the cargo lifters? ;-)


Cheers Euclid
"In any special doctrine of nature there can be only as much proper science as there is mathematics therein.”
- Immanuel Kant (1724-1804), Metaphysical Foundations of the Science of Nature, 4:470, 1786

User avatar
hannahb
Posts: 67
Joined: Fri, 31. Aug 07, 13:33
x3tc

Post by hannahb » Mon, 6. Jan 14, 23:00

Great mod, I really like this one.

If I could recommend an improvement? Perhaps you could limit an auto-traders reports back about their activities based on time,level in order to reduce spam?

Ideally, for example, a sector trader could report back after completing 5 trades instead of every trade and a higher level trader could report back less often as you would then have more confidence he is operating correctly.

Perhaps you could even use his total profits value and a capped logarithmic inverse to make him report back frequently at first and less often as he gains experience. This way you can see right away that he's working and as he gets better he spams you less. This kind of represents a system where you wouldn't worry about him as much once you are confident he is working correctly.
Last edited by hannahb on Mon, 6. Jan 14, 23:23, edited 1 time in total.

toepick
Posts: 103
Joined: Wed, 29. Feb 12, 16:57
x4

Post by toepick » Mon, 6. Jan 14, 23:16

Thanks for the replies :)

Sometimes I like to dock on the ships and let them take me around with them.. watching the busy little bees work is kinda neat and adds a little realism (even if you have to wait in line).. with that said; I can certainly understand not using the code esp if it adds more overhead and bogs things down.

So yeah, really enjoying this and can't wait to see it work with some of the other up coming mods. Been using yours Yorrick, makes for a very busy universe and so far haven't had to wait at all for any capitals to be built. Deliveries run like MAD lol.

User avatar
YorrickVander
Posts: 2689
Joined: Tue, 29. Oct 13, 21:59
x4

Post by YorrickVander » Mon, 6. Jan 14, 23:55

Yeah it's a terribly basic hack but it does make things go ;) Testing to see if it's that that's causing the errors with Auto Trader atm. Hopefully not but a few hours running will see.
X Rebirth - A Sirius Cybernetics Corporation Product

Split irritate visiting pilot with strange vocal patterns.

User avatar
euclid
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 13289
Joined: Sun, 15. Feb 04, 20:12
x4

Post by euclid » Tue, 7. Jan 14, 00:31

@hannahb: That's a nice idea and I'll consider it in a future update. Thanks for your input :-)


@YorrickVander: I've spotted a little flaw: if you board a ship, dock and talk to the marine officer to send him back to the Skunk you get the option "Start sectortrader (yes, it was a Titurel). So I've added the condition 'even.object.type == entitytype.commander'.
And thanks to your debug log I've discovered why the initial cue spams the error 'event.object.ship unknown': some of your faction members do not have a ship, for example if you hire someone. So I've added a main condition '<do_if value="@event.object.ship>'.
So big thanks for reporting this :-)

@toepick: Heheheh - yes, I was wondering who is the first to find out :D It's nice to dock at the autotrader and let him carry you around ;-)



Cheers Euclid
Last edited by euclid on Tue, 7. Jan 14, 18:17, edited 1 time in total.
"In any special doctrine of nature there can be only as much proper science as there is mathematics therein.”
- Immanuel Kant (1724-1804), Metaphysical Foundations of the Science of Nature, 4:470, 1786

User avatar
YorrickVander
Posts: 2689
Joined: Tue, 29. Oct 13, 21:59
x4

Post by YorrickVander » Tue, 7. Jan 14, 02:04

* suspected mod clash vindicated! *

I saw trades working at a loss before disabling my mod and restarting on a clean trader so I think my hack to ignore profit is kicking in there as the trade appeared to have worked correctly (ie no 0cr bug). The money had been over 10 mill, and was showing after last observed trade at 7 mill with 0 cargo.

oh and btw :

[General] ======================================
[=ERROR=] Error in AI script autotrade on entity 0x97B7: Property lookup failed: this.ship.cargo.list.{1}
* Expression: $Cargo.count gt 0 and this.ship.cargo.list.{1} != ware.fuelcells
[General] ======================================

from scaldis built in PMC shipyard delivered sans fuel.

EDIT : to double check the trades, buy, sell + profit, maybe a debug output line until trading fixed up to we can do a quick lookup for 0cr trades and other nasties? There was some question of this in beta forum but that was most likely due to older game version.
Last edited by YorrickVander on Tue, 7. Jan 14, 12:12, edited 2 times in total.
X Rebirth - A Sirius Cybernetics Corporation Product

Split irritate visiting pilot with strange vocal patterns.

User avatar
YorrickVander
Posts: 2689
Joined: Tue, 29. Oct 13, 21:59
x4

Post by YorrickVander » Tue, 7. Jan 14, 03:05

Possibly I posted too soon :( Was just about to shut down the game and goto bed and checked the error log again 1 hour on :

https://docs.google.com/file/d/0BzGfezj ... gybnM/edit

More of the same I'm afriad. A lot of the errors. This is from a new freeplay game start with only auto trader and your player jump mods installed and exe restarted for clean log file. The first hour-ish showed only 2 errors from auto trader as posted above, then *headshot* after 2nd hour.

EDIT : oh and the fast start script that just opens the map and starts me with 50 mill to save time when testing. This runs once only at new game start so I believe that it isn;t the guilty party.
X Rebirth - A Sirius Cybernetics Corporation Product

Split irritate visiting pilot with strange vocal patterns.

Post Reply

Return to “X Rebirth - Scripts and Modding”