===============================================
=== The River of Time / Drakensang - N2Tool ===
===============================================
v1.10 by JOG

N2Tool ist a commandline tool used to modify N2-Files.

Main purpose is retexturing single-object N2-Files (e.g. weapons) as well as to readout, 
modify and reattach single entries from multi-model N2-Libraries 
(e.g. add a green "KGIA" shirt to female.n2, in addition to the blue one) 


N2Tool has the following functions:

- modify Single-Object N2 files as well as separated GfxSkin entries from N2-model-libraries
- extract GfxSkin entries from N2-libraries into a separate file
- modify the GfxSkin entries while extracting
- re-attach the modified GfxSkin entries to the N2-library.
- remove GfxSkin entries from the N2-library.



STANDARD-MODE
--------------------------------------------
N2Tool [options] n2file [target]
--------------------------------------------

In standard mode, N2Tool only expects a file name.
You may use the wildcards '*' and '?' if the search-criteria apply to several files,
all of them will be modified, one after the other.

Without further parameters, only the current values are displayed. N2tool discerns between N2-files
and the extracted GfxSkins created by the GET-command. The later have a header-name in addition to
the texture names and floating point values

If N2Tool fails to recognise the file structure, or if the file is larger than 20 kilobyte, it stops
with an error message. If the file contains several model-entries, only the first one will be modified.

If a target file is specified, this file will be created as a modified copy of the n2-file.
Without a target-file a backup of the original file will be created instead.

The following options may be used to modify the N2-file:

 -n:<text>     Cheange the GfXSkin-name. (Only valid for GfxSkins created with the "GET" command.)

 -tc:<color>   Change the "Color-Map" (texture) to this file. (Path starting at export\textures)
 -tb:<bump>    Change the "Bump-Map" (depth/3d structures) to this file.
 -ts:<spec>    Change the "Specular Map" (reflection) to this file.
 -te:<emsv>    Change the "Emissive Map" (Glowing) to this file.

 -#ei:<value>  The "Emissive Intensity" (luminosity of the glowmap) is set to the specified floating point value.
 -#si:<value>  The "Specular Intensity" (strength of reflection) is set to the specified floating point value.
 -#sp:<value>  The "Specular Power" (concentration/satiation of the reflected light) is set (floating point value).
 -#bs:<value>  The "Bump Scale" (increasing/decreasing the bump map's 3D-effect - floating point value).


