share/hedgewars/Data/Scripts/TargetPractice.lua
changeset 14590 c5f18710a184
parent 14578 50f511588635
child 14591 b4089fa16b34
equal deleted inserted replaced
14587:164ec37e9e4b 14590:c5f18710a184
   177 
   177 
   178 	_G.onGameTick20 = function()
   178 	_G.onGameTick20 = function()
   179 		if TurnTimeLeft < 40 and TurnTimeLeft > 0 and scored < total_targets and game_lost == false then
   179 		if TurnTimeLeft < 40 and TurnTimeLeft > 0 and scored < total_targets and game_lost == false then
   180 			game_lost = true
   180 			game_lost = true
   181 			AddCaption(loc("Time’s up!"), capcolDefault, capgrpGameState)
   181 			AddCaption(loc("Time’s up!"), capcolDefault, capgrpGameState)
   182 			ShowMission(params.missionTitle, loc("Aiming practice"), loc("Oh no! Time's up! Just try again."), -amSkip, 0)
       
   183 			SetHealth(player, 0)
   182 			SetHealth(player, 0)
   184 			time_goal = 1
   183 			time_goal = 1
   185 		end
   184 		end
   186 
   185 
   187 		if band(GetState(player), gstDrowning) == gstDrowning and game_lost == false and scored < total_targets then
   186 		if band(GetState(player), gstDrowning) == gstDrowning and game_lost == false and scored < total_targets then
   188 			game_lost = true
   187 			game_lost = true
   189 			time_goal = 1
   188 			time_goal = 1
   190 			AddCaption(loc("You lose!"), capcolDefault, capgrpGameState)
       
   191 			ShowMission(params.missionTitle, loc("Aiming practice"), loc("Oh no! You failed! Just try again."), -amSkip, 0)
       
   192 		end
   189 		end
   193 
   190 
   194 		if scored == total_targets  or game_lost then
   191 		if scored == total_targets  or game_lost then
   195 			if end_timer == 0 then
   192 			if end_timer == 0 then
   196 				generateStats()
   193 				generateStats()
   246 		end
   243 		end
   247 
   244 
   248 		if GetGearType(gear) == gtHedgehog then
   245 		if GetGearType(gear) == gtHedgehog then
   249 			if not game_lost then
   246 			if not game_lost then
   250 				game_lost = true
   247 				game_lost = true
   251 				AddCaption(loc("You lose!"), capcolDefault, capgrpGameState)
       
   252 				ShowMission(params.missionTitle, loc("Aiming practice"), loc("Oh no! You failed! Just try again."), -amSkip, 0)
       
   253 
   248 
   254 				SetHealth(player, 0)
   249 				SetHealth(player, 0)
   255 				time_goal = 1
   250 				time_goal = 1
   256 			end
   251 			end
   257 		end
   252 		end
   291 			SendStat(siCustomAchievement, string.format(loc("You have destroyed %d of %d targets (+%d points)."), scored, total_targets, end_score_targets))
   286 			SendStat(siCustomAchievement, string.format(loc("You have destroyed %d of %d targets (+%d points)."), scored, total_targets, end_score_targets))
   292 			SendStat(siCustomAchievement, string.format(params.shootText, shots))
   287 			SendStat(siCustomAchievement, string.format(params.shootText, shots))
   293 			SendStat(siCustomAchievement, string.format(loc("Your accuracy was %.1f%% (+%d points)."), accuracy, end_score_accuracy))
   288 			SendStat(siCustomAchievement, string.format(loc("Your accuracy was %.1f%% (+%d points)."), accuracy, end_score_accuracy))
   294 			SendStat(siCustomAchievement, string.format(loc("You had %.1fs remaining on the clock (+%d points)."), (time_goal/1000), end_score_time))
   289 			SendStat(siCustomAchievement, string.format(loc("You had %.1fs remaining on the clock (+%d points)."), (time_goal/1000), end_score_time))
   295 		else
   290 		else
   296 			SendStat(siGameResult, loc("You lose!"))
   291 			SendStat(siGameResult, loc("Challenge over!"))
   297 
   292 
   298 			SendStat(siCustomAchievement, string.format(loc("You have destroyed %d of %d targets (+%d points)."), scored, total_targets, end_score_targets))
   293 			SendStat(siCustomAchievement, string.format(loc("You have destroyed %d of %d targets (+%d points)."), scored, total_targets, end_score_targets))
   299 			SendStat(siCustomAchievement, string.format(params.shootText, shots))
   294 			SendStat(siCustomAchievement, string.format(params.shootText, shots))
   300 			if(shots > 0) then
   295 			if(shots > 0) then
   301 				SendStat(siCustomAchievement, string.format(loc("Your accuracy was %.1f%%."), accuracy))
   296 				SendStat(siCustomAchievement, string.format(loc("Your accuracy was %.1f%%."), accuracy))