share/hedgewars/Data/Maps/ClimbHome/map.lua
changeset 11640 2a53e219bc1a
parent 11632 221691bede23
child 11894 c8979eeb73fa
--- a/share/hedgewars/Data/Maps/ClimbHome/map.lua	Tue Mar 15 22:29:40 2016 +0300
+++ b/share/hedgewars/Data/Maps/ClimbHome/map.lua	Fri Apr 01 14:42:14 2016 +0300
@@ -19,6 +19,7 @@
 local teams = {}
 local teamScoreStats = {}
 local teamBests = {}
+local teamTimes = {}
 local MrMine -- in honour of sparkle's first arrival in the cabin
 local YouWon = false
 local YouLost = false
@@ -447,8 +448,15 @@
             end
 
             if (y > 286) or (y < 286 and MaxHeight > 286) then
+                if MaxHeight > 286 and y <= 286 then
+                    -- wow, reached top
+                    local teamName = GetHogTeamName(CurrentHedgehog)
+                    if teamTimes[teamName] == nil or teamTimes[teamName] > GameTime - startTime then 
+                        teamTimes[teamName] = GameTime - startTime 
+                    end
+                    MaxHeight = 286
+                end
                 if y < MaxHeight and y > 286 then MaxHeight = y end
-                if y < 286 then MaxHeight = 286 end
                 if MaxHeight < hTagHeight then
                     hTagHeight = MaxHeight
                     if hTag ~= nil then DeleteVisualGear(hTag) end
@@ -687,4 +695,7 @@
     for teamname, score in pairs(teamBests) do
         DeclareAchievement("height reached", teamname, "ClimbHome", -score)
     end
+    for teamname, score in pairs(teamTimes) do
+        DeclareAchievement("rope race", teamname, "ClimbHome", score)
+    end
 end