CCG V3-1 Conversion:Part 1 Weapons
From NWN1 Custom Content Guide
Weapons
Let’s start by modeling a new weapon. I want to be able to create Wave, the trident from S2 – White Plume Mountain. We will start by creating a simple trident head and test it out. Then, after we have it working, we will tweak the content to add additional features.
Where do we begin? Well, it usually helps to start with something that at least vaguely resembles the final product you want to create – at least until you have done a few of these. We would start with an existing Bioware model but NWN does not include a trident as a standard weapon. But wait, a spear is similar to a trident (a pointy thing on the end of a long stick) and you attack with it in a similar motion (by jabbing the sharp end at your opponent). So we will start with a spear as our base model.
Part 1: Understanding How NWN Represents Weapons
Let’s look at how NWN represents the different components of a weapon by actually building an existing one in the Aurora Toolset. Try this exercise:
- Open up the Aurora Toolset.
- Create a new Module (we will call it Weapon Tutorial for lack of a better name). Use the Area Wizard to create at least one Area. Use the defaults to set up the area and choose something simple like a Castle Interior.
- Select Wizards | Item Wizard.
- For Item Type select a Spear (we will talk about the standard weapon types later in this section).
- CLick Next.
- Enter a name(Trident).
- Click Next.
- Add to the Weapons, Polearms category (we will talk about the standard categories later in this section).
- Click Next.
- Check the Launch Item Properties checkbox.
- Click Finish.
- Select the Appearances Tab.
You can now modify the appearance of the item. The options you choose correspond to the different Model Ids and Position Codes.
Take a closer look at the Appearance tab. Note that there is both a 3D model (used in the game engine to render a character actually wielding the weapon) and a 2D icon (used in the game engine for the inventory functions).
What you don’t see directly is that each of these models is actually made up of three distinct pieces (top, middle, and bottom). By mixing and matching these pieces, you can create a lot of unique weapons with the basic items included in the game. In our example, the basic spear consists of the spearhead (top), the shaft (middle), and an end cap (bottom). A sword consists of the blade (top), the guard (middle) and the hilt (bottom).
While we are here, play with the Model and Color values. By changing the Model values, you can change the shape of each component. By changing the Color values, the shape of each part does not change but you can change the color of each component.
Now that you understand the different parts of a weapon model, let’s get started.
Part 2: A Rose by Any Other Name
…would not work in NWN.
We are going to model our trident on the existing short spear weapon. Remember, it is generally easier to start from something you know and build your content from there. Where do I get the standard weapon models used in NWN? What about NWVault? Sorry. While you will find a few models on the vault that are NWN-ready, most are in other model formats. So, while they may look nice, they don’t work directly in the game.
So where do I go? That’s what NWN Explorer is for. The content is already stored in the NWN game, you just have to learn how to access it.
- Open up NWN Explorer.
- Select File | Open Neverwinter Nights.
- Use File | Open Neverwinter Nights to open the game files. You will use the File | Open… option later for opening individual custom content files. Don’t open the NWN .BIF files directly using File | Open… - if you do, NWN Explorer will not show all of the context information with each file.
- Click on the boxed ‘+’ sign beside NWN Main Data from the tree on the right.
|
What you get is a listing of all of the core content files for NWN. Each BIF file (Binary Information File) is a packed file like the hakpaks we talked about earlier. They contain standard NWN content.
If you look through these you will find that the core NWN models are stored in two files:
- data/models_01.bif
- contains the character and creature models
- data/models_02.bif
- contains the armor/model pieces, placeable items, and weapon models
We will use data/models_02.bif because we want the weapon models.
Model Type
Scroll down, way down. What you want are the models that start with w.
Weapon models are named using the format: wxxyy_z_nnn. The prefix represents the model type for a weapon. The remainder of the name represents the weapon class and name for the model.
Weapon Class and Name
After the w, the next four characters (wxxyy) describe the class and name of the weapon:
| xx | Model class |
| yy | Model name abbreviation |
For example, wplss_t_011 equates to:
- w for weapon
- pl for polearm
- ss for short spear
We’ll get to the _t_011 part in a moment. First, here are the standard weapon resources for data/models_02.bif:
| Type | Class | Name | Maps to |
| W | Weapon | ||
| AM | Ammo | ||
| AR | Arrow | ||
| BO | Bolt | ||
| BU | Bullet | ||
| DT | Dart (I don’t think this is really valid because it does not appear in the baseitems.2da file). | ||
| AX | Axe | ||
| BT | Battle Axe (two-handed) | ||
| GR | Great Axe | ||
| HN | Hand Axe (one-handed) | ||
| BB | ? | ||
| QS | ? | ||
| BD | ? | ||
| QS | ? | ||
| BI | ? | ||
| MI | ? | ||
| BL | Bludgeoning Weapons | ||
| CL | Club | ||
| FH | Flail, Heavy | ||
| FL | Flail, Light | ||
| HL | Hammer, Light | ||
| HW | Hammer, War | ||
| ML | Mace, Light | ||
| MS | Morningstar | ||
| BW | Bow | ||
| LC | Longbow, Composite | ||
| LN | Longbow | ||
| SC | Shortbow, Composite | ||
| SL | Sling | ||
| SH | Shortbow | ||
| XH | Crossbow, Heavy | ||
| XL | Crossbow, Light | ||
| XR | Crossbow, Repeating | ||
| DB | Double-handed | ||
| AX | Double Axe | ||
| MA | Dire Mace | ||
| QS | Quarterstaff | ||
| SW | Two-bladed Sword | ||
| MG | Magic | ||
| RD | Rod | ||
| ST | Staff | ||
| WN | Wand | ||
| PL | Polearm | ||
| HB | Halberd | ||
| SC | Scythe | ||
| SS | Short Spear | ||
| SP | Special | ||
| GA | Gauntlet? (I don’t think this is really valid because it does not appear in the baseitems.2da file). | ||
| KA | Kama | ||
| KA | Kukri | ||
| NN | Nunchuka (I don’t think this is really valid because it does not appear in the baseitems.2da file). | ||
| SC | Sickle | ||
| SP | ? (I don’t think this is really valid because it does not appear in the baseitems.2da file). | ||
| SW | Sword | ||
| BS | Bastard Sword | ||
| DG | Dagger | ||
| GS | Great Sword | ||
| KA | Katana | ||
| LS | Longsword | ||
| RP | Rapier | ||
| SC | Scimitar | ||
| SS | Shortsword | ||
| TH | Throwing | ||
| AX | Throwing Axe | ||
| DT | Dart | ||
| SH | Shuriken | ||
| WB | ? | ||
| LC | ? |
Position Code
Okay, sounds easy enough so far. But what are all those other numbers and letters I see in data/models_02.bif (the _t_011 stuff)?
We have already looked at how NWN represents the different components of a model by looking at the item properties under Appearance for a custom-created item. The options you choose correspond to the different model types in the data/models_02.bif file.
First is the position code. We know there are three position codes for each weapon:
| t | top |
| m | middle |
| b | bottom |
So in the earlier example, wplss_t_011 equates to the top piece (the head) of the short spear.
Model ID
There is a specific format for the id as well: nnz. There are two characteristics:
| nn | Model (although I’ve not seen the first character anything other than zero and I have had trouble getting past 09) |
| z | Color/Texture (right now the ones typically supported are 1 = metal, 2 = brass, 3 = wood) but you can add your own |
So in the earlier example, wplss_t_011 equates to the first model # and the initial color (usually metal, followed by bronze/brass/gold, followed by wood) of the top piece of the short spear.
Special Models
Now you understand the weapon models and their naming conventions. Well, almost. What about some of those other models with names like waxbt_fxacid? There are special purpose models for special effects:
| _mb | The motion blur model |
| _fxacid, ect. | special effects (acid, etc.) – shows the game engine where to render the colored mist or flames that envelop different models |
| _blur | Ignore this model type. This looks like it is another type of motion blur model but it is not. It is not used for anything and is a vestigial model left from earlier game development days |
| _000 | Ignore this model type as well. It looks like a normal weapon model but it is not valid. It is a vestigial model left from earlier game development days as well |
So waxbt_fxacid shows the model for a weapon, an axe, in fact a battle axe, corresponding to the effect you would get if that battle axe were magically enchanted to drip acid.
There are a few weapons (e.g., the bullet) that do not have the full 3 parts. These are represented with a format of wxxyy_nnn. Just exclude the Position Code.
Part 3: Creating the 3D Model
|
|
|
So with all of that in mind, I am going to create my models for a trident. If I look at the spear models, the first thing I see is that the standard shaft (m as in middle) and end (b as in bottom) models for a spear work just fine for a trident. So I’m just going to create a new model for the head of the spear (t as in top). Here are the basic steps using gmax. Directions may vary according to your software.
- Open NWN Explorer.
- Select File | Open Neverwinter Nights.
- Select data/models_02.bif from NWN Main Data.
- Scroll down and select the model wplss_t_031.mdl.
- Right click on the row and select Export.
- Save the file to a new directory. This is a binary model file. You cannot easily open or read it in binary format.
- Open a command prompt window.
- Run NWNMdlComp –d wplss_t_031 on the binary model file to convert it to an ASCII model file (it should have the name wplss_t_031.mdl.ascii).
- Open gmax. The NWN MDL Tool pane should automatically open on the left side. If it does not, load it manually using Maxscripts | Run Script…
- Load the spear model into gmax by opening the Import MDL sub-menu in this pane (not the File | Import… function) and using the Browse pushbutton to select the ASCII file you created in step 6.
- You can minimize the MDL window after you open the file. Take a close look at the model you loaded. Note the relative size and position of the model. This is important because the relative orientation and offset of your model now will be used when the game engine renders your weapon in three pieces. The reason your spearhead is not centered at the origin (0, 0, 0) of the gmax space is because it must be far enough out to rest comfortably on the tip of the spear’s shaft model (the middle piece). You must keep it there; otherwise it will not appear to be attached to the rest of the weapon when the game engine assembles the three models later.
- Note the base item. This is used by the import/export scripts to link special attributes to models (animations, etc.). The spearhead is a child mesh of the base. Don’t change the name of the model for now, or of the base (this is important for now – we will change it for later models). The spearhead model has a name of wplss_t_031.
- Now modify the standard spearhead or replace it with your trident model (read the tutorials for gmax to see how to actually create 3D models).
- If you created a new model, be sure to link it to the base item as a child object.
- Open the Export MDL sub-menu of the NWN MDL Tools pane. Select Export MDL.
- Wait? Where is my exported file? It didn’t even ask for a filename. The gmax import/export utility does not have the ability to write files. What it does is dump an ASCII version of your model to the MAXScript Listener. What you need to do is open MAXScript | Listener… and then copy and paste the listing into a text file. Save it as wplss_t_031.mdl<tt> and you are done.
- Copy your <tt>wplss_t_031.mdl file to the /override directory of your game installation. If you used a .tga file as a texture, put it in the same directory.
- Open up the Aurora Toolset. If it was still open from before, save and close the module and toolset first then re-open it.
- Open your Weapon Tutorial module.
- Select the Area you created, and then the Item icon on the right toolbar (it looks like a sword).
- Choose the Custom tab.
- Your original spear should be under the Weapons, Polearms category.
- Right click Trident and then select Edit from the pop-up menu.
- Select the Appearance Tab.
- Select Top model 3 if it was not already selected. I also chose the Bottom model 4 (one of the default models) because I like the bladed end better than the rounded model #1. And I made the shaft gold (color 2).
- Click OK and then save your module.
This is what you get when you look at your spear. It is starting to shape up. There are a couple of problems with this model that say we aren’t done.
- Note the picture on the right side – it still looks like a spear with a default spearhead! Where is our trident? We need to create a 2D weapon icon to fix this.
- Now all basic spears using model 3 will look like tridents because we have overridden the default spear model. We need to change a few more things to fix this problem as well.
- Our trident is actually a spear. It will work fine this way but we may want to actually add an entirely new weapon, a trident, rather than piggy-backing on the spear forever.
- "FIller for the end of section note"
| Note on ResetXforms:
Have you ever opened up one of your creations in NWN and found it does not look like what you saw in your modeling tool? Too big? Too small? Parts blown out of proportion or disappearing? Sounds like you have a problem with advanced transforms. This subject is so frequently discussed and so problematic I thought I would pull it out into its own flagged section. Let me start by discussing why you need to care about resetting transforms. Gmax and 3ds Max can hold information about your object (whether or not parts of it are mirrored, which directions normals really point, how it is scaled and rotated, etc.) that is not exported with your model in a way that NWN can understand or use. What this means is that what you see in Max may not be the same as what you see in NWN. For example, objects can be transformed (scaled, rotated or moved) either in world space or in sub-object space. Transforms in sub-object space take place when you transform vertices, edges, faces, polys or elements of an object (or all of them at the same time). Transforms in world space take place by selecting your object at the highest level and transforming it. What this means is that if you rotate an object in world space, it will not be rotated when you export it to the game. Or moved (transformed).Let me repeat that in different words because this part is key: Bioware's NWN engine does not read world space transforms! As you can imagine, this might be a huge problem. One way to fix this problem is to do all of your transforms at the sub-object level. However, this is only a partial solution because the same problem occurs with other operations as well (for example, mirroring objects often inverts the direction of their normals or faces). The good news is that there is a way around it. In Gmax or 3dsMax you can do a ResetXform operation on all the pieces of your model and then collapse each of these modifiers onto your editable mesh. By doing this, you are turning this complex transformation information into something simpler that NWN can understand. In practical terms it means what you see in Max and what you see in NWN are more likely to be the same. ResetXform can be found on the Utilities panel. Use the ResetXform utility to push object Rotation and Scale values onto the Modifier Stack display and align object pivot points and bounding boxes with the World coordinate system. Reset Transform removes all Rotation and Scale values from selected objects and places those transforms in an XForm modifier (no, really, it will). You can then collapse the modifier into your object and away you go. Some notes on ResetXform:
So let me summarize: if your object appears differently in the game than it did in 3dsmax or gmax you probably forgot to reset the transforms on it. Make sure your object is unlinked and then use ResetXforms on the Utility Panel to clean it up before proceeding. |
Part 4: Creating the 2D Weapon Icon
Let’s start by fixing that picture. NWN 2D icons must be 32-bit Targa Bitmap (.tga) files (with an alpha mask channel). Once you understand how the 3D weapon models are named, the 2D icons are easy. Just add an i to the beginning of the 3D name. For example, iwplss_t_011 equates to the 2D icon of the model # 1 and color # 1 (usually metal, followed by #2 bronze/brass/gold, and #3 wood) of the top piece of the short spear.
There are two game files that contain all of the textures:
- data/textures_01.bif
- data/textures_02.bif
You may need to use both. Use data/textures_02.bif for axe and short sword icons. The rest of the icons are in data/textures_01.bif.
How big do I make the icon file? Note that in this example the icon for the spear top is 32 x 128 pixels. But the different icons can be different sizes, just make sure they are a multiple of 32 and that all the pieces for a specific weapon are the same size. In the case of our spear, we will use the same 32 x 128. Why do we need to do this? We do it for the inventory management system of NWN. Each box on the inventory grid is 32 pixels x 32 pixels. Our models have to align with this grid perfectly. Again, I suggest using an existing model to start.
Creating a Trident Icon
|
I use the same basic process to create the 2D icon as I did for the 3D model:
- Open NWN Explorer.
- Select File | Open Neverwinter Nights.
- Select data/textures_01.bif from NWN Main Data.
- Scroll down and select the file iwplss_t_011.tga.
- Right click on the row and select Export.
- Save the file to the directory with your 3D model.
- Open the .tga file with an image manipulation program. I use Micrografx Picture Publisher because it came with my scanner and does most of what I need. Modify the standard spearhead or replace it with your trident model. Keep the name the same (this is still important for now). Don’t use any of that black space below the model – when the game overlays the middle and bottom pieces it will use that space. I chose to do a screen print of my 3D model as it shows in the Aurora Toolset, shrink it down, paste it over top of the sample file I extracted using NWN Explorer, and then tweak the image to get it to look cleaner and brighter.
- Now, to do the overlays of the 3 model pieces, NWN uses a mask channel to know which portions of the bitmap to lay down. What you need to do is create this mask channel for it before you save your image. Details on how to do this will vary depending on the software you use. Using Picture Publisher, it has a magic wand for creating a mask. I start by creating the mask of the black space surrounding the image (magic wands work best if given a single color to encapsulate). Then invert the mask so that it is a mask of the trident head instead of one excluding it. I could have done a mask directly of the trident but it has many colors and I would probably have needed to zoom in and select the mask area manually.
- Now save your image as a Targa Bitmap. Again, be careful. I needed to select Options first and explicitly tell Picture Publisher to save the mask channel. Otherwise it just saves the image as a 24-bit Targa file instead of a 32-bit one with mask.
- Close and re-open your saved file in your image program. If the mask is still there you got it right. If not, try again.
- Copy the new iwplss_t_011.tga file into your /override directory.
- Open up the Aurora Toolset. If it was still open from before, save and close your module first, then close and re-open the toolset.
- Open your Weapon Tutorial module.
- Select the Area you created, and then the Item icon on the right toolbar (it looks like a sword).
- Choose the Custom tab.
- Your spear should be under the Weapons, Polearms category.
- Right click Trident and then select Edit from the pop-up menu.
- Select the Appearance Tab.
- Your trident should now have a 3D model and a 2D icon. If you only have the head of your trident in the 2D icon, your mask was probably not done properly and NWN is overlaying the other two components with your entire image file. Check the mask again and repeat these steps.
Part 5: Using a Hakpak
Up until now we have been using the /override directory to load our new model and icon. This overrides the standard spear model 3 for any module you play. There are two shortcomings to this approach:
|
- Using the /override directory is the wrong way to override content (except as a quick way to test your changes).
- You are replacing an existing model. This is a common way of adding new custom content (select an existing object that you do not plan to use in your module and replace it with your content). But it does not allow you to use the overridden item in that module. And your new model must behave exactly the same as what you are replacing (same damage dice, etc.)
We will examine more sophisticated ways of adding new weapons. We are going to introduce two new concepts here:
- Using a hakpak to load the content into NWN for a specific module (instead of using /override which affects all modules you play on your machine)
- Adding a new spear model (instead of replacing an existing model).
Start by moving your files out of the /override directory. Don’t forget this step! This is one of the reasons I strongly recommend against using the /override directory – it is too easy to forget and leave things in it. A month from now you will be wondering why one of your spears looks like a trident in spite of everything you do to change it.
|
- Move wplss_t_031.mdl and iwplss_t_031.tga from the /override directory. We will put them in a hakpak instead.
- Rename the icon file we just created as iwplss_t_051.tga (don’t put it in the /override directory!). That way they will not override model 3.
- Go back and resave your model file as wplss_t_051.mdl. You should change the internal model name to be wplss_t_051 as well. You can do that either from within gmax (change the name of the model from WPlSs_t_031). Or, open the .mdl file with a text editor and changing all instances of wplss_t_031 to wplss_t_051.
- Create a new hakpak (see appendix for instructions).
- Add your model wplss_t_051.mdl and icon iwplss_t_051.tga. If you used a .tga file as a texture, add it as well (if you used the standard w_metal_tex.tga, you do not need to include it again because it is already in the game).
- Save your hakpak.
- Open up the Aurora Toolset. If it was still open from before, save and close the module and toolset then re-open the toolset.
- Open your ‘Weapon Tutorial’ module.
- Select Edit | Module Properties… and click on the Custom Content tab.
- 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.
- Save and close the module and then reload it.
- Select the Area you created, and then the Item icon on the right toolbar (it looks like a sword).
- Choose the Custom tab.
- Your spear should be in the Weapons, Polearms category.
- Right click Trident and then select Edit from the pop-up menu.
- Select the Appearances Tab.
- Switch the top model type to 5 and you are done. It should look the same as it did before. Now I can use all four original spear models and the trident.
|
Part 6: The Weapon Resource File
|
There is one major problem outstanding: our trident is actually a spear. It looks like a trident. You fight with it like a trident. But in its heart-of-hearts, it is a spear. We can fix that, too.
What we have to do is add a new weapon resource in the baseitems.2da file (2da stands for ‘2 Dimensional Array’ because each .2da file is a matrix of rows and columns). This will allow us to define an entirely new type of weapon. This is a similar procedure we will use for other custom content as well.
I would suggest you open up NWN Explorer and select the baseitems.2da file from the data/2da.bif file. But don’t do it. Bioware has made changes to the .2da files as part of their patching process. Your best bet is to always get 2da files from \source\2dasource.zip. Or, you can download all the SoU 2da files from the Custom Content forums on http://nwn.bioware.com/. So, instead,
- Copy the new baseitems.2da file from \source\2dasource.zip to the directory with your model and icons.
- Open baseitems.2da using a text editor – Notepad works fine although some people use Helios Software Solutions' TextPad (http://www.textpad.com/). Turn off Wordwrap in the Format menu so everything aligns nicely.
- Go ahead and take a look at it. Scroll down until you get to the shortspear entry. You should see this:
|
| 57 | 1551 | towershield | 2... |
| 58 | 1552 | shortspear | 1... |
| 59 | 1553 | shuriken | 1... |
- These different entries describe the many items in the game. I don’t show all of the columns here because there are too many.
- Copy the shortspear entry and paste it at the bottom.
- Modify the entries as appropriate for your new weapon.
- Table ?????????.???
| Column | Desciption | Values |
| ID | An integer ID# identifying the weapon internally. | I chose 200. When choosing an ID for a .2da file, Bioware has suggested padding guidelines so that if they add a new resource later, they do not overwrite yours. For baseitems.2da they suggest starting at line 200. |
| Name | A string reference to dialog.tlk containing the name for your weapon. | My first thought is that this should be **** (should tell the game engine to use the label for a name). However, this does not work. Instead, I went for a jog through dialog.tlk (it is a big file) and found that some forward-thinking individual at Bioware actually included many of the unused weapon names so I chose 67251 (Trident). If you can’t find the right name for your weapon, re-use one of the other weapon names. This will give it the same name as that item in the Item Wizard (more on this issue at the end of this section). |
| Label | The internal programmer’s label for your weapon. | I chose Trident. Use ‘_’ underscore instead of spaces if necessary. |
| InvSlotWidth
InvSlotHeight | Inventory slot width and height, measured in number of inventory grid squares. | Make sure it matches the size of the icon you created earlier (in our case 1 x 4 because our icon is 32 x 128). Each inventory grid square is 32 x 32 pixels.
Note that the icon must be a power of 2 so if your If your slot width and height is is 1 x 3 squares, the icon actually needs to be 32 x 128 (and not 32 x 96). The lower part of the icon will not be used. |
| EquipableSlots | Identifies which slots you can equip the item into. This is a hexadecimal value. You must identify all of the appropriate slots, add together the values, and enter the corresponding hex value into this column. |
0x00000 – Not equipable 0x00001 – Helmet 0x00002 – Armor 0x00004 – Boots 0x00008 – Arms 0x00010 – Right Hand 0x00020 – Left Hand 0x00040 – Cloak 0x00080 – Left Ring 0x00100 – Right Ring 0x00200 – Neck 0x00400 – Belt 0x00800 – Arrow 0x01000 – Bullet 0x02000 – Bolt 0x1C000 – Creature Weapon 0x1C010 – Two-handed Weapon 0x1C030 – One-handed Weapon 0x20000 – Creature Armor |
| CanRotateIcon | 1 if inventory icon for this item may be rotated 90 degrees clockwise, such as when placed on a player's quickbar. If the inventory slot is bigger than 2x2, you *MUST* set the canRotate icon column to 1 if there is any chance that the item will have a Unique Power (i.e., will go in the Quickbar) – otherwise the game will crash. |
0 if no 1 if yes |
| ModelType | Defines how the item's model and icon are constructed. |
0 – simple (e.g., torch) 1 – layered (e.g., helmet) 2 – composite (weapon) 3 – armor |
| ItemClass | Name of the new model you have created (without the _t_001 extension). | I used WPlTr to create a new class. Refer to your naming standards for the basics. |
| GenderSpecific | Are there gender specific versions of this item? No for everything except armor. I can’t for the life of me explain why arrows are gender specific, the one exception to this rule. Female characters get a different kind of arrow? That just seems… politically incorrect. |
0 if no 1 if yes |
| Part1EnvMap
Part2EnvMap Part3EnvMap | Defines how the environment map is applied to the alpha channel in the model's textures.
There is one map for each of the three weapon parts: Part 1 – bottom Part 2 – middle Part 3 – top | 1 will apply the environment map, giving you reflective surfaces. This is used for metal surfaces.
0 will not apply the environment map. This is for wood-like textures and is typically used on the handle of a mace, etc. **** not applicable. This is used for items that do not have 3 pieces or that do not have an actual model. |
| Default Model | The default model for when the item is laying on the ground. | Typically it_bag. |
| Default Icon | Does not appear to be used for anything | **** |
| Container | Is the item a container? |
0 if no 1 if yes This only true for one item, the ‘large box’. This same item is also used to create ‘large bag’ items like the magic bags of holding. Go figure. |
| WeaponWield | Identifies the animations a character uses to wield the item. |
1 Non-weapon 4 Two-handed items (e.g. halberd) 5 Bow 6 Crossbow 7 Shield 8 Double-headed weapons 9 Creature weapon 10 Dart and sling 11 Shuriken and throwing axe **** Standard weapons where the item cannot be wielded or is a melee weapon that is held in one or two hands depending on the size of the creature wielding it. |
| WeaponType | The type of weapon and type of damage it does. |
0 None 1 Piercing 2 Bludgeoning 3 Slashing 4 Slashing and Piercing |
| WeaponSize | Size of the weapon. |
1 Tiny 2 Small 3 Medium 4 Large 5 Huge |
| RangedWeapon | Index to the type of ammunition used by a ranged weapon.
Note: it does not appear to be possible, at least as of v1.29, to create a new ranged weapon. It is possible to replace an existing ranged weapon with a new one. | This can point to either another item (for items that are projectile weapons - e.g., 20 for an arrow) or to the item itself (for items that are thrown – e.g., 59 for a shuriken).
**** if this is not a ranged weapon. |
| PrefAttackDist | The preferred attacking distance when using this weapon. The distance is selected so that attack animations look their best in the most commonly anticipated situations. | **** if not a weapon |
| MinRange | The minimum number of weapon models of this type. Used to tell NWN the part number to scan for in the toolset. | The actual value to put in here for a weapon is the range you want x 10 because for weapons the model number if the first two digits only (which has a range from 01 to 25) |
| MaxRange | The maximum allowed number of weapon models of this type. Most weapons have a limit of 10 models (and 3 colors). The game will ignore any models higher numbered than this figure unless you change this value. | For weapons, the actual value to put in here is the range you want x 10. So it is 100 for most weapons. If you want 11 longswords instead of 10, make it 110.
For other items this field is not multiplied by 10 because the model number is not driven by the first two digits. This has a limit of 255 (i.e., it is a one-byte integer) so you cannot have more than 25 weapons of one type. Or 255 of other items. |
| NumDice
DieToRole | Number of dice to roll of type… | E.g., for damage of 2d6 you would put 2 in NumDice and 6 in DieToRole
**** for non-weapons. |
| CritThreat | Chance out of 20 that you will get a critical hit: |
20 only 1 19-20 2 18-20 3, etc. **** for non-weapons. |
| CritHitMult | Damage multiplier if you get a critical hit. | I chose 2 (if you look in the PHB, a spear has a critical hit multiplier of 3 but a trident is only 2)
**** for non-weapons. |
| Category | I haven’t quite figured this one out. It appears to be related to the Category definition in other tables (like spells.2da) where it defines what the item is used for. This is used for the AI engine to allow NPCs to properly use the item if equipped with it. |
0 - none 1 - melee 2 - ranged 3 - shield 4 - armor 5 - helmet 6 - ammo 7 - thrown 8 - staves 9 - potion 10 - scroll 11 - thieves' tools 12 - misc 13 - wands 14 - rods 15 - traps 16 - misc unequippable 17 - container 19 - healers |
| BaseCost | Basic cost in gold pieces for a non-magical, standard item. For weapons it maps back to the cost in the PHB.
As soon as you start adding magical properties to weapons, the cost goes up accordingly. That is what the cost line items in the item property definition tables account for. | See ItemMultiplier for additional information. |
| Stacking | Number of identical items that can be stacked together in your inventory (this is why you get 99 arrows in a bundle, 10 potions, etc.) | |
| ItemMultiplier | Multiplies the BaseCost to give the actual item cost. | If you look at the BaseCost field for a shortsword, for example, it is set to 10. The ItemMultiplier for shortsword is set to 2. The in-game cost for shortsword is 20.
Set the ItemMultiplier to 3, and the shortsword costs 30 in-game. (tested by Zimero) |
| Description | StrRef of basic description when examining an item of this type, if the item is unidentified, or if there is no description for the item in its Description CExoLocString Field. | Use 198 (0 no longer works because with SoU this gives a Bad StrRef text). This leaves the description blank because there is no entry for a trident description in dialog.tlk. In the next section I will show you how to use a blueprint to overcome this problem in a different manner. |
| InvSoundType | The sound made when clunking items around in your inventory. | Refer to inventorysnds.2da for detailed values.
0 – Armor 1 – Shield 2 - Wood Melee Weapon 3 - Metal Melee Weapon 4 - Ranged Weapon 5 – Ammo 6 – Potion 7 – Paper 8 – Treasure 9 - Generic The resref is contructed in the following way: Non-Armor XX_YYYYY XX = PU or DR for pickup/equipping and drop/unequpping. YYYYY is hardcoded to correspond to one of the above inventory sound types. |
| MaxPropsMinProps | The maximum and minimum number of spell properties that an item can have. This can be seen in the item properties page where scrolls, wands, etc. can cast 1 spell and most other items are able to hold up to 8. Other properties are not included in that max, only cast spells. | For some items, the min/max values are 1/1, implying they must have one property (like a scroll). For most others it ranges from 0 to 8.
I don't know what would happen if you tried to set something to have more than 8 since there is only room for that many around the radial menu without have sub-menus. |
| PropColumn | This column determines what properties can be assigned to a given item. | Refer to itemprops.2da. However, this is not an index to the row in that table, it is an index to the column. For example, melee weapons at column 0 can have almost any property assigned to them, but torches at column 20 can only have light.
**** if the item cannot have properties. |
| StorePanel | The panel of the merchant inventory that this item shows up in. |
0 – Armor and clothing 1 – Weapon 2 – Potions 3 – Scrolls 4 - Miscellaneous |
| ReqFeat0 to ReqFeat4 | The feats required to use this weapon. |
44 Exotic 45 Martial 46 Simple 48 Druid 49 Monk 50 Rogue 51 Wizard |
| AC_Enchant | The type of AC bonus this item provides. |
0 Dodge 1 Natural 2 Armor 3 Shield 4 Deflection |
| BaseAC | The standard or base AC bonus that this item imparts. Shields use this column but armor does not. |
AC1 (e.g., Small Shield) AC2 (e.g., Large Shield) AC3 (e.g., Tower Shield) |
| ArmorCheckPen | The penalty to your skills that equipping this item makes (refer to skills.2da; skills affected are those with a 1 in the column ArmorCheckPenalty). | This is actually the penalty on a d20 roll. E.g., a 1 is a 5% penalty. 2 is a 10%, 10 is a 50%, etc. |
| BaseItemStatRef | String reference to dialog.tlk for a description of the statistics of this item (e.g., required feats, critical hits, etc.) in text form. This goes below the weapon in the inventory when you identify the item. | I use 198 (59 no longer works because it was used in SoU by another text description. This leaves the description blank because there is no entry for a trident’s statistics in dialog.tlk. If we left in the description for a spear we would be close (but no cigar). In the next section I will show you how to use a blueprint to overcome this problem in a different manner. |
| ChargesStarting | Starting # of charges | 0 for most items. 50 for wands, etc. |
| RotateOnGround | An indicator that tells you how to rotate the model so it lays flat on the ground (e.g., you don’t want a sword standing on its edge when you lay it down). | 0 Do not rotate (this is used for most items without models)
1 Rotate 90 deg. about y axis (this is used for most weapons) 2 Rotate 90 deg. about x axis (this is used for crossbows and potions) |
| WeaponMatType | Type of material the weapon is made out of – used to define the sound the weapon makes against different types of armor. | Refer to weaponsounds.2da for detailed listings of the different items. |
| AmmunitionType | Type of ammunition the weapon uses. | I think this should map to ammunitiontypes.2da but everything seems offset by +1.
1 – arrow (0 in ammunitiontypes.2da) 2 – bolt (1) 3 – bullet (2) 4 – dart (3) 5 – shuriken (4) 6 – throwing axe (5) |
| QBBehaviour | Determines the behaviour when this property appears on the player's quick bar. |
0 – default 1 - select spell, targets normally 2 - select spell, always targets self |
| ArcaneSpellFailure | Increased chance this item will cause a spell failure. | Only values are used for shields. |
| TenthLBS | Weight of the item in tenths of pounds (take the weight from the PHB and multiple by 10). | There is a bug with this field: 255 is the maximum value for this field (a weight of 25.5 lbs). Anything over that becomes mod 255 (i.e., resets back to 0 at 256 and goes up again). It appears that this is only a one byte integer value whose max value is FF hex = 255 decimal.
An alternate solution, if you really must have a heavier item, is to add the Base Item Weight Increase property in the toolset (depending on the item you may have to open this option up by adding the flag in itemprops.2da). |
%AnimSlashL %AnimSlashR %AnimSlashS | % of the time that your character will use this animation type when wielding this weapon. | % chance to use the left-slash, right-slash, or stab animation when using this weapon.
**** if the item is not a melee weapon. Left-Slash and Stab should add up to 100, and Right-Slash and Stab should add up to 100. The Left and Right slash percentages are the chances of doing that move if the wielder is in the already proper stance. For example, a creature in the right-ready combat animation can only left-slash or stab, and after a left-slash, it enters the left-ready stance. |
| StorePanelSort | Not sure. Looks like sorting order for the merchant panels. | 0 to 99. Lower-numbered items appear first in the store panel display in the game. Higher-numbered items appear last. |
| ILRStackSize | No idea. It looks like a repeat of the Stacking column. ILR typically refers to Item Level Restriction but I don’t know how this applies here. | Sometimes used instead of StackSize when calculating item cost |
- Back through the same routine. Save the .2da file, load it into your hakpak.
- Rename the WPlSs_t_051 model to WPlTr_t_011 (WPlTr, remember, is the new ID for our trident) and change all the internal references.
- Wait, where are the rest of the WPlTr_x_nnz models and icons? Good point. We only have a model for the trident’s head. That worked fine when we are attaching the trident head onto a spear’s body but now we are creating a new weapon and it needs all three components. Now, remember that the spear shaft and end worked fine for us? Copy the WPlSs_m_011 and WPlSs_b_011 files to make trident files as well (named WPlTr_m_011 and WPlTr_b_011 respectively) and change those internal references as well. Now it is starting to look better.
- Do the same for your icon files.
- Load all of these into your hakpak. You should have, at a minimum, the following:
|
- Load up your module in the Aurora Toolset.
- Now you can create a new trident using the Item Wizard.
-
- If you follow these steps exactly, you don’t get a lot of options for spear components to choose from. Duplicate some of the color versions as well (_012, _013, etc.) and/or the other shaft and end models so that you have a nice selection of components. You can make multiple copies of the trident head as well, with different colors or shapes, if you desire.
- For some weapons you won’t find an entry in dialog.tlk. Chose another appropriate name (I used Custom #1 for some items). This is annoying in the Aurora Toolset because you need to remember that Custom #1 in the Item Wizard is your new weapon. But there is a workaround for this that avoids the problem in game. In the next section we will talk about creating a Weapon Blueprint. Once you have a blueprint, you will not need to remember that Custom #1 is actually your new weapon because you can create new items directly from the blueprint.
With regard to the model type, there are four different options with the following values:
| Value | Description | Has Color Layers | # of parts |
| 0 | simple | no | 1 |
| 1 | layered | yes | 1 |
| 2 | composite | no | 3 |
| 3 | armor | yes | 18 |
| In the early days of content creation, people felt compelled to update the dialog.tlk file to provide names for new objects (otherwise their item names had to re-use existing names – so you could not have a trident because there is no entry for ‘Trident’ in dialog.tlk). As part of their resolution to this problem, Bioware’s latest fixes are starting to allow you to use **** in the .2da files for the dialog.tlk name references. When it sees ****, the game engine will use your custom label or another field instead of looking for the text in dialog.tlk. This now works for some objects. Unfortunately, they haven’t come through for the baseitems.2da file. Maybe Bioware will get this fixed soon so stay tuned. Regardless, DON”T USE dialog.tlk for this type of content. |
Part 7: The Weapon Blueprint
|
The last thing you need to understand is how to create a custom blueprint. A blue print goes into a specific module. Take the spear we created earlier. Change its name and tag on the General tab to Wave if you did not already do so. Under the Properties tab, give Wave a +3 bonus, and whatever other characteristics you think are appropriate. In this case, I will allow Wave to cast the spell Elemental Shield to simulate the Cube of Force effect it should have (maybe at some point I will incorporate the cube of force script Solias wrote). I will grant “On Hit, Wounding” as a special property to simulate the dehydration property.
Add a description to be used when the item has not been identified and another when it has. Now save Wave by exporting it as an .erf file (Exported Resource File). It can now be packaged together with your hakpak and distributed to others to use (do not load it into your hakpak – a .erf file is imported into the NWN Toolset separately using File | Import…)
|
By setting the item description you will find another way to overcome that nasty dialog.tlk problem I mentioned earlier. When you create a blueprint like this, you can override the item name and the default descriptions with appropriate fields for your weapon. This way, as long as module builders load in your .erf file, they won’t have to worry about what dialog.tlk thinks your file should be called because they can build right off the blueprint instead.
You cannot override the BaseItemStatRef this way but you can do something just as good. Remember where we put 59 in the BaseItemStatRef of baseitems.2da? This blanks out the item statistics description – a good first step. But now we are missing the stats. How do we get them in? Put them at the end of the regular Description in the blueprint – at the very end. This works in the game engine because it always displays the item description followed by its statistics. Now the inventory will look just like it does for any other weapon: a description, then the statistics, and then any special items or properties. You’ve tricked the game engine into looking the same as it does if you had a real BaseItemStatRef entry.
Part 8: Special Touches
|
When we created the resource declaration for our model, we separated our trident forevermore from thinking it was some sort of poor third cousin of a spear. Unfortunately, it loses something in the translation. We need to add back in some of the special effects that a spear enjoys but are missing from our trident. Pictured below is the Frost effect:
There are seven magic effects that you need to account for:
| _fxacid | Acid |
| _fxelect | Electric |
| _fxfire | Fire |
| _fxfrost | Frost |
| _fxholy | Holy |
| _fxneg | Negative |
| _fxsonic | Sonic |
Each of these is a special emitter, generally placed somewhere along the blade of the weapon. To recreate these, the simplest approach is to load in an existing model of this type and then move the emitter to the appropriate spot for your models (remember, the positions of the different components of the weapon models should be the same for a given weapon). For our trident, we will just copy the spear effects models. We can even leave the emitters in the same place because the tines of the spear are roughly in the same place as the head of the spear. If we wanted, we could duplicate the emitters, one for each tine, but I don’t think this adds anything to the effect so I chose not to do this.
To test out the effect, create a weapon in the Aurora Toolset. Select the Properties tab and give it a Damage Bonus, frost. Press Edit Property and then change the damage bonus to 5 (you need to choose a damage value > 1 otherwise the toolset does not apply the effect). When you close that pop-up, you will see the special effect from the emitter. If it is not in the right place you may need to move the position of the emitter in the standard model. There is also a motion blur model (_mb). This shows the standard arc of the weapon when being wielded in the game. Again, because the spear is so similar to the trident we have built, I will not adjust the motion blur model. We will just copy the spear model and rename it.
Textures
|
Let me add a few words about textures. If you include no textures your model will take on a uniform chromed finish or be completely white (depending on whether or not your baseitems.2da file specifies the weapon part be metal or not).
Textures are bitmaps (Targa bitmaps, 24-bit or 32-bit, RGB Color, uncompressed) used to introduce features like the special gold and wood-grained models in the game. The default weapon texture that almost all of the Bioware weapon models use is w_metal_tex.tga (it can be found in the data\templates.bif file using NWN Explorer). This file is a matrix of squares with different textures on it. If you use this texture you can get a good selection of metals (plain, gold and bronze) plus wood, a few colors for gems, etc. You do not need to include this file in your hakpak – it is already available in the game.
|
The following points about textures are from Aethelwyn and Danmar and are things to check when your texture doesn’t work:
- Check your filenames.
- Naming for textures should be 16 characters or less. For weapons and most other models, as long as you apply the texture to your model (in the ASCII model file you can check this if the bitmap= line in the model node entry equals the name of the texture minus the tga extension) the reference will work.
- For some custom content (e.g., anatomy) the name of your texture needs to match that of your model, save for the extension (.tga, .dds, .plt, etc.).
- Check your texture size.
- Pixel dimensions for NWN textures must be an even multiple of 16. This is a common goof, as it's pretty easy to miss something while cutting/pasting/resizing/etc. your texture. Not all even powers of 16 work either. Your best bet is to use one of the following:
- 16x16
- 32x32
- 64x64
- 128x128
- 256x256
- 512x512
- You can use higher textures, but this is hard on performance for most machines. You can mix multiples of 2's in the same texture, as a general rule. For example,
- 64x128 works. 64x256 works. 64x192 (64x3=192) doesn't.
- 128x256 works. 128x512 works. 128x384 (128x3=384) doesn't.
- Pixel dimensions for NWN textures must be an even multiple of 16. This is a common goof, as it's pretty easy to miss something while cutting/pasting/resizing/etc. your texture. Not all even powers of 16 work either. Your best bet is to use one of the following:
- Check your file types.
- Not all game elements in NWN take the same texture files. If you try to use the wrong one, it won't get read by the game. There are three types:
- .tga Used on placeables, tiles, most icons, portraits, weapons, etc. -- resources whose colors are not customizable.
- .dds A compressed variety of .tga, thus to be preferred over them whenever possible.
- .plt The special file format used for body parts, clothing, armor, and their associated icons. Allows different "materials" to be given their own color, thus allowing for a lot of variety without texture reduplication.
- Not all game elements in NWN take the same texture files. If you try to use the wrong one, it won't get read by the game. There are three types:
- Check your internal references.
- This requires you to crack open the .mdl file. If everything else checks out, make sure that all the references in your model itself are good. It's easy to misname something, forget to change it, etc. This goes for both texture references and node names themselves. "Find and Replace All" is your friend!
|
- Your textures must be uncompressed.
- Your textures have to be 24 or 32 bit Targa or TGA files in uncompressed format.
- Replacing textures.
- If you are overwriting an existing texture you must replace both the lo-res .tga version and the MIP (mulitple image) .dds version.
- Dark textures.
- The diffuse setting on a texture in the MDL will cause your texture to be dark if you accept the default diffuse in either Max or Gmax when you create your item. Unless you're specifically have a need for it you should always set the diffuse to pure white or modify it in the ASCII model file so that it reads:
- diffuse 1 1 1
- There are many models in various collections that are a lot darker than they should be because of this often overlooked fact.
- The diffuse setting on a texture in the MDL will cause your texture to be dark if you accept the default diffuse in either Max or Gmax when you create your item. Unless you're specifically have a need for it you should always set the diffuse to pure white or modify it in the ASCII model file so that it reads:
Most of your texture woes are going to be caused by one of the items above -- and a simple check is often all it takes to solve the problem.
If you are going to include a custom texture, include a high resolution one (512 x 512 or at least 256 x 256) and pick up Bioware’s DDS Compression Tool or DDSTools to run against your .tga file. Include both the .dds and a lower resolution version of your .tga file into your hakpak (say, 64 x 64). Higher-performance graphics cards will use the dds for high detailing. Older machines will use the .tga file with slower graphics cards. If you leave out the .tga file, machines with lower end graphic cards will see your models in plain white. Not pretty.
While you are at it, you may want to turn your 2D icon files into DDS files as well. You will find DDS files for all of the icons in the \texturepacks\GUI_32bit.erf directory. I think it is done so that they are compressed and take less space than a .tga file. My experience so far has been that the game works fine without them but that may not be true for some hardware.
Normals
Faces (3d model faces, not your character’s face) in NWN are two-dimensional. If viewed from the backside (or inside), they have no ‘existence’ and do not render. A normal is a unit vector that is used to define which way a face is pointing. The direction in which the normal points indicates the front of the face (more specifically, the normal points out from the front of the face). This is the side of the surface that is normally displayed with its texture in the game.
This is important because you will sometimes find your polys don’t render properly (some are see-through, for example). You must manually flip or unify face normals to fix these types of errors (they are typically caused by activities like mirroring objects). To do this, enable Face, Polygon or Element sub-object mode on your editable mesh, and then use the buttons on the Surface Properties rollout to change the directions in which normals point. Flip Normals will reverse the direction of a normal vector. Unify Normals makes all of the selected normals point in a consistent direction (if an object has normals that are inconsistent - some point outward and others inward - it will appear to have holes in its surface).
Sometimes objects will look fine in the modeling tool but will not display correctly in the game or the Aurora toolset. If this happens it may be necessary to ResetXforms and flip normals to fix this issue (refer to part 3 of this Weapons tutorial for detail on ResetXforms).
Smoothing Groups
Smoothing groups define whether a surface is rendered with sharp edges or smooth surfaces. You create smoothing groups by assigning group numbers to the faces of an object. If two faces share an edge and share the same smoothing group, they render as a smooth surface. If they don’t share the same smoothing group, the edge between them renders as a corner.
Smoothing does not affect geometry. It affects only the way geometry is colored when rendered; it blends colors at the edges between faces to produce the appearance of a smooth curved surface. You can control how smoothing is applied to a surface so your objects can have both smooth surfaces and sharp faceted edges where you wish.
When the existing scripts import NWN models, they automatically assign all faces to the same smoothing group. To improve the way that they render in NWN, you should review these objects and reassign smoothing groups as necessary to get the right mix of corners and smoothed transitions.
Part 9: Models that bend
When I started to make a Nunchaku model, I was faced with an interesting problem: Nunchak’s bend in the middle. How do we make this work? The answer lies in looking at the Morning Star, Heavy Flail and Light Flail models. They use a special technique that we can emulate: animation.
Take a look at the heavy flail model. Like other weapons, the flail is made up of several parts. The bottom two parts are what you would expect: g_WBlFh_b_011 and g_WBlFh_m_011. But the top is actually four different parts: g_WBlFh_t_011a, g_WBlFh_t_011b, g_WBlFh_t_011c, and g_WBlFh_t_011d. The first three parts are links in a chain. The last is the flail head itself. At the point where the chain links to the head there is an Fx_Node. The bottom two models work as you would expect. The top model is animated. Select the Aurabase item for that node and look at its animations.
I won’t go into detail in this section on animation – I would suggest coming back to this section after you have completed the Creature tutorial in this guide. You will be treated to an “Aha!” or two. These represent the standard game animations for combat, walking etc. The game engine will treat the components of the top model differently than any other weapon by playing these animations in game. This is what gives the Flail its unusual behavior in melee and as you walk.
The reason I don’t launch into a discussion on animation here is that it is a complex topic and you don’t need to understand animation fully to take advantage of this feature; for weapons like flails, nunchaku, etc. You can use the Supermodel parameter to have your weapon inherit this behaviour.
Take a look at the light flail model. Like the heavy flail and other weapons, the light flail is made up of several parts. The bottom two parts are what you would expect: g_WBlFl_b_011 and g_WBlFl_m_011. But the top is actually named after the heavy flail: g_WBlFh_t_011a, g_WBlFh_t_011b, g_WBlFh_t_011c, and g_WBlFh_t_011d. Also, if you select the Aurabase object, you will see the Super parameter points to the heavy flail. The NWN game engine will use this parameter to impose the heavy flail animations on this model. Animation behaviour is stored component by component in a model (i.e., for each part of the model it stores how that part rotates and moves). The NWN game engine matches the parts up between the Supermodel and child model files by name and applys the animations of the heavy flail to the light one. This is why top of the light flail (where the animations are) is named the same as the heavy flail.
So, to create my Nunchaku I built a similar model with the lower parts named according to what you would expect (g_WBlNn_b_011 and g_WBlNn_m_011). For the upper parts I had to keep the same names as the heavy flail (the g_WBlFh… names) although I used Nn again on the Aurora base item. I was even able to put two more links in the chain so that it looked more realistic. The key is that the Aurora base links to the ‘a’ model, the ‘a’ model links to the ‘b’ model, the ‘b’ model to the ‘c’ model, etc. The final node in the top piece links to the Fx_Node. And I made sure the Super parameter was set properly.
After you go through the tutorial on Creature animation, you could probably come back and do a full set of animations on a new model to create a hooked chain, Manriki-Gusari, bullwhip or other flexible weapon (this is left as an exercise to the reader).
« Introduction | Weapons | Character Portraits »
