You are here

Combining HAK Packs

Author: 
Zarathustra217 (Edited by Bandito)

Hakpaks are much like conventional file archives, like those made with WinZip. They are a number of compressed files combined into a single file. NWN will allow only one hakpak per module, so this is why hakpak combining often is needed. We cannot add custom content in an acceptable way without hakpaks.

You might know many things in this tutorial already, but I've tried to make it understandable to even the newest newbie. I hope that it will answer a lot of questions that you have about this subject. And keep in mind that English is not my native language, so spelling and grammar may be a bit fussy.

OK, here's how to combine two or more hakpaks.

Exporting the files:

First, check if the two hakpaks share any files. This is done by opening the nwhak program, which is located in 'utils' folder of NWN (default: C:\NeverwinterNights\NWN\utils\nwhak.exe). Open two sessions of the program (simply by starting the program twice). Then open a hakpak in each session, by clicking 'Open' in the 'File' menu, and then select a hakpak for each window. If they do not share any filenames, this will be really easy:

You select all files in one of the hakpaks, and from the 'Resource' menu you select 'Export'. It's recommended that you create a new folder for the exported files, or it might be a bit confusing. It will ask you where to save each file in the hak, but simply save them all in the same folder with the names that the original files had. Repeat this step for each hakpak you want to include, and extract them to the same folder. If they did not share any file names, you wouldn't have been asked to overwrite anything. Simply move on to 'Combining the files'. Every file from the two hakpaks should now be in a single folder.

If there were any shared file names, this becomes a bit more complicated, but not impossible. The most common files that share names are those of the type 2da (with the file extension 2da, like 'appearance.2da'). If this is the case export the two 2da files into two separate folders, and the rest into a shared folder.

The 2da's should now have a folder for each hakpak, and the other files from the hakpaks should be in a separate and single folder.

(Other than 2da's, cases of name sharing are extremely rare, so I won't bother to explain what to do if that was the case. I can give you a hint - you'll have to rename one of the files and then edit the 2da where it's referenced.)

2da's:

2da files are in fact 2 dimensional arrays (that's what the names suggest, I think). It's like any table you've made in Excel or other spreadsheet applications, with lines and rows, but it doesn't contain any locked rows. It's simply text. They can be read in notepad (a program that always comes with Windows), and all other programs to view documents. I still suggest that you use Notepad, as other programs might use formatting or UNIX end-of-lines. Don't bother much about what that means, you don't need to understand what UNIX is to combine hakpaks... I know that I don't... :o)

The 2da's found in most hakpaks are most likely not all new 2da's, but a modified versions of NWN original 2da's. NWN uses the 2da's to locate files and know rules for objects in the game. Each line have a number, and when NWN reads a module containing an object, it would look into the line of that number the object is referring to, to see what models, rules and files are attached to that object.

A good way to find out what has been modified in a custom 2da is by comparing it with NWN's default 2da's. The most common 2da's can be found in the 2dasource.zip in the NWN folder (Use a program like the aforementioned WinZip to open this. http://www.winzip.com/). Find the 2da matching the names of the 2da's that are causing the hakpak combine problem by sharing names, and extract it to where you put those other files from the two hakpaks.

You should now have a folder for each hakpak with the 2da that is sharing name, and a folder with all the other files and the original 2da from 2dasource.zip.

Compare each custom 2da with the default from NWN in Notepad. When you open a 2da you will notice a lot of information, but on the left side, you'll see that each line below the header starts with a number, starting with 0 and is increasing down through the 2da. Example from appearance.2da:

2DA V2.0  

           LABEL                   STRING_REF   ...
0          Dwarf                   1985         ...
1          Elf                     1986         ...
2          Gnome                   1987         ...
3          Halfling                1988         ...
...        ...                     ...          ...

