share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice02.lua
changeset 11895 712e20a3d895
parent 11697 68eddcdc9f26
child 11957 63988f36debf
equal deleted inserted replaced
11894:c8979eeb73fa 11895:712e20a3d895
   133 	if checkIfHeroInWaypoint() then
   133 	if checkIfHeroInWaypoint() then
   134 		if not gameEnded and not placeNextWaypoint() then
   134 		if not gameEnded and not placeNextWaypoint() then
   135 			gameEnded = true
   135 			gameEnded = true
   136 			-- GAME OVER, WIN!
   136 			-- GAME OVER, WIN!
   137 			totalTime = totalTime - TurnTimeLeft
   137 			totalTime = totalTime - TurnTimeLeft
   138 			totalTime = totalTime / 1000
   138 			local totalTimePrinted  = totalTime / 1000
   139 			local saucersLeft = GetAmmoCount(hero.gear, amJetpack)
   139 			local saucersLeft = GetAmmoCount(hero.gear, amJetpack)
   140 			local saucersUsed = totalSaucers - saucersLeft
   140 			local saucersUsed = totalSaucers - saucersLeft
   141 			SendStat(siGameResult, loc("Hooray! You are a champion!"))
   141 			SendStat(siGameResult, loc("Hooray! You are a champion!"))
   142 			SendStat(siCustomAchievement, string.format(loc("You completed the mission in %.3f seconds.", totalTime)))
   142 			SendStat(siCustomAchievement, string.format(loc("You completed the mission in %.3f seconds."), totalTimePrinted))
   143 			SendStat(siCustomAchievement, string.format(loc("You have used %d flying saucers.", saucersUsed)))
   143 			local record = tonumber(GetCampaignVar("IceStadiumBestTime"))
   144 			SendStat(siCustomAchievement, string.format(loc("You had %d additional flying saucers left"), saucersLeft))
   144 			if record ~= nil and totalTime >= record then
   145 			SendStat(siPlayerKills,'1',teamA.name)
   145 				SendStat(siCustomAchievement, string.format(loc("Your personal best time so far: %.3f seconds"), record/1000))
       
   146 			end
       
   147 			if record == nil or totalTime < record then
       
   148 				SaveCampaignVar("IceStadiumBestTime", tostring(totalTime))
       
   149 				if record ~= nil then
       
   150 					SendStat(siCustomAchievement, loc("This is a new personal best time, congratulations!"))
       
   151 				end
       
   152 			end
       
   153 			SendStat(siCustomAchievement, string.format(loc("You have used %d flying saucers."), saucersUsed))
       
   154 			SendStat(siCustomAchievement, string.format(loc("You had %d additional flying saucers left."), saucersLeft))
       
   155 
       
   156 			record = tonumber(GetCampaignVar("IceStadiumLeastSaucersUsed"))
       
   157 			if record == nil or saucersUsed < record then
       
   158 				SaveCampaignVar("IceStadiumLeastSaucersUsed", tostring(saucersUsed))
       
   159 			end
       
   160 
       
   161 			SendStat(siPlayerKills,'0',teamA.name)
   146 			EndGame()
   162 			EndGame()
   147 		end
   163 		end
   148 	end
   164 	end
   149 end
   165 end
   150 
   166