Skip to content

Instantly share code, notes, and snippets.

@tmtvl
Forked from ubervison/nwnonlinux.md
Created March 12, 2018 15:47
Show Gist options
  • Save tmtvl/3ac34f73b8450024b47fb5114ea7ceec to your computer and use it in GitHub Desktop.
Save tmtvl/3ac34f73b8450024b47fb5114ea7ceec to your computer and use it in GitHub Desktop.
Install Neverwinter Nights on any linux distribution

Neverwinter Nights Diamond GOG on linux

Prerequisites

First make sure that you have the following tools and libraries installed on your system:

innoextract, unzip, 7z, tar, unrar (to extract the game files)

For the nwmovies, nwlogger, nwuser and nwmouse tools, you will need the 32-bit version of these libraries, including their development headers (-dev or -devel packages):

elfutils
glulibgl
libstdc++5
libxcursor
openal
perl
sdl_mixer
SDL-1.2
libX11
zlib

Use the package manager of your distribution to install them. On Ubuntu, development packages have the suffix -dev appended to their name, and you can install 32-bit versions of packages by appending :i386 to their name. For example, to install the 32-bit version of the sdl development libraries, you would have to type sudo apt-get install libsdl1.2-dev:i386.

In this guide, we will install the game in a folder named Neverwinter at the root of your home directory. Of course, you're free to put it wherever you want.

First, create some folders that we will need during installation:

mkdir ~/Neverwinter
mkdir ~/Neverwinter/nwn

Download these and puth them in the ~/Neverwinter folder you just created:

http://nwdownloads.bioware.com/neverwinternights/linux/gold/nwclientgold.tar.gz

http://nwdownloads.bioware.com/neverwinternights/linux/161/nwclienthotu.tar.gz

http://files.bioware.com/neverwinternights/updates/linux/169/English_linuxclient169_xp2.tar.gz

Note: There is a mirror of the bioware ftp site at:

http://lvlt.bioware.cdn.ea.com/bioware/u/f/eagames/bioware/neverwinternights/

Navigate to ~/Neverwinter and clone these repos:

cd ~/Neverwinter
git clone https://github.com/nwnlinux/nwlogger
git clone https://github.com/nwnlinux/nwmovies
git clone https://github.com/nwnlinux/nwmouse
git clone https://github.com/nwnlinux/nwuser

You need the setup files from GOG, plus the Kingmaker expansion pack (the "premium module reinstaller" in the extras section in your GOG library):

setup_nwn_diamond_2.1.0.21-1.bin
setup_nwn_diamond_2.1.0.21.exe
nvn_KingmakerSetup.zip

Put them in the ~/Neverwinter folder.

To play movies, we need the BinkPlayer from RAD Game Tools. Download it here and extract it somewhere:

http://www.radgametools.com/down/Bink/BinkLinuxPlayer.7z

Finally, we need to write a custom patch file for the nwmovies tool. Open your favorite text editor and paste the following:

--- nwmovies_install.pl	2017-06-18 00:59:03.297013302 +0200
+++ patched.pl	2017-06-18 00:59:43.553680961 +0200
@@ -59,7 +59,7 @@
 			 $gcc, $cflags, $x86_64, $ndir, $ndir, $ndir, $ndir );
 do_exec($command); 
 
