author | Wuzzy |
Fri, 19 Apr 2019 16:07:50 +0100 | |
changeset 1831 | 365c30b4c669 |
parent 1376 | 4d563322d538 |
child 1934 | 59eca637c3d3 |
permissions | -rw-r--r-- |
1376 | 1 |
#summary Lua library documentation of !TargetPractice; for creating simple target practice missions |
1349 | 2 |
#labels !LuaLibrary |
1329
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
3 |
= Lua library: `TargetPractice` = |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
4 |
Starting with 0.9.21, this library provides a function to create an entire target practice mission which follows some basic properties. |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
5 |
|
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
6 |
Here is a brief description of the generated missions: |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
7 |
* The player will get a team with a single hedgehog. |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
8 |
* The team gets a single predefined weapon infinitely times. |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
9 |
* A fixed sequence of targets will spawn at predefined positions. |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
10 |
* When a target has been destroyed, the next target of the target sequence appears |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
11 |
* The mission ends successfully when all targets have been destroyed |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
12 |
* The mission ends unsuccessfully when the time runs out or the hedgehog dies |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
13 |
* 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. |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
14 |
|
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
15 |
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. |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
16 |
|
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
17 |
== `TargetPracticeMission(params)` == |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
18 |
This function sets up the *entire* training mission and needs one argument: `params`. |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
19 |
`params` is a table containing fields which describe the training mission. |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
20 |
|
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
21 |
There are mandatory and optional fields. The optional fields have default values. |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
22 |
|
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
23 |
Mandatory fields: |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
24 |
|| *Field name* || *Description* || |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
25 |
|| `missionTitle` || The name of the mission || |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
26 |
|| `map` || The name of the image map to be used || |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
27 |
|| `theme` || The name of the theme (can be background theme, too) || |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
28 |
|| `time` || The time limit in milliseconds || |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
29 |
|| `ammoType` || The [AmmoTypes ammo type] of the weapon to be used || |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
30 |
|| `gearType` || The [GearTypes gear type] of the gear which is fired by the weapon (used to count shots) || |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
31 |
|| `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. || |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
32 |
|
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
33 |
Optional fields: |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
34 |
|| *Field name* || *Description * || |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
35 |
|| `wind` || The initial wind (`-100` to `100`) (default: `0` (no wind)) || |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
36 |
|| `solidLand` || Weather the terrain is indestructible (default: `false`) || |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
37 |
|| `artillery` || If `true`, the hog can’t move (default: `false`) || |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
38 |
|| `hogHat` || Hat of the hedgehog (default: `"NoHat"`) || |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
39 |
|| `hogName` || Name of the hedgehog (default: `"Trainee"`) || |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
40 |
|| `teamName` || Name of the hedgehog’s team (default: `"Training Team"`) || |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
41 |
|| `teamGrave` || Name of the hedgehog’s grave || |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
42 |
|| `clanColor` || Color of the (only) clan (default: `0xFF0204`, which is a red tone) || |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
43 |
|| `goalText` || A short string explaining the goal of the mission (default: `"Destroy all targets within the time!"`) || |
1350 | 44 |
|| `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."`) || |
1329
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
45 |
|
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
46 |
|
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
47 |
=== Example === |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
48 |
Below is the complete source code of the mission “Target Practice: Cluster Bomb”: |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
49 |
|
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
50 |
<code language="lua">HedgewarsScriptLoad("/Scripts/TargetPractice.lua") |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
51 |
|
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
52 |
local params = { |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
53 |
ammoType = amClusterBomb, |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
54 |
gearType = gtClusterBomb, |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
55 |
missionTitle = "Cluster Bomb Training", |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
56 |
solidLand = false, |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
57 |
map = "Trash", |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
58 |
theme = "Golf", |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
59 |
hog_x = 756, |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
60 |
hog_y = 370, |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
61 |
hogName = loc("Private Nolak"), |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
62 |
hogHat = "war_desertgrenadier1", |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
63 |
teamName = loc("The Hogies"), |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
64 |
targets = { |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
65 |
{ x = 628, y = 0 }, |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
66 |
{ x = 891, y = 0 }, |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
67 |
{ x = 1309, y = 0 }, |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
68 |
{ x = 1128, y = 0 }, |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
69 |
{ x = 410, y = 0 }, |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
70 |
{ x = 1564, y = 0 }, |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
71 |
{ x = 1248, y = 476 }, |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
72 |
{ x = 169, y = 0 }, |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
73 |
{ x = 1720, y = 0 }, |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
74 |
{ x = 1441, y = 0 }, |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
75 |
{ x = 599, y = 0 }, |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
76 |
{ x = 1638, y = 0 }, |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
77 |
}, |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
78 |
time = 180000, |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
79 |
shootText = loc("You have thrown %d cluster bombs."), |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
80 |
} |
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
81 |
|
bd781e19a52d
Split Lua libraries into several sub-pages
Wuzzy <almikes@aol.com>
parents:
diff
changeset
|
82 |
TargetPracticeMission(params)</code> |