Files
dotfiles/scripts/install-gothic2.sh

199 lines
5.9 KiB
Bash
Raw Permalink Normal View History

2021-08-13 18:54:22 +02:00
#!/usr/bin/env bash
2022-12-04 15:24:02 +01:00
# Steam setting: Proton 4.11-13
#
# * It *must not* have any symlinks for the directmusic dlls like:
# pfx/dosdevices/c:/windows/syswow64/dmusic.dll
2021-08-13 18:54:22 +02:00
set -o nounset
set -o xtrace
set -o errexit
2024-05-28 17:06:21 +02:00
STEAMAPPS=$XDG_DATA_HOME/Steam/steamapps/
2022-12-04 15:24:02 +01:00
BASEDIR="${STEAMAPPS}/common/Gothic II"
2021-08-13 18:54:22 +02:00
export GAMEDATA=${BASEDIR}/data/
export ARCHIVE=${BASEDIR}/gothic2.data.tar.zstd
2022-12-04 15:24:02 +01:00
export WINEPREFIX="${STEAMAPPS}/compatdata/39510/pfx/"
2021-08-13 18:54:22 +02:00
export WINEARCH=win64
export WINEVERSION=6.3
2024-05-27 16:09:24 +02:00
DOWNLOADDIR="${XDG_DOWNLOAD_DIR}"/gothic2
2021-08-13 18:54:22 +02:00
mkdir -p "${WINEPREFIX}"
2022-12-04 15:24:02 +01:00
# if [[ "$(wine --version)" != "wine-${WINEVERSION}" ]] ; then
# printf '%s\n' "Wine version ${WINEVERSION} required" >&2
# exit 1
# fi
2021-08-13 18:54:22 +02:00
archive() {
origin="$1"
if [[ -e "${ARCHIVE}" ]] ; then
return
fi
2022-12-04 15:24:02 +01:00
tar -cv --zstd -p -f "${ARCHIVE}" -C "${GAMEDATA}" .
2021-08-13 18:54:22 +02:00
}
extract() {
if [[ -e "${GAMEDATA}" ]] ; then
return
fi
mkdir -p "${GAMEDATA}"
tar x --zstd -f "${ARCHIVE}" -C "${GAMEDATA}"
}
start() {
# For the DX11 renderer, PWD has to be the folder containing the "GD3D11" folder
cd "${GAMEDATA}/system/"
# There is a bug in the DX11 renderer that leads to the mouse cursor always
# being visible
#
# See https://bugs.winehq.org/show_bug.cgi?id=48483
#
# Workaround is to disable the cursor completely during gameplay
# if command -v unclutter >/dev/null ; then
# unclutter --timeout 0 --jitter 100000 --ignore-scrolling &
# pid=$!
# trap "kill $pid" EXIT
# else
# echo "WARNING: Unclutter not installed, cannot disable mouse cursor"
# fi
wine ./Gothic2.exe
}
ini() {
cd "${GAMEDATA}"
set_ini() {
local file="$1"
local key="$2"
local value="$3"
if ! grep -q "^${key}=" "${file}" ; then
echo "Key ${key} not fmund in ${file}"
exit 1
fi
sed -i "s/^${key}=.*$/${key}=${value}\r/" "${file}"
}
set_ini system/Gothic.ini sightValue 14
set_ini system/Gothic.ini modelDetail 1
set_ini system/Gothic.ini animatedWindows 0
set_ini system/Gothic.ini playLogoVideos 0
set_ini system/Gothic.ini useGothic1Controls 1
set_ini system/Gothic.ini keyDelayRate 50
set_ini system/Gothic.ini keyDelayFirst 150
set_ini system/Gothic.ini subTitles 1
set_ini system/Gothic.ini invMaxColumns 8
set_ini system/Gothic.ini invMaxRows 0
set_ini system/Gothic.ini useQuickSaveKeys 1
set_ini system/Gothic.ini zVidResFullscreenX 2560
set_ini system/Gothic.ini zVidResFullscreenY 1440
set_ini system/Gothic.ini zVidResFullscreenBPP 32
set_ini system/Gothic.ini zRainWindScale 0.1
set_ini system/Gothic.ini zMouseRotationScale 15.0
set_ini system/Gothic.ini zSmoothMouse 0
set_ini system/SystemPack.ini VerticalFOV 85.0
set_ini system/SystemPack.ini DrawDistanceMultiplier 3
set_ini system/SystemPack.ini OutDoorPortalDistanceMultiplier 3
set_ini system/SystemPack.ini InDoorPortalDistanceMultiplier 3
}
case $1 in
install)
extract
mkdir -p "${DOWNLOADDIR}"
cd "${DOWNLOADDIR}"
curl -C - -L -o g2addon-2_6.exe "https://www.worldofgothic.de/download.php?id=173"
curl -C - -L -o gothic2_fix-2.6.0.0-rev2.exe "https://www.worldofgothic.de/download.php?id=833"
curl -C - -L -o gothic2_playerkit-2.6f.exe "https://www.worldofgothic.de/download.php?id=518"
curl -C - -L -o G2NoTR-SystemPack-1.8.exe "https://www.worldofgothic.de/download.php?id=1525"
curl -C - -L -o LHiver204_DE_22-06-20.exe "https://www.worldofgothic.de/download.php?id=1580"
curl -C - -L -o LaaHack.zip "https://www.worldofgothic.de/download.php?id=1457"
curl -C - -L -O "https://github.com/Kirides/GD3D11/releases/download/v17.7-dev20/Gothic2-GD3D11-v17.7-dev20.zip"
2022-12-04 15:24:02 +01:00
curl -C - -L -o Normalmaps_LHiver.zip "https://www.worldofgothic.de/download.php?id=1530"
2021-08-13 18:54:22 +02:00
curl -C - -L -O https://github.com/Kirides/ninja-quickloot/releases/download/v1.9.5/Quickloot.vdf
curl -C - -L -O https://github.com/szapp/Ninja/releases/download/v2.7.12/Ninja-2.7.12.exe
# winetricks -q dxvk
winetricks -q directmusic
if command -v setup_dxvk >/dev/null ; then
setup_dxvk install
else
echo "WARNING: Using dxvk via winetricks, untested"
winetricks dxvk
fi
2022-12-04 15:24:02 +01:00
read -p 'During installation, use "${GAMEDATA//\//\\}" as the install directory! <Enter> to continue, <CTRL+C> to abort '
2021-08-13 18:54:22 +02:00
wine "${DOWNLOADDIR}"/g2addon-2_6.exe
wine "${DOWNLOADDIR}"/gothic2_fix-2.6.0.0-rev2.exe
wine "${DOWNLOADDIR}"/gothic2_playerkit-2.6f.exe
wine "${DOWNLOADDIR}"/G2NoTR-SystemPack-1.8.exe
wine "${DOWNLOADDIR}"/LHiver204_DE_22-06-20.exe
wine "${DOWNLOADDIR}"/Ninja-2.7.12.exe
cd "${GAMEDATA}"
unzip -o "${DOWNLOADDIR}"/Gothic2-GD3D11-v17.7-dev20.zip -d ./system/
2022-12-04 15:24:02 +01:00
ln Data/ModVDF/LHE204_DE.mod Data/LHE204_DE.mod
2021-08-13 18:54:22 +02:00
cp "${DOWNLOADDIR}"/Quickloot.vdf ./Data
t="./system/GD3D11/Textures/replacements/Normalmaps_xxx"
mkdir -p "${t}"
2022-12-04 15:24:02 +01:00
set +o errexit
2021-08-13 18:54:22 +02:00
unzip -o "${DOWNLOADDIR}"/Normalmaps_LHiver.zip -d "${t}"
2022-12-04 15:24:02 +01:00
zip_exit="$?"
set -o errexit
if (( $zip_exit != 0 )) && (( $zip_exit != 2 )) ; then
echo zip failed
exit 1
fi
2021-08-13 18:54:22 +02:00
unset t
2022-12-04 15:24:02 +01:00
laatmp=$(mktemp -d)
unzip -o "${DOWNLOADDIR}"/LaaHack.zip -d "${laatmp}"
2021-08-13 18:54:22 +02:00
read -p "For the LAA Hack, select only ${GAMEDATA}/system/Gothic2.exe [<Enter> to continue] "
wine "${laatmp}"/LaaHack.exe
rm -rf "${laatmp}"
# Required to create all ini files
read -p "Now run the game once and exit! [<Enter> to continue] "
ini
;;
ini)
ini
;;
start)
export WINEDLLOVERRIDES="ddraw=n,b;dsound=b,n;d3dcompiler_47=n,b"
start
;;
archive)
archive "$2"
;;
exec)
"${@}"
;;
esac