- Make Racer report achievements
authorunc0rr
Mon, 20 Jan 2014 00:25:40 +0400
changeset 10022 eb981a03de90
parent 10021 7f36194af01c
child 10023 fa9674c94c4f
- Make Racer report achievements - Add official racer challenge map #1 - Helper script to detect official challenge maps by land digest
hedgewars/uLand.pas
misc/OfficialChallenges/racer_#1.hwmap
share/hedgewars/Data/Scripts/Multiplayer/Racer.lua
share/hedgewars/Data/Scripts/OfficialChallenges.lua
--- a/hedgewars/uLand.pas	Sun Jan 19 17:53:16 2014 +0100
+++ b/hedgewars/uLand.pas	Mon Jan 20 00:25:40 2014 +0400
@@ -31,7 +31,7 @@
 implementation
 uses uConsole, uStore, uRandom, uLandObjects, uIO, uLandTexture, SysUtils,
      uVariables, uUtils, uCommands, adler32, uDebug, uLandPainted, uTextures,
-     uLandGenMaze, uLandOutline, uPhysFSLayer;
+     uLandGenMaze, uLandOutline, uPhysFSLayer, uScript;
 
 var digest: shortstring;
 
@@ -886,6 +886,8 @@
         adler:= Adler32Update(adler, @Land[i,0], LAND_WIDTH);
     s:= 'M' + IntToStr(adler) + cScriptName;
 
+    ScriptSetString('LandDigest', s);
+
     chLandCheck(s);
     SendIPCRaw(@s[0], Length(s) + 1)
 end;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/misc/OfficialChallenges/racer_#1.hwmap	Mon Jan 20 00:25:40 2014 +0400
@@ -0,0 +1,1 @@
+AAAAw3icJc6xDcIwEAXQz+niWBhkiggxAS0djZs0kYVASFmBBWiYw0xAQ5sOV7SZgBpKRvAC+Ezz9PWlfzrd8BHmyzvwiTvoFe7QTf0AAoaIUO9hrwUMpQN56iN5tcT8U6C+dKADuzi7scsHeJuEnCaXJOSkXklAtWaXBBjDbRJKF/7dgtsgyPYcBNm+gwBtaTNqqzyqJ3fj1Oeff4W8JYk=
\ No newline at end of file
--- a/share/hedgewars/Data/Scripts/Multiplayer/Racer.lua	Sun Jan 19 17:53:16 2014 +0100
+++ b/share/hedgewars/Data/Scripts/Multiplayer/Racer.lua	Mon Jan 20 00:25:40 2014 +0400
@@ -72,6 +72,7 @@
 -----------------------------
 
 HedgewarsScriptLoad("/Scripts/Locale.lua")
+HedgewarsScriptLoad("/Scripts/OfficialChallenges.lua")
 
 ------------------
 -- Got Variables?
@@ -718,3 +719,14 @@
         end
 
 end
+
+
+function onAchievementsDeclaration()
+    map = detectMap()
+    
+    for i = 0, (numTeams-1) do
+        if teamScore[i] < 100000 then
+            DeclareAchievement("rope race", teamNameArr[i], map, teamScore[i])
+        end
+    end
+end
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/share/hedgewars/Data/Scripts/OfficialChallenges.lua	Mon Jan 20 00:25:40 2014 +0400
@@ -0,0 +1,5 @@
+function detectMap()
+    if LandDigest == "M838018718Scripts/Multiplayer/Racer.lua" then
+        return("Racer Challenge #1")
+    end
+end