CCG V3-1 Conversion:Part 2 Portraits

From NWN1 Custom Content Guide

Jump to: navigation, search

Contents

Character Portraits

Notes
  • I have started with the introductory text from version 1.0 of The Neverwinter Night’s NPC Portraits Tutorial by Conjumen and clarified, updated, and added relevant screenshots and detail that I felt were lacking.
  • Any omissions or errors are mine and not Conjumen’s.

This section covers the subject of portrait conversion and how you add portraits for a Player Character (PC) and a Non-Player Character (NPC) into NWN. Some of this material (at least the basics on PC Portraits) can be found on Bioware’s site (http://nwn.bioware.com/builders/portraits.html).

Part 1: Understanding How NWN Represents Portraits

Start with the best resolution portrait you have. You will need to make several versions of this image in different sizes. An image retains much better detail when scaling down than you can get when trying to enlarge an image.

You are going to have to make some changes to your base image to make sure that it meets the standards for NWN. It will have to be converted to an uncompressed, 24-bit, Targa Bitmap (TGA) file if it is not already in that format. Also, you will need images of the correct sizes.

There are a total of 5 different portrait sizes.

Size Suffix Required Image Dimensions(width x height) Used Image Dimensions (width x height) Displayed on...
Huge _h 256X512 pixel 256X400 pixel During character creation on the selection screen
Large _l 128X256 pixel 128X200 pixel Character sheet
Medium _m 64X128 pixel 64X100 pixel Your portrait on the main screen
Small _s 32X64 pixel 32X50 pixel Other party members on main game screen
Tiny _t 16X32 pixel 16X25 pixel Pop-up dialogue screen
Hints
  • If you choose to scan in your image, please learn how to use your image program’s tone balancing features to brighten the colors – I have seen too many dull, lifeless scans that could have been easily fixed with a little attention.
  • Also, after scanning, use a sharpening filter or mask to tighten the images up before you save them. Don’t do this on the original image, do it on each of the resized images before saving (sharpen works best as the last step because image resizing will often re-blur edges).
  • What to do with that blank space at the bottom? If it is original art, you can sign and date it there. It won’t show up in-game but it will always be there for future vanity sessions.

Part 2: Creating Your Portrait Files

Even though the game will only use 256X400 pixels instead of the full 256X512 (it simply ignores the remaining 112 height pixels), it is still important that you adhere to these 5 portrait sizes. It is important to know that the game uses 256X400 pixels when you are cropping a portrait or picture.

I will use Micrografx Picture Publisher to resize my portrait. There are lots of freeware and shareware image manipulation programs available (see the listing at the beginning of this document).

Here is the starting image (actually, this is a jpeg compressed image to conserve space in this tutorial – I’ll do that with all the photos I show here).

Image:Ccg fig 16.jpeg

Now, this image is too large (it is 400X492) for any of the portraits. We are going to resize it. It is also not in the right aspect ratio (400X492 is not proportional to 256X400, for example). We cannot fix this by resizing. We must crop as well. If we simply resize the picture to 256X400 in one step, it will be distorted. Not pretty. People’s faces get stretched or compressed and the resulting portrait looks very awkward.




Big Warning!
  • If custom portraits aren't saved in the correct uncompressed tga format, the game will crash when you try to save it (this also occurs when the game auto-saves – for example, at the end of a level).
  • If you are using custom portraits and have this problem, it is because some applications indicate that the tga is being saved as uncompressed, but they are not (e.g. InfraView indicates tga files are uncompressed but goes ahead and compresses them).
  • Try either removing the custom portraits to be able to save/load again, or try saving the portraits again in another application as an uncompressed, 24-bit, Targa Bitmap (TGA).

We start by resizing and then cropping again (to get the dimensions right). We will do this once for each image size, starting with the largest. There are many ways to do this – you won’t use the entire image and you can be creative about which pieces you keep. How much do I resize by? I want to keep as much of the face in this photo as possible because it is already cropped so tightly. So I will resize the image to get the height to 400 pixels for the huge image (not 512 pixels – that is the final file size) while keeping the aspect ratio constant so there are no size distortions. In Micrografx Picture Publisher I use Image | Size to do this and make sure that Allow Size Distortion is not checked.

Why did I choose the height and not resize to get the width to 256 pixels first? If I resized to the width first with no size distortions, my picture would only be 315 pixels high. This would be too short for NWN. However, depending on the original dimensions of your portrait, you may need to do the width first.

After I resized the height, I crop the width down to 256 pixels, giving me an even tighter crop on the face. Now I add the extra 112 pixels to the bottom of the file. It does not matter what color this extra data is. In Micrografx Picture Publisher I use Image | Expand to do this. I did not use Image | Size like I did before because that will stretch the whole image.

Image:Ccg fig 17.jpeg

Hint
  • If you use GIMP, check out http://NWNBuilders.com/. SamJones has created a script that automatically takes a portrait file and produces the five file sizes you need for portraits.

Save the file with the _h.tga suffix. And then do it again for each of the different sizes (if you want to use these as NPC portraits, you might want to read the next section about more detailed naming standards first, to save yourself trouble going back and doing it later).

Be creative. The smaller images do not need to show the entire portrait. You might choose to crop differently as you move to the smaller image sizes, having a fuller figure portrait or head-and-chest shot for the larger sizes but cropping down to a tight image of the face for the smaller pictures. I would do this so you retain some detail in the smaller photos instead of cutting them down to nothing more than an unrecognizable, tiny stick figure. I don’t show that technique here because my image is such a close crop on the face already.

Part 3: Using Your Portrait for a PC

Now that you have created your portraits, if you want to use them for a PC, just drop them into your /portraits subfolder of your NWN game directory. Note: for other people in a multiplayer game to see your character as you see it, they will also need a copy of your portrait files. Zip them up and mail them off to the other players. I would suggest using at least some of the naming standards that are applicable for an NPC below.

Part 4: Using Your Portrait for a NPC

It is a little more complicated to use the new portraits for an NPC. You need to set them up as resources available to your game. To do that, you need to follow certain naming standards. You must declare your portraits as available resources to the game. You do that in a 2da file just like we did for our trident in the previous tutorial. Then it is time to go back to the hakpak editor to bring all of the pieces together.

Hints
  • It is a good idea to keep the portrait name under 10 characters.
  • Some add a portrait title in the file name of their portrait like so: po_hu_m_TITLE_X.tga. You can use this naming system too, though it is recommended that you keep the characters to a maximum of 10.
  • Never add portraits to the /override folder, in fact never add anything to your /override folder.
  • You must keep the po_ and the _X (where X is the size of the portrait) extensions, when naming your portrait file(s). Otherwise your portrait will not work in NWN.

A Rose by Any Other Name

…would not work for NPC Portraits either.

You need to change your portrait filenames to meet the NWN standard. This is necessary because there are strict requirements in the portraits.2da file for NPC portraits.

If you extract a portrait from one of the data files in your NWN folder, you will see the NWN naming system. You should take advantage of this system, although some variation is allowed. The following is a description of this system.

The default or generic human male portrait in NWN is named po_hu_m_99_X.tga. The components stand for:

po_ Portrait
hu_ Human
m_ male (_f for female)
99_ Id number
X Image size identifier(h, l, m, s, or t)

You must keep at least two of these abbreviations: namely po_ and X. Say you have a portrait called halfelf.tga and it was divided into the 5 different Bioware standard portrait sizes in the previous step:

Hint
  • It is very important that the filenames are absolutely correct. Also, the names are CASE SENSITIVE. To make things a lot easier, make portraits with no capital letters.

JemyM

1.   Halfelfmale_h.tga
2.   Halfelfmale_l.tga
3.   Halfelfmale_m.tga
4.   Halfelfmale_s.tga, and
5.   Halfelfmale_t.tga.

They could be named like this:

1.   po_ha_m_37_h.tga
2.   po_ha_m_37_l.tga
3.   po_ha_m_37_m.tga
4.   po_ha_m_37_s.tga
5.   po_ha_m_37_t.tga

The Portraits Resource File

The resource file is where we indicate to NWN that our new portraits exist. Like we discussed in the weapon tutorial, I would suggest you open up NWN Explorer and select the 2da.bif file - but don’t do it. Use the portraits.2da file in your \source\2dasource.zip (remember that note earlier about Bioware patches?). Go ahead and take a look at it. You should see this:

2DA V2.0                                                                    
          BaseResRef    Sex    Race   InanimateType   Plot   LowGore       
0          ****          4      ****   ****            ****   ****          
1          dw_f_01_      1      0      ****            0      ****          
2          dw_f_02_      1      0      ****            0      ****          
3          dw_f_03_      1      0      ****            0      ****          
4          dw_f_04_      1      0      ****            0      ****

These different entries are the resources available to the game as portraits. Every resource has several columns attached to it. Check below to find out what the different columns represent:

Column Description Values
An integer ID# identifying the portrait internally. When choosing an ID for a .2da file, use one of the User999 rows.
BaseResRef Refers to the base resource for the model that this portrait represents. Refer to Appearance.2da. They are used in the Aurora Toolset filter when adding a portrait file to an NPC.
Sex Gender, actually. The number comes from the first column in the 2da file gender.2da from the 2da.bif file (you can view the contents of this file using NWN Explorer as well).
0   Male
1   Female
2   Both
3   Other
4   None
Race This number is used for the toolset filter when selecting a portrait for your NPC. The number comes from the first column in the 2da file racialtypes.2da from the 2da.bif file (you can view the contents of this file using NWN Explorer).
0   Dwarf
1   Elf
2   Gnome
3   Halfling
4   Half-Elf
5   Half-Orc
6   Human

Etc. **** if it is a placeable and not a creature

InanimateType The type of placeable. Refers to placeabletypes.2da
0   Battlefield
1   Containers
2   Military
3   Misc
4   Misc_Interior
5   Parks_Nature
6   Penants_Signs
7   Trades_Academic
8   Visual_Effects

**** if it is a creature and not a placeable

Plot Is this a plot portrait? Generally no.
0   if no
1   if yes

**** if it is really a placeable anyway (1 equates to TRUE if you know C or C++)

LowGore The portrait to use in place of this one if the game is set to low gore mode. If you create a really messy portrait, find or create a substitute, low gore, portrait here. Portrait name (generally **** for creatures).

Your First NPC Resource

Hint
  • The reason that the number is 572 in the PL entry is because in v1.26 or so, Bioware added some reserved spots for user portrait updates. Use them.

Begin editing the portraits.2da and adding a new resource, so your portrait can be recognized by the game.

I have created an elven female portrait with the file names ‘po_el_f_50_X.tga’, where X represents the size of the portrait.

Add the last line you see below, under the resource ID 571 (the first User999 space)

570        kobb_         4      15     ****            0      ****          
571        koba_         4      15     ****            0      ****          
572        el_f_50_      1      1      ****            0      ****
Hints
  • It is a good idea to copy a line similar to the one you want to add and use it as a starting point. As an example if you want to add a new female elf, the resource ID you would copy would be entry number 30.
  • The reason for the extension _50_ in the example above is that the last elven female portrait number (that you can use) is 14, so a new portrait would have to start at > 14. I chose 50 for the same reason we use 2001 in the 2da file.

As you can see I’ve omitted the po_ and the X (where X is the size of the portrait) in the resource entry. This is why, earlier, we told you that you had to start and end your portraits with that prefix and suffix. Also the extension .tga is not necessary either. The game already knows that the prefix it should use is po_, the suffix is h, l, m, s or t, and the extension required for all portraits is .tga.

So to conclude, you do not need to add po_ and _X (where X is the size of the portrait) to the resource entry.

Your New Portrait(s) and The Toolset

Now that you have created your portrait TGA files in the standard formats and edited the portraits.2da file, it is time to add them to a hakpak. Refer to the appendix for detailed instructions on using the hakpak editor.

Open the hakpak utility. Now that it is opened, choose Resource | Add. Now you add your modified portraits.2da file and your new portraits (with all its 5 sizes) to the hakpak. All the files should now be displayed in the hakpak window. If you’ve only added one portrait, there should be a total of 6 files in the hakpak now.

Add a title to your hakpak, and a description of the contents. Save the hakpak.

Image:Ccg fig 18.jpeg

Hints
  • Sometimes the Aurora toolset gets confused about hakpaks. The best way to load or reload a hakpak is to close and re-open your module.
  • To add a new hakpak to a module, save and reload your module after adding the hakpak.
  • If you have modified a hakpak and want to use the modifications, save and reload your module again.
  • Sometimes you need to close the Aurora toolset entirely and restart it.
  1. Open up the Aurora Toolset. If it was still open from before, save and close the module and toolset then re-open the toolset.
  2. Create a new module or open an existing one.
  3. Select Edit | Module Properties…
  4. Click on the Advanced tab.
  5. From the drop-down for the Hak file, add your hakpak. If it does not appear in the drop-down, your hakpak is probably not in the /hak folder of your game directory.
  6. Save and close the module and then reload it.
  7. Select the Area you created.
  8. Create a new NPC using the Creature Wizard.
  9. Select Next.
  10. Select Elf and Next.
  11. Select a Class and Next.
  12. Select Female, and then press the Select Portrait button.

Image:Ccg fig 19.jpeg


« Weapons | Character Portraits | Voice Sets »

Main Page | CCG TOC

Personal tools