[MOD] Galaxy Trader MK3

The place to discuss scripting and game modifications for X4: Foundations.

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

staeuber
Posts: 55
Joined: Tue, 8. Feb 05, 00:36
x4

[MOD] Galaxy Trader MK3

Post by staeuber »

Galaxy Trader

IMPORTANT

This mod will no longer receive updates for Version 8 of the base game. I am currently working on adapting it for Version 9.0 Beta. If you are playing the beta and would like to help improve the mod, feel free to join me on Discord to access the latest builds and take part in discussions.


New releases: Nexus Mods
Source & changelog: GitHub | Changelog
Documentation: Documentation | Discord

This mod adds immersion — it is not a fire-and-forget trading script. Pilots start at level 1 and progress through training and experience. If you want all features unlocked from the start, this mod may not be for you. Read the Description and Wiki before asking questions.

SHIP ORDERS
  • MK1 Station Trading and Supply
  • MK2 Distribution Trading
  • MK3 Universal Trader
  • MK4 Supply
  • Galaxy-Miner
GalaxyTrader MK3 brings intelligent autonomous trading, skill progression, and fleet management to X4. Ships learn, grow, and optimize their operations over time.

Features
  • Vanilla Mode to disable the GT XP system
  • Advanced Trading AI
  • XP Progression System
  • Mandatory Training System
  • Ship Management
  • Faction Blacklist
  • Ship Modifications Bonus/Malus
  • Threat Intelligence System
  • Fleet Coordination System
  • Mobile Satellite Intelligence
  • Auto-Repair System
  • Defensive Equipment Auto-Replenishment
read Documentation for the full description


Compatibility
  • X4 8.0+ and 9.0 BETA
  • DLC: Compatible with all (not required)
  • Other Mods: Works with trading mods, faction mods, economy overhauls
Last edited by staeuber on Mon, 30. Mar 26, 13:04, edited 12 times in total.
keine
staeuber
Posts: 55
Joined: Tue, 8. Feb 05, 00:36
x4

Re: [MOD] Galaxy Trader MK3

Post by staeuber »

Current status:

i learned about the MD script and aiscript limitations and now using LUA to overcome those limitations.
X4 Scripting is a journey :)
i guess my next project will be a comprehensive documentation about everything i learned so far to help other modders to avoid the frustration :D

update 2025-06-29
reality hits hard. after finding out about X4s current limitations/restrictions despite using LUA i have to step back about many ideas and have to rewrite a whole piece of code :( i'm frustrated and disappointed

update 2025-10-14
i'm back overcoming my previous frustration
first beta https://github.com/GoAhead-at/GalaxyTraderMK3

update 2025-11-01
the mod evolves https://www.nexusmods.com/x4foundations/mods/1857
Last edited by staeuber on Sat, 1. Nov 25, 13:45, edited 5 times in total.
keine
fraeulein78
Posts: 16
Joined: Sat, 3. Aug 13, 14:19

Re: [MOD] Galaxy Trader MK3

Post by fraeulein78 »

Looks promising.

Is this supposed to work along with Dead Tater?
User avatar
Brinnie
Posts: 909
Joined: Mon, 5. Jun 06, 08:26
x3tc

Re: [MOD] Galaxy Trader MK3

Post by Brinnie »

staeuber wrote: Sun, 15. Jun 25, 20:58
Completely rewritten and inspired by Lucike's scripts - bringing the depth and immersion of classic X3 trading to X4: Foundations.

more to come

1st release planned next weekend

Like the E.S.T. ?

I look forward to it.
Win 10 x64
i7-3770k @ 3.50 GHz
NVIDIA GeForce RTX 3060 12 GB
16GBs RAM DD3
staeuber
Posts: 55
Joined: Tue, 8. Feb 05, 00:36
x4

Re: [MOD] Galaxy Trader MK3

Post by staeuber »

fraeulein78 wrote: Mon, 16. Jun 25, 17:43 Looks promising.

Is this supposed to work along with Dead Tater?
yes sure. but they do not share data and are working on their own logic. lets say you have a galaxytrader trained pilot and apply the Dead Tater order the Skill system isn't recognized by Dead Tater so you will not gain any benefits
keine
Lothmorg
Posts: 663
Joined: Tue, 11. Nov 03, 19:48
x3

Re: [MOD] Galaxy Trader MK3

Post by Lothmorg »

This would be a wonderful addition, if you can get it to work. Please keep us posted.
There are 10 kinds of people in the world.
Those who understand binary and those who don't.
staeuber
Posts: 55
Joined: Tue, 8. Feb 05, 00:36
x4

Re: [MOD] Galaxy Trader MK3

Post by staeuber »

development is back. i just published the github repository.
this is in beta. so everyone is welcome to try it out and make suggestions to it.
keine
staeuber
Posts: 55
Joined: Tue, 8. Feb 05, 00:36
x4

Re: [MOD] Galaxy Trader MK3

Post by staeuber »

first official release available now https://github.com/GoAhead-at/GalaxyTraderMK3/releases v0.2.0
i hope i get some feedback and ideas i can add to this mod :-) everyone welcome
keine
staeuber
Posts: 55
Joined: Tue, 8. Feb 05, 00:36
x4

