Making Your Portal Mod: Difference between revisions
No edit summary |
Thunder4ik (talk | contribs) m (→Setting Up Hammer: Unicodifying, replaced: [[Image: → [[File:) |
||
(9 intermediate revisions by 7 users not shown) | |||
Line 1: | Line 1: | ||
This article will discuss how to create a Portal content mod, from scratch. Part | {{lang|Making Your Portal Mod}} | ||
{{back|Portal Level Creation}} | |||
This article will discuss how to create a ''Portal'' content mod, from scratch. Part | |||
of the reason for creating the mod from scratch is that Valve does not provide a | of the reason for creating the mod from scratch is that Valve does not provide a | ||
specific SDK or mod template for Portal. Another reason is that creating the mod | specific SDK or mod template for Portal. Another reason is that creating the mod | ||
Line 6: | Line 9: | ||
get started. | get started. | ||
{{note|Portal modification is different from some of the other Source-based games in that the source code to build the <code>client.dll</code> and <code>server.dll</code> files is not provided by Valve. However, a modder can still modify anything that isn't built directly into the game, which includes scenes, scripts, sounds, textures, and models, to name a few.}} | |||
==Prerequisites== | |||
== Prerequisites == | |||
To follow along with this article, you will need a copy of Portal and the Source | To follow along with this article, you will need a copy of Portal and the Source | ||
SDK, installed on Steam. | SDK, installed on Steam. | ||
==Creating the Mod== | |||
== Creating the Mod == | |||
Creating the mod consists of creating a game folder and filling it with | Creating the mod consists of creating a game folder and filling it with | ||
configuration files and mod-related content. Let's assume we are creating a mod | configuration files and mod-related content. Let's assume we are creating a mod | ||
named "My Portal Mod", and that <code>[Steam Root]</code> is Steam's | named "My Portal Mod", and that <code>[Steam Root]</code> is Steam's | ||
installed path on your machine. (e.g. <code>C:\Program Files (x86)\Steam</code>) | installed path on your machine. (e.g. <code>C:\Program Files (x86)\Steam</code>) | ||
===Create the Game Folder=== | |||
=== Create the Game Folder === | |||
Navigate to your <code>SourceMods</code> directory and create a folder named | Navigate to your <code>SourceMods</code> directory and create a folder named | ||
"MyPortalMod". | "MyPortalMod". | ||
In this new directory, create a file called <code>GameInfo.txt</code>. | In this new directory, create a file called <code>GameInfo.txt</code>. | ||
Edit the contents of <code>GameInfo.txt</code> so that they look similar to the | Edit the contents of <code>GameInfo.txt</code> so that they look similar to the | ||
Line 41: | Line 33: | ||
"GameInfo" | "GameInfo" | ||
{ | { | ||
game "My Portal Mod" | |||
title | title "My Portal Mod" | ||
type singleplayer_only | |||
nodifficulty 1 | |||
hasportals 1 | |||
nocrosshair 1 | |||
nomodels 1 | |||
developer " Name " | |||
developer_url " Link " | |||
manual " - " | |||
icon "resource/icon" | |||
FileSystem | |||
{ | |||
SteamAppId 400 | |||
ToolsAppId 211 | |||
SearchPaths | |||
{ | |||
game+mod |gameinfo_path|. | |||
platform |gameinfo_path|. | |||
// We search VPK files before ordinary folders, because most files will be found in | |||
// VPK and we can avoid making thousands of file system calls to attempt to open files | |||
// in folders where they don't exist. (Searching a VPK is much faster than making an operating | |||
// system call.) | |||
game_lv portal/portal_lv.vpk | |||
game+mod portal/portal_sound_vo_english.vpk | |||
game+mod portal/portal_pak.vpk | |||
game |all_source_engine_paths|hl2/hl2_textures.vpk | |||
game |all_source_engine_paths|hl2/hl2_sound_vo_english.vpk | |||
game |all_source_engine_paths|hl2/hl2_sound_misc.vpk | |||
game |all_source_engine_paths|hl2/hl2_misc.vpk | |||
platform |all_source_engine_paths|platform/platform_misc.vpk | |||
// Now search loose files. We'll set the directory containing the gameinfo.txt file | |||
// as the first "mod" search path (after any user customizations). This is also the one | |||
// that's used when writing to the "mod" path. | |||
mod+mod_write+default_write_path |gameinfo_path|. | |||
// Add the Portal directory as a game search path. This is also where where writes | |||
// to the "game" path go. | |||
game+game_write portal | |||
// Where the game's binaries are | |||
gamebin portal/bin | |||
// Last, mount in shared HL2 loose files | |||
game |all_source_engine_paths|hl2 | |||
platform |all_source_engine_paths|platform | |||
} | |||
} | |||
} | } | ||
</source> | </source> | ||
Line 105: | Line 93: | ||
<code>GameInfo.txt</code> file will remove the entry. | <code>GameInfo.txt</code> file will remove the entry. | ||
===Configure the Mod=== | |||
=== Configure the Mod === | ====Initial Setup==== | ||
==== Initial Setup ==== | |||
Let's add some standard folders to the game directory that will hold our mod's | Let's add some standard folders to the game directory that will hold our mod's | ||
configuration files and content. Add the following folders to your game | configuration files and content. Add the following folders to your game | ||
Line 125: | Line 110: | ||
* <code>sound</code> | * <code>sound</code> | ||
====Create a Map List==== | |||
==== Create a Map List ==== | |||
In your game directory, create a file called <code>maplist.txt</code>. In it, we | In your game directory, create a file called <code>maplist.txt</code>. In it, we | ||
will list all of the mod's map names (excluding the <code>.bsp</code> | will list all of the mod's map names (excluding the <code>.bsp</code> | ||
extension). This file allows the game to pre-cache the first .125 milliseconds | extension). This file allows the game to pre-cache the first .125 milliseconds | ||
of sound for a map, which is enough time to load the remainder. | of sound for a map, which is enough time to load the remainder. | ||
The following is a sample <code>maplist.txt</code> for a mod with two maps, | The following is a sample <code>maplist.txt</code> for a mod with two maps, | ||
Line 143: | Line 125: | ||
</source> | </source> | ||
====Create Chapter Configuration Files==== | |||
==== Create Chapter Configuration Files ==== | |||
Change to your mod's <code>cfg</code> directory. Create configuration files for | Change to your mod's <code>cfg</code> directory. Create configuration files for | ||
each chapter of your mod, starting with <code>chapter1.cfg</code> and continuing | each chapter of your mod, starting with <code>chapter1.cfg</code> and continuing | ||
on to <code>chapter2.cfg</code>, etc. | on to <code>chapter2.cfg</code>, etc. | ||
In these files, you will issue whatever commands you want to be executed by the | In these files, you will issue whatever commands you want to be executed by the | ||
Line 157: | Line 136: | ||
The following is a <code>chapter1.cfg</code> example: | The following is a <code>chapter1.cfg</code> example: | ||
<source> | <source> | ||
map myportalmod_map_00 | map myportalmod_map_00 | ||
</source> | </source> | ||
====Create a Localization File==== | |||
==== Create a Localization File ==== | |||
Create a localization file, called <code>MyPortalMod_english.txt</code>, in your | Create a localization file, called <code>MyPortalMod_english.txt</code>, in your | ||
game directory's <code>resource</code> folder. | game directory's <code>resource</code> folder. | ||
Modify the contents of <code>MyPortalMod_english.txt</code> so that it is | Modify the contents of <code>MyPortalMod_english.txt</code> so that it is | ||
Line 174: | Line 148: | ||
"lang" | "lang" | ||
{ | { | ||
"Language" "english" | |||
"Tokens" | |||
{ | |||
"MyPortalMod_chapter1" "The First Chapter" | |||
"MyPortalMod_chapter2" "The Second Chapter" | |||
} | |||
} | } | ||
</source> | </source> | ||
In this case, <code>MyPortalMod</code> is used because it is the name of the | In this case, <code>MyPortalMod</code> is used because it is the name of the | ||
mod's game directory. "The First Chapter" is an | mod's game directory. "The First Chapter" is an English title for the mod's | ||
first chapter. Add any additional chapters for your mod by following the | first chapter. Add any additional chapters for your mod by following the | ||
pattern in "Tokens". | pattern in "Tokens". | ||
{{warning|<u>'''This file must be saved in a Unicode format.'''</u>}} | |||
{{note|The author (on Windows Vista) used a little endian UTF-16 encoding. In Notepad, under <code>Save As...</code>, this is equivalent to choosing <code>unicode</code> for the <code>Encoding</code> option at the bottom of the dialog.}} | |||
{{note| The author (on Windows Vista) used a little endian UTF-16 encoding. In Notepad, under <code>Save As...</code>, this is equivalent to choosing <code>unicode</code> for the <code>Encoding</code> option at the bottom of the dialog. | |||
==Setting Up Hammer== | |||
{{note|If you have not yet created a mod from the 'Source SDK' tool (creating a 'Source code only' mod doesn't count), then you will need to first create one. Otherwise, you will not be allowed to add a game configuration file for MyPortalMod. This configuration file is required to save Hammer settings specific for the MyPortalMod mod. See [[Create a Mod]] for details on this process. Do not create a 'Source code only' mod. {{confirm|Is [[Game Directory|vconfig.exe]] a viable alternative to creating an initial dummy mod?}}}} | |||
Launch the 'Source SDK' from your Steam Library 'Tools' section. Make sure that | Launch the 'Source SDK' from your Steam Library 'Tools' section. Make sure that | ||
Line 208: | Line 178: | ||
configuration "My Portal Mod". | configuration "My Portal Mod". | ||
[[ | [[File:Making_your_portal_mod_00.png|center]] | ||
Restart the 'Source SDK' tool. Set 'Engine Version' and 'Current Game' to | Restart the 'Source SDK' tool. Set 'Engine Version' and 'Current Game' to | ||
Line 218: | Line 188: | ||
time you open Hammer from the 'Source SDK' tool with your mod name selected. | time you open Hammer from the 'Source SDK' tool with your mod name selected. | ||
== See | ==See also== | ||
* [[Portal Level Creation]] | |||
<!-- This comment is 80 characters wide. --------------------------------------> | |||
[[Category:Portal]] | |||
[[Category:Modding]] | |||
[[Category:Tutorials]] |
Latest revision as of 05:49, 7 January 2024
This article will discuss how to create a Portal content mod, from scratch. Part of the reason for creating the mod from scratch is that Valve does not provide a specific SDK or mod template for Portal. Another reason is that creating the mod from scratch is not difficult and is of general interest to Source SDK developers that would like to learn more about how everything works. So, let's get started.

client.dll
and server.dll
files is not provided by Valve. However, a modder can still modify anything that isn't built directly into the game, which includes scenes, scripts, sounds, textures, and models, to name a few.Prerequisites
To follow along with this article, you will need a copy of Portal and the Source SDK, installed on Steam.
Creating the Mod
Creating the mod consists of creating a game folder and filling it with
configuration files and mod-related content. Let's assume we are creating a mod
named "My Portal Mod", and that [Steam Root]
is Steam's
installed path on your machine. (e.g. C:\Program Files (x86)\Steam
)
Create the Game Folder
Navigate to your SourceMods
directory and create a folder named
"MyPortalMod".
In this new directory, create a file called GameInfo.txt
.
Edit the contents of GameInfo.txt
so that they look similar to the
following snippet. For details about the structure of this file, see

"GameInfo"
{
game "My Portal Mod"
title "My Portal Mod"
type singleplayer_only
nodifficulty 1
hasportals 1
nocrosshair 1
nomodels 1
developer " Name "
developer_url " Link "
manual " - "
icon "resource/icon"
FileSystem
{
SteamAppId 400
ToolsAppId 211
SearchPaths
{
game+mod |gameinfo_path|.
platform |gameinfo_path|.
// We search VPK files before ordinary folders, because most files will be found in
// VPK and we can avoid making thousands of file system calls to attempt to open files
// in folders where they don't exist. (Searching a VPK is much faster than making an operating
// system call.)
game_lv portal/portal_lv.vpk
game+mod portal/portal_sound_vo_english.vpk
game+mod portal/portal_pak.vpk
game |all_source_engine_paths|hl2/hl2_textures.vpk
game |all_source_engine_paths|hl2/hl2_sound_vo_english.vpk
game |all_source_engine_paths|hl2/hl2_sound_misc.vpk
game |all_source_engine_paths|hl2/hl2_misc.vpk
platform |all_source_engine_paths|platform/platform_misc.vpk
// Now search loose files. We'll set the directory containing the gameinfo.txt file
// as the first "mod" search path (after any user customizations). This is also the one
// that's used when writing to the "mod" path.
mod+mod_write+default_write_path |gameinfo_path|.
// Add the Portal directory as a game search path. This is also where where writes
// to the "game" path go.
game+game_write portal
// Where the game's binaries are
gamebin portal/bin
// Last, mount in shared HL2 loose files
game |all_source_engine_paths|hl2
platform |all_source_engine_paths|platform
}
}
}
Restarting Steam at this point will create an entry in the game Library for the
mod. Deleting the game folder we created or removing the
GameInfo.txt
file will remove the entry.
Configure the Mod
Initial Setup
Let's add some standard folders to the game directory that will hold our mod's configuration files and content. Add the following folders to your game directory:
cfg
resource
maps
.
While we're at it, let's add the following optional folders, for custom content like models and sounds:
materials
models
scenes
scripts
sound
Create a Map List
In your game directory, create a file called maplist.txt
. In it, we
will list all of the mod's map names (excluding the .bsp
extension). This file allows the game to pre-cache the first .125 milliseconds
of sound for a map, which is enough time to load the remainder.
The following is a sample maplist.txt
for a mod with two maps,
named myportalmod_map_00.bsp
and
myportalmod_map_01.bsp
.
myportalmod_map_00
myportalmod_map_01
Create Chapter Configuration Files
Change to your mod's cfg
directory. Create configuration files for
each chapter of your mod, starting with chapter1.cfg
and continuing
on to chapter2.cfg
, etc.
In these files, you will issue whatever commands you want to be executed by the developer console when the chapter is first loaded. Typically, a command to load the chapter's corresponding map is used.
The following is a chapter1.cfg
example:
map myportalmod_map_00
Create a Localization File
Create a localization file, called MyPortalMod_english.txt
, in your
game directory's resource
folder.
Modify the contents of MyPortalMod_english.txt
so that it is
similar to the following:
"lang"
{
"Language" "english"
"Tokens"
{
"MyPortalMod_chapter1" "The First Chapter"
"MyPortalMod_chapter2" "The Second Chapter"
}
}
In this case, MyPortalMod
is used because it is the name of the
mod's game directory. "The First Chapter" is an English title for the mod's
first chapter. Add any additional chapters for your mod by following the
pattern in "Tokens".


Save As...
, this is equivalent to choosing unicode
for the Encoding
option at the bottom of the dialog.Setting Up Hammer


Launch the 'Source SDK' from your Steam Library 'Tools' section. Make sure that
the 'Engine Version' pull-down has "Source Engine 2009" selected. Select 'Edit
Game Configurations'. From the pop-up menu, select 'Add'. A second pop-up will
appear, asking for a name and a directory. Enter the name that you want your
mod to be listed as (with respect to the 'Source SDK' tool) and enter the path to
your game directory ([Steam Root]\steamapps\SourceMods\MyPortalMod
).
Then select 'OK' for the second and first pop-ups. Assume we named our game
configuration "My Portal Mod".
Restart the 'Source SDK' tool. Set 'Engine Version' and 'Current Game' to
'Source Engine 2009' and 'My Portal Mod', respectively. Now, select 'Hammer
Editor'. In the editor, select Tools > Options
. A 'Configure
Hammer' pop-up should appear. Select the 'Game Configurations' tab and then hit
the 'Add' button for 'Game Data Files'. Select the file portal.fgd
and accept the changes. These configurations will be saved and restored the next
time you open Hammer from the 'Source SDK' tool with your mod name selected.