Portal Challenge Script: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Challenge scripting)
 
(Revamped it, adding gcfscape step and made it more detailed)
 
(21 intermediate revisions by 13 users not shown)
Line 1: Line 1:
How to make your own challenge with script
{{lang|Portal_Challenge_Script}}
''For more info on Bonus Maps, BNS files, and BMZ files see [[Bonus Maps]]''
{{Back|Category:Portal_level_design|Portal Level Design}}


note:English may need to be more fluent.
== Extraction of <code>challenges.bns</code> ==
Extract the original file using [[Crowbar]] or [[GCFScape]]. GCFScape is easier to use and less cluttered. We will extract the file to have a reference to making our own. If you want to make it by scratch you can skip the extraction.
<br>
<br>
Crowbar Method:
* Launch Crowbar


Add a challenge isn't faire, that's suppose to edit a Portal files,
* Click the <code>Unpack</code> tab at the top
You can't add your files


==First Step==
* Click the <code>Browse</code> button on the <code>Packages</code> line to the right
You have to got [[GCFScape]] first
* Navigate to <code>Steam/steamapps/common/Portal/portal</code> then select <code>portal_pak_dir.vpk</code> as the file
launch it and open portal.gcf on your steam account folders.


Extract the file :
* Click the <code>Browse</code> button on the <code>Output to</code> line to the right
portal/scripts/challenges/challenges.bns
* Navigate to <code>Steam/steamapps/common/Portal/portal/scripts</code> then select <code>challenges</code> as the folder


Put it in your steam/your_account/portal/portal/scripts/challenges/
* Navigate in Crowbar to <code><root>/scripts/challenges</code> and select <code>challenges.bns</code>
* Click the <code>Unpack</code> button near the bottom, next to <code>Skip Current</code>


Now open it with notepad, or your favorite text editor.
* Open the extracted file with your preferred text editor
<br>
GCFScape Method:
* Launch GCFScape


==Sample Script==
* Click <code>File</code> then <code>Open</code>
* Navigate to <code>Steam/steamapps/common/Portal/portal</code> then select <code>portal_pak_dir.vpk</code> as the file


When you open the chalennges.bns file you can see this type of script :
* Navigate in GCFScape to <code>root/scripts/challenges</code>
* Right-Click <code>challenges.bns</code> and Click <code>Extract</code>
* Navigate to <code>Steam/steamapps/common/Portal/portal/scripts/challenges</code> and extract it there


<code><pre>"#Bonus_Map_TC13Challenges"
* Open the extracted file with your preferred text editor
 
 
{{note|This is not required to make a <code>.bns</code> file. They can be made by renaming a <code>.txt</code> file. We will use the <code>challenges.bns</code> as a reference.}}
 
== Inside the file ==
* When you open the <code>challenges.bns</code> file you can see scripts similar to this one:
 
<pre>"#Bonus_Map_TC13Challenges"
{
{
"map" "testchmb_a_08"
"map" "testchmb_a_08"
Line 27: Line 47:
"image" "bonusmaps/testchmb_a_08_challenges"
"image" "bonusmaps/testchmb_a_08_challenges"
"comment" "#Bonus_Map_ChallengesComment"
"comment" "#Bonus_Map_ChallengesComment"
"lock" "1"
"lock" "0"


"challenges"
"challenges"
Line 56: Line 76:
}
}
}
}
}</pre></code>
}</pre>
 
==Script Explained header==
 
<pre>"#Bonus_Map_TC13Challenges"</pre>
it's a language tag, it's linked to the portal_<Steam_Language>.txt files on ressource folder of portal.
You musn't have to edit this files. Put a sentence here than a tag (withdraw the # symbole).
 
<pre>"map" "testchmb_a_08"</pre>
here is your map name. Replace ''testchmb_a_08'' By your map name, without .bsp extension.
 
 
<pre>"chapter" "chapter5.cfg" [$X360]</pre>
It's refer to a .cfg file on the portal/cfg folder.
 
You have to make a cfg file (use notepad), I don't know at this time if you must keep "chapter" in the name, but try to make your own to
prevent multinaming with other mapping members.


Your cfg have only one line :
=== "#Bonus_Map_TC13Challenges" ===
<pre>map your_map_name</pre>
This piece of code denotes the name of the map. This is linked to the <code>portal_LANGUAGE.txt</code> file in the game's resources folder. {{note|This feature is language specific, and unless you plan to make your map multilingual, you can simply insert text instead of <code>"#Bonus_Map_TC13Challenges"</code>.}}
Juste put your map name without the .bsp extension.


Now close your cfg.
=== map ===
Come back to our script :
This is the name of the map without the bsp extension, the one which you put in the game's maps folder.


<pre>"image" "bonusmaps/testchmb_a_08_challenges"</pre>
=== chapter ===
It's a picture on materials/VGUI/
This line refers to the chapter the map belongs to. You can find these chapter files in your VPK file. Simply create a new chapter with any name and a cfg extension. Add a line for each map in your chapter in to the file in this format:
that's call a .vmt file (tru to have your .vtf in the same folder to make it clean)
map your_map_name
this picture is displayed in challenge panels to represent your challenge.
Now, put this cfg file into the <code>steam\steamapps\common\portal\portal\cfg</code> folder.


<pre>"comment" "#Bonus_Map_ChallengesComment"</pre>
=== image ===
A language tag about your challenge, describe your here.
This is the thumbnail of the map, which is in fact a [[material]]. The root path for this is <code>steam\steamapps\common\portal\portal\materials\VGUI</code>.


<pre>"lock" "1"</pre>
=== comment ===
1 mean it's locked, 0 means it's unlocked
A language based description of your map. Again, unless you want to make the map multilingual, just replace it with text.


==Script Explained Challenge type==
=== lock ===
A [[boolean]] variable, which specifies if the map is locked or not until you complete the game. A standalone map should '''leave this value at ''0'' ''' or the map will always be locked and unplayable. If it is part of a series of maps to be played in order, and not the first map, it can be unlocked via a [[point_bonusmaps_accessor]].


Okay now you have to set your medal criteria.
== Challenge types ==
Three type challenge exist :
You will also have to set the criteria of your map for
Portal
* Portals
Step
* Steps
Time  
* Time  
 
 
'''Portal'''


There are three similar sections at the end of each map. This one below is for portals. For steps or time, replace the "Portals" in each string with Steps or Time, accordingly.
<pre>
<pre>
"#Bonus_Map_ChallengePortals"
"#Bonus_Map_ChallengePortals"
{
{
"comment" "#Bonus_Map_LeastPortalsComment"
"comment" "#Bonus_Map_LeastPortalsComment"
Line 114: Line 116:
</pre>
</pre>


The first line is a language tag.
The first line, again, is a language-based string variable. You don't have to change it here.
Same as '''"comment"''', this one is about max Portal challenge
The following three lines specify the amount of Portals, Steps, or Time needed for each medal.
 
The next line is the medal followed by the max number of portal required to earn the medal.
 
'''Step'''
 
 
<pre>"#Bonus_Map_ChallengeSteps"
{
"comment" "#Bonus_Map_LeastStepsComment"
 
"bronze" "30"
"silver" "20"
"gold" "10"
}</pre>
Same as before, but now it's about the max steps numbers to earn a medal.
 
'''Time '''
 
<pre>
"#Bonus_Map_ChallengeTime"
{
"comment" "#Bonus_Map_LeastTimeComment"
 
"bronze" "40"
"silver" "30"
"gold" "19"
}
</pre>
The last challenge type define the max times (seconds) to earn a medal.
 
==Add your challenge==
 
 
1 - Make your maps


2 - Make your .cfg with this line :
== Adding your own challenge ==
<pre>map map_name</pre>
Adding your own challenge is an easy, 2-to-3-step task.
in portal/cfg
* Make your map(s) and put them in <code>Steam/SteamApps/common/portal/portal/maps</code>
* This is an optional step as you can reuse an old image, or create your own. If you created your own image, put it into the <code>Steam/SteamApps/common/portal/portal/materials/VGUI</code> directory or one of its subdirectories (recommended).
* Finally, create a new .bns file in the <code>Steam/SteamApps/common/portal/portal/scripts/challenges</code> folder and edit it with or without the help of this tutorial.


3 - Make your picture and put it in :
== See also ==
materials/VGUI/bonusmaps/ 
* [[Portal Level Creation]]


4 - Make a new .bns file in portal/script/challenges/ folder
[[Category:Modding]]
Same as language file, you musn't have to edit the mod's files.
[[Category:Portal]]
Copy past the sample script, and replace the value by your challenges values.
[[Category:Tutorials]]

Latest revision as of 20:24, 31 July 2025

English (en)Русский (ru)Translate (Translate)

For more info on Bonus Maps, BNS files, and BMZ files see Bonus Maps

Portal Level Design

Extraction of challenges.bns

Extract the original file using Crowbar or GCFScape. GCFScape is easier to use and less cluttered. We will extract the file to have a reference to making our own. If you want to make it by scratch you can skip the extraction.

Crowbar Method:

  • Launch Crowbar
  • Click the Unpack tab at the top
  • Click the Browse button on the Packages line to the right
  • Navigate to Steam/steamapps/common/Portal/portal then select portal_pak_dir.vpk as the file
  • Click the Browse button on the Output to line to the right
  • Navigate to Steam/steamapps/common/Portal/portal/scripts then select challenges as the folder
  • Navigate in Crowbar to <root>/scripts/challenges and select challenges.bns
  • Click the Unpack button near the bottom, next to Skip Current
  • Open the extracted file with your preferred text editor


GCFScape Method:

  • Launch GCFScape
  • Click File then Open
  • Navigate to Steam/steamapps/common/Portal/portal then select portal_pak_dir.vpk as the file
  • Navigate in GCFScape to root/scripts/challenges
  • Right-Click challenges.bns and Click Extract
  • Navigate to Steam/steamapps/common/Portal/portal/scripts/challenges and extract it there
  • Open the extracted file with your preferred text editor


Note.pngNote:This is not required to make a .bns file. They can be made by renaming a .txt file. We will use the challenges.bns as a reference.

Inside the file

  • When you open the challenges.bns file you can see scripts similar to this one:
"#Bonus_Map_TC13Challenges"
{
	"map"		"testchmb_a_08"
	"chapter"	"chapter5.cfg"	[$X360]
	"image"		"bonusmaps/testchmb_a_08_challenges"
	"comment"	"#Bonus_Map_ChallengesComment"
	"lock"		"0"

	"challenges"
	{
		"#Bonus_Map_ChallengePortals"
		{
			"comment"	"#Bonus_Map_LeastPortalsComment"

			"bronze"	"9"
			"silver"	"5"
			"gold"		"4"
		}
		"#Bonus_Map_ChallengeSteps"
		{
			"comment"	"#Bonus_Map_LeastStepsComment"

			"bronze"	"30"
			"silver"	"20"
			"gold"		"10"
		}
		"#Bonus_Map_ChallengeTime"
		{
			"comment"	"#Bonus_Map_LeastTimeComment"

			"bronze"	"40"
			"silver"	"30"
			"gold"		"19"
		}
	}
}

"#Bonus_Map_TC13Challenges"

This piece of code denotes the name of the map. This is linked to the portal_LANGUAGE.txt file in the game's resources folder.

Note.pngNote:This feature is language specific, and unless you plan to make your map multilingual, you can simply insert text instead of "#Bonus_Map_TC13Challenges".

map

This is the name of the map without the bsp extension, the one which you put in the game's maps folder.

chapter

This line refers to the chapter the map belongs to. You can find these chapter files in your VPK file. Simply create a new chapter with any name and a cfg extension. Add a line for each map in your chapter in to the file in this format:

map your_map_name

Now, put this cfg file into the steam\steamapps\common\portal\portal\cfg folder.

image

This is the thumbnail of the map, which is in fact a material. The root path for this is steam\steamapps\common\portal\portal\materials\VGUI.

comment

A language based description of your map. Again, unless you want to make the map multilingual, just replace it with text.

lock

A boolean variable, which specifies if the map is locked or not until you complete the game. A standalone map should leave this value at 0 or the map will always be locked and unplayable. If it is part of a series of maps to be played in order, and not the first map, it can be unlocked via a point_bonusmaps_accessor.

Challenge types

You will also have to set the criteria of your map for

  • Portals
  • Steps
  • Time

There are three similar sections at the end of each map. This one below is for portals. For steps or time, replace the "Portals" in each string with Steps or Time, accordingly.

		"#Bonus_Map_ChallengePortals"
		{
			"comment"	"#Bonus_Map_LeastPortalsComment"

			"bronze"	"9"
			"silver"	"5"
			"gold"		"4"
		}

The first line, again, is a language-based string variable. You don't have to change it here. The following three lines specify the amount of Portals, Steps, or Time needed for each medal.

Adding your own challenge

Adding your own challenge is an easy, 2-to-3-step task.

  • Make your map(s) and put them in Steam/SteamApps/common/portal/portal/maps
  • This is an optional step as you can reuse an old image, or create your own. If you created your own image, put it into the Steam/SteamApps/common/portal/portal/materials/VGUI directory or one of its subdirectories (recommended).
  • Finally, create a new .bns file in the Steam/SteamApps/common/portal/portal/scripts/challenges folder and edit it with or without the help of this tutorial.

See also