As you see the appearance labeled 'Dwarf' has the number '0'. These numbers are actually the only ones we need to notice when combining 2da's... at least in most cases. When comparing each 2da with the default, look for lines containing a higher number than the end number of the default 2da. These would most likely be placed at the bottom of the custom 2da. Copy that entire line or lines and place it at the bottom of the default 2da that you've extracted. Don't worry about modifying this, as when you extracted it from the 2dasource you actually only extracted a copy. (You can copy the line by placing the blinking cursor at the start of the line in the custom 2da, then holding down shift and press the down key for each line that is unique for the custom 2da. Hit crtl+c to copy. Then open your extracted default 2da and move the blinking cursor to the bottom of the document and hit ctrl+v)

Repeat this for each of your custom 2da's, so that your extracted 'once-default' 2da now contain the unique lines for each 2da. Now look through the numbers of these lines, and make sure that they don't match. I prefer to continue the numbers from where the default ended, so that if BioWare's lines ended with 389, my first custom line would be 390, the next 391 and so on. This does not modify the info that the lines contain in any way. When that is done, save your 2da and close.

Combining the files

Ok, firstly make sure that the folder where you exported the files from each hakpak contains all the files used in the two hakpaks and nothing else. In the case of shared 2da's, make sure that the folder contains your own 2da's made as described above instead of those from the original hakpaks.

Open nwhak, but don't open any hakpaks. From the 'Resource' menu select 'Add'. Mark every file in the folder you created for this combined hakpak and click the open button. All the files should now be listed in the nwhak window. Give it a 'Title' and perhaps an URL (a link to a home page), and explain the contents in the 'Description'. Make sure to mention the authors of the original hakpaks. Now click 'Save' in the 'File' menu, and write the file name you want your hakpak to have. To use it, it has to be placed in the 'hak' folder of NWN and if it doesn't work, try reading this tutorial again, looking for anything you might have done wrong. And if it still doesn't work, try posting at BioWare's NWN forums in the Custom Content forum... People are very willing to help...

If it works, well congratulations on your new hak pak! May your modules from now be even more beautiful and imaginative than before you read this tutorial...

Thank you for reading, it's been a joy writing.

Zarathustra217

(Edited by Bandito... thanks a lot man!)

Migrate Wizard: 
First Release: 
  • up
    66%
  • down
    34%
Proleric
Proleric's picture

The initial premise is wrong.

A module can have many hakpaks.

The loading sequence defined in the module properties ensures that if a filename occurs in more than one hak, the version nearer the top of the list is used.

To look for duplicate files, export each hak into its own folder, then compare them (WinMerge is a handy free tool for this).

2da files are the most common issue. The usual approach is to compare them, then make a master 2da containing all the lines from both sources. The master 2da goes in a new hak at the top of the module properties (a "top hak").

For tilesets, .set files may need to be merged - any decent tileset tutorial will explain this.

If there are other files with the same name but different contents, that needs to be investigated case--by-case.

The important point is that you don't needto merge all the hak contents. Just add all the haks to the module in the desired order, with, if neccessary, a top hak containing any 2da files or suchlike that actually need merging.

See Custom Content Guide for more.

  • up
    100%
  • down
    0%
Dreadlord_Anwyn

If you have two 2das that are using the same lines for different sets of data, then are they just incompatible or can you fix that?

Like I have two 2da's for doorsets and two of the lines are for two different models of doors.

Im not sure, can you just make some new lines at the bottom and insert two of the conflcting door set lines down there instead?

  • up
    50%
  • down
    50%
Proleric
Proleric's picture

Yes, you can move the duplicate lines to new line numbers at the end - or to currently unused lines (the ones with asterisks in all the fields).  

For compatibility, it's best to avoid lines which are used by, or reserved for, CEP etc.

As long as you do that before you start building, you're good to go.

Remember that the line number is usually what is actually stored in objects. So, for example, if you paint door A in an area, then renumber the 2da so that door B now has that number, on reopening the area it will contain door B. Usually easy to fix in the toolset or using moneo, but obviously unnecessary line number changes are to be avoided.

  • up
    100%
  • down
    0%
Dreadlord_Anwyn

Is there a tutorial you would recommend for merging set files?

 

edit - I think Ive figured it out already haha thanks.

  • up
    50%
  • down
    50%