share/hedgewars/Data/Scripts/Multiplayer/Racer.lua
changeset 11928 42e90b244e11
parent 11927 72593678e8d6
child 11929 167de692f2d7
equal deleted inserted replaced
11927:72593678e8d6 11928:42e90b244e11
   180 function RebuildTeamInfo()
   180 function RebuildTeamInfo()
   181 
   181 
   182 
   182 
   183         -- make a list of individual team names
   183         -- make a list of individual team names
   184         for i = 0, (TeamsCount-1) do
   184         for i = 0, (TeamsCount-1) do
   185                 teamNameArr[i] = " " -- = i
   185                 teamNameArr[i] = " "
   186                 teamSize[i] = 0
   186                 teamSize[i] = 0
   187                 teamIndex[i] = 0
   187                 teamIndex[i] = 0
   188                 teamScore[i] = 100000
   188                 teamScore[i] = 100000
   189         end
   189         end
   190         numTeams = 0
   190         numTeams = 0
   275 
   275 
   276                 g1X = g1X - g2X
   276                 g1X = g1X - g2X
   277                 g1Y = g1Y - g2Y
   277                 g1Y = g1Y - g2Y
   278                 dist = (g1X*g1X) + (g1Y*g1Y)
   278                 dist = (g1X*g1X) + (g1Y*g1Y)
   279 
   279 
   280                 --if i == 0 then
       
   281                 --      AddCaption(dist .. "/" .. (wpRad*wpRad) )
       
   282                 --end
       
   283 
       
   284                 NR = (48/100*wpRad)/2
   280                 NR = (48/100*wpRad)/2
   285 
   281 
   286                 if dist < (NR*NR) then
   282                 if dist < (NR*NR) then
   287                 --if dist < (wpRad*wpRad) then
   283                         wpCol[i] = GetClanColor(GetHogClan(CurrentHedgehog))
   288                         --AddCaption("howdy")
       
   289                         wpCol[i] = GetClanColor(GetHogClan(CurrentHedgehog)) -- new                             --GetClanColor(1)
       
   290                         SetVisualGearValues(wpCirc[i], wpX[i], wpY[i], 20, 100, 1, 10, 0, wpRad, 5, wpCol[i])
   284                         SetVisualGearValues(wpCirc[i], wpX[i], wpY[i], 20, 100, 1, 10, 0, wpRad, 5, wpCol[i])
   291 
   285 
   292                         wpRem = 0
   286                         wpRem = 0
   293                         for k = 0, (wpCount-1) do
   287                         for k = 0, (wpCount-1) do
   294                                 if wpActive[k] == false then
   288                                 if wpActive[k] == false then
   338                         else
   332                         else
   339                                 newScore = false
   333                                 newScore = false
   340                         end
   334                         end
   341                 end
   335                 end
   342         end
   336         end
   343 
       
   344         --bestTime = 100000
       
   345         --bestClan = 10
       
   346 
   337 
   347         -- find the best time out of those so far
   338         -- find the best time out of those so far
   348         for i = 0, (numTeams-1) do
   339         for i = 0, (numTeams-1) do
   349                 if teamScore[i] < bestTime then
   340                 if teamScore[i] < bestTime then
   350                         bestTime = teamScore[i]
   341                         bestTime = teamScore[i]
   376                 string.format(loc("Winning time: %s"), bestTimeComment), -amSkip, 4000)
   367                 string.format(loc("Winning time: %s"), bestTimeComment), -amSkip, 4000)
   377                 PlaySound(sndHellish)
   368                 PlaySound(sndHellish)
   378         end
   369         end
   379 
   370 
   380 
   371 
   381         --------
       
   382         --new
       
   383         --------
       
   384 
       
   385         if bestTime == trackTime then
   372         if bestTime == trackTime then
   386                 --AddCaption("wooooooooooooooooooooooooooooo")
       
   387 
   373 
   388                 fastColour = GetClanColor(GetHogClan(CurrentHedgehog))
   374                 fastColour = GetClanColor(GetHogClan(CurrentHedgehog))
   389 
   375 
   390                 for i = 0, (currCount-1) do
   376                 for i = 0, (currCount-1) do
   391                         fastX[i] = currX[i]
   377                         fastX[i] = currX[i]
   392                         fastY[i] = currY[i]
   378                         fastY[i] = currY[i]
   393                 end
   379                 end
   394 
   380 
   395                 fastCount = currCount
   381                 fastCount = currCount
   396                 fastIndex = 0
   382                 fastIndex = 0
   397 
       
   398                 --currCount = 0 -- is this needed?
       
   399 
   383 
   400         else
   384         else
   401                 currCount = 0
   385                 currCount = 0
   402                 fastIndex = 0
   386                 fastIndex = 0
   403         end
   387         end
   471 
   455 
   472 end
   456 end
   473 
   457 
   474 function CheckForNewRound()
   458 function CheckForNewRound()
   475 
   459 
   476         -------------
       
   477         ------ new
       
   478         -------------
       
   479 
       
   480         --[[turnN = turnN + 1
       
   481         if gameBegun == false then
       
   482                 if turnN == 2 then
       
   483                         for i = 0, (numhhs-1) do
       
   484                                 if hhs[i] ~= nil then
       
   485                                         SetEffect(hhs[i], heResurrectable, 0)
       
   486                                         SetHealth(hhs[i],0)
       
   487                                 end
       
   488                         end
       
   489                         gameOver = true
       
   490                         TurnTimeLeft = 1
       
   491                 end
       
   492         else
       
   493 
       
   494 
       
   495         end]]
       
   496 
       
   497         --[[if roundBegun == true then
       
   498 
       
   499                 if RoundHasChanged == true then
       
   500                         roundN = roundN + 1
       
   501                         RoundHasChanged = false
       
   502                         onNewRound()
       
   503                 end
       
   504 
       
   505                 if lastRound ~= TotalRounds then -- new round, but not really
       
   506 
       
   507                         if RoundHasChanged == false then
       
   508                                 RoundHasChanged = true
       
   509                         end
       
   510 
       
   511                 end
       
   512 
       
   513                 AddCaption("RoundN:" .. roundN .. "; " .. "TR: " .. TotalRounds)
       
   514 
       
   515                 lastRound = TotalRounds
       
   516 
       
   517         end]]
       
   518 
       
   519         ------------
       
   520         ----- old
       
   521         ------------
       
   522 
       
   523         if GetHogClan(CurrentHedgehog) == firstClan then
   460         if GetHogClan(CurrentHedgehog) == firstClan then
   524                 onNewRound()
   461                 onNewRound()
   525         end
   462         end
   526 
   463 
   527 end
   464 end
   547 
   484 
   548                 tempE = AddVisualGear(fastX[fastIndex], fastY[fastIndex], vgtSmoke, 0, false)
   485                 tempE = AddVisualGear(fastX[fastIndex], fastY[fastIndex], vgtSmoke, 0, false)
   549                 g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
   486                 g1, g2, g3, g4, g5, g6, g7, g8, g9, g10 = GetVisualGearValues(tempE)
   550                 SetVisualGearValues(tempE, g1, g2, g3, g4, g5, g6, g7, g8, g9, fastColour )
   487                 SetVisualGearValues(tempE, g1, g2, g3, g4, g5, g6, g7, g8, g9, fastColour )
   551 
   488 
   552                 --AddCaption("fC: " .. fastIndex .. " / " .. fastCount)
   489         end
   553 
       
   554         else
       
   555 
       
   556                 --AddCaption("excep fC: " .. fastIndex .. " / " .. fastCount)
       
   557 
       
   558         end
       
   559 
       
   560 
       
   561 
   490 
   562 end
   491 end
   563 
   492 
   564 function TryRepositionHogs()
   493 function TryRepositionHogs()
   565 
   494 
   590 function onGameStart()
   519 function onGameStart()
   591         SendHealthStatsOff()
   520         SendHealthStatsOff()
   592 
   521 
   593         roundN = 0
   522         roundN = 0
   594         lastRound = TotalRounds
   523         lastRound = TotalRounds
   595         RoundHasChanged = false -- true
   524         RoundHasChanged = false
   596 
   525 
   597         for i = 0, (specialPointsCount-1) do
   526         for i = 0, (specialPointsCount-1) do
   598                 PlaceWayPoint(specialPointsX[i], specialPointsY[i])
   527                 PlaceWayPoint(specialPointsX[i], specialPointsY[i])
   599         end
   528         end
   600 
   529