Making a .qc

This is probably around the 500th thread about this topic, but I’m seriously insecure about making a .QC file for a ragdoll.

I ripped a model from World of Warcraft with a skeleton, removed unnecessary bones and had it exported to .smd; how do I build a .QC to compile it to a .mdl?

Decompile a ragdoll from Half-Life 2/Episode 1 or 2 or Garrys Mod and use that qc, and rename the bones accordingly.

This is what I use, its from male7 decompiled: just comment out a line if you get an error and be sure to change the paths/names. Use // to comment out a line.


// Created by Crowbar 0.19.0.0

$modelname "player/naruto/hinata.mdl"
$model "hinata" "hinata.smd"
$cdmaterials "models
aruto\"

// $attachment "eyes" "ValveBiped.Bip01_Head1" 3.2 -3.5 0.12 rotate 0 -80.1 -90
$attachment "mouth" "ValveBiped.Bip01_Head1" 0.6 -5.5 0 rotate 0 -80 -90
$attachment "chest" "ValveBiped.Bip01_Spine2" 5 4 0 rotate 0 90 90
$attachment "forward" "ValveBiped.forward" 0 0 0 rotate 0 0 0
$attachment "anim_attachment_RH" "ValveBiped.Anim_Attachment_RH" 0 0 0 rotate -90 -90 0
$attachment "anim_attachment_LH" "ValveBiped.Anim_Attachment_LH" 0 0 0 rotate -90 -90 0
$attachment "anim_attachment_head" "ValveBiped.Bip01_Head1" 0 0 0 rotate -90 -90 0

$surfaceprop "flesh"

$contents "solid"

$hboxset "default"
$hbox 1 "ValveBiped.Bip01_Head1" -1.25 -6.5 -3.19 8.25 3.5 3.31
$hbox 4 "ValveBiped.Bip01_L_UpperArm" 0 -2.75 -2.75 12.51 1.75 2.25
$hbox 4 "ValveBiped.Bip01_L_Forearm" 0 -2.19 -2.38 13 1.81 1.62
$hbox 4 "ValveBiped.Bip01_L_Hand" 0.06 -2 -1.5 4.06 1 2.5
$hbox 5 "ValveBiped.Bip01_R_UpperArm" 0 -3 -2.25 12.39 2 2.75
$hbox 5 "ValveBiped.Bip01_R_Forearm" -0.5 -2.2 -1.55 12.5 1.8 2.45
$hbox 5 "ValveBiped.Bip01_R_Hand" 0.06 -2 -2.5 4.06 1 1.5
$hbox 6 "ValveBiped.Bip01_L_Thigh" 0 -3.75 -3.25 17.85 3.75 3.25
$hbox 6 "ValveBiped.Bip01_L_Calf" 0 -3.51 -3.28 15.64 3.49 2.72
$hbox 6 "ValveBiped.Bip01_L_Foot" -1.07 -2 -2.84 5.04 5 2.16
$hbox 6 "ValveBiped.Bip01_L_Toe0" -0.5 -3 -2.19 2.5 0 2.46
$hbox 7 "ValveBiped.Bip01_R_Thigh" 0 -3.75 -3.25 17.85 3.75 3.25
$hbox 7 "ValveBiped.Bip01_R_Calf" 0 -3.51 -2.82 15.64 3.49 3.18
$hbox 7 "ValveBiped.Bip01_R_Foot" -1.06 -2.01 -2.28 5.05 4.99 2.72
$hbox 7 "ValveBiped.Bip01_R_Toe0" -0.5 -3 -2.6 2.5 0 2.1
$hbox 3 "ValveBiped.Bip01_Pelvis" -7.5 -5.5 -6 7.5 8.5 5
$hbox 2 "ValveBiped.Bip01_Spine2" -2.5 -2.5 -7 14.5 7.5 7
$skipboneinbbox

$sequence ragdoll "ragdoll" ACT_DIERAGDOLL 1 fps 30.00

$includemodel "m_anm.mdl"

$ikchain "rhand" "ValveBiped.Bip01_R_Hand" knee 0.707 0.707 0
$ikchain "lhand" "ValveBiped.Bip01_L_Hand" knee 0.707 0.707 0
$ikchain "rfoot" "ValveBiped.Bip01_R_Foot" knee 0.707 -0.707 0
$ikchain "lfoot" "ValveBiped.Bip01_L_Foot" knee 0.707 -0.707 0

$ikautoplaylock "rfoot" 1 0.1
$ikautoplaylock "lfoot" 1 0.1

