Pick up the crowbar of research scientist Gordon Freeman, who finds himself on an alien-infested Earth being picked to the bone, its resources depleted, its populace dwindling. Freeman is thrust into the unenviable role of rescuing the world from the wrong he unleashed back at Black Mesa. And a lot of people, people he cares about, are counting on him.

Post tutorial Report RSS HL2 NPC Replacement

This will show you have to make new NPC without coding. :)

Posted by on - Intermediate Client Side Coding

[page=Part I: A new hope]

Hello, I am Grand General Hot, I am here to teach you how to replace HL2 NPCs (well in fact this would work for any source game for that matter). This is very easy to do once you get the hang of it :)

Alright lets get started:

Okay, first off you'll need a set of tools to work with you'll need GCFscape, and a fixed version of StudioCompiler & the older unfixed version here:Old StudioCompiler.

Right first off use GCFscape to find the model you want from HL2/CSS/DoDS/ Sin: Episodes (if you're feeling risky). But for this I'm using CSS for this; I have picked the GIGN for my mission of this tutorial (please ignore the SAS folder in the picture below; I couldn't be bothered to fix it).

Make sure you have placed the textures for your model into your mod/hl2 folders, or you'll have good old checkers for dinner (make sure the texture of the model is in the path folder path as you saw it in the GCFscape window, or you'll have the checker texture again. I can't state this enough you need it in the same DIR path as the texture already was (but there an little extra bonus in there if you like to know, you heard of hexing right? Well you can change the DIR path for the model in the decompiled .qc but the only downside is that you need to change the .vmt DIR path as well to make it work well…)) now that you have GCFscaped the textures into your mod/hl2 apps DIR, we will now GCFscape the needed model files into their folders as seen below

User Posted Image

Make sure that you have every file for that model, there should be six files per model (they have different functions for that model, but important functions nonetheless). By now you should have your model files into those folders (god, hopefully :D). Okay, now bring up your StudioCompiler (this should be in this DIR path "C:\Program Files\Steam\SteamApps\******\sourcesdk\bin") and click on the "Model Decompile" tab.

User Posted Image

Now make sure your output is in that folder as the model you want decompiled compiled and you should have your model selected by now as well. Okay, now press "Extract" and the model should decompile into the folder you selected. Now do the same for the other model. ;)

Now you should have useless files lying in the folders now, delete the six files that was made up into that model you decompiled, but you don't have to delete them if you don't want to.

If your new to QC files and don't know how to open them, here's what to do, click on until a window pops up asking you to open it with a program you already have, pick: NotePad (The author requested WordPad, however, WordPad is a rich text editor, and cause some problems. If you're sure, use WordPad. -Ed) and open it with it and it should bring up a lot of QC code

Now you're combine QC is very importation, the other files in the combine folder are unless, delete them. Only the QC file is what you need for the mean time, please do not delete the other models .smd and .qc files as you WILL need them!

Here is what the QC file of the combine looks like at the moment.

Edit: People have been having problems understanding this tutorial as the bold highlight is gone, there is the word |Strong| in the text, from that until |/Strong|

$cd "C:\Program Files\Steam\SteamApps\username\The Room\modelsrc\combine"
$modelname "Combine_Soldier.mdl"
$model "Soldier" "Soldier_reference.smd"
<strong>$lod 10
 {
  replacemodel "Soldier_reference" "lod1_Soldier_reference"
}
$lod 25
 {
  replacemodel "Soldier_reference" "lod2_Soldier_reference"
}
$lod 40
 {
  replacemodel "Soldier_reference" "lod3_Soldier_reference"
}
$lod 60
 {
  replacemodel "Soldier_reference" "lod4_Soldier_reference"
}
$shadowlod
{
  replacemodel "Soldier_reference" "lod5_Soldier_reference"
}
$cdmaterials "models\Combine_Soldier\"
$hboxset "default"
$hbox 2 "ValveBiped.Bip01_Spine" -1.000  -4.740  -7.220  7.000  8.270  6.780
$hbox 1 "ValveBiped.Bip01_Head1" -1.750  -8.000  -3.500  7.250  4.000  3.500
$hbox 4 "ValveBiped.Bip01_L_UpperArm" -2.000  -2.750  -2.750  12.000  2.750  2.750
$hbox 4 "ValveBiped.Bip01_L_Forearm" 0.000  -2.440  -2.150  10.000  2.060  2.350
$hbox 4 "ValveBiped.Bip01_L_Hand" 0.250  -1.000  -2.000  5.750  1.000  2.000
$hbox 5 "ValveBiped.Bip01_R_UpperArm" -2.000  -2.750  -2.750  12.000  2.750  2.750
$hbox 5 "ValveBiped.Bip01_R_Forearm" 0.000  -2.250  -2.250  10.000  2.250  2.250
$hbox 5 "ValveBiped.Bip01_R_Hand" 0.500  -0.960  -2.330  5.500  1.040  2.610
$hbox 6 "ValveBiped.Bip01_L_Thigh" 1.070  -3.000  -3.000  18.920  5.000  4.000
$hbox 6 "ValveBiped.Bip01_L_Calf" 0.500  -3.500  -2.800  15.500  3.500  3.200
$hbox 6 "ValveBiped.Bip01_L_Foot" -0.500  -1.500  -2.000  5.500  4.500  2.500
$hbox 6 "ValveBiped.Bip01_L_Toe0" -0.250  -1.750  -2.190  3.250  0.750  2.460
$hbox 7 "ValveBiped.Bip01_R_Thigh" 1.000  -5.500  -3.500  19.000  3.500  3.500
$hbox 7 "ValveBiped.Bip01_R_Calf" 0.500  -4.010  -2.570  15.500  3.990  2.930
$hbox 7 "ValveBiped.Bip01_R_Foot" -1.250  -4.000  -2.250  5.250  2.000  2.250
$hbox 7 "ValveBiped.Bip01_R_Toe0" -1.000  -0.750  -2.600  3.000  1.750  2.100
$hbox 0 "ValveBiped.Bip01_Pelvis" -7.000  -4.500  -8.000  7.000  4.500  5.000
$hbox 0 "ValveBiped.Bip01_Spine2" -1.000  -4.250  -7.250  13.000  8.250  7.250
// Model uses material "combinesoldiersheet.vmt"
$attachment "lefthand" "ValveBiped.Bip01_L_Hand" 0.00 -0.00 -0.00 rotate -0.00 0.00 -0.00
$attachment "zipline" "ValveBiped.Bip01_Spine4" 3.00 -4.00 -0.00 rotate 0.00 -0.00 -0.00
$attachment "eyes" "ValveBiped.Bip01_Head1" 4.50 -5.00 0.00 rotate 0.00 -90.00 -90.00
$attachment "anim_attachment_RH" "ValveBiped.Anim_Attachment_RH" -0.00 -0.00 -0.00 rotate -90.00 -90.00 0.00
$attachment "anim_attachment_LH" "ValveBiped.Anim_Attachment_LH" -0.00 -0.00 0.00 rotate -90.00 -90.00 0.00</strong>
$includemodel "combine_soldier_anims.mdl"
$surfaceprop "flesh"
$keyvalues  { physgun_interactions { "onpickup" "boogie" "onlaunch" "spin_zaxis" "onfirstimpact" "bloodsplat"  } } 
$eyeposition 0.000 0.000 73.000
$illumposition -2.255 0.000 36.711
$sequence ragdoll "ragdoll" ACT_DIERAGDOLL 1 fps 30.00
$ikchain rhand ValveBiped.Bip01_R_Hand knee  0.707 0.707 0.000
$ikchain lhand ValveBiped.Bip01_L_Hand knee  0.707 0.707 0.000
$ikchain rfoot ValveBiped.Bip01_R_Foot knee  0.707 -0.707 0.000
$ikchain lfoot ValveBiped.Bip01_L_Foot knee  0.707 -0.707 0.000
$collisionjoints "phymodel.smd" {

	$mass 100.0
	$inertia 2.00
	$damping 0.01
	$rotdamping 0.40
	$rootbone "valvebiped.bip01_pelvis"
	$jointmerge "ValveBiped.Bip01_Pelvis" "ValveBiped.Bip01_Spine1"

	$jointconstrain "valvebiped.bip01_spine2" x limit -48.00 48.00 0.20
	$jointconstrain "valvebiped.bip01_spine2" y limit -25.00 25.00 0.20
	$jointconstrain "valvebiped.bip01_spine2" z limit -25.00 50.00 0.20

	$jointconstrain "valvebiped.bip01_r_upperarm" x limit -50.00 57.00 0.20
	$jointconstrain "valvebiped.bip01_r_upperarm" y limit -19.00 102.00 0.20
	$jointconstrain "valvebiped.bip01_r_upperarm" z limit -93.00 30.00 0.20

	$jointconstrain "valvebiped.bip01_l_upperarm" x limit -50.00 57.00 0.20
	$jointconstrain "valvebiped.bip01_l_upperarm" y limit -102.00 19.00 0.20
	$jointconstrain "valvebiped.bip01_l_upperarm" z limit -93.00 30.00 0.20

	$jointmassbias "valvebiped.bip01_l_forearm" 2.00
	$jointconstrain "valvebiped.bip01_l_forearm" x limit 0.00 0.00 0.00
	$jointconstrain "valvebiped.bip01_l_forearm" y limit 0.00 0.00 0.00
	$jointconstrain "valvebiped.bip01_l_forearm" z limit -120.00 4.00 0.20

	$jointmassbias "valvebiped.bip01_l_hand" 4.00
	$jointconstrain "valvebiped.bip01_l_hand" x limit -120.00 120.00 0.20
	$jointconstrain "valvebiped.bip01_l_hand" y limit 0.00 0.00 0.20
	$jointconstrain "valvebiped.bip01_l_hand" z limit -57.00 70.00 0.20

	$jointmassbias "valvebiped.bip01_r_forearm" 2.00
	$jointconstrain "valvebiped.bip01_r_forearm" x limit 0.00 0.00 0.20
	$jointconstrain "valvebiped.bip01_r_forearm" y limit 0.00 0.00 0.20
	$jointconstrain "valvebiped.bip01_r_forearm" z limit -120.00 4.00 0.20

	$jointmassbias "valvebiped.bip01_r_hand" 4.00
	$jointconstrain "valvebiped.bip01_r_hand" x limit -120.00 120.00 0.20
	$jointconstrain "valvebiped.bip01_r_hand" y limit 0.00 0.00 0.00
	$jointconstrain "valvebiped.bip01_r_hand" z limit -57.00 70.00 0.20

	$jointconstrain "valvebiped.bip01_r_thigh" x limit -25.00 39.00 0.20
	$jointconstrain "valvebiped.bip01_r_thigh" y limit -8.00 75.00 0.20
	$jointconstrain "valvebiped.bip01_r_thigh" z limit -97.00 32.00 0.20

	$jointmassbias "valvebiped.bip01_r_calf" 2.00
	$jointconstrain "valvebiped.bip01_r_calf" x limit 0.00 0.00 0.20
	$jointconstrain "valvebiped.bip01_r_calf" y limit 0.00 0.00 0.20
	$jointconstrain "valvebiped.bip01_r_calf" z limit -12.00 126.00 0.20

	$jointmassbias "valvebiped.bip01_head1" 2.00
	$jointconstrain "valvebiped.bip01_head1" x limit -20.00 20.00 0.20
	$jointconstrain "valvebiped.bip01_head1" y limit -25.00 25.00 0.20
	$jointconstrain "valvebiped.bip01_head1" z limit -13.00 30.00 0.20

	$jointconstrain "valvebiped.bip01_l_thigh" x limit -25.00 20.00 0.20
	$jointconstrain "valvebiped.bip01_l_thigh" y limit -73.00 6.00 0.20
	$jointconstrain "valvebiped.bip01_l_thigh" z limit -93.00 30.00 0.20

	$jointmassbias "valvebiped.bip01_l_calf" 2.00
	$jointconstrain "valvebiped.bip01_l_calf" x limit 0.00 0.00 0.20
	$jointconstrain "valvebiped.bip01_l_calf" y limit 0.00 0.00 0.20
	$jointconstrain "valvebiped.bip01_l_calf" z limit -8.00 126.00 0.20

	$jointmassbias "valvebiped.bip01_l_foot" 4.00
	$jointconstrain "valvebiped.bip01_l_foot" x limit -1.00 -1.00 0.20
	$jointconstrain "valvebiped.bip01_l_foot" y limit -19.00 19.00 0.20
	$jointconstrain "valvebiped.bip01_l_foot" z limit -15.00 35.00 0.20

	$jointmassbias "valvebiped.bip01_r_foot" 4.00
	$jointconstrain "valvebiped.bip01_r_foot" x limit 0.00 0.00 0.00
	$jointconstrain "valvebiped.bip01_r_foot" y limit -21.00 6.00 0.20
	$jointconstrain "valvebiped.bip01_r_foot" z limit -15.00 35.00 0.20
	$animatedfriction 1.000 1000.000 0.800 0.500 0.000


Now we are going to fix that to make it work with the GIGN files, you may also note that some of the lines are in bold, well that is because those are the lines are going to be changed with similar from the GIGN .qc file but only lines above the $includemodel "combine_soldier_anims.mdl” but now move over the GIGN .smd files to the combine folder (but make sure you deleted the combine .smd files first!) but leave the GIGN .qc behind in the folder!

Part 2: Return of the GIGN

Now we will bring up the gign .qc (but I'm only going to copy the bit we only need):

$lod 10
 {
  replacemodel "ct_gign_reference" "lod1_ct_gign_reference"
}
$lod 20
 {
  replacemodel "ct_gign_reference" "lod2_ct_gign_reference"
}
$lod 35
 {
  replacemodel "ct_gign_reference" "lod3_ct_gign_reference"
}
$lod 50
 {
  replacemodel "ct_gign_reference" "lod4_ct_gign_reference"
}
$lod 70
 {
  replacemodel "ct_gign_reference" "lod5_ct_gign_reference"
}
$shadowlod
{
  replacemodel "ct_gign_reference" "lod6_ct_gign_reference"
}
$poseparameter move_yaw -180.00 180.00 360.00
$poseparameter body_pitch -90.00 90.00 360.00
$poseparameter body_yaw -90.00 90.00 360.00
$cdmaterials "models\player\ct_gign\"
$hboxset "cstrike"
$hbox 3 "ValveBiped.Bip01_Pelvis" -8.299  -7.727  -5.429  8.299  2.007  6.583
$hbox 6 "ValveBiped.Bip01_L_Thigh" 4.576  -5.377  -3.432  22.880  3.775  4.576
$hbox 6 "ValveBiped.Bip01_L_Calf" -0.291  -4.295  -3.432  20.883  3.151  3.432
$hbox 6 "ValveBiped.Bip01_L_Foot" -2.288  -1.144  -2.579  5.720  4.576  2.007
$hbox 6 "ValveBiped.Bip01_L_Toe0" -2.860  -2.808  -2.860  4.004  1.196  1.716
$hbox 7 "ValveBiped.Bip01_R_Thigh" 4.576  -5.377  -3.432  22.880  3.775  4.576
$hbox 7 "ValveBiped.Bip01_R_Calf" -0.291  -4.295  -3.432  20.883  3.151  3.432
$hbox 7 "ValveBiped.Bip01_R_Foot" -2.288  -1.144  -2.007  5.720  4.576  2.579
$hbox 7 "ValveBiped.Bip01_R_Toe0" -2.860  -2.808  -1.716  4.004  1.196  2.860
$hbox 3 "ValveBiped.Bip01_Spine1" -9.152  -1.258  -8.008  4.576  11.326  8.008
$hbox 2 "ValveBiped.Bip01_Spine2" -3.068  -3.432  -9.693  13.572  10.317  9.693
$hbox 1 "ValveBiped.Bip01_Neck1" -0.104  -4.576  -2.860  5.512  2.288  2.860
$hbox 1 "ValveBiped.Bip01_Head1" -0.416  -6.240  -3.640  9.360  4.441  3.016
$hbox 4 "ValveBiped.Bip01_L_UpperArm" -1.144  -2.579  -2.288  14.872  2.579  2.288
$hbox 4 "ValveBiped.Bip01_L_Forearm" -1.716  -2.402  -2.402  13.156  2.402  2.402
$hbox 4 "ValveBiped.Bip01_L_Hand" 0.291  -2.465  -1.716  6.583  1.550  2.860
$hbox 5 "ValveBiped.Bip01_R_UpperArm" -1.144  -2.579  -2.288  14.872  2.579  2.288
$hbox 5 "ValveBiped.Bip01_R_Forearm" -1.716  -2.402  -2.402  13.156  2.402  2.402
$hbox 5 "ValveBiped.Bip01_R_Hand" 0.291  -2.465  -2.860  6.583  1.550  1.716
// Model uses material "ct_gign.vmt"
// Model uses material "ct_gign_glass.vmt"
$attachment "forward" "ValveBiped.forward" 0.00 -0.00 0.00 rotate 0.00 0.00 -0.00
$attachment "grenade0" "ValveBiped.Bip01_Spine" 5.99 0.39 7.59 rotate 76.91 71.22 57.14
$attachment "grenade1" "ValveBiped.Bip01_Spine" 6.24 -2.34 6.66 rotate 62.97 100.42 87.46
$attachment "grenade2" "ValveBiped.Bip01_Spine" -0.35 2.21 -8.34 rotate -75.89 92.68 95.17
$attachment "grenade3" "ValveBiped.Bip01_Spine" 1.22 -1.11 -7.34 rotate -78.22 82.38 102.13
$attachment "pistol" "ValveBiped.Bip01_R_Thigh" 0.05 3.84 -6.30 rotate 0.08 -2.59 79.96
$attachment "primary" "ValveBiped.Bip01_Spine2" 10.44 -5.10 -4.88 rotate -11.71 179.79 3.52
$attachment "defusekit" "ValveBiped.Bip01_Pelvis" 0.00 1.22 -6.66 rotate -73.06 90.93 179.75
$attachment "eholster" "ValveBiped.Bip01_L_Thigh" 5.36 0.02 4.90 rotate 8.31 -91.56 99.67
$attachment "lfoot" "ValveBiped.Bip01_L_Foot" 0.00 5.20 0.00 rotate -0.00 0.00 -0.00
$attachment "rfoot" "ValveBiped.Bip01_R_Foot" -0.00 5.20 0.00 rotate 0.00 -0.00 0.00
$attachment "muzzle_flash" "ValveBiped.Bip01_L_Hand" -0.00 -0.00 0.00 rotate -0.00 -0.00 0.00

Now remember the combine QC I bolded, paste that over the part I bolded, but we aren't finished with the QC yet, this what the what it should look like but there will be something you'll need to change, but only a small change, I'll bold it to you show you:

$cd "C:\Program Files\Steam\SteamApps\username\The Room\modelsrc\combine"
$modelname "Combine_Soldier.mdl"
$model "Soldier" "<strong>ct_gign_reference.smd</strong>"

You see what I had bolded? that had to changed because of the QC wouldn't have known it was there in the first place, but it's all fixed now; but here something you need to know! You see this bit of QC code:

Edit: People have been having problems understanding this tutorial as the bold highlight is gone, there is the word |Strong| in the text, from that until |/Strong|

$cd "C:\Program Files\Steam\SteamApps\username\The Room\modelsrc\combine"
$modelname "Combine_Soldier.mdl"
$model "<strong>Soldier</strong>" "ct_gign_reference.smd"

If you want that GIGN model to work properly in game, you need to keep that line I've bolded the same always, or you'll get errors in game! It's very importation that you never change it on the QC you want to compile (It has something to do with the code that was used for the combine when it was made in game I believe)!

Now the combine QC is ready for compiling (Yay!).

User Posted Image

Now pick your combine QC and compile it! :D

If done properly then you will come out with something like this!

User Posted Image

Well done if you got your model to work!

Downsides to this: you can only do this with NPC

Post comment Comments
zombieOnion
zombieOnion - - 632 comments

Why cannot i add animations? If i make them myself in 3dsmax/XSI/Maya and declare them in the QC file.. that should allow them to be called in-game?

Reply Good karma Bad karma+2 votes
Sallycin
Sallycin - - 635 comments

Nicely done tutorial :) I'll have to try it sometime.

Reply Good karma Bad karma+2 votes
hot564231
hot564231 - - 192 comments

This can be used on props as well, lets say a Med-pack you want replaced, it quite easy to do these things, makes modding just that bit easier

Reply Good karma Bad karma+1 vote
R0CKET_B0MB
R0CKET_B0MB - - 77 comments

What is it with people and meds, ha ha ha! :D

Reply Good karma Bad karma+1 vote
Grand_General_Hot Author
Grand_General_Hot - - 95 comments

I mean't in the sense that the AI wouldn't be able to use them, but they might used for Face poser but if you know how to code and make it work with the AI, go right ahead mate; Can't stop you

Reply Good karma+1 vote
Grand_General_Hot Author
Grand_General_Hot - - 95 comments

Well just a thought, you could use them in the AI if you replace that animation for hat action, such as walking and etc. but thats just a thought

Reply Good karma+1 vote
Wraiyth
Wraiyth - - 483 comments

[quote]Downsides to this: you can only do this with NPC

Reply Good karma Bad karma+1 vote
Grand_General_Hot Author
Grand_General_Hot - - 95 comments

Well I didn't know that, I took it for granted.

Reply Good karma+1 vote
drhead
drhead - - 59 comments

Can this be used on an ragdoll?

Reply Good karma Bad karma+1 vote
Qwertyz
Qwertyz - - 354 comments

Hmmm, can't get it working with the corpse model, could someone pelase assit, i'm trying to replace the zombie model with the corpse model, but there are no animations for walking and attacking?

Reply Good karma Bad karma+1 vote
Grand_General_Hot Author
Grand_General_Hot - - 95 comments

Yes, as long as the bones are simlair it should work

Reply Good karma+1 vote
foxconn_subversion
foxconn_subversion - - 5 comments

NOTE: Valve allows you to use their game content freely (from HL2, CSS, DODS) as long as you have a legal copy.

I just got an idea: what about making a CSS:COOP modification?
You and your mates take down evil terrorist NPCs in a single-player story style together!
AFAIU all you need is the code of the AI and your tutorial...

Reply Good karma Bad karma+1 vote
Grand_General_Hot Author
Grand_General_Hot - - 95 comments

Frankly I wouldn't give a crap if allowed it or not.

Reply Good karma+2 votes
J69L
J69L - - 1 comments

I just want to change the Models from the Humans to the Zombie model. Works fine but some animations are missing. Can you tell us how to add existing animations to the animations the "new" Model?

Reply Good karma Bad karma+1 vote
Grand_General_Hot Author
Grand_General_Hot - - 95 comments

I had the same problem, I gave up on the zombie model. It only seems to work with models that have their animations in .mdl's

Reply Good karma+1 vote
xrabohrok
xrabohrok - - 2 comments

Actual coding is required to change how something animates. The programming determines how animations are called.

Reply Good karma Bad karma+2 votes
Exosoldier22
Exosoldier22 - - 172 comments

I cant get the studio compiler to start...every time i start it it says "The procedure entry point Q_vsnprintf could not be locaed in the dynamic link library cstdlib.ddl." can anyone help?

Reply Good karma Bad karma+3 votes
Oxegen_gamming
Oxegen_gamming - - 172 comments

every time i try to compile it says ERROR: c:\( my directory) mdldecompiler.qc(4): - bad command }

Reply Good karma Bad karma+1 vote
Kaweebo
Kaweebo - - 172 comments

I wanted to change the Combine, Barney, Alyx, and Breen models in a mod I have but leave the original models in HL2 and it's episodes, does this help with that or did I read it wrong.

Reply Good karma Bad karma+1 vote
bigbilly21
bigbilly21 - - 62 comments

could this work for cs go models

Reply Good karma Bad karma+1 vote
Cosmin0
Cosmin0 - - 15 comments

DOWNLOAD?

Reply Good karma Bad karma+1 vote
Cosmin0
Cosmin0 - - 15 comments

ce program este care este modelul?

Reply Good karma Bad karma+1 vote
Guest
Guest - - 687,512 comments

This comment is currently awaiting admin approval, join now to view.

Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: