author | Wuzzy <Wuzzy2@mail.ru> |
Sat, 07 Jul 2018 22:50:08 +0200 | |
changeset 13456 | 7d69c5605a9d |
parent 13104 | 071dcdf33f86 |
child 13588 | 141cdfe0f3ca |
permissions | -rw-r--r-- |
10656
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
1 |
--[=[ |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
2 |
Target Practice Mission Framework for Hedgewars |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
3 |
|
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
4 |
This is a simple library intended to make setting up simple training missions a trivial |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
5 |
task requiring just. The library has been created to reduce redundancy in Lua scripts. |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
6 |
|
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
7 |
The training framework generates complete and fully usable training missions by just |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
8 |
one function call. |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
9 |
|
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
10 |
The missions generated by this script are all the same: |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
11 |
- The player will get a team with a single hedgehog. |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
12 |
- The team gets a single predefined weapon infinitely times. |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
13 |
- A fixed sequence of targets will spawn at predefined positions. |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
14 |
- When a target has been destroyed, the next target of the target sequence appears |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
15 |
- The mission ends successfully when all targets have been destroyed |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
16 |
- The mission ends unsuccessfully when the time runs out or the hedgehog dies |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
17 |
- When the mission ends, a score is awarded, based on the performance (hit targets, |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
18 |
accuracy and remaining time) of the hedgehog. When not all targets are hit, there |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
19 |
will be no accuracy and time bonuses. |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
20 |
|
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
21 |
To use this library, you first have to load it and to call TrainingMission once with |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
22 |
the appropriate parameters. Really, that’s all! |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
23 |
See the comment of TrainingMission for a specification of all parameters. |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
24 |
|
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
25 |
Below is a template for your convenience, you just have to fill in the fields and delete |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
26 |
optional arguments you don’t want. |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
27 |
----- snip ----- |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
28 |
HedgewarsScriptLoad("/Scripts/Training.lua") |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
29 |
params = { |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
30 |
missionTitle = , |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
31 |
map = , |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
32 |
theme = , |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
33 |
time = , |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
34 |
ammoType = , |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
35 |
gearType = , |
13103
d3e9f3423ef3
Target Practice: Re-center camera to hog after projectiles get destroyed or drown
Wuzzy <Wuzzy2@mail.ru>
parents:
13070
diff
changeset
|
36 |
secondaryGearType = , |
10656
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
37 |
targets = { |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
38 |
{ x = , y = }, |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
39 |
{ x = , y = }, |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
40 |
-- etc. |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
41 |
}, |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
42 |
|
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
43 |
wind = , |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
44 |
solidLand = , |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
45 |
artillery = , |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
46 |
hogHat = , |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
47 |
hogName = , |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
48 |
teamName = , |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
49 |
teamGrave = , |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
50 |
clanColor = , |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
51 |
goalText = , |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
52 |
shootText = |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
53 |
} |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
54 |
TargetPracticeMission(params) |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
55 |
----- snip ----- |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
56 |
]=] |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
57 |
|
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
58 |
HedgewarsScriptLoad("/Scripts/Locale.lua") |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
59 |
|
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
60 |
local player = nil |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
61 |
local scored = 0 |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
62 |
local shots = 0 |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
63 |
local end_timer = 1000 |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
64 |
local game_lost = false |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
65 |
local time_goal = 0 |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
66 |
local total_targets |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
67 |
local targets |
13103
d3e9f3423ef3
Target Practice: Re-center camera to hog after projectiles get destroyed or drown
Wuzzy <Wuzzy2@mail.ru>
parents:
13070
diff
changeset
|
68 |
local gearsInGameCount = 0 |
d3e9f3423ef3
Target Practice: Re-center camera to hog after projectiles get destroyed or drown
Wuzzy <Wuzzy2@mail.ru>
parents:
13070
diff
changeset
|
69 |
local gearsInGame = {} |
10656
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
70 |
|
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
71 |
--[[ |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
72 |
TrainingMission(params) |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
73 |
|
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
74 |
This function sets up the *entire* training mission and needs one argument: params. |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
75 |
The argument “params” is a table containing fields which describe the training mission. |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
76 |
mandatory fields: |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
77 |
- missionTitle: the name of the mission |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
78 |
- map: the name map to be used |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
79 |
- theme: the name of the theme (does not need to be a standalone theme) |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
80 |
- time: the time limit in milliseconds |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
81 |
- ammoType: the ammo type of the weapon to be used |
13103
d3e9f3423ef3
Target Practice: Re-center camera to hog after projectiles get destroyed or drown
Wuzzy <Wuzzy2@mail.ru>
parents:
13070
diff
changeset
|
82 |
- gearType: the gear type of the gear which is fired (used to count shots and re-center camera) |
10656
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
83 |
- targets: The coordinates of where the targets will be spawned. |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
84 |
It is a table containing tables containing coordinates of format |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
85 |
{ x=value, y=value }. The targets will be spawned in the same |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
86 |
order as specified the coordinate tables appear. Example: |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
87 |
targets = { |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
88 |
{ x = 324, y = 43 }, |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
89 |
{ x = 123, y = 56 }, |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
90 |
{ x = 6, y = 0 }, |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
91 |
} |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
92 |
There must be at least 1 target. |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
93 |
|
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
94 |
optional fields: |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
95 |
- wind: the initial wind (-100 to 100) (default: 0 (no wind)) |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
96 |
- solidLand: weather the terrain is indestructible (default: false) |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
97 |
- artillery: if true, the hog can’t move (default: false) |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
98 |
- hogHat: hat of the hedgehog (default: "NoHat") |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
99 |
- hogName: name of the hedgehog (default: "Trainee") |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
100 |
- teamName: name of the hedgehog’s team (default: "Training Team") |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
101 |
- teamGrave: name of the hedgehog’s grave |
12054
030464f34d47
Tweak flags used in all missions to fit more to the theme
Wuzzy <almikes@aol.com>
parents:
11772
diff
changeset
|
102 |
- teamFlag: name of the team’s flag (default: "cm_crosshair") |
13103
d3e9f3423ef3
Target Practice: Re-center camera to hog after projectiles get destroyed or drown
Wuzzy <Wuzzy2@mail.ru>
parents:
13070
diff
changeset
|
103 |
- secGearType: cluster of projectile gear (if present) (used to re-center camera) |
10656
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
104 |
- clanColor: color of the (only) clan (default: 0xFF0204, which is a red tone) |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
105 |
- goalText: A short string explaining the goal of the mission |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
106 |
(default: "Destroy all targets within the time!") |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
107 |
- shootText: A string which says how many times the player shot, “%d” is replaced |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
108 |
by the number of shots. (default: "You have shot %d times.") |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
109 |
]] |
13070
a297e06d1607
Display score next to team bar in singleplayer challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
13039
diff
changeset
|
110 |
|
a297e06d1607
Display score next to team bar in singleplayer challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
13039
diff
changeset
|
111 |
|
a297e06d1607
Display score next to team bar in singleplayer challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
13039
diff
changeset
|
112 |
local getTargetsScore = function() |
a297e06d1607
Display score next to team bar in singleplayer challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
13039
diff
changeset
|
113 |
return scored * math.ceil(6000/#targets) |
a297e06d1607
Display score next to team bar in singleplayer challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
13039
diff
changeset
|
114 |
end |
a297e06d1607
Display score next to team bar in singleplayer challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
13039
diff
changeset
|
115 |
|
10656
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
116 |
function TargetPracticeMission(params) |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
117 |
if params.hogHat == nil then params.hogHat = "NoHat" end |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
118 |
if params.hogName == nil then params.hogName = loc("Trainee") end |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
119 |
if params.teamName == nil then params.teamName = loc("Training Team") end |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
120 |
if params.goalText == nil then params.goalText = loc("Eliminate all targets before your time runs out.|You have unlimited ammo for this mission.") end |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
121 |
if params.shootText == nil then params.shootText = loc("You have shot %d times.") end |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
122 |
if params.clanColor == nil then params.clanColor = 0xFF0204 end |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
123 |
if params.teamGrave == nil then params.teamGrave= "Statue" end |
12054
030464f34d47
Tweak flags used in all missions to fit more to the theme
Wuzzy <almikes@aol.com>
parents:
11772
diff
changeset
|
124 |
if params.teamFlag == nil then params.teamFlag = "cm_crosshair" end |
10656
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
125 |
if params.wind == nil then params.wind = 0 end |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
126 |
|
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
127 |
local solid, artillery |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
128 |
if params.solidLand == true then solid = gfSolidLand else solid = 0 end |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
129 |
if params.artillery == true then artillery = gfArtillery else artillery = 0 end |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
130 |
|
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
131 |
targets = params.targets |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
132 |
|
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
133 |
total_targets = #targets |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
134 |
|
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
135 |
_G.onAmmoStoreInit = function() |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
136 |
SetAmmo(params.ammoType, 9, 0, 0, 0) |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
137 |
end |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
138 |
|
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
139 |
_G.onGameInit = function() |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
140 |
Seed = 1 |
13104
071dcdf33f86
Fix artillery being broken in some missions
Wuzzy <Wuzzy2@mail.ru>
parents:
13103
diff
changeset
|
141 |
ClearGameFlags() |
071dcdf33f86
Fix artillery being broken in some missions
Wuzzy <Wuzzy2@mail.ru>
parents:
13103
diff
changeset
|
142 |
EnableGameFlags(gfDisableWind, gfInfAttack, gfOneClanMode, solid, artillery) |
10656
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
143 |
TurnTime = params.time |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
144 |
Map = params.map |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
145 |
Theme = params.theme |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
146 |
Goals = params.goalText |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
147 |
CaseFreq = 0 |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
148 |
MinesNum = 0 |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
149 |
Explosives = 0 |
12229
d62d6f8ebef1
Disable Sudden Death consistently in all missions which don't require it
Wuzzy <almikes@aol.com>
parents:
12054
diff
changeset
|
150 |
-- Disable Sudden Death |
d62d6f8ebef1
Disable Sudden Death consistently in all missions which don't require it
Wuzzy <almikes@aol.com>
parents:
12054
diff
changeset
|
151 |
WaterRise = 0 |
d62d6f8ebef1
Disable Sudden Death consistently in all missions which don't require it
Wuzzy <almikes@aol.com>
parents:
12054
diff
changeset
|
152 |
HealthDecrease = 0 |
10656
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
153 |
|
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
154 |
SetWind(params.wind) |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
155 |
|
12054
030464f34d47
Tweak flags used in all missions to fit more to the theme
Wuzzy <almikes@aol.com>
parents:
11772
diff
changeset
|
156 |
AddTeam(loc(params.teamName), params.clanColor, params.teamGrave, "Flowerhog", "Default", params.teamFlag) |
10656
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
157 |
|
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
158 |
player = AddHog(loc(params.hogName), 0, 1, params.hogHat) |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
159 |
SetGearPosition(player, params.hog_x, params.hog_y) |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
160 |
end |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
161 |
|
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
162 |
_G.onGameStart = function() |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
163 |
SendHealthStatsOff() |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
164 |
ShowMission(params.missionTitle, loc("Aiming practice"), params.goalText, -params.ammoType, 5000) |
13070
a297e06d1607
Display score next to team bar in singleplayer challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
13039
diff
changeset
|
165 |
SetTeamLabel(params.teamName, "0") |
10656
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
166 |
spawnTarget() |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
167 |
end |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
168 |
|
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
169 |
_G.onNewTurn = function() |
11772
c21278c4218d
Target Practice: Make targets respawn after drowning, and minor code cleanup
Wuzzy <almikes@aol.com>
parents:
10656
diff
changeset
|
170 |
SetWeapon(params.ammoType) |
10656
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
171 |
end |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
172 |
|
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
173 |
_G.spawnTarget = function() |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
174 |
gear = AddGear(0, 0, gtTarget, 0, 0, 0, 0) |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
175 |
|
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
176 |
x = targets[scored+1].x |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
177 |
y = targets[scored+1].y |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
178 |
|
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
179 |
SetGearPosition(gear, x, y) |
11772
c21278c4218d
Target Practice: Make targets respawn after drowning, and minor code cleanup
Wuzzy <almikes@aol.com>
parents:
10656
diff
changeset
|
180 |
|
c21278c4218d
Target Practice: Make targets respawn after drowning, and minor code cleanup
Wuzzy <almikes@aol.com>
parents:
10656
diff
changeset
|
181 |
return gear |
10656
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
182 |
end |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
183 |
|
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
184 |
_G.onGameTick20 = function() |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
185 |
if TurnTimeLeft < 40 and TurnTimeLeft > 0 and scored < total_targets and game_lost == false then |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
186 |
game_lost = true |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
187 |
AddCaption(loc("Time’s up!"), 0xFFFFFFFF, capgrpGameState) |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
188 |
ShowMission(params.missionTitle, loc("Aiming practice"), loc("Oh no! Time's up! Just try again."), -amSkip, 0) |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
189 |
SetHealth(player, 0) |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
190 |
time_goal = 1 |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
191 |
end |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
192 |
|
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
193 |
if band(GetState(player), gstDrowning) == gstDrowning and game_lost == false and scored < total_targets then |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
194 |
game_lost = true |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
195 |
time_goal = 1 |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
196 |
AddCaption(loc("You lose!"), 0xFFFFFFFF, capgrpGameState) |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
197 |
ShowMission(params.missionTitle, loc("Aiming practice"), loc("Oh no! You failed! Just try again."), -amSkip, 0) |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
198 |
end |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
199 |
|
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
200 |
if scored == total_targets or game_lost then |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
201 |
if end_timer == 0 then |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
202 |
generateStats() |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
203 |
EndGame() |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
204 |
else |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
205 |
TurnTimeLeft = time_goal |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
206 |
end |
13103
d3e9f3423ef3
Target Practice: Re-center camera to hog after projectiles get destroyed or drown
Wuzzy <Wuzzy2@mail.ru>
parents:
13070
diff
changeset
|
207 |
end_timer = end_timer - 20 |
d3e9f3423ef3
Target Practice: Re-center camera to hog after projectiles get destroyed or drown
Wuzzy <Wuzzy2@mail.ru>
parents:
13070
diff
changeset
|
208 |
end |
d3e9f3423ef3
Target Practice: Re-center camera to hog after projectiles get destroyed or drown
Wuzzy <Wuzzy2@mail.ru>
parents:
13070
diff
changeset
|
209 |
|
d3e9f3423ef3
Target Practice: Re-center camera to hog after projectiles get destroyed or drown
Wuzzy <Wuzzy2@mail.ru>
parents:
13070
diff
changeset
|
210 |
for gear, _ in pairs(gearsInGame) do |
d3e9f3423ef3
Target Practice: Re-center camera to hog after projectiles get destroyed or drown
Wuzzy <Wuzzy2@mail.ru>
parents:
13070
diff
changeset
|
211 |
if band(GetState(gear), gstDrowning) ~= 0 then |
d3e9f3423ef3
Target Practice: Re-center camera to hog after projectiles get destroyed or drown
Wuzzy <Wuzzy2@mail.ru>
parents:
13070
diff
changeset
|
212 |
-- Re-center camera on hog if projectile gears drown |
d3e9f3423ef3
Target Practice: Re-center camera to hog after projectiles get destroyed or drown
Wuzzy <Wuzzy2@mail.ru>
parents:
13070
diff
changeset
|
213 |
gearsInGame[gear] = nil |
d3e9f3423ef3
Target Practice: Re-center camera to hog after projectiles get destroyed or drown
Wuzzy <Wuzzy2@mail.ru>
parents:
13070
diff
changeset
|
214 |
gearsInGameCount = gearsInGameCount - 1 |
d3e9f3423ef3
Target Practice: Re-center camera to hog after projectiles get destroyed or drown
Wuzzy <Wuzzy2@mail.ru>
parents:
13070
diff
changeset
|
215 |
if gearsInGameCount == 0 and GetHealth(CurrentHedgehog) then |
d3e9f3423ef3
Target Practice: Re-center camera to hog after projectiles get destroyed or drown
Wuzzy <Wuzzy2@mail.ru>
parents:
13070
diff
changeset
|
216 |
FollowGear(CurrentHedgehog) |
d3e9f3423ef3
Target Practice: Re-center camera to hog after projectiles get destroyed or drown
Wuzzy <Wuzzy2@mail.ru>
parents:
13070
diff
changeset
|
217 |
end |
d3e9f3423ef3
Target Practice: Re-center camera to hog after projectiles get destroyed or drown
Wuzzy <Wuzzy2@mail.ru>
parents:
13070
diff
changeset
|
218 |
end |
10656
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
219 |
end |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
220 |
end |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
221 |
|
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
222 |
_G.onGearAdd = function(gear) |
13103
d3e9f3423ef3
Target Practice: Re-center camera to hog after projectiles get destroyed or drown
Wuzzy <Wuzzy2@mail.ru>
parents:
13070
diff
changeset
|
223 |
if GetGearType(gear) == params.gearType or (params.secGearType and GetGearType(gear) == params.secGearType) then |
10656
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
224 |
shots = shots + 1 |
13103
d3e9f3423ef3
Target Practice: Re-center camera to hog after projectiles get destroyed or drown
Wuzzy <Wuzzy2@mail.ru>
parents:
13070
diff
changeset
|
225 |
gearsInGameCount = gearsInGameCount + 1 |
d3e9f3423ef3
Target Practice: Re-center camera to hog after projectiles get destroyed or drown
Wuzzy <Wuzzy2@mail.ru>
parents:
13070
diff
changeset
|
226 |
gearsInGame[gear] = true |
10656
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
227 |
end |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
228 |
end |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
229 |
|
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
230 |
_G.onGearDamage = function(gear, damage) |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
231 |
if GetGearType(gear) == gtTarget then |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
232 |
scored = scored + 1 |
13070
a297e06d1607
Display score next to team bar in singleplayer challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
13039
diff
changeset
|
233 |
SetTeamLabel(params.teamName, tostring(getTargetsScore())) |
10656
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
234 |
if scored < total_targets then |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
235 |
AddCaption(string.format(loc("Targets left: %d"), (total_targets-scored)), 0xFFFFFFFF, capgrpMessage) |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
236 |
spawnTarget() |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
237 |
else |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
238 |
if not game_lost then |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
239 |
AddCaption(loc("You have destroyed all targets!"), 0xFFFFFFFF, capgrpGameState) |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
240 |
ShowMission(params.missionTitle, loc("Aiming practice"), loc("Congratulations! You have destroyed all targets within the time."), 0, 0) |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
241 |
PlaySound(sndVictory, player) |
13039
fe9c12209f15
Make hog invulnerable after winning SpeedShoppa or TargetPractice mission
Wuzzy <Wuzzy2@mail.ru>
parents:
12785
diff
changeset
|
242 |
SetEffect(player, heInvulnerable, 1) |
10656
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
243 |
SetState(player, bor(GetState(player), gstWinner)) |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
244 |
time_goal = TurnTimeLeft |
12785
659ab77b52c0
Disable hog control after winning target practice challenge
Wuzzy <Wuzzy2@mail.ru>
parents:
12430
diff
changeset
|
245 |
-- Disable control |
659ab77b52c0
Disable hog control after winning target practice challenge
Wuzzy <Wuzzy2@mail.ru>
parents:
12430
diff
changeset
|
246 |
SetInputMask(0) |
659ab77b52c0
Disable hog control after winning target practice challenge
Wuzzy <Wuzzy2@mail.ru>
parents:
12430
diff
changeset
|
247 |
AddAmmo(player, params.ammoType, 0) |
10656
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
248 |
end |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
249 |
end |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
250 |
end |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
251 |
|
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
252 |
if GetGearType(gear) == gtHedgehog then |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
253 |
if not game_lost then |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
254 |
game_lost = true |
12429
b9cc405541c1
Fix various loc() syntax errors in scripts
Wuzzy <almikes@aol.com>
parents:
12229
diff
changeset
|
255 |
AddCaption(loc("You lose!"), 0xFFFFFFFF, capgrpGameState) |
10656
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
256 |
ShowMission(params.missionTitle, loc("Aiming practice"), loc("Oh no! You failed! Just try again."), -amSkip, 0) |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
257 |
|
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
258 |
SetHealth(player, 0) |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
259 |
time_goal = 1 |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
260 |
end |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
261 |
end |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
262 |
end |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
263 |
|
11772
c21278c4218d
Target Practice: Make targets respawn after drowning, and minor code cleanup
Wuzzy <almikes@aol.com>
parents:
10656
diff
changeset
|
264 |
_G.onGearDelete = function(gear) |
c21278c4218d
Target Practice: Make targets respawn after drowning, and minor code cleanup
Wuzzy <almikes@aol.com>
parents:
10656
diff
changeset
|
265 |
if GetGearType(gear) == gtTarget and band(GetState(gear), gstDrowning) ~= 0 then |
12430
f9cbb896967b
Fix 3 more incorrect uses of loc() in scripts
Wuzzy <almikes@aol.com>
parents:
12429
diff
changeset
|
266 |
AddCaption(loc("You lost your target, try again!"), 0xFFFFFFFF, capgrpGameState) |
11772
c21278c4218d
Target Practice: Make targets respawn after drowning, and minor code cleanup
Wuzzy <almikes@aol.com>
parents:
10656
diff
changeset
|
267 |
local newTarget = spawnTarget() |
c21278c4218d
Target Practice: Make targets respawn after drowning, and minor code cleanup
Wuzzy <almikes@aol.com>
parents:
10656
diff
changeset
|
268 |
local x, y = GetGearPosition(newTarget) |
c21278c4218d
Target Practice: Make targets respawn after drowning, and minor code cleanup
Wuzzy <almikes@aol.com>
parents:
10656
diff
changeset
|
269 |
local success = PlaceSprite(x, y + 24, sprAmGirder, 0, 0xFFFFFFFF, false, false, false) |
c21278c4218d
Target Practice: Make targets respawn after drowning, and minor code cleanup
Wuzzy <almikes@aol.com>
parents:
10656
diff
changeset
|
270 |
if not success then |
c21278c4218d
Target Practice: Make targets respawn after drowning, and minor code cleanup
Wuzzy <almikes@aol.com>
parents:
10656
diff
changeset
|
271 |
WriteLnToConsole("ERROR: Failed to spawn girder under respawned target!") |
c21278c4218d
Target Practice: Make targets respawn after drowning, and minor code cleanup
Wuzzy <almikes@aol.com>
parents:
10656
diff
changeset
|
272 |
end |
13103
d3e9f3423ef3
Target Practice: Re-center camera to hog after projectiles get destroyed or drown
Wuzzy <Wuzzy2@mail.ru>
parents:
13070
diff
changeset
|
273 |
elseif gearsInGame[gear] then |
d3e9f3423ef3
Target Practice: Re-center camera to hog after projectiles get destroyed or drown
Wuzzy <Wuzzy2@mail.ru>
parents:
13070
diff
changeset
|
274 |
gearsInGame[gear] = nil |
d3e9f3423ef3
Target Practice: Re-center camera to hog after projectiles get destroyed or drown
Wuzzy <Wuzzy2@mail.ru>
parents:
13070
diff
changeset
|
275 |
gearsInGameCount = gearsInGameCount - 1 |
d3e9f3423ef3
Target Practice: Re-center camera to hog after projectiles get destroyed or drown
Wuzzy <Wuzzy2@mail.ru>
parents:
13070
diff
changeset
|
276 |
if gearsInGameCount == 0 and GetHealth(CurrentHedgehog) then |
d3e9f3423ef3
Target Practice: Re-center camera to hog after projectiles get destroyed or drown
Wuzzy <Wuzzy2@mail.ru>
parents:
13070
diff
changeset
|
277 |
-- Re-center camera to hog after all projectile gears were destroyed |
d3e9f3423ef3
Target Practice: Re-center camera to hog after projectiles get destroyed or drown
Wuzzy <Wuzzy2@mail.ru>
parents:
13070
diff
changeset
|
278 |
FollowGear(CurrentHedgehog) |
d3e9f3423ef3
Target Practice: Re-center camera to hog after projectiles get destroyed or drown
Wuzzy <Wuzzy2@mail.ru>
parents:
13070
diff
changeset
|
279 |
end |
11772
c21278c4218d
Target Practice: Make targets respawn after drowning, and minor code cleanup
Wuzzy <almikes@aol.com>
parents:
10656
diff
changeset
|
280 |
end |
c21278c4218d
Target Practice: Make targets respawn after drowning, and minor code cleanup
Wuzzy <almikes@aol.com>
parents:
10656
diff
changeset
|
281 |
end |
c21278c4218d
Target Practice: Make targets respawn after drowning, and minor code cleanup
Wuzzy <almikes@aol.com>
parents:
10656
diff
changeset
|
282 |
|
10656
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
283 |
_G.generateStats = function() |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
284 |
local accuracy = (scored/shots)*100 |
13070
a297e06d1607
Display score next to team bar in singleplayer challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
13039
diff
changeset
|
285 |
local end_score_targets = getTargetsScore() |
10656
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
286 |
local end_score_overall |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
287 |
if not game_lost then |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
288 |
local end_score_time = math.ceil(time_goal/(params.time/6000)) |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
289 |
local end_score_accuracy = math.ceil(accuracy * 60) |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
290 |
end_score_overall = end_score_time + end_score_targets + end_score_accuracy |
13070
a297e06d1607
Display score next to team bar in singleplayer challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
13039
diff
changeset
|
291 |
SetTeamLabel(params.teamName, tostring(end_score_overall)) |
10656
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
292 |
|
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
293 |
SendStat(siGameResult, loc("You have finished the target practice!")) |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
294 |
|
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
295 |
SendStat(siCustomAchievement, string.format(loc("You have destroyed %d of %d targets (+%d points)."), scored, total_targets, end_score_targets)) |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
296 |
SendStat(siCustomAchievement, string.format(params.shootText, shots)) |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
297 |
SendStat(siCustomAchievement, string.format(loc("Your accuracy was %.1f%% (+%d points)."), accuracy, end_score_accuracy)) |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
298 |
SendStat(siCustomAchievement, string.format(loc("You had %.1fs remaining on the clock (+%d points)."), (time_goal/1000), end_score_time)) |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
299 |
else |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
300 |
SendStat(siGameResult, loc("You lose!")) |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
301 |
|
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
302 |
SendStat(siCustomAchievement, string.format(loc("You have destroyed %d of %d targets (+%d points)."), scored, total_targets, end_score_targets)) |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
303 |
SendStat(siCustomAchievement, string.format(params.shootText, shots)) |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
304 |
if(shots > 0) then |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
305 |
SendStat(siCustomAchievement, string.format(loc("Your accuracy was %.1f%%."), accuracy)) |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
306 |
end |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
307 |
end_score_overall = end_score_targets |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
308 |
end |
11772
c21278c4218d
Target Practice: Make targets respawn after drowning, and minor code cleanup
Wuzzy <almikes@aol.com>
parents:
10656
diff
changeset
|
309 |
SendStat(siPointType, loc("point(s)")) |
10656
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
310 |
SendStat(siPlayerKills, tostring(end_score_overall), loc(params.teamName)) |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
311 |
end |
2093cf51eea1
Add (and slightly tweak) Wuzzy's Target Practice missions
mikade <redgrinner@gmail.com>
parents:
diff
changeset
|
312 |
end |