Re: [MOD] Galaxy Trader MK3

Post by staeuber »

Dear Community,

which feature should i implement next?
  • Rescue-jump system
    applies only to high lvl Pilots
    only avalaible once per hour or less
    jump only triggers on high threat and once ship is attacked
    ship has to carry additional Enegy cells
    jump damages ships hull slightly so autorepair gets triggered (nothing should be for free)
  • Automatic defense resupply
    applies only for mid to high lvl pilots
    Pilots will automatically restock defense drones and lasertowers
keine
Taylor2008
Posts: 310
Joined: Fri, 20. Mar 09, 16:38
x4

Re: [MOD] Galaxy Trader MK3

Post by Taylor2008 »

Automatic Resupply.

Also , the leveling is way to fast even with 50% exp gain , my pilot have lvl 10 after 12 runs.
And why does the normal stars do not grow.

What does "Faction respect" means.
what is the difference between the notifications levels.

when i have a group of 5 traders in Argon and a second group in Two grand , will they "communicate" ?

Everythings else seem good.
staeuber
Posts: 55
Joined: Tue, 8. Feb 05, 00:36
x4

Re: [MOD] Galaxy Trader MK3

Post by staeuber »

Taylor2008 wrote: Sat, 18. Oct 25, 15:12 Automatic Resupply.

Also , the leveling is way to fast even with 50% exp gain , my pilot have lvl 10 after 12 runs.
And why does the normal stars do not grow.

What does "Faction respect" means.
what is the difference between the notifications levels.

when i have a group of 5 traders in Argon and a second group in Two grand , will they "communicate" ?

Everythings else seem good.
i'm currently fixing some bugs and afterwards i have to create a better documentation.
the leveling is in testmode thats why. will be fixed in the next release
---
you mean faction priority?
Faction Priority controls which stations your traders prioritize when searching for trades. It has 3 modes:
0 - Player Only
Only trades with your own stations
Ignores all foreign faction stations

1 - Foreign First (Default)
Searches foreign stations first, then player stations

2 - Equal Priority
---
Communication happens across fleets
What Gets Shared:
Threat Intelligence:
hostile attacks in sectors
missile warnings
ship destructions
real-time enemy detection (class, faction, count)
Threat scores and sector danger levels
Market Intelligence:
price history across all stations
market trends and opportunities
trade execution data
mobile satellite scans (Lv 9+ pilots)
---
traderpilots gain stars in management not piloting. as their main duty is trading, managment made more sense to me.
---
notification levels is for debugging. will also be removed

