How to Add a Weapon to GRAW
By: Brettzies
Published : 08 May 2007


Here's how I usually go about adding a weapon, in this case a pistol.

The best method I have found is this, but it will force you to get comfortable with the xmls to some degree.

1. duplicate the structure of a weapon similar to what you are making into the english folder. In this case, the glock or beretta. What i do is copy all of the dirs and xmls associated with say, the beretta, but change the names to be the new weapon. So in your case, usp. I usually put my initials in front so I can find my weapons quickly, ie bp_usp. Not necessary though. Here are the things you will need to copy/rename:

pistol = beretta, change it to your weapon.

*leave any material names or gfx_names_lodx alone for now, you can rename them when you know what you are doing*
*delete any .bin files you copy*

units/weapons/ u_pistol.xml
textures/atlas_weapons/pistol/bump_set0 <---all files
textures/atlas_weapons/pistol/diffuse_set0 <--- all files
textures/atlas_weapons/3rd_person/pistol/bump_set0 <---all files
textures/atlas_weapons/3rd_person/pistol/diffuse_set0 <--- all files
objects/weapons/pistol/ <--- all files

I know it is a pain, but getting a duplicate weapon into the game that is identical to the original, but with different file names is really the first step to getting things to work correctly. However, just changing the files names is not enough, because each xml(for whatever reason) has lines in it that tell what the file is and where the dir is. So basically you have to open each xml and change any lines that refer to the file or directory, they are pretty easy to spot, but it is tedious.

2. You also need to copy/edit these files to point to your new "identical" weapon:

strings/weapons.xml <--- just add an entry with a new name so you can tell that the identical weapon is new
strings/inventory.xml <--- you can do this one later, it's just info

lib/managers/xml/weapon_data.xml <--- this one is important, you need to duplicate the entry for a pistol, but cange the id# to something new, 43 is the first available slot I think.

Now when you start the game, you should have 2 of the same pistol in the loadout screen. One should be whatever you named your weapon in the strings.xml. The reason to do all this is so that you have the least amount of problems when you go to export your "real" weapon. Otherwise, you will never know what the problem is, it could be an xml or it could be the diesel file(your model). If the weapon doesn't come in correctly, or if you crash, you know you've missed something in the editing of the xmls to point to new files. Go back and start with the u_pistol file. The most common thing to miss is probably the mag and the last two entries at the bottom, @pistol() and @pistol(_3rd). If everything looks good move onto the objects dir and check all of those xmls.

I know this seems like an incredibly tiresome process, but until you get the duplicate weapon in correctly, there is no point in exporting anything from 3dsmax. It will just give you more confusion because that whole process is complex.

3. Setting up in Max

Now that you have a dupilcate structure, ie real mod working, you can begin changing the model and texture images. The best thing to do is this:

.open the beretta sample file that came with the patch
.grab the align null and zero it out(position it to 0,0,0)
.select the 3 lod objects and delete them(keep a note of their names though)
.import or merge in you model and position it correctly.
.rename it to gfx_beretta_body_loda <--- you can change this when you know what you're doing
.reset the xform
.assign the main beretta material to it(you can rename this but for now leave it)
.add a skin modifier to the mesh, won't work without it.
.add skin_root to the skin modifier (dont' worry about skinning or setting up animations, but you at least need that one), note, usually only loda is skinned, but in the pistol sample everything is skinned for no real reason I can see.
.parent the mesh to the align null
.adjust any of the other nulls to line up better(don't worry about the mag_align)
.duplicate the mesh twice but rename the new ones so that a becomes b and c. <--- eventually you will need lowres meshes for b and c, but for testing, just duplicate them. You can also just do an loba or loda and b, but that requires some xml editing.
.save your file if you haven't already
.export via diesel plugin, pick the diesel file you copied earlier in the objects/pistol/ and overwrite it
.don't worry about the mag for now, get the weapon working first and then go back

4. open the game up and if everything went well you should have a new model in the game. The texures will be messed up until you fix them, but that part is just changing image files. For testing purposes, I usually make all the copied textures grey.

If it didn't work or the game crashed but had worked before you went to step 3, then you know something is wrong with your mesh. The most common problems I have are:

.wrong names for the meshes, ie they don't match the xml code, usually gfx_something_loda
.material does not match or is for the wrong kind of mesh(skin or noskin)
.skin modifier not applied

There are probably all kinds of other problems, but if you at least get through steps 1 and 2 with new names for your pistol, you can narrow it down to something with the 3d model.


© GhostRecon.net