Ultimate Portal 2 Modding Guide

This guide will cover all the essential parts of Portal 2 modding. Some methods described may or may not work for other Source engine games.
== Preparation ==
In this guide, we will create a simple Portal 2 Sourcemod, which is going to be called "Portal 2 Modding Guide".
The first thing we need to do is download the Portal 2 Authoring Tools. These can be found under "Tools" on Steam if you own Portal 2 (Make sure Portal 2 is installed. Also, it is imperative that Steam is installed on the C: drive, and that the sourcemods folder is located at C:\Program Files (x86)\Steam\steamapps\sourcemods. Otherwise the mod may not show up in the Steam library). Run the tool and a window, as pictured on the right, will appear. We will only really need the Hammer World Editor. The model viewer can be handy when debugging models and the Face Poser is needed to build scene image files.
== Creating The Mod ==
To create the Sourcemod, navigate to the steamapps directory. (Usually located at C:\Program Files(x86)\Steam\steamapps). There should be a folder called sourcemods. If it doesn't exist, create it. 
In the sourcemods directory, create a new folder with the name of the mod that is being created. Put a file in there and call it gameinfo.txt. Copy and paste this template into the gameinfo.txt:
"GameInfo"
{
	game 							"Portal 2 Modding Guide" // The name of your mod (will be displayed in steam)
	gamedata							"portal2.fgd"
	icon								"resource/icon" // Path to the icon (displayed in steam and, window and task bar)
 	gamelogo 			 				1
 	SupportsDX8 							0
 	SupportsXbox360 						0
 	FileSystem
 	{
 	SteamAppId 						620 // The steamappid of Portal 2
 	ToolsAppId 						211 // The toolsappid of the Source Sdk
 	SearchPaths
 	{
 		Game 	|gameinfo_path|. // Your own assets
 		Game 	portal2_dlc2 // DLC 2 assets
 		Game 	portal2_dlc1 // DLC 1 assets
			Game			portal2 // Base Portal 2 assets
			platform		platform // Core engine files
 	}
 }
}
After that, restart Steam and it will be listed in the Steam library.
The next step is to create the asset directory and other necessary files. Luckily, Source does this automatically when starting the mod, so all we need to do is start it through Steam.
== Custom assets ==
Adding assets like materials, models, sounds, scripts, resources, videos and others is the core purpose of mods. A mod acts as a content path. Assets can exist outside of a vpk if they do not override already existing ones.
== Overriding Portal 2 content ==
Putting custom loading screens, GUIs, playermodels, portal gun models and all those things into a mod is a matter of overriding Portal 2's original assets. To override, they must be put into a VPK. To make vpks you must take your folder with the assets inside, and then drag it to the vpk.exe inside C:\Program Files(x86)\Steam\steamapps\common\Portal 2\bin. I find that if you want to override textures or models, you should only put the asset that you want to override into the folder, and its directories too. For example, to edit the animals texture found in the coop calibration course you would first find the VTF file for the animal texture in the pak01_dir VPK found in the portal2 directory using GCFScape. (In this example it would be in root\materials\signage\coop_animals) Right click the texture you want to change, then extract it to some folder. To edit a VTF, you can get VTFEdit. To convert a VTF to PNG or JPEG in VTFEdit, go to File > Open Then choose the extracted VTF. To save it as a PNG or JPEG, go to File > Export and save it as such. Edit as you please using an image editor such as Photoshop or Gimp. To convert the PNG or JPEG into a VTF, go into VTFEdit and go to File > Import. Select the PNG or JPEG. Go to File > Save. Put your new VTF into your assets folder, in the correct directory. (The directory where you found it in the VPK.) Then convert that assets folder into a VPK using the vpk.exe told about above. After you have your VPK all you have to do is to get it into Portal 2. To do this, I've found that the easiest way is to make a new folder called "portal2_dlc3" and put your VPK inside. Once you run the Portal 2, you might find that a loading screen is taking a while to load. Wait until the progress bar in the bottom right turns orange, then restart the game. Once you restart you'll find that the textures are now showing.
== Configuring hammer ==
=== Making hammer load mod assets ===
By default, Hammer loads all assets from Portal 2's portal2 content directory. To make the editor automatically load all assets from the mod, follow the tutorial on how to Add Mod Content to Hammer
=== Setting compile output ===
In Hammer Build Programs options, set the Place compiled maps in this directory before running the game path to your mod's maps directory. (C:\Program Files(x86)\Steam\steamapps\sourcemods\Portal 2 Modding Guide\maps)
== Editing the GUI ==
todo
== Scripting ==
todo
Category:Tutorials