the mod still need some balancing tho. but this relies also on feedback., so big thx to you
keine
Taylor2008
Posts: 310
Joined: Fri, 20. Mar 09, 16:38
x4

Re: [MOD] Galaxy Trader MK3

Post by Taylor2008 »

:)
Good to know.

Last , maybe stupid , question : Do i assign one Trader to MK3 and than add other Traders with Mimic commond , or every Trader as MK3 ?

When i use Mimic than the Leader will allway have 0 Stars in MK3 overview and does nothing , only the other Traders with Mimic behauvier will trade.

Is it possible that your scripts collide with other Trade-Scripts?
staeuber
Posts: 55
Joined: Tue, 8. Feb 05, 00:36
x4

Re: [MOD] Galaxy Trader MK3

Post by staeuber »

Taylor2008 wrote: Sat, 18. Oct 25, 20:08 :)
Good to know.

Last , maybe stupid , question : Do i assign one Trader to MK3 and than add other Traders with Mimic commond , or every Trader as MK3 ?

When i use Mimic than the Leader will allway have 0 Stars in MK3 overview and does nothing , only the other Traders with Mimic behauvier will trade.

Is it possible that your scripts collide with other Trade-Scripts?
the ship order supports subordinates. so simply add them to mimic and you are fine
interesting observation. i have to investigate

no collision with other tradescripts at all. you can use tatertrade alongside

my 3rd and last edit :-)
i would recommend to wait for the next update. there are a lot of fixes made. i'm working hard to release it within the next hours
keine
Taylor2008
Posts: 310
Joined: Fri, 20. Mar 09, 16:38
x4

Re: [MOD] Galaxy Trader MK3

Post by Taylor2008 »

I am waiting , no , jokes aside , i have 4 MK3 Traders now seperatly and the info log show that the fleet is 4 ships.
So all good.
staeuber
Posts: 55
Joined: Tue, 8. Feb 05, 00:36
x4

Re: [MOD] Galaxy Trader MK3

Post by staeuber »

Taylor2008 wrote: Sat, 18. Oct 25, 21:15 I am waiting , no , jokes aside , i have 4 MK3 Traders now seperatly and the info log show that the fleet is 4 ships.
So all good.
its out
github and nexus https://www.nexusmods.com/x4foundations/mods/1857

still missing is the detailed documentation. but curently i'm focused on bugs
keine
staeuber
Posts: 55
Joined: Tue, 8. Feb 05, 00:36
x4

Re: [MOD] Galaxy Trader MK3

Post by staeuber »

staeuber wrote: Sat, 18. Oct 25, 20:16
Taylor2008 wrote: Sat, 18. Oct 25, 20:08 :)
Good to know.

Last , maybe stupid , question : Do i assign one Trader to MK3 and than add other Traders with Mimic commond , or every Trader as MK3 ?

When i use Mimic than the Leader will allway have 0 Stars in MK3 overview and does nothing , only the other Traders with Mimic behauvier will trade.

Is it possible that your scripts collide with other Trade-Scripts?
the ship order supports subordinates. so simply add them to mimic and you are fine
interesting observation. i have to investigate

no collision with other tradescripts at all. you can use tatertrade alongside

my 3rd and last edit :-)
i would recommend to wait for the next update. there are a lot of fixes made. i'm working hard to release it within the next hours
i guess i found your specific bug. will be out in next release
Version 0.3.3 - 2025-10-18
--------------------------

Trade System - Fixed Stale Active Trade Blocking
- CRITICAL: Ships blocked from finding trades due to stale active trade entries
- Problem: When trade orders fail/cancel, active trade entry wasn't cleaned up
- Symptom: Ship stuck with "already has active trade" message but no actual trades
- Solution: Validate active trade entries before blocking search
1. Check if ship actually has trade orders in queue
2. Check if active trade entry is stale (>10 minutes old)
3. Auto-cleanup stale entries
- Fixed: MD timeout issues and "no trades found" for busy ships
- Fixed in: gt_trading_queue.xml lines 153-173, 239-259
- Also fixed: Float multiplication data loss warnings in cache validation
keine
Taylor2008
Posts: 310
Joined: Fri, 20. Mar 09, 16:38
x4

