share/hedgewars/Data/Scripts/Multiplayer/Racer.lua
changeset 11923 85cbb2368269
parent 11648 89fc5e6ccc76
child 11924 ce277e51b603
equal deleted inserted replaced
11922:d0296b8e60c0 11923:85cbb2368269
   395 
   395 
   396         roundNumber = roundNumber + 1
   396         roundNumber = roundNumber + 1
   397 
   397 
   398         totalComment = ""
   398         totalComment = ""
   399         for i = 0, (TeamsCount-1) do
   399         for i = 0, (TeamsCount-1) do
   400                         if teamNameArr[i] ~= " " then                           -- teamScore[teamClan[i]]
   400                         if teamNameArr[i] ~= " " and teamScore[i] ~= -1 then
   401                                 teamComment[i] = teamNameArr[i] .. ": " .. (teamScore[i]/1000) .. loc("s|")
   401                                 teamComment[i] = string.format(loc("%s: %.1fs"), teamNameArr[i], (teamScore[i]/1000)) .. "|"
   402                                 totalComment = totalComment .. teamComment[i]
   402                         else
   403                         elseif teamNameArr[i] == " " then
   403                                 teamComment[i] = string.format(loc("%s: N/A"), teamNameArr[i]) .. "|"
   404                                 teamComment[i] = "|"
   404                         end
   405                         end
   405                         totalComment = totalComment .. teamComment[i]
   406         end
   406         end
   407 
   407 
   408         ShowMission(    loc("RACER"),
   408         ShowMission(    loc("RACER"),
   409                                         loc("STATUS UPDATE"),
   409                                         loc("STATUS UPDATE"),
   410                                         loc("Rounds Complete: ") .. roundNumber .. "/" .. roundLimit .. "|" .. " " .. "|" ..
   410                                         string.format(loc("ROUNDS COMPLETE: %d/%d"), roundNumber, roundLimit) .. "|" .. " " .. "|" ..
   411                                         loc("Best Team Times: ") .. "|" .. totalComment, 0, 4000)
   411                                         loc("BEST TEAM TIMES: ") .. "|" .. totalComment, 0, 4000)
   412 
   412 
   413         -- end game if its at round limit
   413         -- end game if its at round limit
   414         if roundNumber >= roundLimit then
   414         if roundNumber >= roundLimit then
   415                 for i = 0, (numhhs-1) do
       
   416                         if GetHogClan(hhs[i]) ~= bestClan then
       
   417                                 SetEffect(hhs[i], heResurrectable, 0)
       
   418                                 SetHealth(hhs[i],0)
       
   419                         end
       
   420                 end
       
   421                 gameOver = true
   415                 gameOver = true
   422                 TurnTimeLeft = 1
   416                 TurnTimeLeft = 10000000
       
   417 
       
   418                 -- Sort the scores for the ranking list
       
   419                 local unfinishedArray = {}
       
   420                 local sortedTeams = {}
       
   421                 local k = 1
       
   422                 for i = 0, TeamsCount-1 do
       
   423                         if teamScore[i] ~= 100000 and teamNameArr[i] ~= " " then
       
   424                                sortedTeams[k] = {}
       
   425                                sortedTeams[k].name = teamNameArr[i]
       
   426                                sortedTeams[k].score = teamScore[i]
       
   427                                k = k + 1
       
   428                         else
       
   429                                table.insert(unfinishedArray, string.format(loc("%s did not finish the race."), teamNameArr[i]))
       
   430                         end
       
   431                 end
       
   432                 table.sort(sortedTeams, function(team1, team2) return team1.score < team2.score end)
       
   433 
       
   434                 -- Write all the stats!
       
   435 
       
   436                 for i = 1, #sortedTeams do
       
   437                         SendStat(siPointType, loc("milliseconds"))
       
   438                         SendStat(siPlayerKills, sortedTeams[i].score, sortedTeams[i].name)
       
   439                 end
       
   440 
       
   441                 if #sortedTeams >= 1 then
       
   442                         SendStat(siGameResult, string.format(loc("%s wins!"), sortedTeams[1].name))
       
   443                         SendStat(siGameResult, string.format(loc("%s wins!"), sortedTeams[1].name))
       
   444                         SendStat(siCustomAchievement, string.format(loc("%s wins with a best time of %.1fs."), sortedTeams[1].name, (sortedTeams[1].score/1000)))
       
   445                         for i=1,#unfinishedArray do
       
   446                                  SendStat(siCustomAchievement, unfinishedArray[i])
       
   447                         end
       
   448                 else
       
   449                         SendStat(siGameResult, loc("Round draw"))
       
   450                         SendStat(siCustomAchievement, loc("Nobody managed to finish the race. What a shame!"))
       
   451                         SendStat(siCustomAchievement, loc("Maybe you should try an easier TechRacer map."))
       
   452                 end
       
   453 
       
   454                 -- Game over
       
   455                 EndGame()
   423         end
   456         end
   424 
   457 
   425 end
   458 end
   426 
   459 
   427 function CheckForNewRound()
   460 function CheckForNewRound()
   539         WaterRise = 0
   572         WaterRise = 0
   540 end
   573 end
   541 
   574 
   542 
   575 
   543 function onGameStart()
   576 function onGameStart()
       
   577         SendHealthStatsOff()
   544 
   578 
   545         roundN = 0
   579         roundN = 0
   546         lastRound = TotalRounds
   580         lastRound = TotalRounds
   547         RoundHasChanged = false -- true
   581         RoundHasChanged = false -- true
   548 
   582