11 -- globals |
11 -- globals |
12 local missionName = loc("Chasing the blue hog") |
12 local missionName = loc("Chasing the blue hog") |
13 local challengeObjectives = loc("Use the rope in order to catch the blue hedgehog").."|".. |
13 local challengeObjectives = loc("Use the rope in order to catch the blue hedgehog").."|".. |
14 loc("You have to stand very close to him") |
14 loc("You have to stand very close to him") |
15 local currentPosition = 1 |
15 local currentPosition = 1 |
|
16 local raceSectionStarted = false |
|
17 local runnerCaught = false |
16 local previousTimeLeft = 0 |
18 local previousTimeLeft = 0 |
17 local startChallenge = false |
19 local startChallenge = false |
18 local winningTime = nil |
20 local winningTime = nil |
19 local currentTime = 0 |
21 local currentTime = 0 |
20 local runnerTime = 0 |
22 local runnerTime = 0 |
21 local record |
23 local record |
|
24 local lostGame = false |
|
25 local heroHurt = false |
22 -- dialogs |
26 -- dialogs |
23 local dialog01 = {} |
27 local dialog01 = {} |
24 local dialog02 = {} |
28 local dialog02 = {} |
25 -- mission objectives |
29 -- mission objectives |
26 local goals = { |
30 local goals = { |
123 if CurrentHedgehog ~= hero.gear then |
127 if CurrentHedgehog ~= hero.gear then |
124 EndTurn(true) |
128 EndTurn(true) |
125 runnerTime = runnerTime + runner.places[currentPosition].turnTime |
129 runnerTime = runnerTime + runner.places[currentPosition].turnTime |
126 SetTeamLabel(teamB.name, string.format(loc("%.1fs"), runnerTime/1000)) |
130 SetTeamLabel(teamB.name, string.format(loc("%.1fs"), runnerTime/1000)) |
127 else |
131 else |
128 if GetAmmoCount(hero.gear, amRope) == 0 then |
|
129 lose() |
|
130 end |
|
131 SetWeapon(amRope) |
132 SetWeapon(amRope) |
132 SetTurnTimeLeft(runner.places[currentPosition].turnTime + previousTimeLeft) |
133 SetTurnTimeLeft(runner.places[currentPosition].turnTime + previousTimeLeft) |
133 previousTimeLeft = 0 |
134 previousTimeLeft = 0 |
134 end |
135 if currentPosition > 1 then |
135 end |
136 raceSectionStarted = true |
|
137 end |
|
138 runnerCaught = false |
|
139 end |
|
140 end |
|
141 end |
|
142 |
|
143 function onEndTurn() |
|
144 if raceSectionStarted and currentPosition > 1 and currentPosition < 5 then |
|
145 if CurrentHedgehog == hero.gear and (not runnerCaught) and (not heroHurt) then |
|
146 -- sndBoring played manually because lose calls EndGame, which suppresses |
|
147 -- the taunt. |
|
148 PlaySound(sndBoring, hero.gear) |
|
149 lose() |
|
150 end |
|
151 end |
|
152 raceSectionStarted = false |
136 end |
153 end |
137 |
154 |
138 function onGameTick() |
155 function onGameTick() |
139 AnimUnWait() |
156 AnimUnWait() |
140 if ShowAnimation() == false then |
157 if ShowAnimation() == false then |
256 if not startChallenge then |
279 if not startChallenge then |
257 startChallenge = true |
280 startChallenge = true |
258 end |
281 end |
259 AddAmmo(hero.gear, amRope, 1) |
282 AddAmmo(hero.gear, amRope, 1) |
260 if currentPosition ~= 1 then |
283 if currentPosition ~= 1 then |
261 PlaySound(sndVictory) |
|
262 if currentPosition > 1 and currentPosition < 4 then |
284 if currentPosition > 1 and currentPosition < 4 then |
263 AnimCaption(hero.gear, loc("Go, get him again!"), 3000) |
285 AnimCaption(hero.gear, loc("Go, get him again!"), 3000) |
264 AnimSay(runner.gear, loc("You got me!"), SAY_SAY, 3000) |
286 AnimSay(runner.gear, loc("You got me!"), SAY_SAY, 3000) |
265 end |
287 end |
|
288 runnerCaught = true |
266 previousTimeLeft = TurnTimeLeft |
289 previousTimeLeft = TurnTimeLeft |
267 end |
290 end |
268 currentPosition = currentPosition + 1 |
291 currentPosition = currentPosition + 1 |
269 AddVisualGear(GetX(runner.gear), GetY(runner.gear), vgtExplosion, 0, false) |
292 AddVisualGear(GetX(runner.gear), GetY(runner.gear), vgtExplosion, 0, false) |
270 SetGearPosition(runner.gear, runner.places[currentPosition].x, runner.places[currentPosition].y) |
293 SetGearPosition(runner.gear, runner.places[currentPosition].x, runner.places[currentPosition].y) |
271 EndTurn(true) |
294 EndTurn(true) |
272 end |
295 end |
273 end |
296 end |
274 |
297 |
275 function lose() |
298 function lose() |
|
299 if lostGame then |
|
300 return |
|
301 end |
|
302 lostGame = true |
276 SendStat(siGameResult, loc("Too slow! Try again ...")) |
303 SendStat(siGameResult, loc("Too slow! Try again ...")) |
277 SendStat(siCustomAchievement, loc("You have to catch the other hog 3 times.")) |
304 SendStat(siCustomAchievement, loc("You have to catch the other hog 3 times.")) |
278 SendStat(siCustomAchievement, loc("The time that you have left when you reach the blue hedgehog will be added to the next turn.")) |
305 SendStat(siCustomAchievement, loc("The time that you have left when you reach the blue hedgehog will be added to the next turn.")) |
279 SendStat(siCustomAchievement, loc("Each turn you'll have only one rope to use.")) |
306 SendStat(siCustomAchievement, loc("Each turn you'll have only one rope to use.")) |
280 SendStat(siCustomAchievement, loc("You'll lose if you die or if your time is up.")) |
307 SendStat(siCustomAchievement, loc("You'll lose if you die or if your time is up.")) |