[Script] Update 17.12.06 V1.26 Station trader, automated supply/trade for stations
Posted: Sat, 10. Dec 05, 18:13
After missing some functionality in the orignal trade software i added a command to the trade software mk1 to allow for station/complex automated supply/sell. After having it running stable for about a week now and the bph has not yet been released for x3 i thought some other people might be interested in it.
Features:
Automated buy or sell of a transporter in a station/complex
Import command, transporter only buy needed resources
Export command, transpoter only sell available products
Ships of the same station don't fly to the same target, but ships of different stations do if they don't have enough experience (lack of communication )
Target stations that are nearer are preferred
Automated upgrade of the ship (borrowed that script from trade software mk3)
Use of jumpdrive if available (flight script originally from trade software mk3), a jumpdrive will be ordered/bought if the station has more than 125000 credits
Ships try to sell available products if the station has less than 5000 credits even if there are no resources in the station
Resources are only bought if station is less than 80% full
Products are only sold if the station is more than 20% full
Resources are never bought if they are also an intermediate product
Products that are listed as products are always sold regardless if they are in intermediate product
Download Station Trader
French translation by Azz, merci beaucoup
Installation:
Download the script package file and install with the x3 script installer by cycrow available here: http://forum2.egosoft.com/viewtopic.php ... 51&start=0
Deinstallation:
Remove the package with the x3 script installer by cycrow.
Download the uninstaller package from this location:
Station Trader Uninstaller
Install with the x3 script installer, start x3 and load your game. Wait for the uninstall message to appear in the player logbook and save the game. Exit X3 and use cycrows installer to remove the uninstaller package.
These scripts use a part of the trade software mk3 for buying upgrades and delivering them to the ship, i hope the authors don't mind.
The command setup came originally from the WLS scriptset and was modified to suit my needs.
An experience/level system is included in the scripts and used to decide when another upgrade of the ships cargo, speed or rudder extensions should be made, also the reaction of the ship regarding hull damage varies on the level of experience
Used IDs:
Text ID 8102
Page ID 8102
Commandcode 421,422,423
Update 1.26
Player HQ Compatibility fix
Limits for needed resources defined in t/xx8102.xml, change to your needs if you want
Update 1.25a
Bugfix: Selling energy caused the transport to sell his jump reserve energy also. This has now been fixed, transports will always keep 10% cargo of fuel to jump back.
Update 1.25
Bugfix: Ships were selling very low amounts although much more could be sold
Bugfix: The Signal Undock was sometimes causing the traders to lose their command, resulting in command "None". Traders now ignore the signal.
Bugfix: Unloading resources sometimes led to all the fuel being unloaded
, this has now been fixed by applying the correct (grrr) boolean logic
Bugfix: Ships which are fully loaded with a product and can't unload it at the homestation now take the loaded amount into calculation for selling, so that they have a better chance to sell some of their cargo. This should eliminate most situations where the trader would try to sell something but couldn't because his cargo was full
.
Update 1.24
Buy behaviour has been changed so that transports no longer buy at player owned stations for any price. They now check if the sell price of the target station is below or equal the max price of the homebase.
Buy behaviour was changed so that trading stations and equipment docks are used as potential sellers of a resource.
Fixed a bug that caused the game to freeze
Station traders make use of the library manageForbiddenAreas available here: http://forum.egosoft.com/viewtopic.php?t=122956
Update 1.23a
Fixed bug that caused transporters to fly to a player owned station to buy resources but fail to buy if the target stations price is higher than the buying stations max price for that resource. TRansporters now buy at any price at player owned stations.
Update 1.23
No functionality added
(wow, looks like i have finished it )
Fixed bug with the search for player owned suppliers that was causing them to go any distance
Changed a line in the sell routine to prevent malfunctions if the travel script from tradesoftware mk3 that is used there decides to change it's return value
Update 1.22
Added code that player owned stations are preferred, when buying goods
Bugfix: Fixed bug in the route check code introduced in 1.21 that prevented transports from buying fuel, drones or shields in the local system
some more i don't recall
Update 1.21
Added enhanced checks if a transport would fly through enemy territory when buying fuel, shields or drones
Bugfixes:
fixed wrong variable name that could cause transports to enter hostile sectors when selling instead of preventing it
Update 1.20
Added improved search algorith when buying resources
Ships check now if the target sector is hostile and won't sell there. This does not apply to sectors in between. If a journey is made without jumpdrive it may still travel through hostile sectors.
small code improvements
Bugfixes:
Fixed bug with ordering shields, when one of the shield bays was empty
Update 1.19
Added readme to distribution
Added uninstallation routine to distribution, copy the file setup.strader.uninstall to your scripts directory and load your game. Wait for the confirmation message in the player logbook and save and quit. Delete all scripts from the distribution from your scripts directory and remove the language files xx8102 from your t directory. Transports running the command will be sent home by jump if possible but you should check if they are going through dangerous territory.
Fixed bug which doubled the amount of bought shields for the cost of one
Fixed bug in the sell script that could cause the minimum sell price to be raised 2 above the station sell price instead of one
Fixed bug in supply as noted by beartlaoi
Fixed bug in sell wares which set the wanted ware amount with the wrong command
Search routine now shows progress when trying to find a station it could sell goods to
Optimized search routine to stop if absolutely no buyer can be found
Update 1.18
Added code that lv 4 traders order the best shields available for their ship
Changed code in the sell script that the whole sector quarant is searched for a station that would buy a product with maximum profits
Ships now verify that the sell price at a station is still over the minimum selling price of the hgmebase
Bugfixes:
fixed code in the known customers search which was using a variable of another context
fixed code in the repair script that was causing a transport not to return home or go to a shipyard
fixed a bug in the buy script that caused the experience to be calculated too low
fixed a bug that caused the transport showing buy commands although it was doing something different
fixed a bug that caused the experience not to be limited at 2M+1
probably some more that i don't recall
Update 1.17
Added improved code to find stations that would buy the products of the homebase. In my universe the traders are rarely idle now.
Added more calls to the fuel script to prevent ships running out of energy during a trade run
fuel script now looks if a destination is set and takes 2,5 * needed jumpenergy with it if that value is higher than the 10% energy reserve.
Bugfixes:
changed wrong variable name as discovered by beartlaoi
changed wrong if condition as discovered by beartlaoi
Script will now remove the old, obsolete experience variable on the ship to prevent interference with mk3 traders which would cause the mk3 software to ask for wages in the millions of credits range if a mk3 trader is started on the ship after it was used as a station trader and completed some trade runs.
Update 1.16
No functionality added, only verified 1.3 compatibility. Sadly the script engine has not been extended to reflect the settings of the intermediate products, so the station traders are not aware of the new setting to buy/sell/both for intermediate products. This means that you still have to use the complex manager to add/remove intermediate products to the products list if the station trader should sell them.
Bugfix: Transporters now really return home when they have nothing to do
Bugfix: Transporters now order drones which they didn't do under all circumstances
Bugfix: Equipment save was accidentally using shield bay count to save lasers instead of laser bay count, this has been fixed
Bugfix (well sort of): Transports no longer buy wares that are listed as sellable resources which only happens if they are intermediate products in a player owned complex or in some equipment docks (i think). Anyway this code mostly returned either null or the homebase of the transport, so it did more bad than good. If anybody finds factory combinations that don't work as before, please let me know.
Bugfix: if a transport is not docked at home when the homebase has products for sale he will now check for jump energy before returning home and eventually buy some at the nearest spp)
Update 1.15
reused attack reaction script from trade software mk3 instead of an own implementation (yes, i was lazy)
Transports now return home if they don't have anything to do
Transports now change the pilot name and show the experience level in the name, they do this upon reaching the next level or when you start the command, so this may not show up immediately
Transports now order an amount of 4*level of drones when they are idle and reached at least level 2
TRansports now save the laser and shield equipment to prevent accidentally unloading it
Bugfixes:
Fixed a bug with locking stations which allowed transports to sell/buy at the same station instead of preventing it
Fixed a bug when multiple products are available that only the available of the last product evaluated was sold, instead of the amount that could be sold at the target station
Fixed a bug in the locking mechanism which caused the transport to go idle instead of waiting for the lock
...too many more to remember
Update 1.14
added code that allows a station to remember previous stations it sold products to, so if a transports finds a station where another transport is already flying to, he will now try one of the previous stations. Since this is a learning effort it won't kick in immediately but the effect should show up after some time.
Possible bugfix: changed a line of code that may have prevented transports from ordering a jumpdrive
Update 1.13:
New Command Import, explanation under Features
New Command Export, explanation under Features
localized message texts, english and german
Damaged ships send a message to the player:
Rank 0: No reaction
Rank 1 and hull < 70%: Player gets message, but ship continues trading
Rank 2 and hull < 80%: Player gets message, ship docks at shipyard in at most 3 sectors distance and awaits further commands, if no shipyard is found it continues to trade.
Rank >3 and hull < 90%: Player gets message, ship docks at shipyard in at most 3 sectors distance and awaits further commands, if no shipyard is found it flies/jumps to homebase and looks there for a shipyard, if none found it waits at homebase else docks at the shipyard.
First version of a attack reaction is included but not active because it has not been tested at all...bold pilots can activate it by uncommenting line 17 in script plugin.strader.supply but remember, there are no old, bold pilots
Bugfixes:
Enhanced support for complexes, which sell, produce and require a ware at the same time. In that case transports just went idle, this has now changed.
Transports will now sell wares, which fill either at least 20% station cargo or 80% of the transporter cargo, leading to earlier reactions in a large complex
Wrong variable name in universe lockmanager, causing a wait of 5 to 15 seconds until a lock was requested
local variable name for experience changed to traderXP due to a naming conflict with the trade mk3 soft
Update 1.09:
TRansporters now look at all products or resources instead of only the most needed one, this should enhance parallel distribution in complexes
Bugfixes:
Removed reference to a non-existing script
fixed locking of stations in the universe lock manager
added a check if the ship that originally requested a lock still has the destination that was set in the lock
cleaned up code in some parts
Features:
Automated buy or sell of a transporter in a station/complex
Import command, transporter only buy needed resources
Export command, transpoter only sell available products
Ships of the same station don't fly to the same target, but ships of different stations do if they don't have enough experience (lack of communication )
Target stations that are nearer are preferred
Automated upgrade of the ship (borrowed that script from trade software mk3)
Use of jumpdrive if available (flight script originally from trade software mk3), a jumpdrive will be ordered/bought if the station has more than 125000 credits
Ships try to sell available products if the station has less than 5000 credits even if there are no resources in the station
Resources are only bought if station is less than 80% full
Products are only sold if the station is more than 20% full
Resources are never bought if they are also an intermediate product
Products that are listed as products are always sold regardless if they are in intermediate product
Download Station Trader
French translation by Azz, merci beaucoup
Installation:
Download the script package file and install with the x3 script installer by cycrow available here: http://forum2.egosoft.com/viewtopic.php ... 51&start=0
Deinstallation:
Remove the package with the x3 script installer by cycrow.
Download the uninstaller package from this location:
Station Trader Uninstaller
Install with the x3 script installer, start x3 and load your game. Wait for the uninstall message to appear in the player logbook and save the game. Exit X3 and use cycrows installer to remove the uninstaller package.
These scripts use a part of the trade software mk3 for buying upgrades and delivering them to the ship, i hope the authors don't mind.
The command setup came originally from the WLS scriptset and was modified to suit my needs.
An experience/level system is included in the scripts and used to decide when another upgrade of the ships cargo, speed or rudder extensions should be made, also the reaction of the ship regarding hull damage varies on the level of experience
Used IDs:
Text ID 8102
Page ID 8102
Commandcode 421,422,423
Update 1.26
Player HQ Compatibility fix
Limits for needed resources defined in t/xx8102.xml, change to your needs if you want
Update 1.25a
Bugfix: Selling energy caused the transport to sell his jump reserve energy also. This has now been fixed, transports will always keep 10% cargo of fuel to jump back.
Update 1.25
Bugfix: Ships were selling very low amounts although much more could be sold
Bugfix: The Signal Undock was sometimes causing the traders to lose their command, resulting in command "None". Traders now ignore the signal.
Bugfix: Unloading resources sometimes led to all the fuel being unloaded
, this has now been fixed by applying the correct (grrr) boolean logic
Bugfix: Ships which are fully loaded with a product and can't unload it at the homestation now take the loaded amount into calculation for selling, so that they have a better chance to sell some of their cargo. This should eliminate most situations where the trader would try to sell something but couldn't because his cargo was full
.
Update 1.24
Buy behaviour has been changed so that transports no longer buy at player owned stations for any price. They now check if the sell price of the target station is below or equal the max price of the homebase.
Buy behaviour was changed so that trading stations and equipment docks are used as potential sellers of a resource.
Fixed a bug that caused the game to freeze
Station traders make use of the library manageForbiddenAreas available here: http://forum.egosoft.com/viewtopic.php?t=122956
Update 1.23a
Fixed bug that caused transporters to fly to a player owned station to buy resources but fail to buy if the target stations price is higher than the buying stations max price for that resource. TRansporters now buy at any price at player owned stations.
Update 1.23
No functionality added
(wow, looks like i have finished it )
Fixed bug with the search for player owned suppliers that was causing them to go any distance
Changed a line in the sell routine to prevent malfunctions if the travel script from tradesoftware mk3 that is used there decides to change it's return value
Update 1.22
Added code that player owned stations are preferred, when buying goods
Bugfix: Fixed bug in the route check code introduced in 1.21 that prevented transports from buying fuel, drones or shields in the local system
some more i don't recall
Update 1.21
Added enhanced checks if a transport would fly through enemy territory when buying fuel, shields or drones
Bugfixes:
fixed wrong variable name that could cause transports to enter hostile sectors when selling instead of preventing it
Update 1.20
Added improved search algorith when buying resources
Ships check now if the target sector is hostile and won't sell there. This does not apply to sectors in between. If a journey is made without jumpdrive it may still travel through hostile sectors.
small code improvements
Bugfixes:
Fixed bug with ordering shields, when one of the shield bays was empty
Update 1.19
Added readme to distribution
Added uninstallation routine to distribution, copy the file setup.strader.uninstall to your scripts directory and load your game. Wait for the confirmation message in the player logbook and save and quit. Delete all scripts from the distribution from your scripts directory and remove the language files xx8102 from your t directory. Transports running the command will be sent home by jump if possible but you should check if they are going through dangerous territory.
Fixed bug which doubled the amount of bought shields for the cost of one
Fixed bug in the sell script that could cause the minimum sell price to be raised 2 above the station sell price instead of one
Fixed bug in supply as noted by beartlaoi
Fixed bug in sell wares which set the wanted ware amount with the wrong command
Search routine now shows progress when trying to find a station it could sell goods to
Optimized search routine to stop if absolutely no buyer can be found
Update 1.18
Added code that lv 4 traders order the best shields available for their ship
Changed code in the sell script that the whole sector quarant is searched for a station that would buy a product with maximum profits
Ships now verify that the sell price at a station is still over the minimum selling price of the hgmebase
Bugfixes:
fixed code in the known customers search which was using a variable of another context
fixed code in the repair script that was causing a transport not to return home or go to a shipyard
fixed a bug in the buy script that caused the experience to be calculated too low
fixed a bug that caused the transport showing buy commands although it was doing something different
fixed a bug that caused the experience not to be limited at 2M+1
probably some more that i don't recall
Update 1.17
Added improved code to find stations that would buy the products of the homebase. In my universe the traders are rarely idle now.
Added more calls to the fuel script to prevent ships running out of energy during a trade run
fuel script now looks if a destination is set and takes 2,5 * needed jumpenergy with it if that value is higher than the 10% energy reserve.
Bugfixes:
changed wrong variable name as discovered by beartlaoi
changed wrong if condition as discovered by beartlaoi
Script will now remove the old, obsolete experience variable on the ship to prevent interference with mk3 traders which would cause the mk3 software to ask for wages in the millions of credits range if a mk3 trader is started on the ship after it was used as a station trader and completed some trade runs.
Update 1.16
No functionality added, only verified 1.3 compatibility. Sadly the script engine has not been extended to reflect the settings of the intermediate products, so the station traders are not aware of the new setting to buy/sell/both for intermediate products. This means that you still have to use the complex manager to add/remove intermediate products to the products list if the station trader should sell them.
Bugfix: Transporters now really return home when they have nothing to do
Bugfix: Transporters now order drones which they didn't do under all circumstances
Bugfix: Equipment save was accidentally using shield bay count to save lasers instead of laser bay count, this has been fixed
Bugfix (well sort of): Transports no longer buy wares that are listed as sellable resources which only happens if they are intermediate products in a player owned complex or in some equipment docks (i think). Anyway this code mostly returned either null or the homebase of the transport, so it did more bad than good. If anybody finds factory combinations that don't work as before, please let me know.
Bugfix: if a transport is not docked at home when the homebase has products for sale he will now check for jump energy before returning home and eventually buy some at the nearest spp)
Update 1.15
reused attack reaction script from trade software mk3 instead of an own implementation (yes, i was lazy)
Transports now return home if they don't have anything to do
Transports now change the pilot name and show the experience level in the name, they do this upon reaching the next level or when you start the command, so this may not show up immediately
Transports now order an amount of 4*level of drones when they are idle and reached at least level 2
TRansports now save the laser and shield equipment to prevent accidentally unloading it
Bugfixes:
Fixed a bug with locking stations which allowed transports to sell/buy at the same station instead of preventing it
Fixed a bug when multiple products are available that only the available of the last product evaluated was sold, instead of the amount that could be sold at the target station
Fixed a bug in the locking mechanism which caused the transport to go idle instead of waiting for the lock
...too many more to remember
Update 1.14
added code that allows a station to remember previous stations it sold products to, so if a transports finds a station where another transport is already flying to, he will now try one of the previous stations. Since this is a learning effort it won't kick in immediately but the effect should show up after some time.
Possible bugfix: changed a line of code that may have prevented transports from ordering a jumpdrive
Update 1.13:
New Command Import, explanation under Features
New Command Export, explanation under Features
localized message texts, english and german
Damaged ships send a message to the player:
Rank 0: No reaction
Rank 1 and hull < 70%: Player gets message, but ship continues trading
Rank 2 and hull < 80%: Player gets message, ship docks at shipyard in at most 3 sectors distance and awaits further commands, if no shipyard is found it continues to trade.
Rank >3 and hull < 90%: Player gets message, ship docks at shipyard in at most 3 sectors distance and awaits further commands, if no shipyard is found it flies/jumps to homebase and looks there for a shipyard, if none found it waits at homebase else docks at the shipyard.
First version of a attack reaction is included but not active because it has not been tested at all...bold pilots can activate it by uncommenting line 17 in script plugin.strader.supply but remember, there are no old, bold pilots
Bugfixes:
Enhanced support for complexes, which sell, produce and require a ware at the same time. In that case transports just went idle, this has now changed.
Transports will now sell wares, which fill either at least 20% station cargo or 80% of the transporter cargo, leading to earlier reactions in a large complex
Wrong variable name in universe lockmanager, causing a wait of 5 to 15 seconds until a lock was requested
local variable name for experience changed to traderXP due to a naming conflict with the trade mk3 soft
Update 1.09:
TRansporters now look at all products or resources instead of only the most needed one, this should enhance parallel distribution in complexes
Bugfixes:
Removed reference to a non-existing script
fixed locking of stations in the universe lock manager
added a check if the ship that originally requested a lock still has the destination that was set in the lock
cleaned up code in some parts