-$command = sprintf("%s %s %s -Wall -shared -g -I/usr/include/libelf -I%s/libdis -o %s/nwmovies.so %s/nwmovies.c %s/nwmovies_lookup.c %s/nwmovies_cookie.c %s/nwmovies_player.c %s/nwmovies_link.S %s -ldl -Wl,-static -lelf -Wl,-Bdynamic", 
+$command = sprintf("%s %s %s -Wall -shared -g -I/usr/include/libelf -I%s/libdis -o %s/nwmovies.so %s/nwmovies.c %s/nwmovies_lookup.c %s/nwmovies_cookie.c %s/nwmovies_player.c %s/nwmovies_link.S %s -ldl -Wl,-static -lelf -Wl,-Bdynamic -lz", 
 			$gcc, $cflags, $x86_64,  $ndir, $ndir, $ndir, $ndir, $ndir, $ndir, $ndir, $ldflags ); 
 do_exec($command);

Save it as libz.patch in the ~/Neverwinter folder.

To verify, make sure your ~/Neverwinter folder looks like this (type ls -1):

English_linuxclient169_xp2.tar.gz                                                                                              
libz.patch
nvn_KingmakerSetup.zip
nwclientgold.tar.gz
nwclienthotu.tar.gz
nwlogger
nwmouse
nwmovies
nwuser
README.md
setup_nwn_diamond_2.1.0.21-1.bin
setup_nwn_diamond_2.1.0.21.exe

Steps

Unless specified otherwise, all commands are executed from the ~/Neverwinter folder you created before.

  1. Extract the game's data from the GOG installer:
innoextract -e setup_nwn_diamond_2.1.0.21.exe --gog

This will create a bunch of folders in your ~/Neverwinter directory.

  1. Extract King Maker data files into kingmakertemp (excluding the $PLUGINSDIR folder, as well as exe and dat files):
unzip nvn_KingmakerSetup.zip
7z x KingmakerSetup.exe -xr'!$PLUGINSDIR' -xr'!*.exe' -xr'!*.dat' -okingmakertmp
  1. Move game files from the game subfolder into nwn, as well as your cdkey:
cd game
mv -t ~/Neverwinter/nwn ambient data dmvault hak localvault modules movies music nwm texturepacks premium chitin.key dialog.tlk xp1.key xp2.key
cp ~/Neverwinter/support/app/nwncdkey.ini ~/Neverwinter/nwn
  1. Move over the contents of the nwlogger, nwmovies, nwuser and nwmouse folders into the nwn subfolder:
cd ~/Neverwinter
mv nwmouse/* nwn/
-mv nwlogger/* nwn/
mv nwuser/* nwn/
mv nwmovies/* nwn
  1. Extract the Linux client files in this order and move over the King Maker game files:
tar xfv nwclientgold.tar.gz --directory nwn 
tar xvf nwclienthotu.tar.gz --directory nwn

mv -n kingmakertmp/\$0/* nwn/

tar xvf English_linuxclient169_xp2.tar.gz --directory nwn
  1. Compile and install nwmouse, nwuser, nwlogger and nwmovies. You need to patch nwlogger_cookie.c so that gcc finds the sys/user.h header file. We will also apply the libz.patch patch that we created before:
cp libz.patch nwn/nwmovies/
cd nwn
/bin/sed -i 's|linux/user.h|sys/user.h|1' nwlogger/nwlogger_cookie.c
cd nwmovies
patch < libz.patch
cd ..

./nwmouse_install.pl
./nwlogger_install.pl
./nwmovies_install.pl build
./nwuser_install.pl

cp nwmovies/libdis/libdisasm.so lib/ 
  1. Create the launcher script. Open your favorite text editor and paste the following:
#!/bin/bash

# Create user directory if it doesn't exist
if [ ! -d "$HOME/.nwn/"  ]; then
    mkdir $HOME/.nwn/
fi

# Uncomment to make SDL sound work on software mixers
#export SDL_AUDIODRIVER=esd
export SDL_MOUSE_RELATIVE=0
export SDL_VIDEO_X11_DGAMOUSE=0

# Hardware mouse cursor
export XCURSOR_PATH=/opt/nwn
export XCURSOR_THEME=nwmouse

# Enable AA on NVidia cards
# 3 = 1.5 x 1.5 super sampling
# 4 = 2x2 super sampling
export __GL_FSAA_MODE=4

export LD_PRELOAD=./nwuser.so:./nwuser64.so:./nwmouse.so:./nwmovies.so:./nwlogger.so

export LD_LIBRARY_PATH=./miles:$LD_LIBRARY_PATH
#run the game, allowing for executable flags
./nwmain $@

Save it as nwn.sh inside the nwn directory and make it executable, like so:

cd ~/Neverwinter/nwn
chmod +x nwn.sh
  1. Run the fixinstall script. It will rename a bunch of files and check file permissions. Look carefully at the output and make sure that all tests pass.
cd ~/Neverwinter/nwn
./fixinstall
  1. If you want to play movies, you need to put the BinkPlayer executables you downloaded into the nwmovies folder:
mv BinkPlayer ~/Neverwinter/nwn/nwmovies/
mv BinkPlayer64 ~/Neverwinter/nwn/nwmovies/
chmod +x ~/Neverwinter/nwn/nwmovies/BinkPlayer*
  1. Test the game by running ./nwn.sh. You will have to run it several times in order for the various nwlinux tools to intialize their configuration files.

You can now run the game with ./nwn.sh.

Optional: .desktop entry and icons

In this part we will create a .desktop entry so that you can run the game from your applications menu.

[Desktop Entry]
Categories=Game;
Comment=A Forgotten Realms CRPG
Exec=$HOME/Neverwinter/nwn/nwn.sh
Icon=nwn
Name=Neverwinter Nights
NoDisplay=false
StartupNotify=true
Terminal=false
Type=Application

Save it as nwn.desktop and move it to /usr/share/applications/:

sudo mv nwn.desktop /usr/share/applications/

Next we'll create icons to go with your shiny new desktop entry.

First we will convert the .ico provided by the GOG installer into the more usable png format:

cd ~/Neverwinter
mkdir icons
icotool -x -p 0 game/goggame-1207658890.ico -o icons

Then we'll install them into the system's icon folder:

sudo mv icons/goggame-1207658890_6_256x256x32.png /usr/share/icons/hicolor/256x256/apps/nwn.png
sudo mv icons/goggame-1207658890_7_48x48x32.png /usr/share/icons/hicolor/48x48/apps/nwn.png
sudo mv icons/goggame-1207658890_8_32x32x32.png /usr/share/icons/hicolor/32x32/apps/nwn.png
sudo mv icons/goggame-1207658890_9_16x16x32.png /usr/share/icons/hicolor/16x16/apps/nwn.png

Finally, we update the icon cache:

xdg-icon-resource forceupdate --theme hicolor

Credits

From the AUR:

Stephen Baker Slash <demodevil5[at]yahoo[dot]com> Adam Griffiths <adam_griffithsAATTdart.net.au>

From linuxgamecast.com:

Pedro Mateus: https://linuxgamecast.com/2015/11/l-g-c-how-to-installing-neverwinter-nights-linux-native/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment