Time achievement for ClimbHome 0.9.22
authorunC0Rr
Fri, 01 Apr 2016 14:42:14 +0300
branch0.9.22
changeset 12375 d974b32ab58b
parent 12374 d75c666e2d21
child 12404 bcdffa237f14
Time achievement for ClimbHome
share/hedgewars/Data/Maps/ClimbHome/map.lua
--- a/share/hedgewars/Data/Maps/ClimbHome/map.lua	Mon Mar 28 21:20:11 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