Garry's Mod

Garry's Mod

68 ratings
[WIP] Call of Duty Weapon Porting Guide
By F'Ozzy29
THIS GUIDE IS NOT FINISHED!

NOTE: THIS TUTORIAL IS NOT GEARED TOWARDS BEGINNERS!! I STRONGLY RECOMMEND THAT YOU AT LEAST HAVE 3D APPLICATION EXPERIENCE!!!
--------------------------------------------------
This guide will walk you through porting viewmodels from Call of Duty games into Garry's Mod. This will NOT go over how to make sweps, because there are other tutorials for that.
   
Award
Favorite
Favorited
Unfavorite
Setting Up - Extracting from Black Ops II
You are going to need several programs and plugins:

-Source SDK

-Studio Compiler[www.chaosincarnate.net]

-Maya 8.5, and some 3D application experience.

-Garry's Mod

-A copy of Black Ops II, or any supported Call Of Duty game (cod4, cod5, bo1, mw2, bo2)

-SMD plugin for Maya 8.5 (packaged with Source SDK)

-My Template .QC file for compiling[www.dropbox.com]

-Tom's Maya Plugins[tom-crowley.co.uk]

-Lime[tom-crowley.co.uk]

-Lemon[tom-crowley.co.uk]

Assuming you have everything installed and working, you're gonna want to open up Lime first.



Now load up Black Ops II Multiplayer in windowed mode and hit "Find Game" in Lime.


Now load a custom match in the map of your choice. Class and weapons do not matter. Spawn in-game, and choose "List Models" then "Load Models", and lastly "Export All."
This will extract the models and rigs to be used in Maya.


After that is done, close Lime but not the game, and log in to Lemon. The process will extract the animation data from the game and put it in a folder for later use.

Great! Now we are ready to go into Maya!
Setting Up - The Viewhands
Now that we have all the assets we need from the game, we can start setting up our rigs in Maya!

Navigate to your sourcesdk/maya folder, and choose 8.5. Now run the .bat file to open Maya. You need to do this every time you run an instance of Maya, or else the SMD plugins will not work.

Now go to Window > Settings/Preferences/Plug-In Manager and a window will pop up, displaying all installed Maya plugins. Make sure "vstsmdio.mll" and "Tom_xAnim_8.5" are loaded and set to auto-load.

Now we are going to set up our viewhands. These are the first person hands that the player sees ingame.

Navigate to your Lime folder, and go into your "exported" folder.
You will see a crapload of folders along with an "_images" folder. The images folder is where all the textures are located, so we will be going to it later on.

In the searchbar, search "viewhands" and you should come up with some jumbled list of files and folders.
The folders are the names of the viewhands. Choose a folder with the viewhands that you want. I'm using "c_usa_mp_seal6_shortsleeve_viewhands." Inside you will see three files. The .xmodel_export will not be used. The other two, however, is the model file and the bind script. The model file is circled in red, and the bind script is circled in blue.The model file is self-explanatory.

It is the mesh that Treyarch made for the game. However, it is unweighted, meaning if we moved or rotated a joint, the mesh will not bend or move with it.

The bind script fixes that, hence the name "bind" script.

Now drag the MODEL FILE onto the Maya viewport. Hit 6 on your keyboard. Now you can see your viewhands!

Now drag the BIND SCRIPT into the viewport as well. Maya will freeze for a minute, but that's normal. It's processing the bind script. Your model is now binded and ready for use!

Hit File>Save Scene As, and save it in an organized folder and call it v_hands.
Setting Up - The Weapon Model
Now we are ready to set up our weapon model!

Navigate to your Lime folder again, and search for the weapon you want to port. I will be using the MP7 in this tutorial.
Load the weapon into maya and bind it.
The texture looks bad, but we will fix it later.
Navigate to where you saved your viewhands, and make another folder in that folder called mp7. Save the mp7 model in that folder.

Now choose File > New to clear the scene again. We now have to prepare the magazine for rigging. You may have noticed the weapon model we binded and saved earlier was missing the magazine. Don't worry, this is easy to fix!

Navigate to your Lime/exported folder, and search "t6_attach_mag_WEAPONNAME_view". I will be using t6_attach_mag_mp7_view, but choose whichever mag is appropriate for your weapon.

Load the model into Maya and bind it. You should now have something like this:
Choose File > Save Scene As, and save it in your weapon folder as "mag" or anything you like.


Now we need to attach the magazine onto the weapon itself. Open up your mp7.ma

Now go to your mag.ma, and drag it into the viewport. You should get something like this:
We need to move the magazine into position and link it to the rest of the rig. Go to Window > Outliner and you will see a menu pop up. This is a list of the joints and meshes in the scene, and you can select different parts from this list. It is very handy.

Now select the move tool, then select the "tag_clip" joint from the outliner, and move the magazine into place. You have to eyeball it and make sure that it matches as close as you can. MAKE SURE YOU MOVE THE MAGAZINE FROM THE TOP VIEW ONLY TO MAKE SURE IT'S CENTERED.

Now we need to link it to the rig. With tag_clip selected, go to your outliner, and expand "Joints" and expand "j_gun."

