NWN Dedicated Server

== Introduction ==
[http://nwn.bioware.com/ Never Winter Nights] (NWN) is a [[wikipedia:Computer_role-playing_game|RPG]] computer game created by [http://www.bioware.com/ BioWare Corp.]. It was initaly released for Microsoft Windows platform but BioWare has since then also released both servers and clients for both GNU/Linux and Apple Macintoch systems.

NWN also allows you to create your own worlds and maps (called modules) so you can extend the experiance of the game.

I bought NWN since it is one of the few RPG style computer games that has support for GNU/Linux system and run it mostly on my desktop computer. Just out of curiosity I wanted to setup a dedicated NWN server. Here is a description on the steps I performed.

== Preparing ==
=== Prerequisite ===
Computer Pentium II 233MHz with 256 MB, running Ubuntu 5.10 "Breezy Badger".

To use the script [[#nwncmd|nwncmd]] below you also need to install the package '''since''' (it is in the universe repository).

=== Create a daemon user ===
adduser --system nwnd

==== Getting the software ====
Get [http://nwn.bioware.com/downloads/standaloneserver.html NWN Dedicated Server].

[http://nwn.bioware.com/support/patch_standalone_linux.html Latest patch].

== Installing ==

$ mkdir neverwinternights
$ cd neverwinternights/
$ unzip -x ../NWNDedicatedServer1.66.zip
...
$ tar xvzf linuxdedserver166.tar.gz
$ ./fixinstall
Checking for required files
 
PASSED: data directory exists
PASSED: nwm directory exists
PASSED: chitin.key exists
PASSED: dialog.tlk exists
PASSED: nwserver exists
 
Fixing case
 
data
...............................
dmvault
.
hak
.
localvault
.
override
.
portraits
.
 
Checking for problem files
 
 
Checking for permissions
 
PASSED: nwn.ini is writable
PASSED: nwnplayer.ini is writable
PASSED: saves is writable
PASSED: localvault is writable
PASSED: dmvault is writable
PASSED: /home/nwnd/neverwinternights is writable
 
You are ready to run Neverwinter Nights.
$

Get and install the latest patch even if it says that it is the same version that you just downloaded.

=== Startup script ===
Create the startup script:

#!/bin/bash
# startnwserver 
# This file starts the nwserver as a backgound process.
#
NWNDIR=/home/nwnd/neverwinternights
 
NWNPIPE=$NWNDIR/nwserver.pipe
NWNLOGFILE=$NWNDIR/nwserver.log
MODULE="Chapter1"
SERVERNAME="Server Name"
 
 
if [ ! -d "$NWNDIR" ]; then
  echo "$NWNDIR is not a directory."
  exit 1
fi
cd $NWNDIR
 
if [ ! -p "$NWNPIPE" ]; then
  echo "$NWNPIPE does not exist.";
  mkfifo $NWNPIPE
fi
 
./nwserver -servername $SERVERNAME -module "$MODULE" < $NWNPIPE >> $NWNLOGFILE &
echo > $NWNPIPE

== Helper applications ==
=== nwncmd ===
This is a simple script that executes a server command by echoing it to the input pipe and then list the end of the log.

#!/bin/bash
# nwncmd 
# 
#
NWNDIR=/home/nwnd/neverwinternights
 
NWNPIPE=$NWNDIR/nwserver.pipe
NWNLOGFILE=$NWNDIR/nwserver.log
 
 
if [ ! -d "$NWNDIR" ]; then
  echo "$NWNDIR is not a directory."
  exit 1
fi
cd $NWNDIR
 
if [ ! -p "$NWNPIPE" ]; then
  echo "$NWNPIPE does not exist.";
  exit 1
fi
 
echo $1 > $NWNPIPE
sleep 1
since $NWNLOGFILE