Animating Weapons for Counter-Strike Source/Testing Animations
Appearance
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:
$cd ".\"
This tells the compiler to look in the current directory for the SMD files.
Adjusting the Timing of the Sounds
[edit | edit source]- Find a line that begins like this:
{ event 5004
- 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
[edit | edit source]- 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
[edit | edit source]- 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:
cd %sourcesdk% cd ..\ cd .\counter-strike source\cstrike\materials\models\weapons\v_models\ start .\
The batch file will not work if these folders are not created. If this is the case, remove the second and third lines of code from the batch file. Now with the new window open, go up one folder. Create more folders in the following hierarchy: *username*(folder that you are at)\counter-strike source\cstrike\materials\models\weapons\v_models\ If you did this correctly the batch file with all four lines of code will work. |
- 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
[edit | edit source]- 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:
cd .\ "C:\Program Files\Steam\steamapps\username\sourcesdk\bin\ep1\bin\vtex.exe" -shader VertexLitGeneric .\*.tga
- Save it in the lr300 folder.
- Move the lr300 folder to
\your username\sourcesdk_content\cstrike\materialsrc\models\weapons\v_models\
- 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
[edit | edit source]- 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
$model "studio" "[something].smd"
- Rename [something].smd to the gun's smd file.
- Add a line after this line
$cdmaterials "models\weapons\v_models\hands\"
with the following text:
$cdmaterials "models\weapons\v_models\lr300\"
- \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.)
The $attachment lines are for the muzzle flash and shell ejection. |
- 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
[edit | edit source]- 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
[edit | edit source]- 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:
$origin x y z
- 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
The camera in XSI will be incorrect now. To fix this, unhide the camera. Move it to half way of each axis done on the origin. (e.g. If you put $origin 0 3 0, Translate the camera on the y axis 1.5 units. Set a key for this new position (K). |