* Note: This information is very old and may be invalid. *

Duplicating a NWN tileset

Overview

In this tutorial I''ll explain how to duplicate an entire NWN tileset. Once a tileset is duplicated, modifications can be made to the new tileset without affecting the original. Your newly created tileset will not have any default visual or sound settings. It will also not have any tileset specific doors. The new tileset is placed in a Hak Pak file that can be distributed to other players. I also present a Batch file that when combined with the gsar (general search and replace) tool will make duplicating a tileset a breeze.

Note: I have made every attempt to make this tutorial as easy as possible. However, it is impossible to list every click and keystroke. I think basic DOS and windows skills are necessary to complete these steps.

Before you start

Before you start you will need three things:

  1. The NWN Game
  2. A BIF extractor. Try the NWN Viewer by Zoligato
  3. A program that can search and replace text strings across several files. Try BK Replace EM or gsar - General Search And Replace utility. I suggest you use gsar in combination with the batch file I have below.

1) Extract necessary files

The files for a particular tile set are easy to find. First identify the tileset you wish to extract from the following list:

Name Tileset Prefix Mini-map Prefix BIF File
City Exterior tcn01 micn01 aurora_tcn.bif
Crypt tdc01 midc01 aurora_tdc.bif
Dungeon tde01 mide01 aurora_tde.bif
Mines and Caverns tdm01 midm01 aurora_tdm.bif
Sewers tds01 mids01 aurora_tds.bif
Castle Interior tic01 miic01 aurora_tic.bif
City Interior tin01 miin01 aurora_tin.bif
MicroSet tms01 mims01 aurora_tms.bif
Forest ttf01 mitf01 aurora_ttf.bif
Rural ttr01 mitr01 aurora_ttr.bif

The extract the following files from several locations:

  1. Extract every file from the listed BIF file that contains the listed prefix. For example the rural tileset prefix is ttr01. If you are duplicating the rural tileset extract every file that begins with ttr01 from the aurora_ttr.bif. These are the models, model textures, and walkmeshes.
  2. Extract every files that begins with the listed prefix from the bt_templates.bif BIF files (this should be two ITP files). These are the palette files. They control the list that appears on the right side of the toolset.
  3. Extract the XXX01_edge.2da file from the 2da.bif. This will allow the effect where the edges appear to continue off to infinity in the game.
  4. You may also wish to duplicate the images used in the mini-map. The map images are located in the textures_01.bif BIF file. They are prefixed with mi and then the tileset prefix minus the first "t". Example: the rural tileset is prefixed with ttr01, the map images associated with this tileset are prefixed with mitr01.

You will probably want to keep a master copy of the extracted files in permanent location as you may duplicate the same tileset more then once. Every time you want to make a new duplication make a copy of that directory.

2) Chose a new prefix

Since you don''t want to replace the existing tileset you will need to rename the files. If you are duplicating the rural tileset you may wish to use a prefix like ttr02 but any prefix with a similar pattern will do. You will need to keep your prefix < 5 letters and may wish to keep the AAA## pattern. Obviously avoid prefixes that duplicate existing tilesets. I suggest that you keep the first "t" as this stands for tileset (this becomes important when duplicating the mini map images).

Note: Steps 3 and 4 can be eliminated by using the dupe_set batch file and the gsar tool as discussed below listed below.

3) Search and replace

This is probably the most difficult part. The file references in the MDL and WOK files are in upper case but can actually be either case. The file references in the other files, however, must match the case of your files. Therefore, if your file names are lowercase (ttr02 for example) then you''ll need to reference ttr02 in all files other then the .MDL and .WOK files. Your best bet is to replace all cases of the old prefix with the lowercase version of the new prefix.

You need to replace all references in these files with references to the files with your new prefix. You have two methods to chose from (method two is much easier and avoids some additional complications):
1) You need to insure that you replace every instance of the old prefix with the new prefix while preserving the case (upper or lower)
or
2) replace all prefixes (regardless of case) with the lower case version.

Method one is more difficult to do and has problems with some mixed case prefixes (example tDC or Tdc). I''ll assume that you chose method two.

Use your search and replace tool to replace every instance of "ttr01" and "TTR01" (or "TTr01" and "ttR01") with your new prefix ("ttr02" for example). You may wish to exclude the TGA files from the search and replace.

Now if you wish to duplicate the mini-map images you need to do a search and replace inside the .SET file replacing the old map-images prefix with your new one. For example replace all mitr01 with mitr02.

4) Rename Files

Now you have to rename all the files to match your new prefix. Example: rename every ttr01 file to with the new prefix ttr01. At the command prompt type:

ren ttr01*.* ttr02*.*
to rename the files. You need to make sure that the new prefix is lower case.

If you are duplicating the mini-map images then you need to also issue the following command:

ren mitr01*.TGA mitr02*.TGA

Note: Steps 3 and 4 are combined in the following batch file. To use the batch file simple place the batch file and the gsar executable in the same directory as your tileset files. Then issue the following commands:

dupe_set ttr01 ttr02
or
dupe_set ttr01 ttr02 /mi
if you wish to duplicate the map images.
dupe_set.bat
@echo off
if "%1" == "" goto usage
if "%2" == "" goto usage

gsar -st%1 -rt%2 -o -i *.INI
gsar -st%1 -rt%2 -o -i *.SET
if "%3" == "/mi" gsar -smi%1 -rmi%2 -o -i *.SET
rem ^^^ to duplicate the map images.
gsar -st%1 -rt%2 -o -i *.WOK
gsar -st%1 -rt%2 -o -i *.MDL
gsar -st%1 -rt%2 -o -i *.ITP
gsar -st%1 -rt%2 -o -i *.2DA
ren t%1*.* t%2*.*
if "%3" == "/mi" ren mi%1*.* mi%2*.*
rem ^^^ to duplicate the map images.

goto end

:usage

echo .
echo Usage: dupe_set tr01 tr02 [/mi]
echo Only accepts the four letter prefix.  The beginning t is appended automatically.
echo /mi option will duplicate the map images.
echo This will replace the existing tileset (ttr01) to a new tileset (ttr02).
echo .
echo This version will duplicate the tileset and map images.
echo You need to extract *.TGA, *.MDL, *.WOK, and *.INI from the aurora_tXX.bif file
echo tXX01*.itp from the templates.bif file.
echo miXX01*.tga from the textures_01.bif for map images
echo .

:end

At this point you have successfully duplicated the tileset. However, the two tile sets are sill identical. You can now reskin your new tile set (see my tutorial Retexturing a NWN tileset).

5) Changing tileset names

At this point the two tilesets (your custom skinned tileset and the original) have the same display name in the toolset. The display name is controlled by the DisplayName=XXXX line in the .SET file. The XXXX is a StrRef. A StrRef is an integer number that refers to a text string in the dialog.tlk file. Right now I don''t know of any method of adding a new text string and StrRef combination without editing the Dialog.tlk file directly. The Dialog.tlk file can be edited but cannot be included in the Hak Pak. You would have to get all your users to agree to use the same Dialog.tlk (good luck).

Zoligato''s NWN NWN Viewer allows you to search for strings in the dialog.tlk file. If you want to distinguish your custom tileset from the original you can just search for a replacement name in the dialog.tlk. For example if I search for snow I get the following:

4995: Snowy
5000: snowy
5817: Snowdrift
4995 or 5817 might be a decent title for the winter tileset. Just set DisplayName to 4995 in the [GENERAL] section of the .SET file and the new tile set shows up as "Snowy" rather then "rural".

6) Place files in a Hak Pak

To get custom content into the toolset (or game) you need to place all the files into a Hak Pak. The Hak Pak editor is located in the "utils" directory of your NeverwinterNights installation.

  1. Open the Hak Pak editor
  2. Click Resource - Add (or press Ctrl-A)
  3. Select all the files you just created.
Place the Hak Pak in the HAK directory of your NeverwinterNights _AK directory.

Note: There is currently a bug in the way the NWN game handles Hak Paks and saved games. Games save while using a Hak Pak that contains ITP files cannot be loaded. The current workaround is to place the two ITP files in the override directory and do not place them in the Hak Pak. The ITP files are only needed for the toolset. So you can distribute the Hak Pak without ITP files to the players and they never need to touch the ITP files.

7) Create a Module using the Hak Pak

Now you will get to see the pay off of all your work.
  1. Open the NWN toolset
  2. Create a new Module (use any tileset)
  3. Select Edit - Module Properties
  4. Select the advanced tab.
  5. Select your Hak Pak from the drop down menu.
  6. Create a new area with your new tileset.

Good luck and have fun!

Optional

Here are some optional steps to add more content to your custom tileset.

Default visual and sound settings

The areag.ini file contains the default visual and sound settings for each tileset. If you wish to add default settings for your new tileset do the following (paraphrased from a post by Zilax on the Bioware forums).

Extract areag.ini from the bt_ini.bif file to the Override directory. Open areag.ini in notepad (or other text editor). Find the "[ENTRIES]" section. Add the line "Name011=ttr02" (or whatever you prefix is) to the bottom of the section in accordance with the pattern you see in that section. Go to the bottom of the file and locate the "[ttr01]" (or other section whose default settings you wish to copy) section. Copy and paste that whole section to the end of the file. Change the new sections name to "[ttr02]" (or whatever you prefix is).

Adding Default Doors

The dootypes.2da file contains the tileset specific doors. If you wish to add tileset specific doors for your new tileset do the following (paraphrased from a post by Zilax on the Bioware forums).

Extract the dootypes.2da from the bt_2da.bif file. Open the file in notepad (or other text editor). Copy numbered lines 1 thru 5 (if you are duplicating the rural tileset) in their entirety to the bottom of the list. Renumber the lines starting from the last number in the list. Edit the TTR01''s in the tileset column of the copied lines to match your prefix.

Problems

Missing Palette

If you are missing the tileset palette (the list of tiles on the right) it is probably because either you forgot to extract the ITP files of your did your search and replace using a program that doesn't work well with binary files.