Skip to content

Instantly share code, notes, and snippets.

@LamberKeep
Last active September 29, 2023 06:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LamberKeep/43f7f5af38b620f21b1a76f1c0a9b640 to your computer and use it in GitHub Desktop.
Save LamberKeep/43f7f5af38b620f21b1a76f1c0a9b640 to your computer and use it in GitHub Desktop.
Neverwinter Nights 1 - simple server launcher
#!/bin/sh
# Neverwinter Nights 1 - simple server launcher
#
# Created: 2023.05.24
# Updated: 2023.06.21
#
# Author: Alexey Savin (LamberKeep)
# CONFIGURATION
# Name of your module's .mod file.
MODULE="Prelude"
# In client version of server, you can easily change server config in game settings.
# Otherwise, you can set your own configuration at the end of the code.
USE_SETTINGS=false
# CODE
set -e
clear
# Define system architecture.
echo -n "System architecture: "
arch=$(uname -m)
case $arch in
x86_64)
arch="x86"
;;
aarch64)
arch="arm-64"
;;
*)
echo "Unsupported system architecture."
exit 1
;;
esac
echo $arch
# Searching game directory.
echo -n "Searching install directory: "
game_install_dir=$(
find ~ -name "Neverwinter Nights" | while read i
do
if [ -d "$i/bin" ]
then
echo "$i"
break
fi
done
)
if [ ! -n "$game_install_dir" ]
then
echo "not found."
echo "Try to run this file as the user on which it is installed."
exit
fi
echo "found."
# Getting game install and resourses folders.
cd "$game_install_dir/bin/linux-$arch/"
game_resourses_dir=$(./nwserver-linux 2>&1 | sed -n '2p' | cut -b 42-)
clear
echo \
"
Neverwinter Nights - simple server launcher
Choose save file.
0 - last autosave
1 - last save in game directory
2 - input save ID
"
echo -n "Enter selection: "
read answer
save_id=1
case ${answer} in
"0")
;;
"1")
save_id=$(ls -t "$game_resourses_dir/saves/" | head -1 | grep -Po "^(\d+)")
;;
"2")
echo -n "Input save ID: "
read save_id
;;
*)
echo "Not a option."
exit 1
esac
clear
if $USE_SETTINGS
then
./nwserver-linux -module "$MODULE" -load $save_id
else
# Server configuration: https://nwn.wiki/display/NWN1/NWServer
./nwserver-linux \
-module "$MODULE" \
-userdirectory "$game_resourses_dir" \
-maxclients 244 \
-minlevel 1 \
-maxlevel 40 \
-pauseandplay 0 \
-pvp 0 \
-servervault 0 \
-elc 0 \
-ilr 0 \
-oneparty 0 \
-difficulty 2 \
-autosaveinterval 0 \
-servername 'Default NWN Server'\
-publicserver 1 \
-reloadwhenempty 0 \
-port 5121 \
-load $save_id
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment