[SCR] [X3:TC/AP] [v1.8.9.8] [11/16/2019] MK3 Improvement Reloaded

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

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

Post Reply
User avatar
Khaakbuster
Posts: 393
Joined: Sun, 8. Jan 06, 18:43
x3tc

Re: [SCR] [X3:TC/AP] [v1.8.9.7_fixed] [05/09/2013] MK3 Improvement Reloaded

Post by Khaakbuster » Wed, 13. Nov 19, 00:17

I don't think that the freeze is caused by an infinite loop. I activated forced infinite loop detection with the X3 Customizer. This should prevent infinite loops and break them. My guess is that the freeze is caused by the "= [THIS]-> sell $amount units of $ware" command in "plugin.autotrade.sellware.pck" because the freeze happens as soon as the trader docks at the target station and tries to sell the stuff. Of course I might be completely wrong.

The issue doesn't bother me at the moment, because I'm using the blacklist manager now for all my stations and if I had a station that needed to buy wares, I'd set up an automatic money transfer anyway.

gnasirator
Posts: 1114
Joined: Mon, 13. Dec 04, 16:15
x3tc

Re: [SCR] [X3:TC/AP] [v1.8.9.8] [11/16/2019] MK3 Improvement Reloaded

Post by gnasirator » Sat, 16. Nov 19, 22:01

Alright, I think I found the issue -> new version released.

Basically, you were right. It had to do with selling wares. The traders couldn't use the sell wares command because the station was bankrupt. So I changed their behaviour to use load/unload when dealing with player-owned stations.
This fixes the crash (they were trying to sell their leftover wares to the station they're still docked at in an endless loop).
Also, this allowed me to remove the hard-coded blacklisting of player-owned bankrupt stations. UTs will now help supplying your owned stations, even if they're out of money.

Enjoy and please let me know if there's still an open issue.
Last edited by gnasirator on Tue, 26. Nov 19, 09:27, edited 1 time in total.

User avatar
Khaakbuster
Posts: 393
Joined: Sun, 8. Jan 06, 18:43
x3tc

Re: [SCR] [X3:TC/AP] [v1.8.9.8] [11/16/2019] MK3 Improvement Reloaded

Post by Khaakbuster » Fri, 22. Nov 19, 11:18

That sounds like a nice fix. Thank you. I will still keep using the blacklist because all my complexes and shipyards are self-reliant but if I build a new complex and forget to put it on the blacklist (happens regularly ;) ) the game should not freeze anymore.

AdamXI
Posts: 2
Joined: Tue, 21. Nov 17, 19:51
x3tc

Re: [SCR] [X3:TC/AP] [v1.8.9.8] [11/16/2019] MK3 Improvement Reloaded

Post by AdamXI » Sat, 30. Nov 19, 17:25

Thanks for this awesome script. Really love it - keeps my traders safe :)

But i was wondering if there's any easy way to make the script auto-repair damaged traders when docked at the shipyard? I understand that auto-repairing can be pretty expensive early on, but since i'm past that point in the game now, i want them to be 100% self sufficient and just repair and start trading again instead of messaging me that they need repairs and stop all activity.

It would be super awesome if this could be an option somewhere, whether to auto-repair or not.

AdamXI
Posts: 2
Joined: Tue, 21. Nov 17, 19:51
x3tc

Re: [SCR] [X3:TC/AP] [v1.8.9.8] [11/16/2019] MK3 Improvement Reloaded

Post by AdamXI » Sat, 14. Dec 19, 15:25

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:
[ external image ]

How it works
In the current version 1.8.9.8 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 1.8.9.8
  • 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

  statistics.and.upgrades:
@ $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 )
    gosub go.repair
  else
    $repair.costs.subtracted = [THIS] -> get local variable: name='repair.costs.subtracted'
    if $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
    end
  end
  endsub
  
  
  go.repair:
  * 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]
  end
  
  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]
    else
@     = [THIS] -> call script plugin.autotrade.jump.to.env :  Target env: ship/station/sector=$FlyToWwarf
    end
    [THIS] ->set destination to null
  end
  
  * cannot repair if ship not docked at a shipyard
  if not [DOCKEDAT] -> is of class Shipyard
    $Exception = 22
    gosub Exceptions
    endsub
  end
  
  $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
    gosub Exceptions
    endsub
  end
  
  * 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]
        else
  * 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]
        end
      end
    end
  end
  endsub

gnasirator
Posts: 1114
Joined: Mon, 13. Dec 04, 16:15
x3tc

Re: [SCR] [X3:TC/AP] [v1.8.9.8] [11/16/2019] MK3 Improvement Reloaded

Post by gnasirator » Tue, 17. Dec 19, 21:04

Hey AdamXI,

