Pick up the crowbar of research scientist Gordon Freeman, who finds himself on an alien-infested Earth being picked to the bone, its resources depleted, its populace dwindling. Freeman is thrust into the unenviable role of rescuing the world from the wrong he unleashed back at Black Mesa. And a lot of people, people he cares about, are counting on him.
This tutorial will teach you how to take your custom.bsp level and add the ingredients to make it start in the elaborate way that Half-Life2(r) starts.
Posted by Pitulon on Sep 5th, 2005
Advanced Client Side Coding.
[page=Complete guide for customizing a single-player mod]
Complete guide for customizing a single-player mod.
(setting-up the simple custom.bsp file to make it start like that Half-Life2® does)
This tutorial will teach you how to take your custom.bsp level and add the ingredients to make it start in the elaborate way that Half-Life2® starts.
Few of the steps are well-known from the other tutorials, but I wanted to extract the important steps and assemble the relevant part in a compact, easy understanding tutorial.
You can also take a look at the video version of my *UPDATED tutorial from my friend James Pain from the Brink of War mod HERE.
:warning: BUG REPORT:warning:
DO NOT USE OTHER TEXT EDITOR instead of the Notepad's standard text editor from Windows® (e. g.: EditPad, EditPad Pro, Notepad 2, Notepad++, BDV Notepad, TextEdit, WordStar, WordPad, Microsoft® Office® Word, etc.) to save the text files we are creating or modify in this tutorial.
It seems that by opening and saving the text files (.txt, .cfg, .rc, .res, .gam, .rad, .vdf, .lst, etc.) in Editpad, for example, the program will cut up the size of the file down by half and make something BAD behind the scenes to break it in that way, it will become "corrupted" and the Source® engine won't read it!
(found this problem with the help of my friend Brian from The Suppression mod)
Steps that we'll follow in this tutorial:
1. Seting up Steam® to create our mod files needed to customize.
2. Creation of new folders\files needed for our customization.
3. Adding the .BSP files.
4. Useful tools and internet links.
5. Changing\adding new static\3D background.
6. Changing the main game title and the font used by it.
6a. *UPDATED Changing the main menu titles.
6b. *UPDATED Changing the position of the game title and the menu list.
6c. *UPDATED Adding the "shadow" effect by the second game title.
7. *UPDATED Adding new features into the Steam®'s My Games list for our mod.
8. Adding our own intro-video and tell the engine to display it.
8a. *UPDATED Add a main menu background music theme.
9. Creating our own chapters and add thumbnail pictures for each one of them.
9a. *UPDATED Changing your custom multiple chapters from the default "1st-unlocked/the rest-locked" into "ALL unlocked". (thanx to Tomaz Saraiva aka maveryck21 for bringing this up)
Step 1. After you finished the work on your single-player levels, you need to set them up to resemble like a complete job.
Open up the <Source SDK> window, from Steam® menu (or desktop shortcut), in the lower part of the <Source SDK> window be sure to select Current Game: Half-Life2
In the Utilities menu, select Create a Mod and launch it
In the <Create a Mod> window be sure to check Modify HL2 Single Player
In the <Mod information> window select the destination directory of the basic HL2 Single Player source code (less important for our lesson, but is necessary for Steam® to continue). The important step is to name your mod, which will be saved in the \SourceMods folder. Lets name it <MySPmod>.
After copying the necessary files, Next > and Finish.
Step 2. Now we begin our work.
Let's go in the <MySPmod> folder we created with Steam®'s help under the \SourceMods folder.
Steam® created these files:
(into the \resource and \scripts folders, Steam® created A LOT of files, that we REALY DON'T NEED to start-up our level with this tutorial)
So you can safely ignore (delete) the following files:
- from\resource folder:
- from \scripts folder:
Ok. Next we will create a few new folders needed for our customization.
Now it will look like this:
Now we need to create/copy some files into \cfg and \media folders.
1st we have to copy the file <valve.rc> from <....\valve\steam\SteamApps\your_username\half-life 2\hl2\cfg> folder into <....\MySPmod\cfg> folder.
2nd we will create 3 .CFG files into <....\MySPmod\cfg> folder with the names: <chapter1.cfg>, <chapter2.cfg> and <chapter3.cfg> (we will get back on what these files LATER) like this:
3rd we will create 1 .TXT file into <....\MySPmod\media> folder and name it <StartupVids.txt> (we will get back on what these files LATER)
Step 3. Good. Now we'll put our .BSP files into the <....\MySPmod\maps> folder.
Step 4. We will leave the start level set-up for a little bit, for the Main Menu customization.
(This tutorials also follows most of the steps, regarding the Main Menu customization)
VALVe® erc - Making a Menu Background Map
SourceWiki - Main Menu Editing
SourceWiki - Main Menu Editing Part 2
(I will try to resume them, and not only this ones, into a simple and fast way)
So, first let's start making a static background (for now, the static background is the fastest way to escape from loading the default Half-Life2® 3D background, which in most cases takes a lot of time).
The fast way to edit a picture is Adobe® Photoshop®, so you will need the "VTF Photoshop® plug-in v1.06" by Ryan Gregg, Nemesis.thewavelength.net (DOWNLOAD: Nemesis.thewavelength.net ) a useful tool for creating simple .VTF files (VALVe® Texture File); and the "Windows® XP/2000 VTF Shell Extensions - VTF Thumbnail & Info support v1.02" by Neil "Jed" Jedrzejewski, Wunderboy.org (DOWNLOAD: Wunderboy.org ) if you want the Windows® Explorer to visualize your .VTF files.
*UPDATED: You can try "VTF Explorer v1.3 build 1" by Vyacheslav Dzhura, Hl2source.com. VTF Explorer is a tool for viewing and extracting Source® Engine format texture files . The program allows you to view whole folder where your .VTF are located, either from hard disk or .GCF file as a collection of thumbnails. You can view all frames, mip levels and cubemap faces of the .VTF files as well as read their flags. You can also use "VTF Explorer" to extract files from Steam®'s .GCF packages.
Step 5. Unleash your magic and create your 1024x768 future background picture in Photoshop®. For some reason the Source® engine needs the image dimension to be to the power of 2, so don't forget to resize your image to a power of 2 size: 1024x1024 (if you worked with multiple layers in Photoshop® you'll need to flatten them: in the menu --> Layer / Flatten Image). Save your work in the .VTF format. Place the VTF into <....\MySPmod\materials\console> folder with the name <background01.vtf>.
Now we need to tell Source® engine to load this map/picture. There are 2 ways:
1st is to tell the engine to load only this map, so you have to open <....\MySPmod\scripts> folder and edit the <ChapterBackgrounds.txt>:
- when opened, you will find something like this:
- replace it with this:
And now the engine will load ONLY your static background image.
2nd step is to open <....\MySPmod\cfg> folder and edit the <valve.rc> (use Notepad to edit):
- when opened, you will find something like this:
// Setup custom controller
// run a user script file if present
// stuff command line statements
// display the startup level
- at the end of the text find startupmenu and “comment” it:
And now the Half-Life2® default 3D background map should be replaced with a constant static image.
If you want to have a 3D background map (as Half-Life2® has) leave the files copied by Steam® intact and
a. insert the static LOADING... background image (the one before the main menu background image or map is loaded) as a different theme from your 3D background map (e.g.: like a loading logo of your mod or team). The editing of the .VTF file is exactly like the static background explanation above.
b. insert a "blur" image previewing the 3D map that will be loaded in your main menu (like Half-Life2® has when it loads a 3D background map). Editing it is the same as the static image.
The 3D map used for your background theme (a .BSP file) has to be located into <....\MySPmod\maps> folder and it must have the same name as the static one that is loaded before the 3D one (in our example: "background01") which is located in the <....\MySPmod\materials\console> folder (it is a .VTF file) and the code for loading it is the same as in the static background case:
open <....\MySPmod\scripts> folder and edit the <ChapterBackgrounds.txt> file
Step 6. Now when we finished customizing the static\3D background image\map, let's move forward and create a custom Game Title with a custom FONT also.
1st, if you have a custom font, take it and copy it into <....\MySPmod\resource> folder. Be sure to be a .TTF - TrueType Font. Now let's tell the game engine how to read our custom font. Open up the <ClientScheme.res> file (use Notepad to edit) from <....\MySPmod\resource> folder and lets edit it:
- you will find there a ton of rows, just scroll down till you will find the following line:
- now edit the lines like following:
- in the line "name" "Font name" you need to get the true name of the font from inside the font file rather than just using the name of the font file:
(for example, I used in this tutorial the Matrix vs Miltown font (free font) theme from The Matrix® movie)
- now we have to tell the game engine where to find this custom font. In the same <ClientScheme.res> file, scroll till the end of the text and find the following line:
- and add the folowing line:
- in the line "3" "resource/matrix_cyr.ttf" replace matrix_cyr.ttf with the file name of your font.
- if you want to change the titles in the Main Menu (like New Game, Load, Save, Quit) open the <GameMenu.res> from ....\MySPmod\resource> folder and you will find this:
- now replace next to each "label" text with the desired title.
- you can change the position, color of the main title, the second title and of the menu titles (X and Y coordinate). Open <ClientScheme.res> from ....\MySPmod\resource> folder and you find this:
// Top-left corner of secondary title e.g. "DEMO" on the main screen
"Main.Title2.Color" "255 255 255 200"
// Top-left corner of the menu on the main screen
// Blank space to leave beneath the menu on the main screen
- replace with the X and Y coordinates to position your main title, second title and the main menu.
*NOTE: To create a "shadow" for your main title, just change the X and Y to adjust the position below the main title font.
- well, i've noticed a weird thing :confused: (or maybe is just me...) The main title "layer" is ordered below the second title's one... so if you want to set up the second title to act as a "shadow" for the main one, well... you have to reverse roles. Your second title has to act as the main title and reverse. If it is like this, the main will be a "shadow" for the second one... cool, isnt it ? :D
// Top-left corner of secondary title e.g. "DEMO" on the main screen
"Main.Title2.Color" "255 255 255 255"
// Top-left corner of the menu on the main screen
This is valid only for the order of the titles layers and is set up only in the above code (in the example above, the code will act as i described: the main title will be black [the shadow] and the second title will be white [the main title]). And of course, in this case, both of the titles have to be the same word(s) :lol: llooll
2nd, after we finished telling the game engine to use our custom font, now let's change the Game Title.
First we have to edit the file <gameinfo.txt> from <....\MySPmod> root folder. Open it up and you will find these lines:
- now lets add a few lines, and tell the engine what's the name of our single-player mod:
Line translation :)
name "MySPmod" = needed to tell to the game engine the names of the chapters inside the <New Game> menu
game "MySPmod" = it tells Steam® to display the name of your mod in the <My Games> menu window:
= and also it tells the engine to display the name of your mod on the taskbar when running:
<-- you have noticed a custom icon beside our mod title. Well, it's very easy to add even your custom icon to your mod. Just make yourself an icon (Icon WorkShop®), and copy it into the <....\MySPmod\resource> folder, and rename it <game.ico>.
title "P I T U L O N" = will tell the game engine to change the default Half-Life2® title with our custom one.
(in the <ClientScheme.res> file under <....\MySPmod\resource> folder, at the line ClientTitleFont you can change the tall, weight, antialiasing values)
title2 "No 1" = it lets you add a subtitle to your main Game Title (thanx to imatard from HL2 Coding forum). If you use the "shadow" effect, the word(s) has to be the same as the other title.
"icon" "resource\icon_MySPmod" = adds a icon in the Steam® My Games menu near your mod name. The icon is a .TGA file 16x16 pixels (original HL2 size) (the maximum size inside the Steam® My Games menu line is 19x19 pixels) with Alpha Channels and it has to be located inside <....\MySPmod\resource> folder. The location of the .TGA file can be anywhere inside your mod folder, just change the location into the code
e. g.: "icon" "icon_MySPmod" - now it has to be in the root folder of your mod.
(notice that in the code it doesnt have a extension for the icon file. Its how the engine read this file code)
- click on the icons to download the .TGA file (16x16 or 19x19) with Alpha Channels which you can use to create your custom icon (edit it with Photoshop®)
You will find the tutorial on how to create and modify an Alpha Channel HERE.
"homepage" "Valvesoftware.com" = it will create a internet link to your mod homepage. The link will be under your mod Properties from the Steam® list.
and it will look like this:
"developer" "Pitulon" = it will add your name (your team) as the developer of the mod and will apear in the Steam® My Games menu
and in your mod Properties from the Steam® list
"developer_url" "Valvesoftware.com" = it will transform your developer name into a internet link to your developer page (if you have one separately from your mod page)
"manual" "Half-life2.com" = it adds a internet link into your mod Properties from the Steam® list to your mod manual (Reference Help, Walkthroughs, FAQ, Hints and Tips, Cheat Codes, etc.)
That's enough for the game engine to change the Game Title and to change the title's font and add other misc features.
I've tested all this, but in a few tutorials I found that is necessary to change also some other lines from other files. For example:
In the <....\MySPmod\scripts> folder, open the file <gameinfo.txt> and you will find:
- now replace the lines with:
Save it. (nothing will change this :D )
- and also in the <....\MySPmod\scripts> folder, open the file <liblist.gam> (use Notepad to edit) and you will find:
- now replace the lines with:
Save it. (nothing will happen again :D )
So what we did is to edit files for nothing. The last 2 steps are worthless, and worth editing the files just to be correct and have our mod title everywhere. :P
Step 8. At the Step 2, at the 3rd line, we said something about a <StartupVids.txt> file. Well, this file will tell the game engine to load a INTRO-VIDEO at the beginning, replacing the default video from VALVe®.
1st you should have created a custom video, with whatever you want to show up in it (must be a .AVI format). Name it <my_video.avi> for example. Remember to put it into <....\MySPmod\media> folder.
2nd let's open the <StartupVids.txt> file that we created into the <....\MySPmod\media> folder and add this line:
Step 8a. If you want your mod to have a custom background menu MUSIC, follow the next steps.
Open the <valve.rc> file located into the <....\MySPmod\cfg> folder and at the end of the text add this line:
The .MP3 file can be located wherever you want inside your mod folder. Be sure to specify the path and also be sure to have the same name in the code like the one of the .MP3 file. For the code to work you must have the ../ in front of the file name (if it is located in the root directory of your mod) or the path to your file.
The music file can be any format you chose for your sound file (.MP3, .WAV, .WMA, etc.).
• Now we'll start the final phase of our tutorial: Setting-up the levels to start from the <New Game> menu.
Step 9. Let's get busy!
1st lets tell our Source® engine to load our custom levels from the <New Game> menu, so when you press on the level's chapter button the level will load.
In the <....\MySPmod\cfg> folder, open the newly created <chapter1.cfg> file (we created it on the 4th step). Into the blank text add the following line:
(my_single-player_level_chapter1 being the name of your .BSP that you want to start first (like a chapter, in case you have sub-levels for that chapter)
In case you have multiple chapters (in my example, 3), you must do the same thing for the other two.
- open <chapter2.cfg> file and edit the line : map my_single-player_level_chapter2
- open <chapter3.cfg> file and edit the line : map my_single-player_level_chapter3
- ...... till chapter 213 :D
2nd step is to add a chapter title that will appear into the <New Game> menu window.
Go in <....\MySPmod\resource> folder and there you will find the <hl2_english.txt> file. Rename it to <MySPmod_english.txt>. Open it. You will find a lot of lines there, select all and delete them! In the new blank text file add the following strings:
In this way we have inside the <New Game> window this 3 chapters listed, so you can start the chapters individually, as in Half-Life2® <New Game> window.
Step 9a. *UPDATED - When customizing a new single player mod with multiple chapters, the game will lock your chapters and leave unlocked ONLY the first one. So when you need to test your work from a custom chapter (2nd, 3rd or X-number in the chapter list) the option to have your the custom chapters unlocked from the begining is found in the <config.cfg> file under the <....\MySPmod\cfg> folder, find the line sv_unlockedchapters.
We have to change the line sv_unlockedchapters ''1'' (which is the default value - allways the first chapter is unlocked, and the other ones will become unlocked along with your progress in the game) with:
The number we put in the "X" place is the number of the chapters that you want to be unlocked. (e.g.: you have 5 chapters, you write down 5 instead of "X")
3rd step is to create the small thumbnail picture that's characterizing for each one of your chapters. The easiest way is to edit one of the existing thumb picture from one of the Half-Life2® chapters:
the image is 256x128 pixels (so you can edit even this one in Photoshop® because it's the correct size)
After you made your modifications on each chapter's thumb picture, save them in the .VTF format and place them in the <....\MySPmod\materials\VGUI\chapters> folder that we created when we started.
You should have 3 .VTF files:
It should look like this after all the editing:
OK. So far we did:
1. Steam® copied our mod into the \SourceMods folder.
2. We deleted\created a few folders and files.
3. We put our .BSP file into \maps folder
4. We created a static background.
5. We changed the Game Title with a new one and using a custom font, changed the position and add more features to the Steam®'s My Games menu.
6. We created our own intro-video and a background music theme.
7. We made our levels to start from <New Game> menu and we added for each chapter a title and a thumb picture.
Well, my friends, that's all about the fast customization of your Half-Life2® single-player mod.
For any questions or bugs please e-mail me at: email@example.com