Two additional options determine backup handling.

 -b:<text>  Instead of ".bak", the specified text will be used for the backup's file extension
            (e.g. with "-b:shirt.bak", the backup's name will be "female.n2.shirt.bak".)
            If the first char is a dot, it will be ignored "-b:.shirt.bak" is equal to "-b:shirt.bak".

 -nb        No backup will be created.  


Options may be put at any place in the program call.
Instead of a colon (:) you may use an equal sign (=) as well.  
Floating point values are acceptable with a decimal point as well as a decimal comma. 



COMMANDS
========

In standard mode, only single-model files (e.g. weapons) can be modified.

To change model collections (e.g. clothes, faces) you use the commands GET (extract),
ADD (insert), MOD (extract, modify and insert) and DEL (delete)

These commands can be put at any place in the program call, just like options.

For the file-name, the wildcards '*' and '?' can be used as well, if several files
are found, only the first one will be modified, though.



GET - Extract
--------------------------------------------
N2Tool [options] GET n2file GfxSkin [target]
--------------------------------------------
Extracts a GfxSkin-entry from an N2-Library

 n2file    The N2-File (e.g. "female_n2") from which will be read.
 GfxSkin   The name of the entry that will be extracted (Under "GfxSkin" in the database)
 target    (Optional) The target-file to save to. If no target-file is specified one will be created
           based on the GfxSkin's name (e.g. "torso_cl_hemd_dieb.itm")

 Options:

 -n:<text>     Cheange the GfXSkin-name. (Required to create a new entry)

 -tc:<color>   Change the "Color-Map" (texture) to this file.
 -tb:<bump>    Change the "Bump-Map" (depth/3d structures) to this file.
 -ts:<spec>    Change the "Specular Map" (reflection) to this file.
 -te:<emsv>    Change the "Emissive Map" (Glowing) to this file.

 -#ei:<value>  The "Emissive Intensity" (luminosity of the glowmap) is set to the specified floating point value.
 -#si:<value>  The "Specular Intensity" (strength of reflection) is set to the specified floating point value.
 -#sp:<value>  The "Specular Power" (concentration/satiation of the reflected light) is set (floating point value).
 -#bs:<value>  The "Bump Scale" (increasing/decreasing the bump map's 3D-effect - floating point value).

 -a[:<target>] The target-file will not be overwritten, instead the output will be attached to the target file.

The parameter -a is useful to create one file that has several modified entries and insert it into the N2-file
with one single ADD command. (So only one backup will be created) 

Alternatively to a third main parameter, the name of the target file may also be specified here. Since the
default-name oi the GfxSkin name, it is reasonable to specify a target file when using the option -a to read
the same entry from different N2-files (e.g. male.n2 and female.n2)

Postprocessing in standard-mode isn't possible on such files, since only the first entry could be modified.





ADD - Insert
----------------------------------------------
N2Tool [options] ADD n2file ADDinFile [target]
----------------------------------------------
Adds the GfxSkin entry to the N2-Library

 n2file    The N2-File (z.B. "female_n2") to be modified.
 ADDinFile The file with the data to attach (created with GET and modified if need be) 
 target    (Optional) Instead of modifying n2file, the output will be saved to this alternative target file.  

 Options:

 -b:<text>  Instead of ".bak", the specified text will be used for the backup's file extension
            (e.g. with "-b:shirt.bak", the backup's name will be "female.n2.shirt.bak".)
            If the first char is a dot, it will be ignored "-b:.shirt.bak" is equal to "-b:shirt.bak".

 -nb        No backup will be created.  




MOD - Extract and Insert
------------------------------------------------
N2Tool [options] MOD n2file GfxSkin [target]
------------------------------------------------
The data will be read from the N2-file and attached immediately afterwards.
This function only makes sense when changes are made at the same time.

 n2file    The N2-File (e.g. "female_n2") from which will be read.
 GfxSkin   The name of the entry that will be extracted (Under "GfxSkin" in the database)
 target    (optional) the temporary target file for the extracted data, will be deleted afterwards.    

All options described for GET and ADD are valid here as well. If you use the option -a and specify an existing
target-file, this target-file will be extended by the extracted data and then attached to the n2-file as a whole.
In any case the target file will be deleted afterwards.




DEL - Delete
----------------------------------------------
N2Tool [options] DEL n2file GfxSkin [target]
----------------------------------------------
Removes an entry from a N2-Library

 n2file    The N2-File (z.B. "female_n2") to be modified.
 GfxSkin   Name (GfxSkin) of the entry to remove
 target    (Optional) Instead of modifying n2file, the output will be saved to this alternative target file.  

 Options: 

 -b:<text>  Use the specified text for the backup's file extension
 -nb        No backup required




Examples:
==========

Reading out the GfxSkin "torso_cl_hemd_dieb" to edit it in standard-mode or using hex-editor  
> N2Tool GET female.n2 torso_cl_hemd_dieb  


Extracting the GfxSkin "torso_cl_hemd_dieb" and changing the GfxSkin-name as well as the texture
> N2Tool GET female.n2 torso_cl_hemd_dieb -n:new_shirt -tc:my_mod\new_shirt.dds


Including the file we just created to female.n2 so that we can use it ingame
> N2Tool ADD female.n2 torso_cl_hemd_dieb.itm


Extract and modify as above, using a specified file name. 
> N2Tool GET female.n2 torso_cl_hemd_dieb my_shirt.itm -n:new_shirt -tc:my_mod\new_shirt.dds


Attaching a second modification to the file we just created 
> N2Tool GET female.n2 torso_cl_hemd_dieb -a:my_shirt.itm -n:second_hand_shirt -tc:my_mod\used_shirt.dds


Including the file with the two shirts:
> N2Tool ADD female.n2 my_shirt.itm


Alternatively: Attaching a third variant and including afterwards
> N2Tool MOD female.n2 torso_cl_hemd_dieb -a:my_shirt.itm -n:filthy_shirt -tc:my_mod\well_used_shirt.dds


Deinstalling one of the shirts we just installed
> N2Tool DEL female.n2 second_hand_shirt



Extracting the GfxSkin "torso_cl_hemd_dieb" and specifiying a glowmap with high intensity
> N2Tool GET female.n2 torso_cl_hemd_dieb -n:glow_shirt -te:mein_mod\glow_shirt_emissive.dds -#ei:3.14159265

Viewing the current values in the file we just created
> N2Tool torso_cl_hemd_dieb.itm

Reducing the luminosity and renaming to "shirt_with_luminous_embroidery"
> N2Tool torso_cl_hemd_dieb.itm -#ei:1.23456 -n:shirt_with_luminous_embroidery


--------------------------------------------------------------------------------------------
MISC
--------------------------------------------------------------------------------------------

N2Tool is a COMMANDLINE program, starting it from the explorer has no effect at all.

For commandline-haters and as template for mod-installation the file "N2tool_demo.bat" is included.
Copy N2Tool and this batch file into the same folder as the N2-File you want to modify, change the
SET entries in the BAT and start it.

set oldname=  The GfxSkin-name of the original model
set newname=  The new GfxSkin-name 
set color=    The texture (Path starting at export\textures)
set bump=     bump-map
set spec=     specular-map


--------------------------------------------------------------------------------------------
CREDITS
--------------------------------------------------------------------------------------------
Gerald - On whose resarch this tool bases on.


--------------------------------------------------------------------------------------------
VERSIONS
--------------------------------------------------------------------------------------------

v1.00   (27.04.10) 
        
v1.10   (08.05.10) 
        - Added retexturing option for "emissive-map"
        - Added functions to set Emissive Intensity, Specular Intensity, Specular Power and Bump Scale
        - New standard-mode to edit single-model N2-files (e.g. weapons) as well as extracted GfxSkin files
