So i decided to implement the auto-repair feature myself
Playing X3AP with XRM, the universe has become a lot more dangerous and pirates roam everywhere with their annoying mass drives bypassing shields. This also means that my fleet of UTs often requests my assistance for repairs when docked at a shipyard. At the time of writing I have 21 UTs doing my business, and i plan to expand this to at least 30 before moving on to other ventures. So repair requests will for me only become an even bigger burden.
I uploaded the patch fix here:
How it works
In the current version 220.127.116.11 of MK3 IR, a trader will head for a shipyard if he is either: below 80% hull, or above level 20 and below 100% hull. Once docked, he will notify the player that his ship needs repairs, and then just idle at the station.
With the changes I implemented in the patch, the trader will simply repair once docked at a shipyard and resume trading - business as usual
However, if the player is either lacking the funds to pay for the repairs or the trader had to dock at a station that is not a shipyard, the player will still receive the usual message that the ship is damaged and needs assistance.
The auto-repair feature is compatible with trade overview and the repair costs is of course subtracted from the players funds.
How to install
- Download and install MK3 IR version 18.104.22.168
- Download the auto-repair patch and overwrite the old plugin.autotrade.main.xml file in the scripts folder, with the new one
- I noticed that i had to restart my current UTs for them to run with the latest script changes - not sure if you have to do the same
Happy profits !
@gnasirator: If you wish to integrate these changes with MK3 IR, these are the only changes made in the plugin.autotrade.main.xml file:
Code: Select all
@ $Gained = [THIS] -> call script plugin.autotrade.update.gain : Income=$anull Costs=$anull
inc $Traderun =
[THIS] ->set local variable: name='flight.number' value=$Traderun
@ = [THIS] -> call script plugin.autotrade.after.trade :
* = wait randomly from 5000 to 10000 ms
$Hull = [THIS] -> get hull percent
* Top Traders only work with ships in perfect conditions!
if $Hull <= 80 OR ( $experience >= 20 AND $Hull < 100 )
$repair.costs.subtracted = [THIS] -> get local variable: name='repair.costs.subtracted'
* repair costs have been subtracted from gain var but ship is repaired now
$repair.costs.subtracted = 0
[THIS] ->set local variable: name='repair.costs.subtracted' value=$repair.costs.subtracted
* write to log file 12345 append=[TRUE] value='repair sub'
$maxjumps = [THIS] -> get local variable: name='sellrange'
skip if $maxjumps
$maxjumps = 10
$flags = [Find.Nearest] | [Find.DockingAllowed] | [Find.Known]
$FlyToWwarf = find station in galaxy: startsector=[SECTOR] class or type=Shipyard race=null flags=$flags refobj=[THIS] serial=null max.jumps=$maxjumps num=1
if not $FlyToWwarf -> is of class Shipyard
[THIS] ->set command: COMMAND_DOCKAT target=null target2=null par1=null par2=null
@ = [THIS] -> call script !move.movetosafestation :
$FlyToWwarf = [DOCKEDAT]
if not [DOCKEDAT] == $FlyToWwarf
$wharf.sector = $FlyToWwarf -> get sector
$fuel.onboard = [THIS] -> get true amount of ware Energy Cells in cargo bay
$Jumpdrive.installed = [THIS] -> get true amount of ware Jumpdrive in cargo bay
$fuel.needed = [THIS] -> needed jump drive energy for jump to sector $wharf.sector
[THIS] ->set command: COMMAND_DOCKAT target=$FlyToWwarf target2=null par1=null par2=null
[THIS] ->set destination to $FlyToWwarf
if $fuel.onboard * $Jumpdrive.installed >= $fuel.needed
@ = [THIS] -> call script !move.jumptostation : station=$FlyToWwarf should followers jump too=[TRUE]
@ = [THIS] -> call script plugin.autotrade.jump.to.env : Target env: ship/station/sector=$FlyToWwarf
[THIS] ->set destination to null
* cannot repair if ship not docked at a shipyard
if not [DOCKEDAT] -> is of class Shipyard
$Exception = 22
$repair.costs = [DOCKEDAT] -> get repair cost of ship [THIS]
$funds = get player money
* cannot repair if player doesn't have enough funds to pay this
if $funds < $repair.costs
$Exception = 22
* subtract repair cost from player funds
$repair.costs.negative = $repair.costs * -1
add money to player: $repair.costs.negative
* set hull to max
$hull.max = [THIS] -> get max hull
[THIS] ->set hull to $hull.max
* subtract repair costs from gain
@ $Gained = [THIS] -> call script plugin.autotrade.update.gain : Income=null Costs=$repair.costs
* Add support for trade overview
if does script name exist: 'plugin.trov.buy'
$trov.ships.ref = get global variable: name='trov.ships.ref'
if is datatype[ $trov.ships.ref ] == DATATYPE_ARRAY
if find [THIS] in array: $trov.ships.ref
$repair.costs.text = read text: page=$Page id=513
$repair.costs.ware.text = sprintf: fmt='%s', Ship repair costs, null, null, null, null
if $repair.costs.text == $repair.costs.ware.text
* new added wares are fine
@ = [THIS] -> call script plugin.trov.buy : trading partner=[THIS] ware=Ship repair costs amount=1 price=$repair.costs object=[THIS]
* conflict with another script/mod detected
@ = [THIS] -> call script plugin.trov.buy : trading partner=[THIS] ware=$repair.costs.text amount=1 price=$repair.costs object=[THIS]