author | Wuzzy <Wuzzy2@mail.ru> |
Fri, 21 Dec 2018 16:54:41 +0100 | |
changeset 14497 | 6c62f7ebea45 |
parent 14485 | 208359558642 |
child 14654 | e7b2542c4d28 |
permissions | -rw-r--r-- |
11410 | 1 |
--[[ |
2 |
Flying Saucer Training |
|
3 |
This is a training mission which teaches many basic (and not-so-basic) moves |
|
4 |
with the flying saucer. |
|
5 |
||
6 |
Lesson plan: |
|
7 |
- Taking off |
|
8 |
- Basic flight |
|
9 |
- Landing safely |
|
10 |
- Managing fuel |
|
11 |
- Changing saucers in mid-flight |
|
12 |
- Diving |
|
13 |
- Dropping weapons from flying saucer |
|
14 |
- Firing from flying saucer with [Precise] + [Attack] |
|
15 |
- Aiming in flying saucer with [Precise] + [Up]/[Down] |
|
16 |
- Underwater attack |
|
17 |
- Free flight with inf. fuel and some weapons at end of training |
|
18 |
||
19 |
FIXME: |
|
20 |
- Bad respawn animation ("explosion" just happens randomly because of the way the resurrection effect works) |
|
21 |
- Hide fuel if infinite (probably needs engine support) |
|
22 |
]] |
|
23 |
||
24 |
HedgewarsScriptLoad("/Scripts/Locale.lua") |
|
25 |
HedgewarsScriptLoad("/Scripts/Tracker.lua") |
|
26 |
||
27 |
local Player = nil -- Pointer to hog created in: onGameInit |
|
28 |
local Target = nil -- Pointer to target hog |
|
29 |
local Objective = false -- Get to the target |
|
30 |
||
31 |
local TargetNumber = 0 -- The current target number |
|
32 |
local GrenadeThrown = false -- Used for the Boom Target |
|
33 |
local BazookasLeft = 0 -- Used by the Launch Target and the Unterwater Attack Target |
|
34 |
||
35 |
local InfFuel = false -- If true, flying saucer has infinite fuel |
|
36 |
local SaucerGear = nil -- Store flying saucer gear here (if one exists) |
|
37 |
local TargetGears = {} -- List of remaining gears to collect or destroy in the current round |
|
38 |
local TargetsRemaining = 0 |
|
39 |
local Barrels = {} -- Table contraining the explosive barrel gears |
|
40 |
||
41 |
local CheckTimer = 500 -- Time to wait at least before checking safe landing |
|
42 |
local Check = false -- The last target has recently been collected/destroyed and the CheckTimer is running |
|
43 |
local GrenadeTimer = 0 -- Time after a grenade has been thrown |
|
44 |
||
45 |
local TargetPos = {} -- Table of targets |
|
46 |
||
47 |
local StartPos = { X = 742, Y = 290 } |
|
48 |
||
49 |
--[[ |
|
50 |
List of all targets (or "objectives"). The player has to complete them one-by-one and must always land safely afterwards. |
|
51 |
Some target numbers have names for easier reference. |
|
52 |
]] |
|
14458
09bfe9df51e9
Make various stunts in flying saucer training easier
Wuzzy <Wuzzy2@mail.ru>
parents:
13768
diff
changeset
|
53 |
-- Intro |
11410 | 54 |
TargetPos[1] = { |
55 |
Targets = {{ X = 1027, Y = 217 }}, |
|
56 |
Ammo = { }, |
|
57 |
Message = loc("Here you will learn how to fly the flying saucer|and get so learn some cool tricks.") .. "|" .. |
|
58 |
loc("Collect the first crate to begin!"), |
|
59 |
MessageIcon = -amJetpack, } |
|
14458
09bfe9df51e9
Make various stunts in flying saucer training easier
Wuzzy <Wuzzy2@mail.ru>
parents:
13768
diff
changeset
|
60 |
|
09bfe9df51e9
Make various stunts in flying saucer training easier
Wuzzy <Wuzzy2@mail.ru>
parents:
13768
diff
changeset
|
61 |
-- First flight, infinite fuel |
11410 | 62 |
TargetPos[2] = { |
63 |
Targets = {{ X = 1369, Y = 265 }}, |
|
64 |
Ammo = { [amJetpack] = 100 }, |
|
65 |
InfFuel = true, |
|
66 |
MessageTime = 10000, |
|
67 |
Message = loc("Get to the crate using your flying saucer!") .. "|" .. |
|
13359 | 68 |
loc("Press [Attack] (space bar by default) to start,|repeatedly tap the up, left and right movement keys to accelerate.") .. "|" .. |
11410 | 69 |
loc("Try to land softly, as you can still take fall damage!"), } |
14458
09bfe9df51e9
Make various stunts in flying saucer training easier
Wuzzy <Wuzzy2@mail.ru>
parents:
13768
diff
changeset
|
70 |
|
09bfe9df51e9
Make various stunts in flying saucer training easier
Wuzzy <Wuzzy2@mail.ru>
parents:
13768
diff
changeset
|
71 |
-- First flight, limited fuel |
11410 | 72 |
TargetPos[3] = { |
73 |
Targets = {{ X = 689, Y = 58 }}, |
|
74 |
Ammo = { [amJetpack] = 100 }, |
|
75 |
MessageTime = 5000, |
|
76 |
Message = loc("Now collect the next crate!") .. "|" .. loc("Be careful, your fuel is limited from now on!") .."|" .. |
|
77 |
loc("Tip: If you get stuck in this training, use \"Skip turn\" to restart the current objective.") } |
|
78 |
||
79 |
-- The Double Target |
|
80 |
TargetPos[4] = { |
|
14458
09bfe9df51e9
Make various stunts in flying saucer training easier
Wuzzy <Wuzzy2@mail.ru>
parents:
13768
diff
changeset
|
81 |
Targets = { { X = 178, Y = -20 }, { X = 1962 , Y = -20 } }, |
11410 | 82 |
Ammo = { [amJetpack] = 2 }, |
14458
09bfe9df51e9
Make various stunts in flying saucer training easier
Wuzzy <Wuzzy2@mail.ru>
parents:
13768
diff
changeset
|
83 |
CratesContainAmmo = true, |
11410 | 84 |
MessageTime = 9000, |
85 |
Message = loc("Now collect the 2 crates to the far left and right.") .. "|" .. |
|
86 |
loc("You only have 2 flying saucers this time.") .. "|" .. |
|
87 |
loc("Tip: You can change your flying saucer|in mid-flight by hitting the [Attack] key twice."), } |
|
14458
09bfe9df51e9
Make various stunts in flying saucer training easier
Wuzzy <Wuzzy2@mail.ru>
parents:
13768
diff
changeset
|
88 |
|
09bfe9df51e9
Make various stunts in flying saucer training easier
Wuzzy <Wuzzy2@mail.ru>
parents:
13768
diff
changeset
|
89 |
-- Intermission |
11410 | 90 |
TargetPos[5] = { |
91 |
Targets = {{ X = 47, Y = 804 }}, |
|
92 |
Ammo = { [amJetpack] = 100 }, |
|
93 |
MessageTime = 5000, |
|
94 |
Message = loc("Time for a more interesting stunt, but first just collect the next crate!"), } |
|
14458
09bfe9df51e9
Make various stunts in flying saucer training easier
Wuzzy <Wuzzy2@mail.ru>
parents:
13768
diff
changeset
|
95 |
|
09bfe9df51e9
Make various stunts in flying saucer training easier
Wuzzy <Wuzzy2@mail.ru>
parents:
13768
diff
changeset
|
96 |
-- First Dive |
11410 | 97 |
TargetPos[6] = { |
98 |
Targets = {{ X = 604, Y = 871}}, |
|
99 |
MessageTime = 15000, |
|
100 |
Message = loc("You can dive with your flying saucer!") .. "|" .. |
|
101 |
loc("Try it now and dive here to collect the crate on the right girder.") .. "|" .. |
|
102 |
loc("You only have one flying saucer this time.") .. "|" .. |
|
103 |
loc("Beware, though, you will only be able to move slowly through the water.") .. "|" .. |
|
104 |
loc("Warning: Never ever leave the flying saucer while in water!"), |
|
14458
09bfe9df51e9
Make various stunts in flying saucer training easier
Wuzzy <Wuzzy2@mail.ru>
parents:
13768
diff
changeset
|
105 |
Ammo = { [amJetpack] = 1 }, |
09bfe9df51e9
Make various stunts in flying saucer training easier
Wuzzy <Wuzzy2@mail.ru>
parents:
13768
diff
changeset
|
106 |
Respawn = { X = 758, Y = 847, FaceLeft = false }, } |
11410 | 107 |
|
14458
09bfe9df51e9
Make various stunts in flying saucer training easier
Wuzzy <Wuzzy2@mail.ru>
parents:
13768
diff
changeset
|
108 |
-- Second Dive |
11410 | 109 |
TargetPos[7] = { |
110 |
Targets = {{ X = 1884, Y = 704 }}, |
|
111 |
MessageTime = 6500, |
|
12429
b9cc405541c1
Fix various loc() syntax errors in scripts
Wuzzy <almikes@aol.com>
parents:
11410
diff
changeset
|
112 |
Message = loc("Now dive just one more time and collect the next crate.") .. "|" .. |
b9cc405541c1
Fix various loc() syntax errors in scripts
Wuzzy <almikes@aol.com>
parents:
11410
diff
changeset
|
113 |
loc("Tip: Don't remain for too long in the water, or you won't make it."), |
14458
09bfe9df51e9
Make various stunts in flying saucer training easier
Wuzzy <Wuzzy2@mail.ru>
parents:
13768
diff
changeset
|
114 |
Ammo = { [amJetpack] = 2 }, } |
11410 | 115 |
|
14458
09bfe9df51e9
Make various stunts in flying saucer training easier
Wuzzy <Wuzzy2@mail.ru>
parents:
13768
diff
changeset
|
116 |
-- The Grenade Drop Target |
11410 | 117 |
local BoomTarget = 8 |
118 |
TargetPos[8] = { |
|
119 |
Modifier = true, Func = function() |
|
120 |
Info(loc("Instructions"), |
|
121 |
loc("Now let's try to drop weapons while flying!") .. "|" .. |
|
122 |
loc("You have to destroy the target above by dropping a grenade on it from your flying saucer.") .. "|" .. |
|
123 |
loc("It's not that easy, so listen carefully:") .. "|" .. |
|
124 |
loc("Step 1: Activate your flying saucer but do NOT move yet!") .. "|" .. |
|
125 |
loc("Step 2: Select your grenade.") .. "|" .. |
|
126 |
loc("Step 3: Start flying and get yourself right above the target.") .. "|" .. |
|
127 |
loc("Step 4: Drop your grenade by pressing the [Long jump] key.") .. "|" .. |
|
12429
b9cc405541c1
Fix various loc() syntax errors in scripts
Wuzzy <almikes@aol.com>
parents:
11410
diff
changeset
|
128 |
loc("Step 5: Get away quickly and land safely anywhere.") .. "| |" .. |
b9cc405541c1
Fix various loc() syntax errors in scripts
Wuzzy <almikes@aol.com>
parents:
11410
diff
changeset
|
129 |
loc("Note: We only give you grenades if you stay in your flying saucer."), nil, 20000) |
11410 | 130 |
|
131 |
SpawnBoomTarget() |
|
132 |
||
133 |
if SaucerGear ~= nil then |
|
134 |
AddAmmo(Player, amGrenade, 1) |
|
135 |
else |
|
136 |
AddAmmo(Player, amGrenade, 0) |
|
137 |
end |
|
138 |
GrenadeThrown = false |
|
139 |
||
140 |
end, |
|
141 |
Ammo = { [amJetpack] = 100 }, |
|
14458
09bfe9df51e9
Make various stunts in flying saucer training easier
Wuzzy <Wuzzy2@mail.ru>
parents:
13768
diff
changeset
|
142 |
Respawn = { X = 2000, Y = 742, FaceLeft = true }, } |
11410 | 143 |
|
144 |
-- The Launch Target |
|
145 |
local LaunchTarget = 9 |
|
146 |
TargetPos[9] = { |
|
147 |
Targets = {{ X = 1700, Y = 640, Type = gtTarget }, { X = 1460, Y = 775, Type = gtTarget }}, |
|
148 |
MessageTime = 20000, |
|
149 |
Message = loc("Only the best pilots can master the following stunts.") .. "|" .. |
|
150 |
loc("As you've seen, the dropped grenade roughly fell into your flying direction.") .. "|" .. |
|
151 |
loc("You have to destroy two targets, but the previous technique would be very difficult or dangerous to use.") .. "|" .. |
|
152 |
loc("So you are able to launch projectiles into your aiming direction, always at full power.") .."|".. |
|
153 |
loc("To launch a projectile in mid-flight, hold [Precise] and press [Long jump].") .. "|" .. |
|
13359 | 154 |
loc("You can even change your aiming direction in mid-flight if you first hold [Precise] and then press [Up] or [Down].") .. "|" .. |
11410 | 155 |
loc("Tip: Changing your aim while flying is very difficult, so adjust it before you take off."), |
156 |
Ammo = { [amJetpack] = 1, }, |
|
14458
09bfe9df51e9
Make various stunts in flying saucer training easier
Wuzzy <Wuzzy2@mail.ru>
parents:
13768
diff
changeset
|
157 |
Respawn = { X = 1760, Y = 754, FaceLeft = true }, |
11410 | 158 |
ExtraFunc = function() |
159 |
if SaucerGear ~= nil then |
|
160 |
AddAmmo(Player, amBazooka, 2) |
|
161 |
else |
|
162 |
AddAmmo(Player, amBazooka, 0) |
|
163 |
end |
|
164 |
BazookasLeft = 2 |
|
165 |
||
166 |
end } |
|
167 |
||
168 |
-- The Underwater Attack Target |
|
169 |
local UnderwaterAttackTarget = 10 |
|
170 |
TargetPos[10] = { |
|
171 |
MessageTime = 17000, |
|
172 |
Message = loc("Now for the supreme discipline of saucer flying, the underwater attack.") .. "|" .. |
|
173 |
loc("Basically this is a combination of diving and launching.") .. "|" .. |
|
174 |
loc("Dropping a weapon while in water would just drown it, but launching one would work.") .."|" .. |
|
175 |
loc("Based on what you've learned, destroy the target on the girder and as always, land safely!"), |
|
176 |
Targets = {{ X = 1200, Y = 930, Type = gtTarget }}, |
|
177 |
Ammo = { [amJetpack] = 1, }, |
|
14458
09bfe9df51e9
Make various stunts in flying saucer training easier
Wuzzy <Wuzzy2@mail.ru>
parents:
13768
diff
changeset
|
178 |
Respawn = { X = 1027, Y = 217, FaceLeft = true }, |
11410 | 179 |
ExtraFunc = function() |
180 |
if SaucerGear ~= nil then |
|
181 |
AddAmmo(Player, amBazooka, 1) |
|
182 |
else |
|
183 |
AddAmmo(Player, amBazooka, 0) |
|
184 |
end |
|
185 |
BazookasLeft = 1 |
|
186 |
end } |
|
14458
09bfe9df51e9
Make various stunts in flying saucer training easier
Wuzzy <Wuzzy2@mail.ru>
parents:
13768
diff
changeset
|
187 |
-- Final target / Sandbox |
11410 | 188 |
TargetPos[11] = { |
189 |
Targets = {{ X = 742, Y = 290 }}, |
|
190 |
MessageTime = 5000, |
|
191 |
Message = loc("This almost concludes our tutorial.") .. "|" .. |
|
192 |
loc("You now have infinite fuel, grenades and bazookas for fun.") .. "|" .. |
|
193 |
loc("Collect or destroy the final crate to finish the training."), |
|
194 |
Ammo = { [amJetpack] = 100, [amGrenade] = 100, [amBazooka] = 100 }, |
|
195 |
InfFuel = true, } |
|
14458
09bfe9df51e9
Make various stunts in flying saucer training easier
Wuzzy <Wuzzy2@mail.ru>
parents:
13768
diff
changeset
|
196 |
-- Outro |
11410 | 197 |
TargetPos[12] = { Modifier = true, Func = function() |
198 |
Objective = true |
|
13648 | 199 |
AddCaption(loc("Training complete!"), capcolDefault, capgrpGameState) |
11410 | 200 |
Info(loc("Training complete!"), loc("Good bye!"), 4, 5000) |
201 |
||
202 |
if SaucerGear ~= nil then |
|
203 |
DeleteGear(SaucerGear) |
|
204 |
end |
|
205 |
SetState(Player, band(GetState(Player), bnot(gstHHDriven))) |
|
206 |
SetState(Player, bor(GetState(Player), gstWinner)) |
|
207 |
PlaySound(sndVictory, Player) |
|
14469
ead8928a59f8
Report mission victory for most missions
Wuzzy <Wuzzy2@mail.ru>
parents:
14458
diff
changeset
|
208 |
SaveMissionVar("Won", "true") |
11410 | 209 |
|
210 |
SendStat(siGameResult, loc("You have finished the Flying Saucer Training!")) |
|
211 |
SendStat(siCustomAchievement, loc("Good job!")) |
|
14485
208359558642
Use player-chosen team identity for training and a few challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
14469
diff
changeset
|
212 |
SendStat(siPlayerKills, "0", GetHogTeamName(Player)) |
11410 | 213 |
|
13768
29abd3d5f9bb
Call EndTurn(true) instead of TurnTimeLeft(0) in flying saucer training
Wuzzy <Wuzzy2@mail.ru>
parents:
13755
diff
changeset
|
214 |
EndTurn(true) |
11410 | 215 |
EndGame() |
216 |
end, |
|
217 |
} |
|
218 |
||
219 |
-- Just a wrapper for ShowMission |
|
220 |
function Info(Title, Text, Icon, Time) |
|
221 |
if Time == nil then Time = 0 end |
|
222 |
if Icon == nil then Icon = 2 end |
|
223 |
ShowMission(loc("Flying Saucer Training"), Title, Text, Icon, Time) |
|
224 |
end |
|
225 |
||
226 |
-- Spawn all the gears for the Boom Target |
|
227 |
function SpawnBoomTarget() |
|
228 |
if TargetsRemaining < 1 then |
|
229 |
TargetGears[1] = AddGear(1602, 507, gtTarget, 0, 0, 0, 0) |
|
230 |
TargetsRemaining = TargetsRemaining + 1 |
|
231 |
end |
|
232 |
||
233 |
if Barrels[1] == nil then |
|
234 |
Barrels[1] = AddGear(1563, 532, gtExplosives, 0, 0, 0, 0) |
|
235 |
end |
|
236 |
if Barrels[2] == nil then |
|
237 |
Barrels[2] = AddGear(1648, 463, gtExplosives, 0, 0, 0, 0) |
|
238 |
end |
|
239 |
||
240 |
for i=1,#Barrels do |
|
241 |
SetHealth(Barrels[i], 1) |
|
242 |
end |
|
243 |
end |
|
244 |
||
245 |
-- Generic target spawning for the current target |
|
246 |
function SpawnTargets() |
|
247 |
for i=1,#TargetPos[TargetNumber].Targets do |
|
248 |
if TargetGears[i] == nil then |
|
249 |
SpawnTarget(TargetPos[TargetNumber].Targets[i].X, TargetPos[TargetNumber].Targets[i].Y, |
|
14458
09bfe9df51e9
Make various stunts in flying saucer training easier
Wuzzy <Wuzzy2@mail.ru>
parents:
13768
diff
changeset
|
250 |
TargetPos[TargetNumber].Targets[i].Type, i, TargetPos[TargetNumber].CratesContainAmmo ) |
11410 | 251 |
end |
252 |
end |
|
253 |
end |
|
254 |
||
14458
09bfe9df51e9
Make various stunts in flying saucer training easier
Wuzzy <Wuzzy2@mail.ru>
parents:
13768
diff
changeset
|
255 |
function SpawnTarget( PosX, PosY, Type, ID, ContainsAmmo ) |
11410 | 256 |
if Type ~= nil and Type ~= gtCase then |
257 |
if Type == gtTarget then |
|
258 |
TargetGears[ID] = AddGear(PosX, PosY, gtTarget, 0, 0, 0, 0) |
|
259 |
end |
|
260 |
else |
|
14458
09bfe9df51e9
Make various stunts in flying saucer training easier
Wuzzy <Wuzzy2@mail.ru>
parents:
13768
diff
changeset
|
261 |
if ContainsAmmo == true then |
09bfe9df51e9
Make various stunts in flying saucer training easier
Wuzzy <Wuzzy2@mail.ru>
parents:
13768
diff
changeset
|
262 |
TargetGears[ID] = SpawnSupplyCrate(PosX, PosY, amJetpack) |
09bfe9df51e9
Make various stunts in flying saucer training easier
Wuzzy <Wuzzy2@mail.ru>
parents:
13768
diff
changeset
|
263 |
else |
09bfe9df51e9
Make various stunts in flying saucer training easier
Wuzzy <Wuzzy2@mail.ru>
parents:
13768
diff
changeset
|
264 |
TargetGears[ID] = SpawnFakeUtilityCrate(PosX, PosY, false, false) |
09bfe9df51e9
Make various stunts in flying saucer training easier
Wuzzy <Wuzzy2@mail.ru>
parents:
13768
diff
changeset
|
265 |
end |
11410 | 266 |
end |
267 |
TargetsRemaining = TargetsRemaining + 1 |
|
268 |
end |
|
269 |
||
270 |
function AutoSpawn() -- Auto-spawn the next target after you've obtained the current target! |
|
271 |
TargetNumber = TargetNumber + 1 |
|
272 |
TargetsRemaining = 0 |
|
273 |
||
274 |
if TargetPos[TargetNumber].Ammo then |
|
275 |
for ammoType, count in pairs(TargetPos[TargetNumber].Ammo) do |
|
276 |
AddAmmo(Player, ammoType, count) |
|
277 |
end |
|
278 |
if GetCurAmmoType() ~= amJetpack then |
|
279 |
SetWeapon(amJetpack) |
|
280 |
end |
|
281 |
end |
|
282 |
if TargetPos[TargetNumber].InfFuel then |
|
283 |
InfFuel = true |
|
284 |
else |
|
285 |
InfFuel = false |
|
286 |
end |
|
13599
ddd90e92c4c3
Use proper infinite fuel feature in flying saucer training
Wuzzy <Wuzzy2@mail.ru>
parents:
13588
diff
changeset
|
287 |
UpdateInfFuel() |
11410 | 288 |
|
289 |
-- Func (if present) will be run instead of the ordinary spawning handling |
|
290 |
if TargetPos[TargetNumber].Modifier then -- If there is a modifier, run the function |
|
291 |
TargetPos[TargetNumber].Func() |
|
292 |
return true |
|
293 |
end |
|
294 |
||
295 |
-- ExtraFunc is for additional events for a target |
|
296 |
if TargetPos[TargetNumber].ExtraFunc ~= nil then |
|
297 |
TargetPos[TargetNumber].ExtraFunc() |
|
298 |
end |
|
299 |
||
300 |
local subcap |
|
301 |
if TargetNumber == 1 then |
|
302 |
subcap = loc("Training") |
|
303 |
else |
|
304 |
subcap = loc("Instructions") |
|
305 |
end |
|
306 |
Info(subcap, TargetPos[TargetNumber].Message, TargetPos[TargetNumber].MessageIcon, TargetPos[TargetNumber].MessageTime) |
|
307 |
||
308 |
-- Spawn targets on the next position |
|
309 |
SpawnTargets() |
|
310 |
||
311 |
if TargetNumber > 1 then |
|
13648 | 312 |
AddCaption(loc("Next target is ready!"), capcolDefault, capgrpMessage2) |
11410 | 313 |
end |
314 |
end |
|
315 |
||
316 |
-- Returns true if the hedgehog has safely "landed" (alive, no flying saucer gear and not moving) |
|
317 |
-- This is to ensure the training only continues when the player didn't screw up and to restart the current target |
|
318 |
function HasHedgehogLandedYet() |
|
319 |
if band(GetState(Player), gstMoving) == 0 and SaucerGear == nil and GetHealth(Player) > 0 then |
|
320 |
return true |
|
321 |
else |
|
322 |
return false |
|
323 |
end |
|
324 |
end |
|
325 |
||
326 |
-- Clean up the gear mess left behind when the player failed to get a clean state after restarting |
|
327 |
function CleanUpGears() |
|
328 |
-- (We track flames, grenades, bazooka shells) |
|
329 |
runOnGears(DeleteGear) |
|
330 |
end |
|
331 |
||
332 |
-- Completely restarts the current target/objective; the hedgehog is spawned at the last "checkpoint" |
|
333 |
-- Called when hedgeghog is resurrected or skips turn |
|
334 |
function ResetCurrentTarget() |
|
335 |
GrenadeThrown = false |
|
336 |
GrenadeTimer = 0 |
|
337 |
if TargetNumber == LaunchTarget then |
|
338 |
BazookasLeft = 2 |
|
339 |
elseif TargetNumber == UnderwaterAttackTarget then |
|
340 |
BazookasLeft = 1 |
|
341 |
else |
|
342 |
BazookasLeft = 0 |
|
343 |
end |
|
344 |
Check = false |
|
345 |
||
346 |
CleanUpGears() |
|
347 |
||
14458
09bfe9df51e9
Make various stunts in flying saucer training easier
Wuzzy <Wuzzy2@mail.ru>
parents:
13768
diff
changeset
|
348 |
local X, Y, FaceLeft |
11410 | 349 |
if TargetNumber == 1 then |
350 |
X, Y = StartPos.X, StartPos.Y |
|
351 |
else |
|
352 |
if TargetPos[TargetNumber-1].Modifier or TargetPos[TargetNumber-1].Respawn ~= nil then |
|
353 |
X, Y = TargetPos[TargetNumber-1].Respawn.X, TargetPos[TargetNumber-1].Respawn.Y |
|
14458
09bfe9df51e9
Make various stunts in flying saucer training easier
Wuzzy <Wuzzy2@mail.ru>
parents:
13768
diff
changeset
|
354 |
FaceLeft = TargetPos[TargetNumber-1].Respawn.FaceLeft |
11410 | 355 |
else |
356 |
X, Y = TargetPos[TargetNumber-1].Targets[1].X, TargetPos[TargetNumber-1].Targets[1].Y |
|
357 |
end |
|
358 |
end |
|
359 |
if TargetNumber == BoomTarget then |
|
360 |
SpawnBoomTarget() |
|
361 |
end |
|
362 |
if TargetPos[TargetNumber].Modifier ~= true then |
|
363 |
SpawnTargets() |
|
364 |
end |
|
365 |
if TargetPos[TargetNumber].Ammo then |
|
366 |
for ammoType, count in pairs(TargetPos[TargetNumber].Ammo) do |
|
367 |
AddAmmo(Player, ammoType, count) |
|
368 |
end |
|
369 |
if GetCurAmmoType() ~= amJetpack then |
|
370 |
SetWeapon(amJetpack) |
|
371 |
end |
|
372 |
end |
|
373 |
if TargetPos[TargetNumber].InfFuel then |
|
374 |
InfFuel = true |
|
375 |
else |
|
376 |
InfFuel = false |
|
377 |
end |
|
13599
ddd90e92c4c3
Use proper infinite fuel feature in flying saucer training
Wuzzy <Wuzzy2@mail.ru>
parents:
13588
diff
changeset
|
378 |
UpdateInfFuel() |
11410 | 379 |
|
380 |
SetGearPosition(Player, X, Y) |
|
14458
09bfe9df51e9
Make various stunts in flying saucer training easier
Wuzzy <Wuzzy2@mail.ru>
parents:
13768
diff
changeset
|
381 |
if FaceLeft ~= nil then |
09bfe9df51e9
Make various stunts in flying saucer training easier
Wuzzy <Wuzzy2@mail.ru>
parents:
13768
diff
changeset
|
382 |
HogTurnLeft(Player, FaceLeft) |
09bfe9df51e9
Make various stunts in flying saucer training easier
Wuzzy <Wuzzy2@mail.ru>
parents:
13768
diff
changeset
|
383 |
end |
11410 | 384 |
end |
385 |
||
386 |
function onGameInit() |
|
387 |
Seed = 1 |
|
388 |
GameFlags = gfInfAttack + gfOneClanMode + gfSolidLand + gfDisableWind |
|
13755
110d6c1e817f
Lua: Rename globals: NoPointX→NO_CURSOR, cMaxTurnTime→MAX_TURN_TIME, cMaxHogHealth→MAX_HOG_HEALTH
Wuzzy <Wuzzy2@mail.ru>
parents:
13745
diff
changeset
|
389 |
TurnTime = MAX_TURN_TIME --[[ This effectively hides the turn time; a turn time above 1000s is not displayed. |
13669
85506d95977d
Use new script variable cMaxTurnTime in scripts for consistency
Wuzzy <Wuzzy2@mail.ru>
parents:
13648
diff
changeset
|
390 |
We will also ensure this timer always stays above 999s later ]] |
11410 | 391 |
CaseFreq = 0 |
392 |
MinesNum = 0 |
|
393 |
Explosives = 0 |
|
394 |
Map = "Eyes" |
|
395 |
Theme = "EarthRise" |
|
396 |
SuddenDeathTurns = 50 |
|
397 |
WaterRise = 0 |
|
398 |
HealthDecrease = 0 |
|
399 |
||
14485
208359558642
Use player-chosen team identity for training and a few challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
14469
diff
changeset
|
400 |
AddMissionTeam(-9) |
11410 | 401 |
|
14485
208359558642
Use player-chosen team identity for training and a few challenges
Wuzzy <Wuzzy2@mail.ru>
parents:
14469
diff
changeset
|
402 |
Player = AddMissionHog(1) |
11410 | 403 |
SetGearPosition( Player, StartPos.X, StartPos.Y) |
404 |
SetEffect( Player, heResurrectable, 1 ) |
|
405 |
end |
|
406 |
||
407 |
function onGameStart() |
|
408 |
SendHealthStatsOff() |
|
409 |
||
410 |
-- Girder near first crate |
|
411 |
PlaceGirder(1257, 204, 6) |
|
412 |
||
413 |
-- The upper girders |
|
14458
09bfe9df51e9
Make various stunts in flying saucer training easier
Wuzzy <Wuzzy2@mail.ru>
parents:
13768
diff
changeset
|
414 |
PlaceGirder(84, 16, 4) |
09bfe9df51e9
Make various stunts in flying saucer training easier
Wuzzy <Wuzzy2@mail.ru>
parents:
13768
diff
changeset
|
415 |
PlaceGirder(243, 16, 4) |
09bfe9df51e9
Make various stunts in flying saucer training easier
Wuzzy <Wuzzy2@mail.ru>
parents:
13768
diff
changeset
|
416 |
PlaceGirder(1967, 16, 4) |
11410 | 417 |
|
418 |
-- The lower girder platform at the water pit |
|
419 |
PlaceGirder(509, 896, 4) |
|
420 |
PlaceGirder(668, 896, 4) |
|
421 |
PlaceGirder(421, 896, 2) |
|
422 |
PlaceGirder(758, 896, 2) |
|
423 |
||
424 |
-- Girders for the Launch Target and the Underwater Attack Target |
|
425 |
PlaceGirder(1191, 960, 4) |
|
426 |
PlaceGirder(1311, 960, 0) |
|
427 |
PlaceGirder(1460, 827, 3) |
|
428 |
PlaceGirder(1509, 763, 2) |
|
429 |
PlaceGirder(1605, 672, 4) |
|
430 |
PlaceGirder(1764, 672, 4) |
|
431 |
PlaceGirder(1803, 577, 6) |
|
432 |
||
433 |
-- Spawn our 1st target using the wrapper function |
|
434 |
AutoSpawn() |
|
435 |
end |
|
436 |
||
437 |
function onAmmoStoreInit() |
|
14458
09bfe9df51e9
Make various stunts in flying saucer training easier
Wuzzy <Wuzzy2@mail.ru>
parents:
13768
diff
changeset
|
438 |
SetAmmo(amJetpack, 0, 0, 0, 1) |
09bfe9df51e9
Make various stunts in flying saucer training easier
Wuzzy <Wuzzy2@mail.ru>
parents:
13768
diff
changeset
|
439 |
SetAmmo(amGrenade, 0, 0, 0, 1) |
09bfe9df51e9
Make various stunts in flying saucer training easier
Wuzzy <Wuzzy2@mail.ru>
parents:
13768
diff
changeset
|
440 |
SetAmmo(amBazooka, 0, 0, 0, 1) |
11410 | 441 |
|
442 |
-- Added for resetting current target/objective when player is stuck somehow |
|
443 |
SetAmmo(amSkip, 9, 0, 0, 0) |
|
444 |
end |
|
445 |
||
446 |
function onGearAdd(Gear) |
|
447 |
if GetGearType(Gear) == gtJetpack then |
|
448 |
SaucerGear = Gear |
|
449 |
if TargetNumber == BoomTarget and GrenadeThrown == false then |
|
450 |
AddAmmo(Player, amGrenade, 1) |
|
451 |
end |
|
452 |
if (TargetNumber == LaunchTarget or TargetNumber == UnderwaterAttackTarget) and BazookasLeft > 0 then |
|
453 |
AddAmmo(Player, amBazooka, BazookasLeft) |
|
454 |
end |
|
13599
ddd90e92c4c3
Use proper infinite fuel feature in flying saucer training
Wuzzy <Wuzzy2@mail.ru>
parents:
13588
diff
changeset
|
455 |
UpdateInfFuel() |
13076
bcb205281f38
Some minor convenience improvements in Basic Flying Saucer Training
Wuzzy <Wuzzy2@mail.ru>
parents:
12429
diff
changeset
|
456 |
-- If player starts using saucer, the player probably finished reading and the mission panel |
bcb205281f38
Some minor convenience improvements in Basic Flying Saucer Training
Wuzzy <Wuzzy2@mail.ru>
parents:
12429
diff
changeset
|
457 |
-- would just get in the way. So we hide it! |
bcb205281f38
Some minor convenience improvements in Basic Flying Saucer Training
Wuzzy <Wuzzy2@mail.ru>
parents:
12429
diff
changeset
|
458 |
HideMission() |
11410 | 459 |
end |
460 |
if GetGearType(Gear) == gtGrenade then |
|
461 |
GrenadeThrown = true |
|
462 |
GrenadeTimer = 0 |
|
463 |
end |
|
464 |
if GetGearType(Gear) == gtShell then |
|
465 |
BazookasLeft = BazookasLeft - 1 |
|
466 |
end |
|
467 |
if GetGearType(Gear) == gtFlame or GetGearType(Gear) == gtGrenade or GetGearType(Gear) == gtShell then |
|
468 |
trackGear(Gear) |
|
469 |
end |
|
470 |
end |
|
471 |
||
472 |
function onGearDelete(Gear) |
|
473 |
if GetGearType(Player) ~= nil and (GetGearType(Gear) == gtTarget or GetGearType(Gear) == gtCase) then |
|
474 |
for i=1, #TargetGears do |
|
475 |
if Gear == TargetGears[i] then |
|
476 |
TargetGears[i] = nil |
|
477 |
TargetsRemaining = TargetsRemaining - 1 |
|
478 |
end |
|
479 |
end |
|
480 |
if TargetsRemaining <= 0 then |
|
481 |
if TargetNumber == BoomTarget or not HasHedgehogLandedYet() then |
|
482 |
if SaucerGear then |
|
13648 | 483 |
AddCaption(loc("Objective completed! Now land safely."), capcolDefault, capgrpMessage2) |
11410 | 484 |
end |
485 |
Check = true |
|
486 |
CheckTimer = 500 |
|
487 |
else |
|
488 |
AutoSpawn() |
|
489 |
end |
|
490 |
end |
|
491 |
end |
|
492 |
if GetGearType(Gear) == gtGrenade then |
|
493 |
GrenadeTimer = 0 |
|
494 |
GrenadeExploded = true |
|
495 |
end |
|
496 |
if GetGearType(Gear) == gtJetpack then |
|
497 |
SaucerGear = nil |
|
498 |
if TargetNumber == BoomTarget then |
|
499 |
AddAmmo(Player, amGrenade, 0) |
|
500 |
end |
|
501 |
if TargetNumber == LaunchTarget or TargetNumber == UnderwaterAttackTarget then |
|
502 |
AddAmmo(Player, amBazooka, 0) |
|
503 |
end |
|
504 |
end |
|
14458
09bfe9df51e9
Make various stunts in flying saucer training easier
Wuzzy <Wuzzy2@mail.ru>
parents:
13768
diff
changeset
|
505 |
-- Fake crate collected |
09bfe9df51e9
Make various stunts in flying saucer training easier
Wuzzy <Wuzzy2@mail.ru>
parents:
13768
diff
changeset
|
506 |
if GetGearType(Gear) == gtCase and band(GetGearMessage(Gear), gmDestroy) ~= 0 and band(GetGearPos(Gear), 0x8) ~= 0 then |
11410 | 507 |
PlaySound(sndShotgunReload) |
508 |
end |
|
509 |
if Gear == Barrels[1] then |
|
510 |
Barrels[1] = nil |
|
511 |
end |
|
512 |
if Gear == Barrels[2] then |
|
513 |
Barrels[2] = nil |
|
13648 | 514 |
AddCaption(loc("Kaboom!"), capcolDefault, capgrpMessage) |
11410 | 515 |
end |
516 |
end |
|
517 |
||
518 |
||
519 |
||
520 |
function onNewTurn() |
|
13076
bcb205281f38
Some minor convenience improvements in Basic Flying Saucer Training
Wuzzy <Wuzzy2@mail.ru>
parents:
12429
diff
changeset
|
521 |
if GetAmmoCount(CurrentHedgehog, amJetpack) > 0 then |
bcb205281f38
Some minor convenience improvements in Basic Flying Saucer Training
Wuzzy <Wuzzy2@mail.ru>
parents:
12429
diff
changeset
|
522 |
SetWeapon(amJetpack) |
bcb205281f38
Some minor convenience improvements in Basic Flying Saucer Training
Wuzzy <Wuzzy2@mail.ru>
parents:
12429
diff
changeset
|
523 |
end |
11410 | 524 |
end |
525 |
||
526 |
function onGameTick20() |
|
527 |
if (TurnTimeLeft < 1500000 and not Objective) then |
|
13745
2bb7141496a9
Use SetTurnTimeLeft and SetReadyTimeLeft in all scripts
Wuzzy <Wuzzy2@mail.ru>
parents:
13669
diff
changeset
|
528 |
SetTurnTimeLeft(TurnTime) |
11410 | 529 |
end |
530 |
if Check then |
|
531 |
CheckTimer = CheckTimer - 20 |
|
532 |
if CheckTimer <= 0 then |
|
533 |
if HasHedgehogLandedYet() then |
|
534 |
AutoSpawn() |
|
535 |
Check = false |
|
536 |
GrenadeThrown = false |
|
537 |
end |
|
538 |
end |
|
539 |
end |
|
13648 | 540 |
if GrenadeExploded and TargetNumber == BoomTarget and GetHealth(Player) then |
11410 | 541 |
GrenadeTimer = GrenadeTimer + 20 |
542 |
if GrenadeTimer > 1500 then |
|
543 |
GrenadeTimer = 0 |
|
544 |
GrenadeThrown = false |
|
545 |
GrenadeExploded = false |
|
546 |
if SaucerGear and TargetNumber == BoomTarget and TargetsRemaining > 0 then |
|
547 |
PlaySound(sndShotgunReload) |
|
13648 | 548 |
AddCaption(loc("+1 Grenade"), GetClanColor(GetHogClan(Player)), capgrpAmmoinfo) |
11410 | 549 |
AddAmmo(Player, amGrenade, 1) |
550 |
end |
|
551 |
end |
|
552 |
end |
|
553 |
end |
|
554 |
||
13599
ddd90e92c4c3
Use proper infinite fuel feature in flying saucer training
Wuzzy <Wuzzy2@mail.ru>
parents:
13588
diff
changeset
|
555 |
function UpdateInfFuel() |
ddd90e92c4c3
Use proper infinite fuel feature in flying saucer training
Wuzzy <Wuzzy2@mail.ru>
parents:
13588
diff
changeset
|
556 |
if SaucerGear then |
ddd90e92c4c3
Use proper infinite fuel feature in flying saucer training
Wuzzy <Wuzzy2@mail.ru>
parents:
13588
diff
changeset
|
557 |
if InfFuel then |
ddd90e92c4c3
Use proper infinite fuel feature in flying saucer training
Wuzzy <Wuzzy2@mail.ru>
parents:
13588
diff
changeset
|
558 |
SetHealth(SaucerGear, JETPACK_FUEL_INFINITE) |
ddd90e92c4c3
Use proper infinite fuel feature in flying saucer training
Wuzzy <Wuzzy2@mail.ru>
parents:
13588
diff
changeset
|
559 |
elseif GetHealth(SaucerGear == JETPACK_FUEL_INFINITE) then |
ddd90e92c4c3
Use proper infinite fuel feature in flying saucer training
Wuzzy <Wuzzy2@mail.ru>
parents:
13588
diff
changeset
|
560 |
SetHealth(SaucerGear, 2000) |
ddd90e92c4c3
Use proper infinite fuel feature in flying saucer training
Wuzzy <Wuzzy2@mail.ru>
parents:
13588
diff
changeset
|
561 |
end |
11410 | 562 |
end |
563 |
end |
|
564 |
||
565 |
function onGearDamage(Gear) |
|
566 |
if Gear == Player then |
|
567 |
CleanUpGears() |
|
568 |
GrenadeThrown = false |
|
569 |
Check = false |
|
570 |
end |
|
571 |
end |
|
572 |
||
13635
fe7d2bbf5f3f
Fix resurrection animation appearing at wrong position for some missions and styles
Wuzzy <Wuzzy2@mail.ru>
parents:
13599
diff
changeset
|
573 |
function onGearResurrect(Gear, VGear) |
11410 | 574 |
if Gear == Player then |
13648 | 575 |
AddCaption(loc("Oh no! You have died. Try again!"), capcolDefault, capgrpMessage2) |
11410 | 576 |
ResetCurrentTarget() |
13635
fe7d2bbf5f3f
Fix resurrection animation appearing at wrong position for some missions and styles
Wuzzy <Wuzzy2@mail.ru>
parents:
13599
diff
changeset
|
577 |
if VGear then |
fe7d2bbf5f3f
Fix resurrection animation appearing at wrong position for some missions and styles
Wuzzy <Wuzzy2@mail.ru>
parents:
13599
diff
changeset
|
578 |
SetVisualGearValues(VGear, GetX(Gear), GetY(Gear)) |
fe7d2bbf5f3f
Fix resurrection animation appearing at wrong position for some missions and styles
Wuzzy <Wuzzy2@mail.ru>
parents:
13599
diff
changeset
|
579 |
end |
11410 | 580 |
end |
581 |
end |
|
582 |
||
13177
159004144897
Use onSkipTurn in scripts to detect turn skips
Wuzzy <Wuzzy2@mail.ru>
parents:
13076
diff
changeset
|
583 |
function onSkipTurn() |
13648 | 584 |
AddCaption(loc("Try again!"), capcolDefault, capgrpMessage2) |
13177
159004144897
Use onSkipTurn in scripts to detect turn skips
Wuzzy <Wuzzy2@mail.ru>
parents:
13076
diff
changeset
|
585 |
ResetCurrentTarget() |
11410 | 586 |
end |