share/hedgewars/Data/Scripts/Multiplayer/TechRacer.lua
changeset 11935 e1bae42efacd
parent 11934 c17e5ac9f76d
child 11936 c750c21e4a44
equal deleted inserted replaced
11934:c17e5ac9f76d 11935:e1bae42efacd
   455                                         string.format(loc("Rounds complete: %d/%d"), roundNumber, roundLimit) .. "|" .. " " .. "|" ..
   455                                         string.format(loc("Rounds complete: %d/%d"), roundNumber, roundLimit) .. "|" .. " " .. "|" ..
   456                                         loc("Best team times: ") .. "|" .. totalComment, 0, 4000)
   456                                         loc("Best team times: ") .. "|" .. totalComment, 0, 4000)
   457 
   457 
   458         -- end game if its at round limit
   458         -- end game if its at round limit
   459         if roundNumber >= roundLimit then
   459         if roundNumber >= roundLimit then
   460                 for i = 0, (numhhs-1) do
       
   461                         if GetHogClan(hhs[i]) ~= bestClan then
       
   462                                 SetEffect(hhs[i], heResurrectable, 0)
       
   463                                 SetHealth(hhs[i],0)
       
   464                         end
       
   465                 end
       
   466                 gameOver = true
   460                 gameOver = true
   467                 TurnTimeLeft = 1
   461                 TurnTimeLeft = 10000000
       
   462 
       
   463                 -- Sort the scores for the ranking list
       
   464                 local unfinishedArray = {}
       
   465                 local sortedTeams = {}
       
   466                 local k = 1
       
   467                 for i = 0, TeamsCount-1 do
       
   468                         if teamScore[i] ~= -1 and teamNameArr[i] ~= " " then
       
   469                                sortedTeams[k] = {}
       
   470                                sortedTeams[k].name = teamNameArr[i]
       
   471                                sortedTeams[k].score = teamScore[i]
       
   472                                k = k + 1
       
   473                         else
       
   474                                table.insert(unfinishedArray, string.format(loc("%s did not finish the race."), teamNameArr[i]))
       
   475                         end
       
   476                 end
       
   477                 table.sort(sortedTeams, function(team1, team2) return team1.score < team2.score end)
       
   478 
       
   479                 -- Write all the stats!
       
   480 
       
   481                 for i = 1, #sortedTeams do
       
   482                         SendStat(siPointType, loc("milliseconds"))
       
   483                         SendStat(siPlayerKills, sortedTeams[i].score, sortedTeams[i].name)
       
   484                 end
       
   485 
       
   486                 if #sortedTeams >= 1 then
       
   487                         SendStat(siGameResult, string.format(loc("%s wins!"), sortedTeams[1].name))
       
   488                         SendStat(siCustomAchievement, string.format(loc("%s wins with a best time of %.1fs."), sortedTeams[1].name, (sortedTeams[1].score/1000)))
       
   489                         for i=1,#unfinishedArray do
       
   490                                  SendStat(siCustomAchievement, unfinishedArray[i])
       
   491                         end
       
   492                 else
       
   493                         SendStat(siGameResult, loc("Round draw"))
       
   494                         SendStat(siCustomAchievement, loc("Nobody managed to finish the race. What a shame!"))
       
   495                         SendStat(siCustomAchievement, loc("Maybe you should try an easier TechRacer map."))
       
   496                 end
       
   497 
       
   498                 -- Game over
       
   499                 EndGame()
   468         end
   500         end
   469 
   501 
   470 end
   502 end
   471 
   503 
   472 function CheckForNewRound()
   504 function CheckForNewRound()
   913 	end
   945 	end
   914 
   946 
   915 end
   947 end
   916 
   948 
   917 function onGameStart()
   949 function onGameStart()
       
   950 	SendHealthStatsOff()
   918 
   951 
   919 		trackTeams()
   952 		trackTeams()
   920 
   953 
   921 		roundN = 0
   954 		roundN = 0
   922         lastRound = TotalRounds
   955         lastRound = TotalRounds