$collisionjoints "male_07_physics.smd"
{
	$mass 0
	$inertia 10
	$damping 0.01
	$rotdamping 1.5
	$rootbone "valvebiped.bip01_pelvis"

	$jointconstrain "ValveBiped.Bip01_Spine2" x limit -48 48 0
	$jointconstrain "ValveBiped.Bip01_Spine2" y limit -25 25 0
	$jointconstrain "ValveBiped.Bip01_Spine2" z limit -25 50 0

	$jointconstrain "ValveBiped.Bip01_R_UpperArm" x limit -39 39 0
	$jointconstrain "ValveBiped.Bip01_R_UpperArm" y limit -79 95 0
	$jointconstrain "ValveBiped.Bip01_R_UpperArm" z limit -93 23 0

	$jointconstrain "ValveBiped.Bip01_L_UpperArm" x limit -30 30 0
	$jointconstrain "ValveBiped.Bip01_L_UpperArm" y limit -95 84 0
	$jointconstrain "ValveBiped.Bip01_L_UpperArm" z limit -86 26 0

	$jointconstrain "ValveBiped.Bip01_L_Forearm" x limit 0 0 0
	$jointconstrain "ValveBiped.Bip01_L_Forearm" y limit 0 0 0
	$jointconstrain "ValveBiped.Bip01_L_Forearm" z limit -149 4 0

	$jointconstrain "ValveBiped.Bip01_L_Hand" x limit -37 37 0
	$jointconstrain "ValveBiped.Bip01_L_Hand" y limit 0 0 0
	$jointconstrain "ValveBiped.Bip01_L_Hand" z limit -57 59 0

	$jointconstrain "ValveBiped.Bip01_R_Forearm" x limit 0 0 0
	$jointconstrain "ValveBiped.Bip01_R_Forearm" y limit 0 0 0
	$jointconstrain "ValveBiped.Bip01_R_Forearm" z limit -149 4 0

	$jointconstrain "ValveBiped.Bip01_R_Hand" x limit -60 60 0
	$jointconstrain "ValveBiped.Bip01_R_Hand" y limit 0 0 0
	$jointconstrain "ValveBiped.Bip01_R_Hand" z limit -57 70 0

	$jointconstrain "ValveBiped.Bip01_R_Thigh" x limit -12 12 0
	$jointconstrain "ValveBiped.Bip01_R_Thigh" y limit -8 75 0
	$jointconstrain "ValveBiped.Bip01_R_Thigh" z limit -97 32 0

	$jointconstrain "ValveBiped.Bip01_R_Calf" x limit 0 0 0
	$jointconstrain "ValveBiped.Bip01_R_Calf" y limit 0 0 0
	$jointconstrain "ValveBiped.Bip01_R_Calf" z limit -12 126 0

	$jointconstrain "ValveBiped.Bip01_Head1" x limit -20 20 0
	$jointconstrain "ValveBiped.Bip01_Head1" y limit -25 25 0
	$jointconstrain "ValveBiped.Bip01_Head1" z limit -13 30 0

	$jointconstrain "ValveBiped.Bip01_L_Thigh" x limit -12 12 0
	$jointconstrain "ValveBiped.Bip01_L_Thigh" y limit -73 6 0
	$jointconstrain "ValveBiped.Bip01_L_Thigh" z limit -93 30 0

	$jointconstrain "ValveBiped.Bip01_L_Calf" x limit 0 0 0
	$jointconstrain "ValveBiped.Bip01_L_Calf" y limit 0 0 0
	$jointconstrain "ValveBiped.Bip01_L_Calf" z limit -8 126 0

	$jointconstrain "ValveBiped.Bip01_L_Foot" x limit 0 0 0
	$jointconstrain "ValveBiped.Bip01_L_Foot" y limit -19 19 0
	$jointconstrain "ValveBiped.Bip01_L_Foot" z limit -15 35 0

	$jointconstrain "ValveBiped.Bip01_R_Foot" x limit 0 0 0
	$jointconstrain "ValveBiped.Bip01_R_Foot" y limit -25 6 0
	$jointconstrain "ValveBiped.Bip01_R_Foot" z limit -15 35 0
}

$collisiontext
{
	animatedfriction 
	{
		"animfrictionmin" "1.000000"
		"animfrictionmax" "400.000000"
		"animfrictiontimein" "0.500000"
		"animfrictiontimeout" "0.300000"
		"animfrictiontimehold" "0.000000"
	}
	editparams 
	{
		"rootname" "valvebiped.bip01_pelvis"
		"totalmass" "90.000000"
		"jointmerge" "valvebiped.bip01_pelvis,valvebiped.bip01"
		"jointmerge" "valvebiped.bip01_pelvis,valvebiped.bip01_spine1"
	}
}
$proceduralbones "male_07.vrd"

$bonemerge "ValveBiped.Bip01_Pelvis"
$bonemerge "ValveBiped.Bip01_Spine"
$bonemerge "ValveBiped.Bip01_Spine1"
$bonemerge "ValveBiped.Bip01_Spine2"
$bonemerge "ValveBiped.Bip01_Spine4"
$bonemerge "ValveBiped.Bip01_R_Clavicle"
$bonemerge "ValveBiped.Bip01_R_UpperArm"
$bonemerge "ValveBiped.Bip01_R_Forearm"
$bonemerge "ValveBiped.Bip01_R_Hand"
$bonemerge "ValveBiped.Anim_Attachment_RH"

Thanks!
[editline] God damn Studiocompiler…[/editline]

I guess the .qc works, if it wasn’T for the studiocompiler who has pretty much no motivation to work at all.
I set in the paths, textures, smds, animations and it spews out an error.

If it spews out an error, at least tell us what it says.

