Half-Life 2

Half-Life 2

48 ratings
[OUTDATED] Source Modding: Part 1 - Basics
By Spooky Moopy
A complete guide to setting up your Source Mod. This guide will explain how to set up your Singleplayer or Multiplayer mod.
   
Award
Favorite
Favorited
Unfavorite
Getting Started
The Source Engine is a game engine created by Valve Software. The engine was first used in a commercial game in 2004 for the game Counter-Strike: Source. Later that year, Half-Life 2 and Half-Life 2: Deathmatch were both released on the Source Engine as well. Since then, the Source Engine has been used in all of Valve's commercial games, as well as several third party games and a huge number of mods. And now I'm going to teach you how to make your own Source Mod.

To do this you will need:
  • Either a Source Engine game such as Half-Life 2 (NOTE: This doesn't work for games such as the original Half-Life since they are made on the GoldSRC Engine).
    OR
    Source SDK Base 2006 and/or Source SDK Base 2007 (NOTE: Depending on which engine version you want to make your mod with. For more information, see Choosing an Engine Version.
    OR
    Alternatively you can mod the Source Engine 2009 (read Creating a mod manually).
  • Source SDK
  • A program that allows you to code C++ such as Microsoft Visual C++ Express 2010 (free).
  • Steam (of course).
Choosing an engine version
When modding on the Source Engine, there are several different engine versions to choose from. This list will give you a basic idea of which engine type you'll want to use to create your mod.

Source Engine 2006
This is the oldest version of the Source Engine. This version is used by Half-Life: Source, Half-Life: Deathmatch and various mods built on the old Source 2006 code.

NOTE: Anyone can play mods on this engine version, as long as they have the Source SDK Base 2006.

Source Engine 2007
This is the engine version that most Source Mods use. Various Source Mods have used this engine version such as Black Mesa, Dear Esther (mod), Minerva and The Stanley Parable (mod).

NOTE: Anyone can play mods on this engine version, as long as they have the Source SDK Base 2007.

Source Engine 2009
This is the engine version that is currently used by Half-Life 2, Half-Life 2: Episode 1, Half-Life 2: Episode 2 and Portal. This engine version doesn't currently have a source code available.

NOTE: You can still mod this engine version, read Creating a mod manually.

Source Engine MP
This is the engine version that is currently used by multiplayer Source games. This version is used by Team Fortress 2, Half-Life 2: Deathmatch, Counter-Strike: Source, Day of Defeat: Source and Garry's Mod. This engine version doesn't currently have a source code available.

Other things you should know
Games such as Left 4 Dead, Left 4 Dead 2, Portal 2, Counter-Strike: Global Offensive and DotA 2 all run on different engine branches or have their own engine branches.
Project type
Half-Life 2 Single Player
Projects for Source Engine 2006 and Source Engine 2007.

Half-Life 2 Multiplayer
Projects for Half-Life 2: Deathmatch. This option is only available if you own Half-Life 2: Deathmatch; otherwise it will be greyed out.

Multiplayer mod from template
A specially-created SDK project that allows you to configure settings such as if your mod is team based, or if you have abilities such as sprinting and prone. This option does not require Half-Life 2: Deathmatch.

Source code only
Dumps the code without creating an actual mod. This handy if you are only creating a server plugin.

Whichever option you choose, you get the same actual source code files (even if you didn't own one or another game). You also get an "everything" solution which includes a collection of development tools.

Most of the information from this section is from here.

NOTE: Some information has been edited to make it more accurate.
Creating a mod
Step 1: Open the Source SDK.
Step 2: Select your engine version of choice (for more information, read Choosing an engine version). Now, making sure you have your engine version of choice is selected, select the Create a Mod option.

Step 3: You will be given several options, select Modify Half-Life 2 Single Player or Modify Half-Life 2 Multiplayer (NOTE:Modify Half-Life 2 Multiplayer option requires you to own Half-Life 2: Deathmatch and will require players to own Half-Life 2: Deathmatch to play your mod).

Step 4: In the first box on the Mod Information page, type in the directory that you would like to install your mod into (eg. C:\MyMod). This is where the source code for Half-Life 2 and a bare-bones will copied to. Next, in the second box, enter the name of your mod. This will become a sub-directory under Steam's SourceMods folder, which will contain all of your mod's content files.

Step 5: The Source SDK will then install and copy all of your mod's files.
Step 6: Once this is done, go to the directory in which you copied the source code for Half-Life 2 and a bare-bones (eg. C:\MyMod). Open the src folder and open Game_Episodic-2005.sln with your C++ program.
Step 7: You might given the option to create a backup of your solution, select yes or no, and wait for the program to finish preparing the solution (and create a backup of your solution if you chose yes).
Step 8: Right click on Solution 'Game_Episodic-2005', a drop down menu will appear, select Properties.

Step 9: Click Configuration Properties, then change the Client Episodic and the Server Episodic configuration from Debug to Release. Then click Apply.

Step 10: Right click on Solution 'Game_Episodic-2005' again, then click Build Solution. Wait for the solution to build.

Step 11: Restart Steam and your mod will appear in your Steam library.
Creating a mod manually
Step 1: Create a folder under steamapps\SourceMods\ (A mod can actually reside anywhere, but placing it here allows Steam to detect and launch it.)
Step 2: Create a gameinfo.txt in the folder. You now have a mod!
Step 3: Open the SDK launcher and switch to the relevant engine branch.
Step 4: Choose "Edit Game Configurations" and click "Add". Enter your mod's name and folder.

To get the source code (or indeed any other files of Valve's that you want to modify) you will need to use GCFScape and access sourcesdk.gcf/src_mod/. Remember to change the custom build steps to point to your mod's folder.

All information from this section is from here.
Conclusion
That concludes Source Modding: Part 1 - Basics, if you have any problems or want to ask me a question, just post a comment and I'll do my best to help you out. If you found this guide helpful give it a thumbs up. If you didn't, that's what the thumbs down is for. Post feedback in the comments section (I really appreciate it). Follow me for more guides coming soon.
3 Comments
Venny Apr 12, 2014 @ 9:12am 
Outdated, if you wish to mod Source Engine, you'll need to go into Valve's GitHub repository [github.com]. Also, you will need to have Microsoft's Visual Studio 2010 with Service Pack 1. Source SDK is no longer functional after the 2013 SteamPipe update (altough it had started before 2013). You can still use the tools, but they're almost certanly broken, for optimal use, go to the bin folder of your desired game/mod.
myback Feb 22, 2013 @ 5:37pm 
Great guide, keep it up
tetra Jan 23, 2013 @ 5:32pm 
Oh god, please make more. I'm a programmer and want to learn how to help people with their source mods.