Save fastest rounds in Killing the specialists and Precise shooting missions
authorWuzzy <almikes@aol.com>
Wed, 16 Nov 2016 16:35:43 +0100
changeset 11892 0526a26ddd6e
parent 11891 d79621bcb709
child 11893 25a6faa5ac46
Save fastest rounds in Killing the specialists and Precise shooting missions
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death02.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit03.lua
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death02.lua	Wed Nov 16 16:35:09 2016 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death02.lua	Wed Nov 16 16:35:43 2016 +0100
@@ -188,6 +188,16 @@
 	saveBonus(3, 4)
 	SendStat(siGameResult, loc("Congratulations, you won!"))
 	SendStat(siCustomAchievement, string.format(loc("You completed the mission in %d rounds."), TotalRounds))
+	local record = tonumber(GetCampaignVar("FastestSpecialistsKill"))
+	if record ~= nil and TotalRounds >= record then
+		SendStat(siCustomAchievement, string.format(loc("Your fastest victory so far: %d rounds"), record))
+	end
+	if record == nil or TotalRounds < record then
+		SaveCampaignVar("FastestSpecialistsKill", tostring(TotalRounds))
+		if record ~= nil then
+			SendStat(siCustomAchievement, loc("This is a new personal best, congratulations!"))
+		end
+	end
 	SendStat(siCustomAchievement, loc("The next 4 times you play the \"The last encounter\" mission you'll get 20 more hit points and a laser sight."))
 	SendStat(siPlayerKills,'1',teamA.name)
 	EndGame()
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit03.lua	Wed Nov 16 16:35:09 2016 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit03.lua	Wed Nov 16 16:35:43 2016 +0100
@@ -214,6 +214,16 @@
 	saveBonus(2, 1)
 	SendStat(siGameResult, loc("Congratulations, you won!"))
 	SendStat(siCustomAchievement, string.format(loc("You completed the mission in %d rounds."), TotalRounds))
+	local record = tonumber(GetCampaignVar("FastestPreciseShooting"))
+	if record ~= nil and TotalRounds >= record then
+		SendStat(siCustomAchievement, string.format(loc("Your fastest victory so far: %d rounds"), record))
+	end
+	if record == nil or TotalRounds < record then
+		SaveCampaignVar("FastestPreciseShooting", tostring(TotalRounds))
+		if record ~= nil then
+			SendStat(siCustomAchievement, loc("This is a new personal best, congratulations!"))
+		end
+	end
 	SendStat(siCustomAchievement, loc("You will gain some extra ammo from the crates the next time you play the \"Getting to the device\" mission."))
 	SendStat(siPlayerKills,'1',teamA.name)
 	EndGame()