share/hedgewars/Data/Missions/Challenge/User_Mission_-_That_Sinking_Feeling.lua
changeset 14475 2113296b7a29
parent 14464 ead8928a59f8
child 14482 d4aa64f51c9f
--- a/share/hedgewars/Data/Missions/Challenge/User_Mission_-_That_Sinking_Feeling.lua	Wed Dec 19 01:47:41 2018 +0100
+++ b/share/hedgewars/Data/Missions/Challenge/User_Mission_-_That_Sinking_Feeling.lua	Wed Dec 19 05:50:02 2018 +0100
@@ -1,6 +1,7 @@
 
 
 HedgewarsScriptLoad("/Scripts/Locale.lua")
+HedgewarsScriptLoad("/Scripts/Utils.lua")
 HedgewarsScriptLoad("/Scripts/Achievements.lua")
 
 local player
@@ -15,6 +16,17 @@
 local watGear = nil
 local cinematic = false
 
+function printMission()
+	local highscore = tonumber(GetMissionVar("Highscore"))
+	local show = (type(highscore) == "number") and (highscore > 0)
+	local recordInfo = ""
+	if show then
+		recordInfo = getReadableChallengeRecord("Highscore")
+	end
+	ShowMission(loc("That Sinking Feeling"), loc("Challenge"), loc("Save as many hapless hogs as possible!")
+	.. "|" .. recordInfo, 4, 0)
+end
+
 -- allow skipping of the intro via hitting precise key
 function onPrecise()
 	if introStage < 100 then
@@ -22,7 +34,7 @@
 		genCounter = 0
 		FollowGear(CurrentHedgehog)
 		AddCaption(loc("Good luck out there!"))
-		ShowMission(loc("That Sinking Feeling"), loc("Challenge"), loc("Save as many hapless hogs as possible!"), 4, 0)
+		printMission()
 		SetInputMask(0xFFFFFFFF)
 	end
 end
@@ -70,11 +82,12 @@
 
 
 function onGameStart()
-    cinematic = true
-    SetCinematicMode(true)
+	cinematic = true
+	SetCinematicMode(true)
 	SendHealthStatsOff()
 
-	ShowMission(loc("That Sinking Feeling"), loc("Challenge"), loc("Save as many hapless hogs as possible!"), 4, 1)
+	printMission()
+	HideMission()
 
 	HogTurnLeft(hh[0], false)
 	HogTurnLeft(hh[1], true)
@@ -241,6 +254,9 @@
 
 				SendStat(siCustomAchievement, string.format(loc("You saved %d of 8 Hapless Hogs."), hhLeft))
 
+				-- Update highscore
+				updateChallengeRecord("Highscore", hhLeft)
+
 				if hhLeft == 8 then
 					SaveMissionVar("Won", "true")
 					awardAchievement(loc("Lively Lifeguard"))
@@ -293,6 +309,9 @@
 		end
 		SendStat(siPointType, loc("points"))
 		SendStat(siPlayerKills, "0", loc("Nameless Heroes"))
+		local highscore = tonumber(GetMissionVar("Highscore"))
+		show = (type(highscore) == "number") and (highscore > 0)
+		updateChallengeRecord("Highscore", 0, show)
 
 		SendStat(siGameResult, loc("Disqualified!"))
 		GameOver = true