Game development

On this page you will find various projects and sourcecode snippets that I have made for various games.
Here are primarily scripts and 3rd party utilities for the first version of Neverwinter Nights. Most are from the period 2004-2006 where I was lead programmer and server admin of the persistent gameworld NCS-LegendForge.

3rd party utilities

NWN Portrait Database Application


The portrait application was an attempt to make a web based solution to exchange character images so that everyone would have each others portraits to see in-game.
To support the software devil it was based on ASP and an Access Database thus making it incompatible with the Apache/MySQL-dominated world of today - Yes, I should have known better...
Nonetheless it worked great as proof-of-concept.

A more throughout explanation can be found at the portrait application section.
NWN Character Modifier


The Character Modifier Plugin is a collection of internal NWScript's and external Java functionality for letting a player modify a Player Character in a server vault without the need for direct access.
The following character modifications are supported Note that you will need the updated Abyss 404 Server Log Command System found on this page.

modifier_readme.txt
modifier 0.5.rar
Abyss 404 Server Log Command System


This is my modification to beta 9 of the original Server Log Command System written by Andrew Wang (http://abyss404.d2g.com/) which I used for dealing with special character types in a PW. This version is modified to work with newer patch versions of NWN.
More specifically, this version disables the functions regarding readback of data through 2da files (as NWN can no longer read data during runtime, due to caching).

l404_b9-tazar-r1.rar
Batch-script for incremental, timestamped backup of logs
This is a simple batch-script for storing timestamped backups of the NWN client logs, which may be useful in saving interesting gaming sessions.
It works by starting the NWN client, and saving a backup after the game exits.

StartLog.cmd - Windows NT/2000/XP version.
StartLogW9x.cmd - UNTESTED Windows 9x version.
Server status checker
A host-side perl/shell script for Linux used to poll a NWN server over the networking, outputting static HTML with the servers player count. The script need not to be run as the same computer as the server. I am not author of the original Perl-script, but I can't remember where I got it from.
Produces output like

Last server query: Mon May 7 18:55:01 CEST 2007
NCS Legend Forge (IP 80.62.178.206)
Players 1 / 10

Could for instance be run every 5 minutes by the following crontab entry:

*/5 * * * * root nice -n 19 /opt/nwnded/check_status

(you may omit the nice setting). There's more info that can be obtained from the perl script (look for the line containing "$lvlout==3").

check_status - Shell script
new_status.pl - Perl script
Linux server startup/shutdown scripts
Here are some example scripts on how to running a NWN server and support utilities (in this case, the Abyss l404 log system) on Linux. The server and utilities are run in each their screen session, by executing "./serverstart" which make simple calls "_spawnServer.sh" and "_spawnLogger.sh". These two are responsible for creating the screen sessions named respectively "server" and "logger". The "server" session runs "_nwnstartup.sh" making the final call to the NWN server. "logger" calls the "_startLogCheckerThread" responsible for starting the java-based Abyss L404.
The server may be stopped again by executing "serverstop" or "serverstopbrutal" (the former allows the server to shut down gently, while the other kills everything asap).

serverstart
serverstop
serverstopbrutal
_nwnstartup.sh
_spawnLogger.sh
_spawnServer.sh
_startLogCheckerThread.sh
Two different flavours of log parsing
First a very simple log parser. It's a simple shellscript, that just greps for the "Joined" part of the log and writes the corresponding name.

parselog.sh

Next is a more advanced log parser written in Python which parses a server log and calculates the total number of playerjoins, the number of unique players seen and number of killed creatures. A list of players and the number of times they've joined the server is created along with a list of killed creatures (including players). A sample output is

Joins: 695
Killed creatures (including players): 10710
Unique players seen: 70
-----------------------------------------------------------------
List of players and the number of times they've Joined the server
-----------------------------------------------------------------
Player1,111
Player2,85
....
--------------------------------------------
List of killed creatures (Including players)
--------------------------------------------
Elite Orc Archer,338
Rat,313

It's thus very useful for keeping track of your playerbase and what kind of creatures they hate the most. The script is run with no parameters (it assumes a copy of the server log renamed to log.txt". It sends it's data to standard output.


logparser.py

Useful NWScripts

PW-related
Part of the core systems for the NCS-LegendForge PW server.

inc_debt.nss - XP Debt scripts for creating a debt to a character at death, avoiding deleveling.
inc_ilr.nss - Custom Item Level Restrictions, replacing Bioware's hardcoded default. (A chart over the character level vs. item cost can be found here)
inc_penalty.nss - Pretty standard XP penalty scripts, showing usage of the XP debt scripts
inc_periodicsave.nss - Simple periodic servervault storage of characters.

You can also download all of these with dependencies in ERF-format.