|
1 #summary Lua library documentation: TargetPractice |
|
2 #labels LuaLibrary |
|
3 |
|
4 = Lua library: `TargetPractice` = |
|
5 Starting with 0.9.21, this library provides a function to create an entire target practice mission which follows some basic properties. |
|
6 |
|
7 Here is a brief description of the generated missions: |
|
8 * The player will get a team with a single hedgehog. |
|
9 * The team gets a single predefined weapon infinitely times. |
|
10 * A fixed sequence of targets will spawn at predefined positions. |
|
11 * When a target has been destroyed, the next target of the target sequence appears |
|
12 * The mission ends successfully when all targets have been destroyed |
|
13 * The mission ends unsuccessfully when the time runs out or the hedgehog dies |
|
14 * When the mission ends, a score is awarded, based on the performance (hit targets, accuracy and remaining time) of the hedgehog. When not all targets are hit, there will be no accuracy and time bonuses. |
|
15 |
|
16 If you want to create a more sophisticated training mission, use your own code instead. The main motivation to write this library was to reduce redundancy in existing target practice missions. |
|
17 |
|
18 == `TargetPracticeMission(params)` == |
|
19 This function sets up the *entire* training mission and needs one argument: `params`. |
|
20 `params` is a table containing fields which describe the training mission. |
|
21 |
|
22 There are mandatory and optional fields. The optional fields have default values. |
|
23 |
|
24 Mandatory fields: |
|
25 || *Field name* || *Description* || |
|
26 || `missionTitle` || The name of the mission || |
|
27 || `map` || The name of the image map to be used || |
|
28 || `theme` || The name of the theme (can be background theme, too) || |
|
29 || `time` || The time limit in milliseconds || |
|
30 || `ammoType` || The [AmmoTypes ammo type] of the weapon to be used || |
|
31 || `gearType` || The [GearTypes gear type] of the gear which is fired by the weapon (used to count shots) || |
|
32 || `targets` || The coordinates of where the targets will be spawned. It is a table containing tables containing coordinates of format `{ x=value, y=value }`. The targets will be spawned in the same order as specified the coordinate tables appear. There must be at least 1 target. || |
|
33 |
|
34 Optional fields: |
|
35 || *Field name* || *Description * || |
|
36 || `wind` || The initial wind (`-100` to `100`) (default: `0` (no wind)) || |
|
37 || `solidLand` || Weather the terrain is indestructible (default: `false`) || |
|
38 || `artillery` || If `true`, the hog can’t move (default: `false`) || |
|
39 || `hogHat` || Hat of the hedgehog (default: `"NoHat"`) || |
|
40 || `hogName` || Name of the hedgehog (default: `"Trainee"`) || |
|
41 || `teamName` || Name of the hedgehog’s team (default: `"Training Team"`) || |
|
42 || `teamGrave` || Name of the hedgehog’s grave || |
|
43 || `clanColor` || Color of the (only) clan (default: `0xFF0204`, which is a red tone) || |
|
44 || `goalText` || A short string explaining the goal of the mission (default: `"Destroy all targets within the time!"`) || |
|
45 || `shootText`: || A string which says how many times the player shot, “`%d`” is replaced by the number of shots. (default: `"You have shot %d times."`) || |
|
46 |
|
47 |
|
48 === Example === |
|
49 Below is the complete source code of the mission “Target Practice: Cluster Bomb”: |
|
50 |
|
51 <code language="lua">HedgewarsScriptLoad("/Scripts/TargetPractice.lua") |
|
52 |
|
53 local params = { |
|
54 ammoType = amClusterBomb, |
|
55 gearType = gtClusterBomb, |
|
56 missionTitle = "Cluster Bomb Training", |
|
57 solidLand = false, |
|
58 map = "Trash", |
|
59 theme = "Golf", |
|
60 hog_x = 756, |
|
61 hog_y = 370, |
|
62 hogName = loc("Private Nolak"), |
|
63 hogHat = "war_desertgrenadier1", |
|
64 teamName = loc("The Hogies"), |
|
65 targets = { |
|
66 { x = 628, y = 0 }, |
|
67 { x = 891, y = 0 }, |
|
68 { x = 1309, y = 0 }, |
|
69 { x = 1128, y = 0 }, |
|
70 { x = 410, y = 0 }, |
|
71 { x = 1564, y = 0 }, |
|
72 { x = 1248, y = 476 }, |
|
73 { x = 169, y = 0 }, |
|
74 { x = 1720, y = 0 }, |
|
75 { x = 1441, y = 0 }, |
|
76 { x = 599, y = 0 }, |
|
77 { x = 1638, y = 0 }, |
|
78 }, |
|
79 time = 180000, |
|
80 shootText = loc("You have thrown %d cluster bombs."), |
|
81 } |
|
82 |
|
83 TargetPracticeMission(params)</code> |