Linux Script to find Erlking vaults

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

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

x30n
Posts: 44
Joined: Sun, 16. Jan 05, 13:20
x4

Linux Script to find Erlking vaults

Post by x30n »

Hi

I cooked up a little script to make Erlking data vaults as player owned allowing you to memorize their locations and go find them in an unmodified game once again.

This works with Linux or at least GNU tools. So Windows without a Linux subsystem is out. For that a bat file is rumoured to exist but I could not find it (yet).

Script and instructions are here:
https://code.geber.io/-/snippets/51

Good Profitssss to you
i7700K @ 4.8 GHz / 32 GB RAM / nvidia 1080 GTX 8 GB / Linux
greystar
Posts: 47
Joined: Wed, 6. Nov 02, 20:31
x4

Re: Linux Script to find Erlking vaults

Post by greystar »

Wish I'd seen this first, without creating a modified save game I do it like this:

Code: Select all

#!/usr/bin/env zsh
 
errx() {
    echo "ERROR: $*"
    exit 1
}
 
declare -A macrotocoords
macrotocoords=(
     [zone004_cluster_503_sector001a_macro]="139680 0 -3215.59"
     [zone003_cluster_500_sector003_macro]="-115796.9 0 -96109.38"
     [zone002_cluster_503_sector001_macro]="-2269.199 0 165758.4"
     [zone006_cluster_500_sector002_macro]="-184409.83 0 -3343.0"
     [zone003_cluster_501_sector001_macro]="-97898.44 0 -23632.81"
     [zone003_cluster_500_sector001_macro]="-97898.44 0 -23632.81"
     [zone005_cluster_501_sector001_macro]="-23023.44 0 -160132.8"
     [zone004_cluster_504_sector001_macro]="157616.8 0 -84263.63"
     [tzonecluster_500_sector002shcon9_gatezone_macro]="-39827.2 0 200000"
     [tzonecluster_500_sector002shcon5_gatezone_macro]="-50000 0 200000"
     [zone001_cluster_500_sector003_macro]="-117046.9 0 82593.75"
     [zone001_cluster_501_sector001_macro]="-127062.5 0 133718.8"
     [zone005_cluster_504_sector001_macro]="-23023.44 0 -160132.8"
     [zone004_cluster_500_sector001_macro]="103164.1 0 -32492.19"
     [zone002_cluster_500_sector001_macro]="-10960.94 0 112070.3"
     [zone003_cluster_500_sector002_macro]="-7132.69 0 531.25"
     [zone002_cluster_500_sector002_macro]="-118489.4 0 -131687.5"
     [tzonecluster_500_sector003shcon9_gatezone_macro]="50000 0 200000"
     [zone005_cluster_500_sector002_macro]="98694.83 0 -126406.3"
     [tzonecluster_500_sector001shcon2_gatezone_macro]="66960.9 0 -207957"
     [tzonecluster_500_sector003shcon5_gatezone_macro]="40054.7 0 200000"
     [tzonecluster_500_sector001shcon10_gatezone_macro]="-45738.28 0 -200000"
     [zone005_cluster_500_sector003_macro]="34671.88 0 -152515.6"
     [zone001_cluster_504_sector001_macro]="-127062.5 0 133718.8"
     [zone003_cluster_502_sector001_macro]="-97898.44 0 -23632.81"
     [zone002_cluster_504_sector001_macro]="137904.1 0 135199.3"
     [zone005_cluster_503_sector001_macro]="-23023.44 0 -160132.8"
     [zone001_cluster_500_sector001_macro]="-127062.5 0 133718.8"
     [zone004_cluster_501_sector001_macro]="103164.1 0 -32492.19"
     [tzonecluster_500_sector001shcon4_gatezone_macro]="76886.7 0 -207957"
     [zone006_cluster_502_sector001_macro]="47000.0 0 172000.0"
     [zone002_cluster_500_sector003_macro]="44015.63 0 158125"
     [tzonecluster_500_sector001shcon6_gatezone_macro]="-55785.2 0 -200000"
     [zone002_cluster_501_sector001_macro]="-10960.94 0 112070.3"
     [zone001_cluster_500_sector002_macro]="-78593.63 0 157937.5"
     [zone003_cluster_503_sector001_macro]="-199365.3 0 -55454.45"
     [zone001_cluster_502_sector001_macro]="-127062.5 0 133718.8"
     [zone003_cluster_504_sector001_macro]="-226443.3 0 -97194.67"
     [zone005_cluster_500_sector001_macro]="-23023.44 0 -160132.8"
     [zone004_cluster_500_sector003_macro]="110359.4 0 7250"
     [zone001_cluster_503_sector001_macro]="-190039.3 0 180073.9"
     [zone005_cluster_502_sector001_macro]="-23023.44 0 -160132.8"
     [zone004_cluster_500_sector002_macro]="101721.7 0 100656.3"
     [zone002_cluster_502_sector001_macro]="108009.3 0 115933.7"
     [zone004_cluster_502_sector001_macro]="103164.1 0 -32492.19"
)
 
declare -A secnames
secnames=(
    [cluster_500]="Avarice I"
    [cluster_500_sector002]="Avarice V"
    [cluster_500_sector003]="Avarice IV"
    [cluster_501]="Windfall I"
    [cluster_502]="Windfall III"
    [cluster_503]="Windfall IV"
)
 
declare -A vltnames
vltnames=(
    [vault_01_macro]="Engine"
    [vault_02_macro]="Shield"
    [vault_03_macro]="Main Battery"
    [vault_04_macro]="L Turrets"
    [vault_05_macro]="M Turrrets"
)
 
parse_vault_location() {
    while read -r name place dx dy dz; do
        echo $macrotocoords[$place] | read xo yo zo
        (( x=(dx+xo)/1000, y=(dy+yo)/1000, z=(dz+zo)/1000 ))
        fn=$place[9,-1]
        sn=${fn//_macro/}
        placename=${sn//_sector001/}
        printf "% 40s is in %20s at %7.2f, %7.2f, %7.2f (From $dx $dy $dz off $xo $yo $zo)\n" $vltnames[$name] $secnames[$placename]  $x $y $z  
    done
}
 
# Main Code
 
LSAVE=`/bin/ls -1tr *save*gz | tail -1`
[ -f ./${LSAVE} ] || errx "Unable to open ${LSAVE}"
 
[ -f stage1file ] || zgrep -A2 -E 'landmarks_erlking_vault_|_cluster_50._|position' ${LSAVE} > stage1file
 
[ -f stage2file ] ||
    cat stage1file | while read -r line; do
        [[ $line == *"cluster_50"* ]] && CLUSTER=${line}
        [[ $line == *"position"* ]] && POSDAT=${line}
        [[ $line == *"vault"* ]] && echo "$POSDAT" "${CLUSTER}" "$line"
    done > stage2file
 
sed -e 's#<position ##g' \
    -e 's#/> <component class="zone"##g' \
    -e 's#connection="space"##g' \
    -e 's#connection="sector"##g' \
    -e 's#macro=##g' \
    -e 's#code=".*" id=".*"> <component class="object"##g' \
    -e 's#"##g' \
    -e 's#x=# #g' \
    -e 's# y=# #g' \
    -e 's# z=# #g' \
    -e 's#  # #g' \
    -e 's#landmarks_erlking_##g' \
    stage2file | awk '{print $5 " " $4 " " $1 " " $2 " " $3}' | sort |
    parse_vault_location
 


The output looks like so, for this save, and it felt slightly less cheaty than seeing them on the map (it still requires me to send a ship to explore the sector, I assume that point mostly seems to be 0,0,0)

Code: Select all

                                  Engine is in            Avarice V at    8.23,   17.29, -167.68 (From -90465.875 17289.73 -41270.43 off 98694.83 0 -126406.3)
                                  Shield is in         Windfall III at -107.02,  -39.29, -289.34 (From -9119.863 -39294.117 -265711.562 off -97898.44 0 -23632.81)
                            Main Battery is in          Windfall IV at    5.74,   -1.59,  194.92 (From 8010.519 -1585.458 29157.469 off -2269.199 0 165758.4)
                               L Turrets is in           Windfall I at  -23.03,    0.00, -160.14 (From -4.772 0.3411 -7.016 off -23023.44 0 -160132.8)
                              M Turrrets is in           Windfall I at   -3.33,    2.28,  137.76 (From 7629.597 2281.158 25692.703 off -10960.94 0 112070.3)
I assume my code probably works for others too, but there's so little shell script to do this out there that I thought I'd share my hacky approach here and at least maybe yours will get found more often too.

Glad it's not just me who hacked a shell script together.

Return to “X4: Foundations - Scripts and Modding”