NSS Files

Script files are simple text files and as such can be edited with any text editor. They contain the raw, uncompiled scripts. Script files have the file extension *.nss. NSS files are not executable. They have to be compiled to NCS files with nwnnsscomp first.

The scripting language is called Nwscript and its syntax is a subset of C. The most notable difference to standard C is the absence of pointers and arrays.

Note that there's not an NSS file for each and every of the game's NCS files. nwnnsscomp does come with a limited decompiler but it can only translate the opcodes into human readable form. It cannot restore the NSS from which the NCS was created.

The majority of the NSS files cannot be compiled as such because they're includes that cannot be executed all by themselves. Includes can be spotted by the  in their file names.

Any script - include or main script - may contain an unlimited number of includes:


 * 1) include "j00_i_reward_cbt"

Main files have a  function that is - unlike all other functions - executed automatically. The main function must not return a value. Its return type must be set to :

void main { // code... }

In addition to main files there are conditional scripts. Conditional scripts must return a value of type :

int StartingConditional { return 1; // 1: true - 0: false }

Conditional scripts are used exclusively in dialog files to decide which branch of the dialog options to choose under what circumstances.

To compile a NSS file into a NCS file so it can be executed by game engine, use this command: nwnnsscomp -c filename.nss Only NSS files with either of main or StartingConditional routine can be compiled. Ones without them, considered as include file that should be used from other NSS files by #include.

To get opcode of a NCS file, use this command: nwnnsscomp -d filename.ncs It won't return the script the way NSS files 're written, but the PCODE file can be used as reference to manually do reverse engineering NCS file into NSS file.