Setting Up NWN to Preload Haks
Post Reply
User avatar
Pstemarie
Posts: 157
Joined: Sun Sep 12, 2010 6:42 pm

Setting Up NWN to Preload Haks

Post by Pstemarie »

As anyone knows who has been following the Development forum for NWN Enhanced, I have been working on putting together a HAK version and setting up NWN to preload the hak files.

Why Preload HAKs?
First, preloading HAKs is essentially an alternative method to using the override. Like the override, any resources that are preloaded will become available in ALL NWN games. This includes new content as well as content designed to overwrite standard resources.

Second, from the testing I've done, preloading seems to be more stable than using the override. Furthermore,
since both the Toolset and game load rather quickly, it appears that this method uses less memory than placing thousands of files in the override. This would seem to support Brian Chung's statement in this thread on the Bioware forums:
[INDENT]Not surprised - every file in your /nwn/override/ folder takes up memory as the game has to build up a resource table of what is in the core game, and then override it. When you start getting into the 1000's of files, this table can grow pretty large and suck up memory which can hamper performance.

Same for the localvault for your character files.

Not to mention disk fragmentation from so many small individual files, vs. packing them up into a HAK.
[/INDENT]
Lastly, I have run NWN (game and Toolset) using both the override and preload versions of NWN Enhanced in "windowed mode", with a 3rd-party utility running that monitors both CPU and GPU load. The preload version showed a greatly REDUCED load upon my system than when I was running the override version.


This fact alone makes preloaded resources much more stable for multiplayer and PW use.


How Is It Set Up?
Preloading uses both the patch folder and patch.ini - both of which you'll notice are empty files. Any HAK that is placed in the game's Patch folder (C:\NeverwinterNights\NWN\patch) then listed in patch.ini will be preloaded when the game or toolset starts.

As far as I can tell, load order for resources follows this priority:

  1. Core *.bif files
  2. Patch *.bif files
  3. patch.ini
  4. Override folder
  5. Module Haks
Therefore anything loaded from patch.ini will overwrite core *.bif resources (i.e. standard resources). Files loaded from the Override folder will overwrite core *bif resources as well as patch.ini preloads. Finally resources in module specific HAKs will overwrite anything lower in the above hierarchy.

The internal hierarchy of patch.ini is the opposite of the hierarchy tree used for loading module HAKs. Files at the bottom of the patch.ini internal hierarchy tree take precendent over files listed earlier in the tree. For example (using the NWN Enhanced patch.ini file):
[INDENT][FONT=Courier New][Patch]
PatchFile000=x4_textures
PatchFile001=x4_portraits
PatchFile002=x4_supersets
PatchFile003=x4_females
PatchFile004=x4_males
PatchFile005=X4_effects
PatchFile006=x4_items
PatchFile007=x4_monsters
PatchFile008=x4_placeables
PatchFile009=x4_scripts
PatchFile010=x4_2da[/FONT]
[/INDENT]The last file preloaded is "x4_2da". Any resources in this HAK will overwrite identical resources in HAKs listed earlier in the hierarchy tree. For example is both "x4_2da" and "x4_placeables" have a "placeables.2da" file, the "placeables.2da" from "x4_2da" will overwrite the version in "x4_placeables".

Also note that the filenames do NOT need the extension. Furthermore, it would appear that the files MUST have unique names. For example, when the files "x4_supersets", "x4_males", and "x4_females" were originally named "x4_anatomy1", "
"x4_anatomy2", and "x4_anatomy3" respectively; it appeared that only "x4_anatomy3" was loading. This would seem to indicate some sort of hardcoded value that the engine limits the number of strings the engine reads from the filenames in patch.ini. If the files are the same name upto this string value, only the topmost file is in the hierarchy is loaded.

Can Preloading Be Used With The Override Folder?
YES. In fact, the current build of NWN Enhanced I'm testing uses the Override folder to
load the templates for all the new creatures, items, and placeables included as part of Enhanced. This setup was required to prevent the templates from appearing on both the standard palette (which they have been added to) and the custom palette.

Is It Easy to Uninstall Preloaded Content?
YES. All you need to do is empty or rename your "patch.ini" file to something else. Alternatively, you can empty the contents of the Patch folder. If patch.ini can't find the resources, it doesn't load them.

Can Content Be Directly Preloaded From the HAK Folder?
YES, but you will need to add/change a setting in nwn.ini. Under [ALIAS] change:
[INDENT][FONT=Courier New]PATCH=.\patch[/FONT]
[/INDENT]to:
[INDENT][FONT=Courier New]PATCH=.\hak[/FONT]
[/INDENT] Now any files that you specify in the internal hierarchy of patch.ini that are in the HAK Folder will be preloaded when the game or Toolset starts.

Is There A Limit To The Number Of Files That Can Be Preloaded?
NO. At this time it appears that any number of HAK files can be preloaded using this method. However, this has not been fully explored and it is not known if the Module HAK limit applies to preloading through patch.ini.

---------------------------------------------
The foundation for much of this information was gleaned from this thread on the Bioware forums and some personal discussions with Ragnarok_mr4 and Brian Chung.

User avatar
Pstemarie
Posts: 157
Joined: Sun Sep 12, 2010 6:42 pm

Post by Pstemarie »

Scripts (.NSS and .NCS)
Apparently, preload HAKs have the same limitation as module HAKs regarding scripting - any edits made in the module to a script WILL NOT overwrite the HAK version of the script. Therfore, NWN Enhanced modified scripts have been removed from the preload HAK and placed in the override folder to allow editing by Builders.

Post Reply