188 end |
188 end |
189 |
189 |
190 _G.onGameTick20 = function() |
190 _G.onGameTick20 = function() |
191 if TurnTimeLeft < 40 and TurnTimeLeft > 0 and scored < total_targets and game_lost == false then |
191 if TurnTimeLeft < 40 and TurnTimeLeft > 0 and scored < total_targets and game_lost == false then |
192 game_lost = true |
192 game_lost = true |
193 AddCaption(loc("Time’s up!"), 0xFFFFFFFF, capgrpGameState) |
193 AddCaption(loc("Time’s up!"), capcolDefault, capgrpGameState) |
194 ShowMission(params.missionTitle, loc("Aiming practice"), loc("Oh no! Time's up! Just try again."), -amSkip, 0) |
194 ShowMission(params.missionTitle, loc("Aiming practice"), loc("Oh no! Time's up! Just try again."), -amSkip, 0) |
195 SetHealth(player, 0) |
195 SetHealth(player, 0) |
196 time_goal = 1 |
196 time_goal = 1 |
197 end |
197 end |
198 |
198 |
199 if band(GetState(player), gstDrowning) == gstDrowning and game_lost == false and scored < total_targets then |
199 if band(GetState(player), gstDrowning) == gstDrowning and game_lost == false and scored < total_targets then |
200 game_lost = true |
200 game_lost = true |
201 time_goal = 1 |
201 time_goal = 1 |
202 AddCaption(loc("You lose!"), 0xFFFFFFFF, capgrpGameState) |
202 AddCaption(loc("You lose!"), capcolDefault, capgrpGameState) |
203 ShowMission(params.missionTitle, loc("Aiming practice"), loc("Oh no! You failed! Just try again."), -amSkip, 0) |
203 ShowMission(params.missionTitle, loc("Aiming practice"), loc("Oh no! You failed! Just try again."), -amSkip, 0) |
204 end |
204 end |
205 |
205 |
206 if scored == total_targets or game_lost then |
206 if scored == total_targets or game_lost then |
207 if end_timer == 0 then |
207 if end_timer == 0 then |
236 _G.onGearDamage = function(gear, damage) |
236 _G.onGearDamage = function(gear, damage) |
237 if GetGearType(gear) == gtTarget then |
237 if GetGearType(gear) == gtTarget then |
238 scored = scored + 1 |
238 scored = scored + 1 |
239 SetTeamLabel(params.teamName, tostring(getTargetsScore())) |
239 SetTeamLabel(params.teamName, tostring(getTargetsScore())) |
240 if scored < total_targets then |
240 if scored < total_targets then |
241 AddCaption(string.format(loc("Targets left: %d"), (total_targets-scored)), 0xFFFFFFFF, capgrpMessage) |
241 AddCaption(string.format(loc("Targets left: %d"), (total_targets-scored)), capcolDefault, capgrpMessage) |
242 spawnTarget() |
242 spawnTarget() |
243 else |
243 else |
244 if not game_lost then |
244 if not game_lost then |
245 AddCaption(loc("You have destroyed all targets!"), 0xFFFFFFFF, capgrpGameState) |
245 AddCaption(loc("You have destroyed all targets!"), capcolDefault, capgrpGameState) |
246 ShowMission(params.missionTitle, loc("Aiming practice"), loc("Congratulations! You have destroyed all targets within the time."), 0, 0) |
246 ShowMission(params.missionTitle, loc("Aiming practice"), loc("Congratulations! You have destroyed all targets within the time."), 0, 0) |
247 PlaySound(sndVictory, player) |
247 PlaySound(sndVictory, player) |
248 SetEffect(player, heInvulnerable, 1) |
248 SetEffect(player, heInvulnerable, 1) |
249 SetState(player, bor(GetState(player), gstWinner)) |
249 SetState(player, bor(GetState(player), gstWinner)) |
250 time_goal = TurnTimeLeft |
250 time_goal = TurnTimeLeft |
256 end |
256 end |
257 |
257 |
258 if GetGearType(gear) == gtHedgehog then |
258 if GetGearType(gear) == gtHedgehog then |
259 if not game_lost then |
259 if not game_lost then |
260 game_lost = true |
260 game_lost = true |
261 AddCaption(loc("You lose!"), 0xFFFFFFFF, capgrpGameState) |
261 AddCaption(loc("You lose!"), capcolDefault, capgrpGameState) |
262 ShowMission(params.missionTitle, loc("Aiming practice"), loc("Oh no! You failed! Just try again."), -amSkip, 0) |
262 ShowMission(params.missionTitle, loc("Aiming practice"), loc("Oh no! You failed! Just try again."), -amSkip, 0) |
263 |
263 |
264 SetHealth(player, 0) |
264 SetHealth(player, 0) |
265 time_goal = 1 |
265 time_goal = 1 |
266 end |
266 end |
267 end |
267 end |
268 end |
268 end |
269 |
269 |
270 _G.onGearDelete = function(gear) |
270 _G.onGearDelete = function(gear) |
271 if GetGearType(gear) == gtTarget and band(GetState(gear), gstDrowning) ~= 0 then |
271 if GetGearType(gear) == gtTarget and band(GetState(gear), gstDrowning) ~= 0 then |
272 AddCaption(loc("You lost your target, try again!"), 0xFFFFFFFF, capgrpGameState) |
272 AddCaption(loc("You lost your target, try again!"), capcolDefault, capgrpGameState) |
273 local newTarget = spawnTarget() |
273 local newTarget = spawnTarget() |
274 local x, y = GetGearPosition(newTarget) |
274 local x, y = GetGearPosition(newTarget) |
275 local success = PlaceSprite(x, y + 24, sprAmGirder, 0, 0xFFFFFFFF, false, false, false) |
275 local success = PlaceSprite(x, y + 24, sprAmGirder, 0, 0xFFFFFFFF, false, false, false) |
276 if not success then |
276 if not success then |
277 WriteLnToConsole("ERROR: Failed to spawn girder under respawned target!") |
277 WriteLnToConsole("ERROR: Failed to spawn girder under respawned target!") |