# Animating Weapons for Counter-Strike Source/Testing Animations

You've made an animation, but it's important to ensure it looks correct in-game.
* In the default folder, find mdldecompiler.qc and copy and paste it to the tocompile folder.
* Replace the first line in the new mdldecompiler.qc with this:
This tells the compiler to look in the current directory for the SMD files.

## Adjusting the Timing of the Sounds

* Find a line that begins like this:
* After 5004 you will see a number. Change the number to a number from 0 to 15 for each line. A number from 0 to 15 is used because the idle animation goes from frame 0 to frame 15.
* Save the QC file. Do not close it yet.

## Copying and Pasting Animations

* Count how many times $sequence is typed in QC file.
* Subtract one (for the idle animation.)
* Copy and paste idle.smd that many times.
* Rename the SMD files to whatever word comes after $sequence in the QC file. (e.g. shoot1, reload, draw)
* Save the QC file. Do not close it yet.

## Converting the Textures to Targa Format

* If your textures are already in TGA format skip this.
* Open IrfanView.
* Open each texture.
* Go to File>Save as and save as a Targa (.TGA) file.
* Put these Targa files in a folder called lr300.
* Make a .bat (text) file with the following code:
* Execute the batch file. Now you will see your materials folder for first person view models. Keep this folder open for later.

## Converting the Textures to VTF Format

* Find vtex.exe. Is located in %sourcesdk%\bin\ep1\bin\
* Make a new text file somewhere (with .bat at the end) and write the complete location of vtex.exe in quotes in the first line of the batch file. Now edit it is similarly to the following:
* Save it in the lr300 folder.
* Move the lr300 folder to
* Double click the batch file and the window opened earlier should have a folder called lr300 with the textures and VMT files in it.

## Finalizing the QC

* Open the QC file if it is not open already.
* Find all of the lines that begin with $hbox. Delete them.
* There should still be a line that says $hboxset "default". Keep it. This lets the engine compile the hitboxes for you.
* Find a line beginning with
* Rename [something].smd to the gun's smd file.
* Add a line after this line
with the following text:
* \lr300\ should be replaced with whatever folder name you gave the materials earlier.
* Find all lines that begin with $attachment.
* Replace the phrase in quotes (in the $attachment lines) with the name of the bone of the weapon. (In this tutorial it would be ValveBiped.Frame.)
* Save the QC and close it.
* Right click the QC and click Compile.
* The QC should compile successfully.
* The QC may not compile successfully. Check any errors studiomdl.exe gives you and post them on the talk page for help.

## Testing Animations in the Game

* Open Counter-Strike Source
* Create a server.
* Buy the weapon you are animating to test it.
* There are smoothing errors in certain lighting conditions; we will fix those later.
* Turn on cheats using the console command sv_cheats 1.
* Here are a few cheats you can play with:
** cl_drawhud 0 - disables HUD, good for recording videos and taking pictures
** give weapon_sg552 - give a weapon. sg552 can be replaced with other weapon names
** impulse 101 - refill ammo and money
* Take some pictures by pressing F5. The pictures will end up in cstrike\screenshots\map_name####.jpg
* Share these pictures and get some feedback! The idle animation should be perfected before starting any other animation.

## Adjusting the Origin of the Animations

* You can make a minor adjustment to the model without editing the SMD files. It is called setting the origin.
* To do this, open your QC file.
* After the $cd line, add a new line.
* Enter the following:
* Replace x y and z with numbers that depend on which way you want the model to be offset.
* Refer to this picture to see how origins work. Changing Origins