Now, in Outliner, MIDDLE MOUSE DRAG tag_clip, and move it below tag_sights and let go. You should get something like this:

Now the magazine is linked to your gun!

Choose File > Save Scene As, and overwrite mp7.ma or whatever weapon your are porting.
Setting Up - Linking Your Weapon to the Viewhands
So we have our viewhands, and we have our weapon model prepared, but we are not ready to load the animations yet. We need to join the weapon model to the viewhands rig so we can load the animation data correctly.

Clear the Maya scene, BUT MAKE SURE YOU SAVED THE MP7 WITH THE MAG ATTACHED FIRST!

Now open up your viewhands from earlier, and drag the mp7 you just saved onto the viewport. You should get this:

Now go to Tom_Bmx > Join weapon to rig, and the weapon should snap into place. If you don't have the option, make sure you have installed tom's plugins correctly.

Great! Now we need to add a camera so we know what it will look like in-game. Go to create > cameras >camera. Change the X rotation to 90 and the Z rotation to -90. Then change the focal length to 20.

To preview the camera, go to panals > perspective > camera1.


Now we are ready to load up the animations and export them to SMD for compiling!
Choose File>Save Scene As and save it as v_mp7.
Loading .tanims and exporting as SMD
We now have a viewmodel rig ready for some animations! Animation files that you've exported from Lemon are save as .tanim. These are the files that we will import onto the weapon rig. The files were saved in your Lemon folder when we exported them earlier from Black Ops II. In Maya, choose File > Import and click the little box next to it.
Now choose COD XAnim as the file type
and choose these options and hit Apply:
Now hit Import, and browse to Lemon/export/bo2/mp, and find viewmodel_mp7_idle,


and import it.
The idle animation should load in the viewport, like this:

Now go to File>Export All and click the little box next to it. Choose SMD Animated Model as your file type, scroll down to General Options and make sure Bind Current is checked.
Export the .SMD in your weapon folder where your .ma's are, and save it as "idle.smd."

Now go to File>Recent Files and click on your v_mp7. DO NOT SAVE!! NEVER SAVE OVER THE V_MP7 WITH AN ANIMATION APPLIED TO IT!!!

Now, repeat these steps with the following animations and save them with the following names:

viewmodel_mp7_ads_fire-----> shoot_ads.smd
viewmodel_mp7_fire-----> shoot.smd
viewmodel_mp7_first_raise-----> draw.smd
viewmodel_mp7_reload-----> reload.smd
viewmodel_mp7_reload_empty-----> reload_empty.smd


Awesome! Now we are ready to set up our .qc file for compiling our weapon!
Preparing our .QC for compile
Before we can compile, we need to set up our .qc file. The .qc file is a script that tells Studio Compiler how to compile our model. We need to specify which .smd animation does what in Source so that it will work correctly in Garry's Mod, and also what frames to play the different reloading and draw sounds. Open up the template.qc with your favorite text editor. Don't get confused! It's actually quite simple!

Now, everywhere you see WEAPONNAME in all caps, replace that with your unique weapon name. In my case, it is "blops2_mp7". Make sure the weapon name is something unique to avoid conflicts with other addons.






Now we need to add the sound events. These events will tell the game what frame to play the different sounds for the draw and reload animations, such as the removing the magazine, etc. This can be a little tricky because we don't want the sounds to play too early or too late.

So, in maya, load "viewmodel_mp7_first_raise" onto your v_mp7, and switch to you camera view.
11 Comments
Zealt Aug 15, 2019 @ 9:16pm 
well, the first sentence I saw was WARNING NOT FOR BEGINNERS

ill just excuse my self thanks.
MattMX May 27, 2018 @ 11:32pm 
Can I just use the view arms
KernCore Jun 26, 2017 @ 10:35am 
I followed every step of your guide except I don't own Maya 8.5 and currently it's very difficult to find one (even with piracy these days), so I tried Maya 2012 instead, I got everything working correctly with the exception of the SMD Exporter, which crashes every time I try to export it.

Some help would be appreciated, and if I get this thing working, I'll port CoD weapons into Sven Co-op.
Green Ghost Nov 5, 2016 @ 10:30am 
The link to the template .QC is broken. Any chance of a reupload?
ʚ ♡ Sarahtonin ♡ ɞ Aug 27, 2016 @ 4:52pm 
Sweet! Awesome guide! Hope this works with BO1, maybe WaW?
Rymd Aug 3, 2016 @ 8:15pm 
How about a tut for Blender ? It's free and there's the Source Tools.
S = KB ln W Jul 28, 2016 @ 7:36pm 
This tutorial is super useful after some workarounds regarding the maya software and its plug-in set up. For anyone who's wondering, you can also use literally any version of maya before 2014 for the process.
S = KB ln W Jul 27, 2016 @ 8:45pm 
that maya 8.5 from 6 years ago?? I don't think it's even purchasable
Shower Jul 5, 2016 @ 8:46am 
Lime and Lemon XD
F'Ozzy29  [author] Jul 3, 2016 @ 6:16pm 
@Dr. Gordon Freeman, Ph.D Just import the weapon as a static mesh with the magazine, delete the bones, export, and compile as a static prop.