Please or Register to create posts and topics.

How to have a custom turret skin in your map

Page 1 of 5Next

Hey!

For this tutorial you'll need:

  1. Notepad++
  2. Squirrel syntax highlighter for Notepad++, installation instructions should be on the linked article
  3. GCFScape
  4. 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.

Image

Edit turrrt_casing.vtf/vmt to your heart's content. Here's what mine looks like:

Image

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.

Image

Then place a logic_script, name it something and point it to the vscript we just made. (modelchanger/turret_red.nut)

Image

Make a logic_auto, give it an OnMapSpawn output, tell it to make the logic_script execute the ChangeTurrets() function.

Image

Compile, run then you should have a custom turret! Here's my red turret right beside a console-spawned turret:
Image

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 :)

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)

.:: [SP] Lost in Testing :: #1 :: #2 :: #3 :: #4 ::.

Are you referring to this? You could port these over to P2 but they're actually skins for the P1 turret

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?

.:: [SP] Lost in Testing :: #1 :: #2 :: #3 :: #4 ::.

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.

-ArttyIntel-

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!

No problem! :D

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

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.

Image

What error is the script giving you? (If any)

?????????????????????????????TWP Releases | My Workshop
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.

Image
Page 1 of 5Next