Skip to content
H. C. Kruse edited this page Aug 3, 2022 · 2 revisions
#!/bin/bash

# Usage
# ./sc-extract.sh <Output Folder> <Game Version>
# ./sc-extract.sh 3161-7939065 3.16.1-LIVE.7939065

set -e

TOOLS_DIR="/mnt/e/SC/sc-tools"
OUT_DIR="/mnt/e/SC/sc-data"
OUT_DIR_WIN="E:\\SC\\sc-data"
PAK_PATH="C:\Program Files\Roberts Space Industries\StarCitizen\LIVE\Data.p4k"

if [ -z "$1" ]
  then
    echo "Please provide the output dir as the first argument"
fi

VERSION="$1"

OUT_PATH="$OUT_DIR/$VERSION"
OUT_PATH_WIN="$OUT_DIR_WIN\\$VERSION"

mkdir -p "$OUT_PATH"
mkdir -p "$OUT_PATH-json"

cd "$OUT_PATH"

echo "Unpacking..."
"$TOOLS_DIR/unpacked/unp4k.exe" "$PAK_PATH" "*.xml"
"$TOOLS_DIR/unpacked/unp4k.exe" "$PAK_PATH" "*.ini"

echo "Unforging..."

"$TOOLS_DIR/unpacked/unforge.exe" "$OUT_PATH_WIN"

cd "$OUT_DIR"

# Fixes
sed -i 's/\.\.6/\.6/g' "$VERSION/Data/Scripts/Entities/Vehicles/Implementations/Xml/CRUS_Starfighter.xml"
sed -i 's/1E+07/10000000/g' "$VERSION/Data/Libs/Foundry/Records/entities/scitem/weaponregenpools/weaponregenpool_turret_bengal.xml"

echo "Converting..."
"$TOOLS_DIR/scunpacked/Loader/bin/Debug/netcoreapp3.1/Loader.exe" --input "$OUT_PATH_WIN" --output "$OUT_PATH_WIN-json"

if [ -z "$2" ]
  then
    exit 0
  else
    echo "Pushing to git"
fi

rm -rf /tmp/tmpgit
rm -rf /tmp/scdata

git clone [email protected]:StarCitizenWiki/scunpacked-data.git /tmp/scdata
mkdir /tmp/tmpgit
cp -R /tmp/scdata/.git /tmp/tmpgit

cp -R "$OUT_PATH-json/"* /tmp/tmpgit

cd /tmp/tmpgit

git add .
git commit -m "$2"
git push

git checkout -b "$2"
git push -u origin "$2"

rm -rf /tmp/tmpgit
rm -rf /tmp/scdata
Clone this wiki locally