share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon02.lua
changeset 14577 221380cdee7e
parent 14576 2087e50e03e2
child 14578 50f511588635
equal deleted inserted replaced
14576:2087e50e03e2 14577:221380cdee7e
    39 		{x = 3880,y = 33, turnTime = 30000},
    39 		{x = 3880,y = 33, turnTime = 30000},
    40 		{x = 250,y = 1780, turnTime = 25000},
    40 		{x = 250,y = 1780, turnTime = 25000},
    41 		{x = 3850,y = 1940, turnTime = 20000},
    41 		{x = 3850,y = 1940, turnTime = 20000},
    42 	}
    42 	}
    43 }
    43 }
       
    44 local runnerTimeTotal = 0
       
    45 for i=1, #runner.places do
       
    46 	runnerTimeTotal = runnerTimeTotal + runner.places[i].turnTime
       
    47 end
    44 -- teams
    48 -- teams
    45 local teamA = {
    49 local teamA = {
    46 	name = loc("Hog Solo"),
    50 	name = loc("Hog Solo"),
    47 	color = -6
    51 	color = -6
    48 }
    52 }
   232 			HogTurnLeft(runner.gear, false)
   236 			HogTurnLeft(runner.gear, false)
   233 		end
   237 		end
   234 		AddAnim(dialog02)
   238 		AddAnim(dialog02)
   235 
   239 
   236 		-- Update time record
   240 		-- Update time record
   237 		local baseTime = 0
   241 		winningTime = runnerTimeTotal - TurnTimeLeft
   238 		for i=1, #runner.places do
       
   239 			baseTime = baseTime + runner.places[i].turnTime
       
   240 		end
       
   241 		winningTime = baseTime - TurnTimeLeft
       
   242 		SetTeamLabel(teamA.name, string.format(loc("%.3fs"), winningTime/1000))
   242 		SetTeamLabel(teamA.name, string.format(loc("%.3fs"), winningTime/1000))
   243 		SendStat(siCustomAchievement, string.format(loc("You have managed to catch the blue hedgehog in %.3f seconds."), winningTime/1000))
   243 		SendStat(siCustomAchievement, string.format(loc("You have managed to catch the blue hedgehog in %.3f seconds."), winningTime/1000))
   244 		if record ~= nil and winningTime >= record then
   244 		if record ~= nil and winningTime >= record then
   245 			SendStat(siCustomAchievement, string.format(loc("Your personal best time so far: %.3f seconds"), record/1000))
   245 			SendStat(siCustomAchievement, string.format(loc("Your personal best time so far: %.3f seconds"), record/1000))
   246 		end
   246 		end
   276 	SendStat(siGameResult, loc("Too slow! Try again ..."))
   276 	SendStat(siGameResult, loc("Too slow! Try again ..."))
   277 	SendStat(siCustomAchievement, loc("You have to catch the other hog 3 times."))
   277 	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."))
   278 	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."))
   279 	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."))
   280 	SendStat(siCustomAchievement, loc("You'll lose if you die or if your time is up."))
   281 	sendSimpleTeamRankings({teamB.name, teamA.name})
   281 	SendStat(siPointType, loc("milliseconds"))
       
   282 	SendStat(siPlayerKills, tostring(runnerTimeTotal), teamB.name)
       
   283 	SendStat(siPlayerKills, tostring(GetTeamStats(teamA.name).Kills), teamA.name)
   282 	EndGame()
   284 	EndGame()
   283 end
   285 end
   284 
   286 
   285 function win()
   287 function win()
   286 	SendStat(siGameResult, loc("Congratulations, you are the fastest!"))
   288 	SendStat(siGameResult, loc("Congratulations, you are the fastest!"))
   287 	-- siCustomAchievements were added earlier
   289 	-- siCustomAchievements were added earlier
   288 	sendSimpleTeamRankings({teamA.name, teamB.name})
   290 	SendStat(siPointType, loc("milliseconds"))
       
   291 	SendStat(siPlayerKills, tostring(winningTime), teamA.name)
       
   292 	SendStat(siPointType, loc("milliseconds"))
       
   293 	SendStat(siPlayerKills, tostring(runnerTimeTotal), teamB.name)
   289 	SaveCampaignVar("Mission13Won", "true")
   294 	SaveCampaignVar("Mission13Won", "true")
   290 	checkAllMissionsCompleted()
   295 	checkAllMissionsCompleted()
   291 	EndGame()
   296 	EndGame()
   292 end
   297 end