great job! Thanks for taking care of this. Sounds like a very useful feature. I'm thinking whether it would be a nice co-feature to add a switch to the ship commands to enable / disable the auto repair feature.
Not sure yet how to do it in detail - especially as I'm very low on free time right now. Work is super busy, usual end-of-year trouble. For now, if you want, I can put a link to your mod on page 1. Then players can decide what they want to do. If you manage to get a proper switch working, I will happily include it into the main project and you will be credited accordingly - IF you'd want that :)

User avatar
N8M4R3
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 392
Joined: Fri, 24. Nov 06, 15:48
x4

Re: [SCR] [X3:TC/AP] [v1.8.9.8] [11/16/2019] MK3 Improvement Reloaded

Post by N8M4R3 » Wed, 18. Dec 19, 02:57

Nice feature AdamXI! I prefer a switch to turn this feature on or off too. I think a small configuration menu maybe would be better as to switch it in the ships commands itself. This config menu could maybe opened by cycrows plugin cofiguration, or otherwise i would like to integrate this switch in my mk3 Commandmenu. For the last one i think it would be nice if theres a global var to set true or false or something like that. I also work right now on a new version of my mk3 Commandmenu. There are a few modifications and tests left but i think that i will get it done before new year, i hope :) The unreleased version still has a working dynamic menu like trade overview and even with the same big window with more specified information for mk3 traders and some other new stuff.
Neue Erweiterung für X3 verfügbar: Farnham's Legacy | +Optional: weitere Verbesserungen im inoffiziellen Patch v1.3.14 *** Modified*** :khaak: :thumb_up:
Diese Woche im Angebot: HUD-GUI-Mix (FL) | Text-DB 0001-L049 (FL) | Textkorrekturen & Verbesserungen (FL)
Weitere Veröffentlichungen hier: N8workX
Nützliches Tool für nicht mehr vorhandene Downloads: web.archive.org
Externes Archiv für MOD/SCR Ressourcen: xdownloads.co.uk | code.google.com/archive/p/x3tcscripts/

Qilue
Posts: 108
Joined: Tue, 23. Dec 03, 10:36
x4

Re: [SCR] [X3:TC/AP] [v1.8.9.8] [11/16/2019] MK3 Improvement Reloaded

Post by Qilue » Fri, 21. Feb 20, 04:28

I tried to like this, but the traders level up too slowly and need constant micromanagement until lvl 10. Their only real use is to raise my trading rank so I can make real money doing missions.
Skill counts for nothing when an angel pees down the touchhole of your musket.
- Anonymous soldier.

gnasirator
Posts: 1114
Joined: Mon, 13. Dec 04, 16:15
x3tc

Re: [SCR] [X3:TC/AP] [v1.8.9.8] [11/16/2019] MK3 Improvement Reloaded

Post by gnasirator » Sat, 22. Feb 20, 13:16

Sorry to hear that Qilue - I tried to keep the traders as close to vanilla as possible, balancing-wise. If you prefer faster levelling, you can spawn max-level traders using the script editor.
If you prefer to avoid using the script editor, I can promise you that after you managed to finally level up your traders, you will value them much more, given that you had to put so much effort into them :)

atsjewell
Posts: 5
Joined: Sun, 6. Nov 16, 17:25
x3ap

Re: [SCR] [X3:TC/AP] [v1.8.9.8] [11/16/2019] MK3 Improvement Reloaded

Post by atsjewell » Fri, 28. Apr 23, 18:01

I loved and depended upon this script on my pre-FL playthroughs.
I'm jumping into FL after a hiatus of several years. I understand FL already incorporates many improvements over AP as to be expected with any kind of new release.
How about UT traders though? Is this script still meaningful (or compatible) with FL?

User avatar
X2-Illuminatus
Moderator (Deutsch)
Moderator (Deutsch)
Posts: 24950
Joined: Sun, 2. Apr 06, 16:38
x4

Re: [SCR] [X3:TC/AP] [v1.8.9.8] [11/16/2019] MK3 Improvement Reloaded

Post by X2-Illuminatus » Sun, 30. Apr 23, 11:28

atsjewell wrote:
Fri, 28. Apr 23, 18:01
How about UT traders though? Is this script still meaningful (or compatible) with FL?
UT traders also received several adjustments and improvements with X3FL. So out of the box this script isn't compatible with X3FL.
Nun verfügbar! X3: Farnham's Legacy - Ein neues Kapitel für einen alten Favoriten

Die komplette X-Roman-Reihe jetzt als Kindle E-Books! (Farnhams Legende, Nopileos, X3: Yoshiko, X3: Hüter der Tore, X3: Wächter der Erde)

Neuauflage der fünf X-Romane als Taschenbuch

The official X-novels Farnham's Legend, Nopileos, X3: Yoshiko as Kindle e-books!

Post Reply

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