How to have a custom turret skin in your map
For this tutorial you'll need:
- Notepad++- Squirrel syntax highlighter for Notepad++, installation instructions should be on the linked article- GCFScape- The latest version of VTFEdit, so you can edit Portal 2's textures
Navigate to your steamapps/common/portal 2/portal2/ folder, and open pak01_dir.vpk with GCFScape. Navigate to models > npcs > turret, then extract the turret.* files into your portal2 folder (preserving the structure, so you should make a models/npcs/turret/ folder for the extracted turret)
Now, rename them to something unique. I'll rename them to turret_red, so turret_red.mdl turret_red.vtx etc.
Then extract materials > models > npcs > turret from the VPK into your Portal 2 folder, preserving structure like with the model file.
The texture file I want to edit right now is turret_casing.vtf, so we do a crucial step: renaming it. **The new name of the texture MUST** be the same length as the old name. I'll call it turrrt_casing.vtf, be sure to rename turret_casing.vmt, and edit it so it points to the new texture name;
VertexLitGeneric
{
$baseTexture "models/npcs/turret/turret_casing"
$surfaceprop solidmetal
$phong 1
$phongexponent 50
$phongfresnelranges "[5 1 2]"
$phongboost ".6"
$basemapalphaphongmask 1
}
would become:
VertexLitGeneric
{
$baseTexture "models/npcs/turret/turrrt_casing"
$surfaceprop solidmetal
$phong 1
$phongexponent 50
$phongfresnelranges "[5 1 2]"
$phongboost ".6"
$basemapalphaphongmask 1
}
Now we're ready to edit the model. Open turret_red.mdl in Notepad++ and search for "turret_casing", then edit it to "turrrt_casing". If you do not pick a name that is the same length as the old one, the model will break.

Edit turrrt_casing.vtf/vmt to your heart's content. Here's what mine looks like:
Now for the next part: the VScripts.
Navitate to portal2/scripts/vscripts, make a folder called "modelchanger" then in there make a file called "turret_red.nut" and put this text in and save:
function ChangeTurrets(){
Entities.FindByClassname(null, "npc_portal_turret_floor").SetModel("models/npcs/turret/turret_red.mdl");
}
Now for the Hammer step.
Load up a map you wanna put a custom turret in, and place a prop_dynamic somewhere you don't think a player will see it and give it the custom turret model. This loads the model into memory so the vscript is able to change the turret's model.
Then place a logic_script, name it something and point it to the vscript we just made. (modelchanger/turret_red.nut)
Make a logic_auto, give it an OnMapSpawn output, tell it to make the logic_script execute the ChangeTurrets() function.
Compile, run then you should have a custom turret! Here's my red turret right beside a console-spawned turret:

Note: The turret has more textures than turret_casing.vmt, so you'll have to edit those too. You should also be able to use this method with other ents you can't normally skin, like npc_personality_core
If you have any questions or ideas on how to improve this tutorial, fire away 
Would i be able to add those turrets to the game/hammer using your method? or does that require a different method?
And when using your method did you simply recreate a skin for the original turret model or a completely new turret model?
KenJeKenny!? wrote:
Yeh those are the ones i mean...Would i be able to add those turrets to the game/hammer using your method? or does that require a different method?
And when using your method did you simply recreate a skin for the original turret model or a completely new turret model?
I made a new skin using portal 2's turret model. Also P2's textures use a completely different texture layout from Portal's turrets so you're going to need to remake those skins in Portal 2 (or ask the creator of those turret skins to) if you wanna use 'em
EDIT: And I just now realize how old this thread is, crap!
I do want to do this however, is there a way to make this work? The script is broken for me.
chickenmobile wrote:
What error is the script giving you? (If any)
I posted it, it complains the index "ChangeTurrets" doesn't exist. I know I spelled it right in the script and in Hammer, so I'm not sure what's wrong.
That may be displayed beacuse:
- The script you are referencing is wrong in the logic_script. E.g. the script isn't even listed in the Entity Scripts field.- There is a syntax error- You are trying to RunScriptCode ChangeTurrets not ChangeTurrets()- Some other obscure reason which is not listed here.
Thanks, that saved me from having to use a custom script.
CamBen wrote:
does the mdl text changing work with XVI32?
Should work, yes. But then again, so does editing it with Notepad++. The things you can read, at least, are changeable. 
Any reccomendations?
If you want to replace ALL turrets with that new skin, it's enough to pack the original VMT into the map but change it's path.
I just did this in a map for Garry's Mod.
It seems like the game will ever use the VTFs given by the GCF/VPK. But, at least in the "older" Source games, the VMT of the BSP has the higher priority.
Just make a copy of the turret VMT into your map and change the path of $basetexture to your new VTF.
(I hope I don't mix something up, but it should be right).
So you don't need to hex any model or to use any script.



