Replacing Source Models/Skins With a Hex Editor.

2011-07-14_00015
In this tutorial, we’re gonna replace Rochelle (Not so Pretty) with Zoey (Pretty) using only a hex editor, then reskin our new Zoey – or Zoeys!

If you’ve tried this before, you’ll soon realise that renaming one .mdl file to another just doesn’t work.

 

 

On top of this, reskinning generally requires that you overwrite a texture instead of adding a completely new set. We’re using Left 4 Dead 2 in this example, but it works identically for GMod, Portal, HL2, etc.

This is the model only (and texture further into the tutorial). So for all intents and purposes, the character will be Rochelle (voices, name, etc),  but will look like Zoey (Texture, Shape, Animations). Just for kicks, we’ll package the lot into an addon at the end.

 

Required Tools:

Nem’s GCFScape
http://nemesis.thewavelength.net/index.php?p=26
-To extract .VPK files, and other packages
Hex Workshop:
http://www.hexworkshop.com/
-The demo should be fine.
Optionally, you can also grab a copy of the Left 4 Dead 2 SDK (Left 4 Dead 2 Authoring tools) on steam. You’ll need it if you decide to package your model into an addon.

Step 1 – Extract the Zoey files from the package.

Make a folder:   c:\zoeymod\
Open GCFScape, and point it at: 
C:\Program Files\Steam\steamapps\common\left 4 dead 2\left4dead2_dlc2\pak01_dir.vpk
Go to \models\survivors\  and copy the survivor_teenangst.* file into 
c:\zoeymod\models\survivors\survivor_teenangst.*
i.e.
survivor_teenangst.phy
survivor_teenangst.vvd
survivor_teenantst.mdl
survivor_teenantst.dx90.vtx
Why do we need the other files?
Without them the game engine will complain incessantly about checksum errors.
(For the sake of shortening the tutorial, I’ll give you the hint that the original rochelle model is stored in: C:\Program Files\Steam\steamapps\common\left 4 dead 2\left4dead2\pak01_dir.vpk  as  survivor_producer.mdl  – remember this name)

Step 2 – Hex the file.

Open survivor_teenangst.mdl in hex works.
Look at the very top, notice the first line ‘survivors/survivor_TeenAngst.mdl’. This is the line that tells the mdl file where it *should* be placed.
Since we know rochelle’s file is survivor_producer.mdl,  let’s start typing over it..
At some point you’ll end up with an extra “l”  we can’t be leaving that there.
Whenever you need to make a string shorter, start inserting 00’s .
Select the extra L, and look in the right hand side panel, it should have ‘6c’ highlighted.
Click on the left, and write over it with 00, it now look a little like this:
00000000 49 44 53 54 31 00 00 00 7D 38 09 F4 73 75 72 76 69 76 6F 72 73 2F 73 75 72 76 IDST1…}8..survivors/surv
0000001A 69 76 6F 72 5F 70 72 6F 64 75 63 65 72 2E 6D 64 6C 00 00 00 00 00 00 00 00 00 ivor_producer.mdl………
Save the file and make a backup if you wish.
Close the hex editor, and rename the files:
rename survivor_teenangst.dx90.vtx   survivor_producer.dx90.vtx
rename survivor_teenangst.phy    survivor_producer.phy
rename survivor_teenangst.vvd    survivor_producer.vvd
rename survivor_teenangst.mdl    survivor_producer.mdl

Step 3 – Package the addon file.

If you’ve not downloaded the Left 4 Dead 2 Authoring tools via steam, do so, and keep reading this line till it’s done.
In your c:\zoeymod\ folder, make a file called addoninfo.txt
I’ll save you some time, paste this into it:
“AddonInfo”
{
addontitle “Rochelle is Zoey”
addonversion “1.0”
addonauthor “Sicklebrick”
addonDescription “Makes certain things happen that often you wish might happen, but generaly dont’t.”
addonURL0 “http://sicklebrick.com”
//original file addonDescription “zoey body_ravaged_0_8_l4d2”
addonContent_Survivor 1 “zoey” 
addonContent_Skin 1 
}
Save up, close the .txt.
Open the folder:
C:\Program Files\Steam\steamapps\common\left 4 dead 2\bin
Now drag your c:\zoeymod folder onto the  VPK.exe file, and check your C: drive.
Assuming all went to plan, it should be zipped up and ready in c:\zoeymod.vpk
Copy this to
c:\zoeymod.vpk into C:\Program Files\Steam\steamapps\common\left 4 dead 2\left4dead2\addons\
Start left 4 dead, and have a wee look for zoey!

Step 4 – Give the altered zoey, a different texture.

So now we have rochelle replaced with zoey. 
We could for example replace coach and ellis with Zoey also, but then we have a little problem,
they all use the same texture file, and as such, it’s hard to tell them apart.
If we were to alter zoey’s texture, anything using that texture, including the original zoey will also be altered.
Open
 C:\Program Files\Steam\steamapps\common\left 4 dead 2\left4dead2_dlc2\pak01_dir.vpk
 in GCFScape, and open \materials\models\survivors\teenangst\ 
These are all of zoey’s textures. Let’s extract them to 
c:\zoeymod\materials\models\survivors\teenangst\
Right, since this is a dirty hack, we’ll start by renaming the teenangst folder to xeenangst.
Open the folder and take a wee looksee inside.
All of the .vmt files are plain text and describe the properties of the .VTF textures.
Open each one in notepad, and look for paths like this:
For example open zoey_color.vmt and locate this line:
$baseTexture “models\survivors\TeenAngst/zoey_color”
change it to the following:
$baseTexture “models\survivors\XeenAngst/zoey_color”
Do this wherever you see “TeenAngst” – there should be about 10-15 instances between all of the .vmt files.
**Only do this as part of a folder name:  i.e.  models\survivors\xeenangst\   not models\something\xeenangst.vtf
The last step is to hex the model file to use the new texture directory.
Open survivor_producer.mdl with hexworks, scroll down to the bottom of the file, you’ll see a string:
models/survivors/teenangst/zoey_hair
As before, if the new string was smaller, you’d have to pad the end with 00s, but for now, let’s just rename it to 
models/survivors/Xeenangst/zoey_hair
Do the same for:
models/survivors/teenangst/teenangst_eyeball_r
models/survivors/teenangst/teenangst_eyeball_l
models\survivors\TeenAngst\
which would become:
models/survivors/xeenangst/teenangst_eyeball_r
models/survivors/xeenangst/teenangst_eyeball_l
models\survivors\XeenAngst\
See what we’re doing here?
It’s still looking for the same file names for textures, but they’re in different folders.
 
And, that’s pretty much it!
If you want to quickly edit zoey_color.vtf, to prove it’s using a different texture source, grab these tools:
Nem’s VTF Plug=In for photoshop:
http://nemesis.thewavelength.net/index.php?c=154
Adobe Photoshop 6 (Free)
http://www.brothersoft.com/adobe-photoshop-249357.html
and draw a wavy line over zoey just to prove it works.
Repackage the mod as before, and have a looksee!
You now posess the skillset to say, turn every character into zoey, with a different skin, to reskin every civilian in HL2 into one clone,
or whatever takes your fancy. You could even download 4 separate Zoey models, and replace each cast member with one.
Hell, even Coach or Ellis if that floats your boat. Never Nick.
 
[Zoom in on the screenies to see the wavy line on billzoey’s chest]

Leave a Reply

Your email address will not be published. Required fields are marked *