Making Your Portal Mod: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
m (→‎Setting Up Hammer: Unicodifying, replaced: [[Image: → [[File:)
 
(26 intermediate revisions by 12 users not shown)
Line 1: Line 1:
{{cleanup}}
{{lang|Making Your Portal Mod}}
{{warning|This tutorial contains inaccuracies and needs to be fixed!}}
{{back|Portal Level Creation}}


== Not an executable mod ==
This article will discuss how to create a ''Portal'' content mod, from scratch. Part
You can't modify the executables, libraries, or anything like that. You CAN modify/create scenes, scripts, sounds, textures, models, or anything else that isn't completely built into the game.
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.


== Getting 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.}}
You do NOT need any tools to do this (apart from Windows, Steam and a copy of Portal on Steam).


== Creating Necessary Folders ==
==Prerequisites==
In a Windows Explorer window, navigate to your Steam directory. Then go to the folders: SteamApps, sourcemods.
To follow along with this article, you will need a copy of Portal and the Source
Inside sourcemods, create a folder. For this tutorial I will use "MyPortalMod". You can use anything -- it does not affect the mod's actual name.
SDK, installed on Steam.
Make the following folders:


    * cfg
==Creating the Mod==
    * resource
Creating the mod consists of creating a game folder and filling it with
    * maps
configuration files and mod-related content. Let's assume we are creating a mod
    * materials -- Optional
named "My Portal Mod", and that <code>[Steam Root]</code> is Steam's
    * models -- Optional
installed path on your machine. (e.g. <code>C:\Program Files (x86)\Steam</code>)
    * sound -- Optional (not SOUNDS, just sound)
===Create the Game Folder===
    * scripts -- Optional
Navigate to your <code>SourceMods</code> directory and create a folder named
    * scenes -- Optional
"MyPortalMod".


In this new directory, create a file called <code>GameInfo.txt</code>.


== Create files ==
Edit the contents of <code>GameInfo.txt</code> so that they look similar to the
Create and open a file called GameInfo.txt.
following snippet. For details about the structure of this file, see
[[Gameinfo.txt]]. {{note| This page has been edited after the SteamPipe update}}


Copy and paste this into the file and then we'll go through what it means.
<source>
<pre>"GameInfo"
"GameInfo"
{
{
  game     "MyPortalMod"
game "My Portal Mod"
  title       "MyPortalMod"
        title "My Portal Mod"
  type     singleplayer_only
type singleplayer_only
  "icon"     "icon"
nodifficulty 1
hasportals 1
nocrosshair 1
nomodels 1
     
developer " Name "
developer_url " Link "
manual " - "
icon "resource/icon"


  nodifficulty  1
FileSystem
  hasportals  1
{
SteamAppId 400
ToolsAppId 211


  FileSystem
SearchPaths
  {
{
      SteamAppId            400
game+mod |gameinfo_path|.
      ToolsAppId            211     
platform |gameinfo_path|.


      SearchPaths
// 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
        Game            |gameinfo_path|.
// in folders where they don't exist.  (Searching a VPK is much faster than making an operating
        Game            portal
// system call.)
        Game            hl2
game_lv portal/portal_lv.vpk
      }
game+mod portal/portal_sound_vo_english.vpk
  }
game+mod portal/portal_pak.vpk
}</pre>
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


game "MyPortalMod" Tells Steam that the name of this game is MyPortalMod. This will appear in the Steam menu.
// Now search loose files. We'll set the directory containing the gameinfo.txt file
title "MyPortalMod" Tells Source that it should display the title MyPortalMod on the titlescreen.
// as the first "mod" search path (after any user customizations). This is also the one
type singleplayer_only Tells Source that this is NOT a multiplayer game. Not sure of the point of this.
// that's used when writing to the "mod" path.
"icon" "icon" Tells Steam to look for a file called icon.tga, which will be the game's icon. Note: The FIRST "icon" is telling Steam this is the icon line, the SECOND icon is telling it to look for a file called icon.tga.
mod+mod_write+default_write_path |gameinfo_path|.
nodifficulty 1 Tells Source not to show difficulty settings.
hasportals 1 Tells Portal's Source that this game includes portals. Not sure of the point of this.
The rest is telling Steam to load Portal's Source engine and models.


Now, create a file called maplist.txt. In this, put all of your mod's map names without the ".bsp" extenstion.
// Add the Portal directory as a game search path. This is also where where writes
Not sure of the point of this. Maybe to make chapters work.
// to the "game" path go.
game+game_write portal


Change to your cfg directory and make a file called chapter1.cfg.
// Where the game's binaries are
Add all the lines you want executed in the developer console when you load the first chapter of your mod to this file.
gamebin portal/bin
Usually all you'd do is type in map and then the name of the first map of chapter 1 without the ".bsp" extenstion.
If you want more chapters make chapter2.cfg, chapter3.cfg, and so on.


Now, create a file called MyPortalMod_english.txt with the name of your mod's folder replacing MyPortalMod.
// Last, mount in shared HL2 loose files
Type in text like this:
game |all_source_engine_paths|hl2
"MyPortalMod_chapter1" "First Chapter"
platform |all_source_engine_paths|platform
MyPortalMod is the name of your mod's folder. First Chapter is the name of your first chapter.
}
Add additional lines with chapter2, chapter3, etc. instead of chapter1 for additional chapters.
}
Save the file AS UNICODE. IT HAS TO BE UNICODE.
}
</source>


== Setting up Source SDK to work with your mod ==
Restarting Steam at this point will create an entry in the game Library for the
Go into Source SDK. Select Edit Game Configurations.
mod. Deleting the game folder we created or removing the  
== Setting up the Hammer Editor ==
<code>GameInfo.txt</code> file will remove the entry.
To set up your Hammer Editor klick '''Tools''' and then '''Options'''.
Under '''Game Data Files''' klick '''add''' and navigate to '''steam/steamapps/UserName/sourcesdk/bin/orangebox/bin/'''
and add '''portal.fgd'''.Now klick '''OK''' and you can use things like the Portal-Gun in your maps.


== Topics not covered for this mod ==
===Configure the Mod===
    * Creating a background map for the menu
====Initial Setup====
    * Creating a background image for the menu
Let's add some standard folders to the game directory that will hold our mod's
    * Creating images for the chapter titles
configuration files and content. Add the following folders to your game
directory:
* <code>cfg</code>
* <code>resource</code>
* <code>maps</code>.


I have not chose to explain how to do this, because the way you do this for Half-Life 2 is the same for Portal.
While we're at it, let's add the following optional folders, for custom content
And also anything else that you do for a Half-Life 2 mod, is all done in the same manner for Portal.
like models and sounds:  
So head over here: http://developer.valvesoftware.com/wiki/Category:Modding
* <code>materials</code>
To learn more on modding if needed.
* <code>models</code>
* <code>scenes</code>
* <code>scripts</code>
* <code>sound</code>


==See Also==
====Create a Map List====
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>
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.


* [[Portal mod template]]
The following is a sample <code>maplist.txt</code> for a mod with two maps,
named <code>myportalmod_map_00.bsp</code> and
<code>myportalmod_map_01.bsp</code>.
 
<source>
myportalmod_map_00
myportalmod_map_01
</source>
 
====Create Chapter Configuration Files====
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
on to <code>chapter2.cfg</code>, 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 <code>chapter1.cfg</code> example:
<source>
map myportalmod_map_00
</source>
 
====Create a Localization File====
Create a localization file, called <code>MyPortalMod_english.txt</code>, in your
game directory's <code>resource</code> folder.
 
Modify the contents of <code>MyPortalMod_english.txt</code> so that it is
similar to the following:
<source>
"lang"
{
"Language" "english"
"Tokens"
{
"MyPortalMod_chapter1" "The First Chapter"
"MyPortalMod_chapter2" "The Second Chapter"
}
}
</source>
 
In this case, <code>MyPortalMod</code> 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".
 
{{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.}}
 
==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
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 (<code>[Steam Root]\steamapps\SourceMods\MyPortalMod</code>).
Then select 'OK' for the second and first pop-ups. Assume we named our game
configuration "My Portal Mod".
 
[[File:Making_your_portal_mod_00.png|center]]
 
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 <code>Tools > Options</code>. 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 <code>portal.fgd</code>
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.
 
==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

English (en)Русский (ru)Translate (Translate)
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 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.

Note.pngNote:Portal modification is different from some of the other Source-based games in that the source code to build the 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.txt.

Note.pngNote: This page has been edited after the SteamPipe update
"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".

Warning.pngWarning:This file must be saved in a Unicode format.
Note.pngNote:The author (on Windows Vista) used a little endian UTF-16 encoding. In Notepad, under Save As..., this is equivalent to choosing unicode for the Encoding option at the bottom of the dialog.

Setting Up Hammer

Note.pngNote: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 vconfig.exe a viable alternative to creating an initial dummy mod?

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".

Making your portal mod 00.png

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.

See also