Re: [MOD] Galaxy Trader MK3

Post by Taylor2008 »

Super!!
staeuber
Posts: 55
Joined: Tue, 8. Feb 05, 00:36
x4

Re: [MOD] Galaxy Trader MK3

Post by staeuber »

for people who want more technical insight on how version 0.5.9 will handle tradesearches
https://crapcode.dev/TradeSearch_Flowcharts.html
keine
staeuber
Posts: 55
Joined: Tue, 8. Feb 05, 00:36
x4

Re: [MOD] Galaxy Trader MK3

Post by staeuber »

keine
staeuber
Posts: 55
Joined: Tue, 8. Feb 05, 00:36
x4

Re: [MOD] Galaxy Trader MK3

Post by staeuber »

here is a Powershell script to check if all translations files are in sync. this can be annoying when translation files are big
execution example:

Code: Select all

powershell -ExecutionPolicy Bypass -File "[YOURPATH]\Check-TranslationSync.ps1"

SOURCE:

Code: Select all

# GalaxyTrader MK3 Translation Synchronization Checker
# Checks if all translation files have the same set of translation IDs
# Usage: .\Check-TranslationSync.ps1

param(
    [string]$ModPath = "GalaxyTraderMK3",
    [switch]$Verbose
)

# Set error action preference
$ErrorActionPreference = "Stop"

# Get script directory and construct full path
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$TranslationPath = Join-Path (Join-Path $ScriptDir $ModPath) "t"

Write-Host "GalaxyTrader MK3 Translation Synchronization Checker" -ForegroundColor Cyan
Write-Host ("=" * 60) -ForegroundColor Cyan
Write-Host ""

# Check if translation directory exists
if (-not (Test-Path $TranslationPath)) {
    Write-Host "ERROR: Translation directory not found: $TranslationPath" -ForegroundColor Red
    exit 1
}

# Get all translation files
$TranslationFiles = Get-ChildItem -Path $TranslationPath -Filter "0001-l*.xml" | Sort-Object Name

if ($TranslationFiles.Count -eq 0) {
    Write-Host "ERROR: No translation files found in $TranslationPath" -ForegroundColor Red
    exit 1
}

Write-Host "Found $($TranslationFiles.Count) translation files:" -ForegroundColor Green
foreach ($file in $TranslationFiles) {
    Write-Host "  - $($file.Name)" -ForegroundColor Gray
}
Write-Host ""

# Dictionary to store translation IDs per file
$TranslationData = @{}

# Function to extract translation IDs from XML file
function Get-TranslationIDs {
    param([string]$FilePath)
    
    $ids = @()
    
    try {
        # Load XML file
        [xml]$xml = Get-Content -Path $FilePath -Encoding UTF8
        
        # Find all <t> elements with id attribute
        $tElements = $xml.SelectNodes("//t[@id]")
        
        foreach ($element in $tElements) {
            $id = $element.GetAttribute("id")
            if ($id) {
                $ids += [int]$id
            }
        }
    }
    catch {
        Write-Host "ERROR: Failed to parse $FilePath`: $_" -ForegroundColor Red
        return @()
    }
    
    return $ids | Sort-Object -Unique
}

# Extract translation IDs from all files
Write-Host "Extracting translation IDs..." -ForegroundColor Yellow
foreach ($file in $TranslationFiles) {
    $fileName = $file.Name
    $ids = Get-TranslationIDs -FilePath $file.FullName
    
    if ($ids.Count -eq 0) {
        Write-Host "  WARNING: No translation IDs found in $fileName" -ForegroundColor Yellow
    }
    else {
        $TranslationData[$fileName] = $ids
        if ($Verbose) {
            Write-Host "  $fileName`: $($ids.Count) translation IDs" -ForegroundColor Gray
        }
    }
}

Write-Host ""

# Check if we have any data
if ($TranslationData.Count -eq 0) {
    Write-Host "ERROR: No translation data extracted from any file" -ForegroundColor Red
    exit 1
}

# Find the reference file (file with most translation IDs, or first file)
$ReferenceFile = $TranslationData.Keys | Sort-Object { $TranslationData[$_].Count } -Descending | Select-Object -First 1
$ReferenceIDs = $TranslationData[$ReferenceFile]

Write-Host "Reference file: $ReferenceFile ($($ReferenceIDs.Count) translation IDs)" -ForegroundColor Cyan
Write-Host ""

# Compare all files against reference
$AllInSync = $true
$IssuesFound = 0

foreach ($fileName in $TranslationData.Keys | Sort-Object) {
    $fileIDs = $TranslationData[$fileName]
    
    # Find missing IDs (in reference but not in this file)
    $missingIDs = $ReferenceIDs | Where-Object { $_ -notin $fileIDs }
    
    # Find extra IDs (in this file but not in reference)
    $extraIDs = $fileIDs | Where-Object { $_ -notin $ReferenceIDs }
    
    if ($missingIDs.Count -gt 0 -or $extraIDs.Count -gt 0) {
        $AllInSync = $false
        $IssuesFound++
        
        Write-Host "[X] $fileName" -ForegroundColor Red
        Write-Host "   Total IDs: $($fileIDs.Count) (Reference: $($ReferenceIDs.Count))" -ForegroundColor Gray
        
        if ($missingIDs.Count -gt 0) {
            Write-Host "   Missing IDs ($($missingIDs.Count)): " -ForegroundColor Yellow -NoNewline
            $missingIDsSorted = $missingIDs | Sort-Object
            if ($missingIDsSorted.Count -le 20) {
                Write-Host ($missingIDsSorted -join ", ") -ForegroundColor Yellow
            }
            else {
                Write-Host ($missingIDsSorted[0..19] -join ", ") -ForegroundColor Yellow
                Write-Host "   ... and $($missingIDsSorted.Count - 20) more" -ForegroundColor Yellow
            }
        }
        
        if ($extraIDs.Count -gt 0) {
            Write-Host "   Extra IDs ($($extraIDs.Count)): " -ForegroundColor Magenta -NoNewline
            $extraIDsSorted = $extraIDs | Sort-Object
            if ($extraIDsSorted.Count -le 20) {
                Write-Host ($extraIDsSorted -join ", ") -ForegroundColor Magenta
            }
            else {
                Write-Host ($extraIDsSorted[0..19] -join ", ") -ForegroundColor Magenta
                Write-Host "   ... and $($extraIDsSorted.Count - 20) more" -ForegroundColor Magenta
            }
        }
        
        Write-Host ""
    }
    else {
        Write-Host "[OK] $fileName ($($fileIDs.Count) IDs)" -ForegroundColor Green
    }
}

Write-Host ""
Write-Host ("=" * 60) -ForegroundColor Cyan

# Summary
if ($AllInSync) {
    Write-Host "[SUCCESS] All translation files are synchronized!" -ForegroundColor Green
    Write-Host "   All $($TranslationFiles.Count) files have the same set of $($ReferenceIDs.Count) translation IDs." -ForegroundColor Green
    exit 0
}
else {
    Write-Host "[FAILURE] Translation files are NOT synchronized!" -ForegroundColor Red
    Write-Host "   Found issues in $IssuesFound out of $($TranslationFiles.Count) files." -ForegroundColor Red
    Write-Host ""
    Write-Host "Recommendation:" -ForegroundColor Yellow
    Write-Host "   Review the missing/extra IDs above and synchronize all translation files." -ForegroundColor Yellow
    exit 1
}
keine

Return to “X4: Foundations - Scripts and Modding”