share/hedgewars/Data/Scripts/Multiplayer/TechRacer.lua
branch0.9.22
changeset 12401 7342f5020691
parent 12367 3e4044f959a9
equal deleted inserted replaced
12400:c7d73e5840c8 12401:7342f5020691
   171 
   171 
   172 local fastX = {}
   172 local fastX = {}
   173 local fastY = {}
   173 local fastY = {}
   174 local fastCount = 0
   174 local fastCount = 0
   175 local fastIndex = 0
   175 local fastIndex = 0
   176 local fastColour
   176 local fastColour = 0xffffffff
   177 
   177 
   178 local currX = {}
   178 local currX = {}
   179 local currY = {}
   179 local currY = {}
   180 local currCount = 0
   180 local currCount = 0
   181 
   181 
   244         -- make a list of individual team names
   244         -- make a list of individual team names
   245         for i = 0, (TeamsCount-1) do
   245         for i = 0, (TeamsCount-1) do
   246                 teamNameArr[i] = " " -- = i
   246                 teamNameArr[i] = " " -- = i
   247                 teamSize[i] = 0
   247                 teamSize[i] = 0
   248                 teamIndex[i] = 0
   248                 teamIndex[i] = 0
   249                 teamScore[i] = 100000
   249                 teamScore[i] = 1000000
   250         end
   250         end
   251         numTeams = 0
   251         numTeams = 0
   252 
   252 
   253         for i = 0, (numhhs-1) do
   253         for i = 0, (numhhs-1) do
   254 
   254 
   348 end
   348 end
   349 
   349 
   350 function AdjustScores()
   350 function AdjustScores()
   351 
   351 
   352         if bestTime == nil then
   352         if bestTime == nil then
   353                 bestTime = 100000
   353                 bestTime = 1000000
   354                 bestClan = 10
   354                 bestClan = 10
   355                 bestTimeComment = "N/A"
   355                 bestTimeComment = "N/A"
   356         end
   356         end
   357 
   357 
   358         newScore = false
   358         newScore = false
   378                         bestTime = teamScore[i]
   378                         bestTime = teamScore[i]
   379                         bestClan = teamClan[i]
   379                         bestClan = teamClan[i]
   380                 end
   380                 end
   381         end
   381         end
   382 
   382 
   383         if bestTime ~= 100000 then
   383         if bestTime ~= 1000000 then
   384                 bestTimeComment = (bestTime/1000) ..loc("s")
   384                 bestTimeComment = (bestTime/1000) ..loc("s")
   385         end
   385         end
   386 
   386 
   387         if newScore == true then
   387         if newScore == true then
   388                 if trackTime == bestTime then -- best time of the race
   388                 if trackTime == bestTime then -- best time of the race
   688 	end
   688 	end
   689 
   689 
   690 end
   690 end
   691 
   691 
   692 function onGameInit()
   692 function onGameInit()
   693 
   693     if mapID == nil then
   694 		if mapID == nil then
   694         mapID = 2 + GetRandom(7)
   695 			mapID = 2 + GetRandom(7)
   695     end
   696 		end
   696 
       
   697     addHashData(mapID)
   697 
   698 
   698 		Theme = "Cave"
   699 		Theme = "Cave"
   699 
   700 
   700 		MapGen = mgDrawn
   701 		MapGen = mgDrawn
   701 		TemplateFilter = 0
   702 		TemplateFilter = 0
   722     end
   723     end
   723 
   724 
   724 end
   725 end
   725 
   726 
   726 function onSpecialPoint(x,y,flag)
   727 function onSpecialPoint(x,y,flag)
   727     specialPointsX[specialPointsCount] = x
   728     if flag == 99 then
   728     specialPointsY[specialPointsCount] = y
   729         fastX[fastCount] = x
   729 	specialPointsFlag[specialPointsCount] = flag
   730         fastY[fastCount] = y
   730     specialPointsCount = specialPointsCount + 1
   731         fastCount = fastCount + 1
       
   732     elseif flag == 0 then
       
   733         techX[techCount], techY[techCount] = x, y
       
   734         techCount = techCount + 1
       
   735     else
       
   736         addHashData(x)
       
   737         addHashData(y)
       
   738         addHashData(flag)
       
   739         specialPointsX[specialPointsCount] = x
       
   740         specialPointsY[specialPointsCount] = y
       
   741         specialPointsFlag[specialPointsCount] = flag
       
   742         specialPointsCount = specialPointsCount + 1
       
   743     end
   731 end
   744 end
   732 
   745 
   733 function InterpretPoints()
   746 function InterpretPoints()
   734 
   747 
   735 	-- flags run from 0 to 127
   748 	-- flags run from 0 to 127
  1243     usedWeapons[at] = 0
  1256     usedWeapons[at] = 0
  1244 end
  1257 end
  1245 
  1258 
  1246 function onAchievementsDeclaration()
  1259 function onAchievementsDeclaration()
  1247     usedWeapons[amSkip] = nil
  1260     usedWeapons[amSkip] = nil
       
  1261     usedWeapons[amExtraTime] = nil
  1248 
  1262 
  1249     usedRope = usedWeapons[amRope] ~= nil
  1263     usedRope = usedWeapons[amRope] ~= nil
  1250     usedPortal = usedWeapons[amPortalGun] ~= nil
  1264     usedPortal = usedWeapons[amPortalGun] ~= nil
  1251     usedSaucer = usedWeapons[amJetpack] ~= nil
  1265     usedSaucer = usedWeapons[amJetpack] ~= nil
  1252 
  1266 
  1268         raceType = "no tools race"
  1282         raceType = "no tools race"
  1269     else -- at least two of rope, portal and saucer used
  1283     else -- at least two of rope, portal and saucer used
  1270         raceType = "mixed race"
  1284         raceType = "mixed race"
  1271     end
  1285     end
  1272 
  1286 
  1273     map = detectMap()
  1287     map = detectMapWithDigest()
  1274 
  1288 
  1275     for i = 0, (numTeams-1) do
  1289     for i = 0, (numTeams-1) do
  1276         if teamScore[i] < 100000 then
  1290         if teamScore[i] < 1000000 then
  1277             DeclareAchievement(raceType, teamNameArr[i], map, teamScore[i])
  1291             DeclareAchievement(raceType, teamNameArr[i], map, teamScore[i])
  1278         end
  1292         end
  1279     end
  1293     end
  1280 
  1294 
  1281     if map ~= nil and fastCount > 0 then
  1295     if map ~= nil and fastCount > 0 then