Skip to content

Commit bb1a601

Browse files
feat: P2CE Campaign System Documentation (#151)
1 parent bb11e60 commit bb1a601

20 files changed

Lines changed: 629 additions & 0 deletions
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
---
2+
title: Useful Commands, Convars, and Launch Options
3+
features:
4+
- USE_CAMPAIGNMANAGER
5+
---
6+
7+
# Useful Commands
8+
9+
## `campaign_reload`
10+
11+
Reloads the campaign list. New & change campaign scripts should appear in the UI. If you are on the campaign selection screen, re-enter that screen to see the new/update campaign.
12+
13+
## `campaign_info`
14+
15+
Spews information about the current campaign into the console.
16+
17+
## `campaign_list`
18+
19+
Lists all campaigns detected by P2:CE to the console.
20+
21+
## `campaign_clear`
22+
23+
Clears the currently active campaign.
24+
25+
## `campaign_continue`
26+
27+
Continue a campaign from the latest save. Usage: `campaign_continue [campaign_id]`.
28+
29+
## `campaign_level_next`
30+
31+
Changes the map to the next level in the campaign, if it exists.
32+
33+
## `campaign_level_prev`
34+
35+
Changes the map to the previous level in the campaign, if it exists.
36+
37+
## `campaign_savedata_reset`
38+
39+
Wipes all save data relating to campaign progression. Does not delete saved game files.
40+
41+
## `campaign_savedata_show`
42+
43+
Display save data relating to campaign progression.
44+
45+
## `campaign_set_active`
46+
47+
Set a specified campaign as active. Usage: `campaign_set_active [campaign_id]`
48+
49+
## `campaign_start`
50+
51+
Starts a specified campaign at a certain chapter. Usage: `campaign_start [campaign_id] [chapter_index]`
52+
53+
## `startupmenu`
54+
55+
Enters the appropriate background map as detailed by the campaign script.
56+
57+
# Useful Cvars
58+
59+
## `campaign_debug`
60+
61+
If value is 1, prints additional debugging information to the console in relation to the campaign system.
62+
63+
## `campaign_default`
64+
65+
Sets the default campaign to boot into on startup. The background map will be entered automatically without intervention by a script.
66+
67+
# Useful Launch Options
68+
69+
## `-unlockchapters`
70+
71+
Treats all campaigns as completely unlocked for testing. This does not make any changes to the progression save. Must be used in conjunction with the `-dev` launch option.
72+
73+
## `-nochapterprogress`
74+
75+
Treats all campaigns as completely locked for testing. This does not make any changes to the progression save. Must be used in conjunction with the `-dev` launch option.
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
---
2+
title: Getting Started
3+
features:
4+
- USE_CAMPAIGNMANAGER
5+
---
6+
7+
# Getting Started with P2:CE Campaigns
8+
9+
![Campaign Selection UI](images/campaign-selection-screen.webp)
10+
11+
P2:CE includes the ability for sourcemods, mappers, and addon authors to create custom campaigns. These custom campaigns can then be published to the Steam Workshop. A campaign refers to an organized bundle of maps, which could be tightly related (such as story-based campaigns) or have no relation at all (map/competition packs).
12+
13+
P2:CE's campaign system is the primary form of user created playable content. Standalone maps are still available, but are folded into a "P2:CE Workshop" campaign as a playlist.
14+
15+
# Creation
16+
17+
A campaign addon is much like a standard addon. It will contain all required assets, and optionally link to other external dependencies on the Steam Workshop. Campaign addons ship with additional image assets that the game's menu will use in various locations.
18+
19+
To begin, [create a new addon](/modding/workshop/workshopgui) and include all required content. Next, create a `campaigns.kv3` file within the `scripts` folder of the addon. This will define the campaign to the game.
20+
21+
Each campaign has a subset of metadata that all dictate your how your chapters are ordered and unlocked, and what art assets are used. The campaign script is a KeyValue3 file, structured in the following way:
22+
23+
> [!NOTE]
24+
> This snippet is not valid syntax and will not work in P2:CE!
25+
26+
```
27+
{
28+
meta = {
29+
(asset information)
30+
}
31+
"campaigns" = {
32+
"CAMPAIGN_ID" = {
33+
title = (string)
34+
unlock_all = (boolean)
35+
meta = {
36+
(overrides)
37+
}
38+
chapters = [
39+
// chapter block
40+
{
41+
title = (string)
42+
save_comment = (string)
43+
meta = {
44+
(overrides)
45+
}
46+
maps = [
47+
// map entry
48+
{
49+
name=(string)
50+
meta = {
51+
(overrides)
52+
}
53+
}
54+
]
55+
},
56+
// etc.
57+
]
58+
}
59+
}
60+
}
61+
```
62+
In order:
63+
- `meta`, a block that details information for P2:CE to use in its menu presentation and loading screens.
64+
- Meta keys are unique to the respective mod and it is up to the menu script to recognize and use them.
65+
- Meta blocks can exist at the Root/Campaign/Chapter/Map level. Priority is established in reverse order.
66+
- Matching fields inside the meta block will override based on this priority. For example, `background_map` specified at the chapter level overrides that field at the campaign or root level.
67+
- Full meta keys for P2:CE are described in the [Full Script Reference](/modding/p2ce-campaigns/script-reference#meta-keys) page.
68+
- `campaigns`, top-level block that groups all campaigns provided by the addon together.
69+
- `CAMPAIGN_ID`, an internal name to refer to the campaign by.
70+
- `title`, a human readable name for the campaign/chapter. This string will be localized if a token is set.
71+
- `unlock_all`, should all chapters be unlocked to start with?
72+
- `chapters`, an array containing blocks that describe each chapter.
73+
- `save_comment`, optional field that sets the save comment for saves created at the belonging chapter.
74+
- `maps`, an array containing blocks that describe each map.
75+
- Each map must specify the `name` field.
76+
77+
Fill in as much information as possible in the above snippet, or copy the sample from the [Full Script Reference](/modding/p2ce-campaigns/script-reference#ideal-meta-locations) page.
78+
79+
Duplicate the chapter block for each individual chapter. Duplicate the map block inside the `maps` array for every map that belongs to that chapter.
80+
81+
For example:
82+
```
83+
chapters = [
84+
// chapter block
85+
{
86+
title = "My Cool Chapter 1"
87+
maps = [
88+
// map entry
89+
{ name="sp_a1_intro1" },
90+
{ name="sp_a1_intro2" },
91+
// comma on the last entry in an array is valid syntax
92+
{ name="sp_a1_intro3" },
93+
]
94+
},
95+
{
96+
title = "My Cool Chapter 2"
97+
maps = [
98+
// map entry
99+
{ name="sp_a1_intro4" },
100+
]
101+
},
102+
]
103+
```
104+
105+
If you are having trouble placing meta keys, or want a script to copy and paste, see the [Full Script Reference](/modding/p2ce-campaigns/script-reference#ideal-meta-locations) page.
106+
107+
Once the campaign script has been created with the necessary information, it can be found in the campaign selector.
108+
109+
The bare minimum script to have a campaign appear on the selector can be found below:
110+
```
111+
{
112+
"campaigns" = {
113+
"[CAMPAIGN_ID]" = {
114+
}
115+
}
116+
}
117+
```
118+
Required art assets will be replaced with one of several fallback images if they are not found. Art assets that are optional will instead be hidden from the UI. Consult the [Full Script Reference](/modding/p2ce-campaigns/script-reference#meta-keys) for information on which assets are optional, and art asset guidelines.
119+
120+
![Selector & Fallback UI](images/campaign-minimum.webp)
121+
122+
**All art assets must reside in the `.assets` subfolder in the respective addon. The game will not find the art assets if they are in another location.**
123+
124+
# Example Campaign Files
125+
126+
P2:CE ships with local addons to play Portal 2, Portal 1, and Half-Life 2 (including its episodes). These addons can be found [here](https://github.com/StrataSource/p2ce-addons/tree/feat/campaign-tests).
127+
128+
# Campaign Progression
129+
130+
Campaigns have their progression information saved inside `SAVE/campaign_save_data.kv3`. This file can be erased using the `campaign_savedata_reset` command. Campaign progression is currently tracked by chapter & map number.
131+
132+
# Developing a Sourcemod?
133+
134+
P2:CE and its menu system was designed as a gateway to sourcemods/standalone games. If a default campaign is specified (cvar: `campaign_default`), the game will use that campaign as the base menu state instead of the standard P2:CE menu. This can be helpful for mods that cannot or do not want to create a custom menu system (or simply as a starting platform while developing the mod).
135+
136+
> [!NOTE]
137+
> **There are extra considerations to take when developing a menu script that leverages the campaign system. Full details can be found on [the Technical Notes page](/modding/p2ce-campaigns/technical-notes).**
38.8 KB
Loading
460 KB
Loading
137 KB
Loading
9.67 KB
Loading
141 KB
Loading
420 KB
Loading
362 KB
Loading
879 KB
Loading

0 commit comments

Comments
 (0)