|
1 #summary How to create singleplayer missions |
|
2 |
|
3 = Missions = |
|
4 == Introduction == |
|
5 Missions can be played in singleplayer mode and are selected from the single player menu in the mission menu (the hedgehog at the blackboard). |
|
6 |
|
7 == Mission files == |
|
8 Only the Lua script is needed, the other files/data are optional. But it is still recommended to create them. |
|
9 |
|
10 === The mission's Lua script === |
|
11 This is the heart of your mission. Here you will set up the mission and define the entire game logic of the mission. |
|
12 |
|
13 See [LuaGuide], [LuaAPI] and [LuaLibraries] for more information about scripting. |
|
14 |
|
15 This file needs to be saved in `Data/Missions/Training`. The file name must end with “`.lua`”. Remember the file name, you will need it for the other files. |
|
16 |
|
17 ==== Hints ==== |
|
18 In mission scripting, some patterns appear often, so here are some hints for your convenience (Refer to [LuaAPI] for a full documentation): |
|
19 |
|
20 * Start with `onGameInit` to set up the most basic environment parameters, teams, hedgehogs, etc. |
|
21 * Important set up functions: `AddTeam`, `AddHog`, `AddGear`, `SetGearPosition`. |
|
22 * You probably almost always want to call `ShowMission` at the beginning of the game (`onGameStart`) to show the objectives of your mission. |
|
23 * Enable the game flag `gfOneClanMode` if you need only one clan for your mission. |
|
24 * Normally, the game ends when all hedgehogs are dead or one clan is remaining (unless `gfOneClanMode` is set). You can call `EndGame` to end the game manually. |
|
25 * Call `SendStat` to customize the statistics screen. |
|
26 * Use the [LuaLibraries#Locale Locale] library to make your mission translatable. Enclose the human-readable texts in `loc`. |
|
27 * When making your mission translatable, use Lua's `string.format` to insert numbers and other strings instead of just concatenating everything together. |
|
28 * If you want to create complex animations and/or cinematics, include and use the [LuaLibraries#Animate Animate] library. |
|
29 |
|
30 === Preview image === |
|
31 The preview image is displayed in the mission menu when you have selected the mission. |
|
32 It must be a PNG image of size 314px×260px. |
|
33 |
|
34 The file must be saved in `Data/Graphics/Missions/Training`. The file name must follow this pattern: |
|
35 |
|
36 `<mission name>@2x.png` |
|
37 |
|
38 Where `<mission name>` is name of the mission script without the file name suffix. |
|
39 |
|
40 For example, the preview image for the mission script `User_Mission_-_Teamwork.lua` must have the name `User_Mission_-_Teamwork@2x.png`. |
|
41 |
|
42 === Mission title and description === |
|
43 The mission title and its description as shown in the mission menu must be edited in the missions files in `Data/Locale`. The file name is `missions_<language code>.txt`. There is one file per language. I.e. `missions_en.txt` for English, `missions_de.txt` for German, etc. Note that these files are supposed to contain the titles and descriptions of *all* missions on your computer. This makes these files unsuitable for sharing or inclusion into [HWPFormat HWP files], for example. |
|
44 |
|
45 To add the title an description for your mission, just add these 2 lines into the file according to this syntax: |
|
46 |
|
47 {{{ |
|
48 <mission name>.name=<mission title> |
|
49 <mission name>.desc=<mission description> |
|
50 }}} |
|
51 |
|
52 * `<mission name>` is the file name of the mission script without the file suffix. |
|
53 * `<mission title>` is the mission title as shown in the mission menu. |
|
54 * `<mission description>` is a short description of the mission, also only shown in the mission menu. |
|
55 |
|
56 You can optionally enclose `<mission title>` and `<mission description>` in quotation marks (they will be removed by the game). |
|
57 |
|
58 If the mission title and description are missing, the mission menu will derive the title from the file name of the Lua script instead and shows no description. |
|
59 |
|
60 For more information about translating Hedgewars, see [Translations]. |
|
61 |
|
62 ==== Example ==== |
|
63 Here are the English title and description of the mission “Bamboo Thicket” (file name of script: “`User_Mission_-_Bamboo_Thicket.lua`”): |
|
64 |
|
65 {{{ |
|
66 User_Mission_-_Bamboo_Thicket.name=Mission: Bamboo Thicket |
|
67 User_Mission_-_Bamboo_Thicket.desc="Death comes from above." |
|
68 }}} |