How to have a custom turret skin in your map
Quote from walropodes on June 24, 2011, 1:24 amHey!
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;
- Code: Select all
VertexLitGeneric
{
$baseTexture "models/npcs/turret/turret_casing"
$surfaceprop solidmetal
$phong 1
$phongexponent 50
$phongfresnelranges "[5 1 2]"
$phongboost ".6"
$basemapalphaphongmask 1
}would become:
- Code: Select all
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:
- Code: Select all
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
Hey!
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;
- Code: Select all
VertexLitGeneric
{
$baseTexture "models/npcs/turret/turret_casing"
$surfaceprop solidmetal
$phong 1
$phongexponent 50
$phongfresnelranges "[5 1 2]"
$phongboost ".6"
$basemapalphaphongmask 1
}
would become:
- Code: Select all
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:
- Code: Select all
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
Quote from KenJeKenny!? on June 24, 2011, 2:49 amThere was somebody who posted all of the crazy turret skin models. So not just the coloured ones but more (all that you can see in the turret movie vgui)
There was somebody who posted all of the crazy turret skin models. So not just the coloured ones but more (all that you can see in the turret movie vgui)
Quote from walropodes on June 24, 2011, 2:51 amAre you referring to this? You could port these over to P2 but they're actually skins for the P1 turret
Are you referring to this? You could port these over to P2 but they're actually skins for the P1 turret
Quote from KenJeKenny!? on June 24, 2011, 4:56 amYeh 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?
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?
Quote from -ArttyIntel- on June 24, 2011, 3:11 pmI was thinking about doing this. Like having reg turrets being white like usual. Then have stronger turrets that are red. So you can tell the difference.
I was thinking about doing this. Like having reg turrets being white like usual. Then have stronger turrets that are red. So you can tell the difference.
Quote from h3X on June 28, 2011, 5:33 pmNo wonder I wasn't able to just use the textures right out of the box. Thanks a million, I would've never been able to figure this out without this awesome tutorial!
No wonder I wasn't able to just use the textures right out of the box. Thanks a million, I would've never been able to figure this out without this awesome tutorial!
Quote from walropodes on June 28, 2011, 9:12 pmNo problem!
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
No problem!
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
Quote from Groxkiller585 on May 24, 2012, 8:09 pmWhen I try running the script I get an error about the index not existing.
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.
When I try running the script I get an error about the index not existing.
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.


Quote from ChickenMobile on May 24, 2012, 9:20 pmWhat error is the script giving you? (If any)
What error is the script giving you? (If any)
Quote from Groxkiller585 on May 24, 2012, 10:28 pmchickenmobile 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.
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.
