2070
|
1 |
#summary How to create campaigns
|
|
2 |
|
|
3 |
= Campaigns =
|
2071
|
4 |
|
2070
|
5 |
== Introduction ==
|
|
6 |
A campaign is a series of missions that tell a story. Campaigns are played in singleplayer mode only.
|
|
7 |
|
|
8 |
== Campaign files ==
|
|
9 |
Campaigns are stored in `Data/Missions/Campaign/<CAMPAIGN NAME>`, with `<CAMPAIGN NAME>` being the campaign name.
|
|
10 |
|
|
11 |
In this directory, the following files are used:
|
|
12 |
|
|
13 |
* `campaign.ini`: Campaign mission list
|
|
14 |
* `*.lua`: A bunch of Lua scripts for the missions
|
|
15 |
|
|
16 |
=== `campaign.ini` ===
|
|
17 |
This is a file in the INI format. This lists the available missions.
|
|
18 |
|
|
19 |
* No section:
|
|
20 |
* `MissionNum`: Number of missions
|
|
21 |
* `ResetRetry`: Unused
|
|
22 |
* `[Mission X]`: Configuration for mission `X`, where X is the mission number. Mission 1 is the first mission.
|
|
23 |
* `Name`: Human-readable mission name in English
|
|
24 |
* `Script`: Name of Lua script file to load for this mission
|
|
25 |
|
|
26 |
=== The mission's Lua scripts ===
|
2072
|
27 |
There's one Lua script per mission. Scripting works basically like in singleplayer missons, see [Missions].
|
|
28 |
|
|
29 |
Exception: Campaign missions use campaign variables instead of mission variables to track progress.
|
2070
|
30 |
|
|
31 |
=== Preview image ===
|
|
32 |
The preview image is displayed in the menu when you have selected the mission.
|
|
33 |
It must be a PNG image of size 314px×260px.
|
|
34 |
|
|
35 |
The file must be saved in `Data/Graphics/Campaigns/<CAMPAIGN NAME>`. The file name must follow this pattern:
|
|
36 |
|
|
37 |
`<mission script name>@2x.png`
|
|
38 |
|
|
39 |
Where `<mission script name>` is name of the mission script without the file name suffix.
|
|
40 |
|
2101
|
41 |
For example, the preview image for the mission script `mission1.lua` must have the name `mission1@2x.png`.
|
2070
|
42 |
|
|
43 |
=== Localization ===
|
|
44 |
Campaign title, mission titles and mission descriptions menu must be edited in the missions files in `Data/Locale`. The file name is `campaigns_<language code>.txt`. There is one file per language. E.g. `campaigns_en.txt` for English. Note that these files are supposed to contain the titles and descriptions of *all* campaigns on your computer. This makes these files unsuitable for sharing or inclusion into [HWPFormat HWP files], for example.
|
|
45 |
|
|
46 |
This is the syntax:
|
|
47 |
|
|
48 |
{{{
|
|
49 |
<campaign dir name>.name="<campaign name>"
|
|
50 |
|
|
51 |
<campaign dir name>-<mission 1 script name>.name="<mission 1 name>"
|
|
52 |
<campaign dir name>-<mission 1 script name>.desc="<mission 1 description>"
|
|
53 |
|
|
54 |
<campaign dir name>-<mission 2 script name>.name="<mission 2 name>"
|
|
55 |
<campaign dir name>-<mission 2 script name>.desc="<mission 2 description>"
|
|
56 |
}}}
|
|
57 |
|
|
58 |
And so on.
|
|
59 |
|
|
60 |
* `<campaign dir name>` is the directory name of the campaign. Replace spaces with underscores here.
|
|
61 |
* `<campaign name>` is the human-readable campaign name.
|
|
62 |
* `<mission x script name>` is the file name of the script of mission _x_ without file name suffix
|
|
63 |
* `<mission x name>` is the human-readable name of mission _x_
|
|
64 |
* `<mission x description>` is the description of mission _x_
|
|
65 |
|
|
66 |
If something is, the campaign menu will derive the title from the directory/file names instead and shows no description.
|
|
67 |
|
|
68 |
For more information about translating Hedgewars, see [Translations].
|
|
69 |
|
|
70 |
==== Example ====
|
|
71 |
|
|
72 |
Excerpt from `campaigns_en.txt`:
|
|
73 |
|
|
74 |
{{{
|
|
75 |
A_Classic_Fairytale.name="A Classic Fairytale"
|
|
76 |
|
|
77 |
A_Classic_Fairytale-first_blood.name="Mission 1: First Blood"
|
|
78 |
A_Classic_Fairytale-first_blood.desc="Help Leaks a Lot to complete his training and become a proper hedgehog warrior. You will be trained in the art of rope, parachute, shoryuken and desert eagle."
|
|
79 |
}}}
|
|
80 |
|
2075
|
81 |
== Campaign variables / campaign progress ==
|
|
82 |
Campaigns support campaign variables which allow to store arbitrary values about the campaign in the team file. Most importantly, the campaign progress is stored here. This uses the functions `SaveCampaignVar` and `GetCampaignVar`. Note that `SaveMissionVar` and `GetMissionVar` do *not* work in campaign missions.
|
|
83 |
|
|
84 |
Initially, only mission 1 is unlocked. To unlock more missions and to mark missions and the campaign as completed, you must set campaign variables. For linear campaigns, you can use this idiom:
|
2070
|
85 |
|
2075
|
86 |
{{{
|
|
87 |
-- To be called when mission 5 was won:
|
|
88 |
local progress = tonumber(GetCampaignVar("Progress"))
|
|
89 |
if progress == nil or progress < 5 then
|
|
90 |
SaveCampaignVar("Progress", "5")
|
|
91 |
end
|
|
92 |
}}}
|
|
93 |
|
|
94 |
For non-linear campaigns, a more sophisticated unlocking is available.
|
|
95 |
|
|
96 |
Read [ConfigurationFiles] to learn how campaign variables work in detail. |