In any case, I’ve been building off the example male05 QC file in sourcesdk_content’s hl2mp reference files. There’s also a male 06 QC reference in the hl2 files. Since then I’ve learned quite a bit from the files and I’ve started adapting some of the newer methods using the Left 4 Dead 2 sdk_content which once again has released QCs.

There’s a lot of info that decompilers simply cannot read and translate for us and they still sometimes spit out a bunch of unnecessary info. If the source files are publicly released for us to use, why use a crude decompiled version instead? Not to mention the source files available to use usually split the QC into multiple files rather than cramming everything into a giant eyesore. Splitting them into parent folders often even allows you to share certain tidbits of code across different models if, say, the hitboxes were shared (though I guess alternatively you could just copy and paste the hitbox code across your model multiple times whenever you make changes).

Lastly, since the source code was actually released for modders to use, they often provide small comments above certain things in the QC which explain what it is and/or why they did it. It certainly helps reduce the amount of head scratching when working on QC edits.

Use Crowbar to compile & decompile models, it works much better and is actually being updated compared to other ones.

I made progress!

I wrote a .qc myself, but I get the error “Leaking 1 element” or something like that before StudioMDL closes down. (I stopped using studiocompiler because I found it a bit too tedious)

Is the error a qc-related one, or a model related one?

Honestly, it could be either problem. Mind posting the qc in


 tags?


$cd "D:\garrosh\"

$modelname "garrosh\garrosh.mdl"

$model "Garrosh" "Garrosh" {
}

$surface "flesh"

$body Garrosh "garrosh.smd"

$cdmaterials "garrosh"

$sequence idle "garrosh" loop fps 30

$collisionjoints "garrosh.smd" {

	$mass 90.0
	$inertia 10.000
	$damping 0.01
	$rotdamping 1.50
	
	$rootbone "garrosh_bone_Root"
	}



Here you go.

Instead of


$model "Garrosh" "Garrosh" {
}

you should do


 $model "Garrosh" "Garrosh.smd"

assuming you have an smd file named “Garrosh” in the same folder as the qc file.

I tried that out.

Now it sends out a red text that I can’t even read correctly before closing down.

[Editline]sec[/editline]
Oh wait! I used the wrong .QC file. I had an old one stored in D:.

Here’s the new one, I doubt anything other than the location changed, however:



$cd "G:\Steam\steamapps\common\SourceFilmmaker\content\usermod\materialsrc\model"

$modelname "garrosh\garrosh.mdl"

$model "Garrosh" "Garrosh" {
}

$surface "flesh"

$body Garrosh "garrosh2.smd"

$cdmaterials "garrosh"

$sequence idle "garrosh" loop fps 30

$collisionjoints "garrosh2.smd" {

	$mass 90.0
	$inertia 10.000
	$damping 0.01
	$rotdamping 1.50
	
	$rootbone "garrosh_bone_Root"
	}


Take note that the .smd is now called garrosh2.

Your idle animation is still looking for garrosh which you said you renamed to garrosh2. You should also change $model to $body and removed the brackets you have there as they aren’t doing anything. Other than that, we’d need to know what the error being printed is (or is leaking 1 element still it?).

On a side note, you should probably move your materials folder into models/garrosh so it’s located in materials/models/garrosh (just for organization purposes).

The current error was a bunch of yellow text, then some red text and then studiomdl shut down.
I couldn’t read it.

[editline]WOA[/editline]

Another update:

I removed one of the two $bodys and I ended up getting a full report.

It’s too quick for me to see what’s going on, though, but I see no models anywhere.

New new code:


$cd "G:\Steam\steamapps\common\SourceFilmmaker\content\usermod\materialsrc\models"

$modelname "garrosh\garrosh2.mdl"

$surface "flesh"

$body Garrosh "garrosh2.smd"

$cdmaterials "garrosh"

$sequence idle "garrosh2" loop fps 30

$collisionjoints "garrosh2.smd" {

	$mass 90.0
	$inertia 10.000
	$damping 0.01
	$rotdamping 1.50
	
	$rootbone "garrosh_bone_Root"
	}



Change


$sequence idle "garrosh2" loop fps 30

to


$sequence idle "idle" loop fps 30

And make sure that the idle animation smd file is named idle.smd

Tried that; it didn’t work, sadly.

Do you have an idle animation in an smd format for this model?
Also, switch to Crowbar, it’s 100x easier to use and will give you a full report on the error instead of closing.

I don’t. I tried copying the garrosh smd and using that one (with a rename, of course), but that didn’t seem to work.

I tried compiling.
I end up with an empty log and no progress.

That’s why you have the “leak”. You’ll have to make an idle animation that lasts at least 1 frame for you to loop it. Do a quick Google search on how to add animations in your 3d modeling program and make a 1 frame idle animation for it.

I tried making an animation, but I can’t get it to work in Blender.
I’m using 3DS Max 2015, so no plugins for SMD export work, hence I must use Blender.

I added keyframes, but it didn’t seem to change anything.

I don’t use Blender and have no idea how to use it, but try following this video on how to export the file with animations.

Unfortunately, that’s the best solution I can offer you, unless you want to look up more Blender animation tutorials.