share/hedgewars/Data/Scripts/Multiplayer/Racer.lua
changeset 11924 ce277e51b603
parent 11923 85cbb2368269
child 11925 7123bfc9643c
equal deleted inserted replaced
11923:85cbb2368269 11924:ce277e51b603
   289                                 if wpActive[k] == false then
   289                                 if wpActive[k] == false then
   290                                         wpRem = wpRem + 1
   290                                         wpRem = wpRem + 1
   291                                 end
   291                                 end
   292                         end
   292                         end
   293 
   293 
   294                         AddCaption(loc("Way-Points Remaining") .. ": " .. wpRem,0xffba00ff,capgrpAmmoinfo)
   294                         AddCaption(string.format(loc("Waypoints remaining: %d"), wpRem),0xffba00ff,capgrpAmmoinfo)
   295 
   295 
   296                 end
   296                 end
   297 
   297 
   298                 if wpActive[i] == false then
   298                 if wpActive[i] == false then
   299                         trackFinished = false
   299                         trackFinished = false
   337                         bestClan = teamClan[i]
   337                         bestClan = teamClan[i]
   338                 end
   338                 end
   339         end
   339         end
   340 
   340 
   341         if bestTime ~= 100000 then
   341         if bestTime ~= 100000 then
   342                 bestTimeComment = (bestTime/1000) ..loc("s")
   342                 bestTimeComment = string.format(loc("%.1fs"), (bestTime/1000))
   343         end
   343         end
   344 
   344 
   345         if newScore == true then
   345         if newScore == true then
   346                 if trackTime == bestTime then -- best time of the race
   346                 if trackTime == bestTime then -- best time of the race
   347                         ShowMission(loc("RACER"),
   347                         ShowMission(loc("Racer"),
   348                         loc("TRACK COMPLETED"),
   348                         loc("Track completed!"),
   349                         loc("NEW RACE RECORD: ") .. (trackTime/1000) ..loc("s") .. "|" ..
   349                         string.format(loc("New race record: %.1fs"), (trackTime/1000)) .. "|" ..
   350                         loc("WINNING TIME: ") .. bestTimeComment, 0, 4000)
   350                         string.format(loc("Winning time: %s"), bestTimeComment), 0, 4000)
   351                         PlaySound(sndHomerun)
   351                         PlaySound(sndHomerun)
   352                 else    -- best time for the clan
   352                 else    -- best time for the clan
   353                         ShowMission(loc("RACER"),
   353                         ShowMission(loc("Racer"),
   354                         loc("TRACK COMPLETED"),
   354                         loc("Track completed!"),
   355                         loc("NEW CLAN RECORD: ") .. (trackTime/1000) ..loc("s") .. "|" ..
   355                         string.format(loc("New clan record: %.1fs"), (trackTime/1000)) .. "|" ..
   356                         loc("WINNING TIME: ") .. bestTimeComment, 4, 4000)
   356                         string.format(loc("Winning time: %s"), bestTimeComment), 4, 4000)
   357                 end
   357                 end
   358         else -- not any kind of new score
   358         else -- not any kind of new score
   359                 ShowMission(loc("RACER"),
   359                 ShowMission(loc("Racer"),
   360                 loc("TRACK COMPLETED"),
   360                 loc("Track completed!"),
   361                 loc("TIME: ") .. (trackTime/1000) ..loc("s") .. "|" ..
   361                 string.format(loc("Time: %.1fs"), (trackTime/1000)) .. "|" ..
   362                 loc("WINNING TIME: ") .. bestTimeComment, -amSkip, 4000)
   362                 string.format(loc("Winning time: %s"), bestTimeComment), -amSkip, 4000)
   363                 PlaySound(sndHellish)
   363                 PlaySound(sndHellish)
   364         end
   364         end
   365 
   365 
   366 
   366 
   367         --------
   367         --------
   403                                 teamComment[i] = string.format(loc("%s: N/A"), teamNameArr[i]) .. "|"
   403                                 teamComment[i] = string.format(loc("%s: N/A"), teamNameArr[i]) .. "|"
   404                         end
   404                         end
   405                         totalComment = totalComment .. teamComment[i]
   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                                         string.format(loc("ROUNDS COMPLETE: %d/%d"), 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                 gameOver = true
   415                 gameOver = true
   416                 TurnTimeLeft = 10000000
   416                 TurnTimeLeft = 10000000
   446                                  SendStat(siCustomAchievement, unfinishedArray[i])
   446                                  SendStat(siCustomAchievement, unfinishedArray[i])
   447                         end
   447                         end
   448                 else
   448                 else
   449                         SendStat(siGameResult, loc("Round draw"))
   449                         SendStat(siGameResult, loc("Round draw"))
   450                         SendStat(siCustomAchievement, loc("Nobody managed to finish the race. What a shame!"))
   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."))
   451                         SendStat(siCustomAchievement, loc("Maybe you should try easier waypoints next time."))
   452                 end
   452                 end
   453 
   453 
   454                 -- Game over
   454                 -- Game over
   455                 EndGame()
   455                 EndGame()
   456         end
   456         end
   585         end
   585         end
   586 
   586 
   587         RebuildTeamInfo()
   587         RebuildTeamInfo()
   588 
   588 
   589         ShowMission     (
   589         ShowMission     (
   590                                 loc("RACER"),
   590                                 loc("Racer"),
   591                                 loc("a Hedgewars mini-game"),
   591                                 loc("A Hedgewars mini-game"),
   592 
   592 
   593                                 loc("Build a track and race.") .. "|" ..
   593                                 loc("Build a track and race.") .. "|" ..
   594                                 loc("Round Limit:") .. " " .. roundLimit .. "|" ..
   594                                 string.format(loc("Round limit: %d"), roundLimit) .. "|" ..
   595 
   595 
   596                                 "", 4, 4000
   596                                 "", 4, 4000
   597                                 )
   597                                 )
   598 
   598 
   599         TryRepositionHogs()
   599         TryRepositionHogs()
   611 
   611 
   612             SetVisualGearValues(wpCirc[wpCount], wpX[wpCount], wpY[wpCount], 20, 100, 1, 10, 0, wpRad, 5, wpCol[wpCount])
   612             SetVisualGearValues(wpCirc[wpCount], wpX[wpCount], wpY[wpCount], 20, 100, 1, 10, 0, wpRad, 5, wpCol[wpCount])
   613 
   613 
   614             wpCount = wpCount + 1
   614             wpCount = wpCount + 1
   615 
   615 
   616             AddCaption(loc("Waypoint placed.") .. " " .. loc("Available points remaining: ") .. (wpLimit-wpCount))
   616             AddCaption(string.format(loc("Waypoint placed. Available points remaining: %d"), wpLimit-wpCount))
   617         end
   617         end
   618     end
   618     end
   619 end
   619 end
   620 
   620 
   621 function onSpecialPoint(x,y,flag)
   621 function onSpecialPoint(x,y,flag)
   657         if (gameOver == false) and (gameBegun == false) then
   657         if (gameOver == false) and (gameBegun == false) then
   658                 if wpCount >= 3 then
   658                 if wpCount >= 3 then
   659                         gameBegun = true
   659                         gameBegun = true
   660                         roundNumber = 0
   660                         roundNumber = 0
   661                         firstClan = GetHogClan(CurrentHedgehog)
   661                         firstClan = GetHogClan(CurrentHedgehog)
   662                         ShowMission(loc("RACER"),
   662                         ShowMission(loc("Racer"),
   663                         loc("GAME BEGUN!!!"),
   663                         loc("A Hedgewars mini-game"),
   664                         loc("Complete the track as fast as you can!"), 2, 4000)
   664                         loc("Complete the track as fast as you can!"), 2, 4000)
   665                 else
   665                 else
   666                         ShowMission(loc("RACER"),
   666                         ShowMission(loc("Racer"),
   667                         loc("NOT ENOUGH WAYPOINTS"),
   667                         loc("Waypoint placement phase"),
   668                         loc("Place more waypoints using the 'Air Attack' weapon."), 2, 4000)
   668                         loc("Place more waypoints using the 'Air Attack' weapon."), 2, 4000)
   669                         AddAmmo(CurrentHedgehog, amAirAttack, 4000)
   669                         AddAmmo(CurrentHedgehog, amAirAttack, 4000)
   670                         SetWeapon(amAirAttack)
   670                         SetWeapon(amAirAttack)
   671                 end
   671                 end
   672         end
   672         end
   692                 if x > -9000 then
   692                 if x > -9000 then
   693                         x,y = GetGearTarget(cGear)
   693                         x,y = GetGearTarget(cGear)
   694 
   694 
   695 
   695 
   696                         if TestRectForObstacle(x-20, y-20, x+20, y+20, true) then
   696                         if TestRectForObstacle(x-20, y-20, x+20, y+20, true) then
   697                                 AddCaption(loc("Please place the way-point in the open, within the map boundaries."))
   697                                 AddCaption(loc("Please place the waypoint in the air, within the map boundaries"))
   698                                 PlaySound(sndDenied)
   698                                 PlaySound(sndDenied)
   699                         elseif (y > WaterLine-50) then
   699                         elseif (y > WaterLine-50) then
   700                                 AddCaption(loc("Please place the way-point further from the waterline."))
   700                                 AddCaption(loc("Please place the waypoint further away from the waterline"))
   701                                 PlaySound(sndDenied)
   701                                 PlaySound(sndDenied)
   702                         else
   702                         else
   703                                 PlaceWayPoint(x, y)
   703                                 PlaceWayPoint(x, y)
   704                                 if wpCount == wpLimit then
   704                                 if wpCount == wpLimit then
   705                                         AddCaption(loc("Race complexity limit reached."))
   705                                         AddCaption(loc("Race complexity limit reached"))
   706                                         DisableTumbler()
   706                                         DisableTumbler()
   707                                 end
   707                                 end
   708                         end
   708                         end
   709                 else
   709                 else
   710                         DeleteGear(cGear)
   710                         DeleteGear(cGear)
   758 
   758 
   759                         trackTime = trackTime + 20
   759                         trackTime = trackTime + 20
   760 
   760 
   761                         if GameTime%100 == 0 then
   761                         if GameTime%100 == 0 then
   762 
   762 
   763                 if trackTime%1000 == 0 then
   763                                 AddCaption(string.format(loc("Time: %.1fs"), (trackTime/1000)),GetClanColor(GetHogClan(CurrentHedgehog)),capgrpMessage2)
   764                     AddCaption((trackTime/1000)..'.0',GetClanColor(GetHogClan(CurrentHedgehog)),capgrpMessage2)
       
   765                 else
       
   766                     AddCaption(trackTime/1000,GetClanColor(GetHogClan(CurrentHedgehog)),capgrpMessage2)
       
   767                 end
       
   768 
   764 
   769                                 if (CheckWaypoints() == true) then
   765                                 if (CheckWaypoints() == true) then
   770                                         AdjustScores()
   766                                         AdjustScores()
   771                                         DisableTumbler()
   767                                         DisableTumbler()
   772                                 end
   768                                 end