Neverwinter Nights

Neverwinter Nights [L1 ] is a computer role-playing game (RPG) from Bioware that comes with a toolkit for creating your own game worlds and you can even build small-scale multiplayer persistent worlds using it (supporting around 50+ players). It has no particular connection with Tcl that I (NEM) know of, but I have recently been using it as a testbed for some intelligent agents research I have been doing. To help with this work I created a small Tcl package for parsing the binary file formats used to store game data (the formats are documented at [L2 ]). I imagine this is of limited usefulness to most people, but I will release the files anyway.

Download: http://www.cs.nott.ac.uk/~nem/tcl/

Usage

 package require Tcl 8.5
 package require nwn 0.3

 nwn module unpack $module ?directory? ?-progress $cmd?

        This command unpacks an ERF format file (e.g. a module or hakpak) to a
        directory on the disk, much like unzipping a .zip file. If the
        directory argument is not given then it defaults to the same name as
        the module file without the ".mod" extension. The -progress option can
        be given to specify a command to call for each file unpacked, passing
        in the number of files unpacked so far and the total number of files.
        This defaults to a simple text-based progress bar.

        EXAMPLE
        nwn module unpack modules/Rhun.mod

 nwn module files $module ?options..? {file chan size} $script

        Loop through each file in the module calling a script, passing in the
        name of the file, a readable channel positioned at the start of the
        file in the module, and the size of the file in bytes. The options
        available are:

        -progress cmd       Call a command for each iteration of the loop.
        -filter glob        Only loop through files that match the pattern.

        EXAMPLE
        # Equivalent to the "unpack" command
        nwn module files modules/Rhun.mod {file chan size} {
            set out [open $file w]
            chan configure $out -translation binary
            chan copy $chan $out -size $size
            close $out
        }

 nwn module areas ?-progress $cmd? {name area} $script

        Loop through each area in the module calling the script with the
        filename of the area and an array of information about the area taken
        from the corresponding .are and .git files in the module. See the Area
        File documentation from Bioware for a description of the fields
        available.

        EXAMPLE
        nwn module areas modules/Rhun.mod {file area} {
            puts "$file tag = $area(Tag)"
        }

 nwn gff parse $chan ?$offset?

        Parse a Generic File Format (GFF) file read from the given channel
        starting at the given offset (default = 0). The entire file is read
        and parsed into a nested dictionary data structure describing the
        toplevel struct in the file (and thus all other structures in the
        file). All data structures and transformed into corresponding Tcl data
        structures. 

 nwn gff parsefile $file

        Parse a GFF file from disk.

HJG 2012-03-30 - Download-Link gives error 404