share/hedgewars/Data/Maps/ClimbHome/map.lua
changeset 10632 5ae7ba0b2849
parent 10598 9dd0f41d3244
child 10645 b8c73bacb31e
equal deleted inserted replaced
10631:3d164350cc48 10632:5ae7ba0b2849
    12 local Fire = {}
    12 local Fire = {}
    13 --local BoomFire = nil
    13 --local BoomFire = nil
    14 local HH = {}
    14 local HH = {}
    15 local totalHedgehogs = 0
    15 local totalHedgehogs = 0
    16 local deadHedgehogs = 0
    16 local deadHedgehogs = 0
       
    17 local currTeam = ''
       
    18 local teams = {}
    17 local teamScoreStats = {}
    19 local teamScoreStats = {}
    18 local teamBests = {}
    20 local teamBests = {}
    19 local MrMine -- in honour of sparkle's first arrival in the cabin
    21 local MrMine -- in honour of sparkle's first arrival in the cabin
    20 local YouWon = false
    22 local YouWon = false
    21 local YouLost = false
    23 local YouLost = false
    28 local jokeAwardNavy = nil
    30 local jokeAwardNavy = nil
    29 local jokeAwardSpeed = nil
    31 local jokeAwardSpeed = nil
    30 local jokeAwardDamage = nil
    32 local jokeAwardDamage = nil
    31 local recordBroken = false
    33 local recordBroken = false
    32 local ready = false
    34 local ready = false
    33 -- TODO. Fix use of dummy team for scaling the graph.
       
    34 local showWaterStats = false -- uses the AI team to draw water height.
    35 local showWaterStats = false -- uses the AI team to draw water height.
    35 local scaleGraph = false
    36 local scaleGraph = true
    36 local dummyHog = nil
    37 local dummyHog = nil
    37 local dummySkip = 0
    38 local dummySkip = 0
    38 
    39 
    39 function onGameInit()
    40 function onGameInit()
    40     -- Ensure people get same map for same theme
    41     -- Ensure people get same map for same theme
    66 
    67 
    67 function onGearAdd(gear)
    68 function onGearAdd(gear)
    68     if GetGearType(gear) == gtHedgehog then
    69     if GetGearType(gear) == gtHedgehog then
    69         HH[gear] = 1
    70         HH[gear] = 1
    70         totalHedgehogs = totalHedgehogs + 1
    71         totalHedgehogs = totalHedgehogs + 1
       
    72         teams[GetHogTeamName(gear)] = 1
    71     end
    73     end
    72 end
    74 end
    73 
    75 
    74 function onGearDelete(gear)
    76 function onGearDelete(gear)
    75     if gear == MrMine then
    77     if gear == MrMine then
   125     SetWaterLine(32768)
   127     SetWaterLine(32768)
   126     YouWon = false
   128     YouWon = false
   127     YouLost = false
   129     YouLost = false
   128     tauntNoo = false
   130     tauntNoo = false
   129     recordBroken = false
   131     recordBroken = false
       
   132     currTeam = GetHogTeamName(CurrentHedgehog)
   130     if CurrentHedgehog ~= nil then
   133     if CurrentHedgehog ~= nil then
   131         if CurrentHedgehog ~= dummyHog then
   134         if CurrentHedgehog ~= dummyHog then
   132             SetGearPosition(CurrentHedgehog, 1951,32640)
   135             SetGearPosition(CurrentHedgehog, 1951,32640)
   133             if not HogsAreInvulnerable then SetEffect(CurrentHedgehog,heInvulnerable,0) end
   136             if not HogsAreInvulnerable then SetEffect(CurrentHedgehog,heInvulnerable,0) end
   134             AddVisualGear(1951,32640,vgtExplosion,0,false)
   137             AddVisualGear(1951,32640,vgtExplosion,0,false)
   305                     teamName = GetHogTeamName(CurrentHedgehog),
   308                     teamName = GetHogTeamName(CurrentHedgehog),
   306                     distance = distanceFromWater
   309                     distance = distanceFromWater
   307                 }
   310                 }
   308             end
   311             end
   309         end
   312         end
   310 
       
   311 -- this block was moved out of the % 500 below because it was not triggering fast enough to give correct stats for all teams.
       
   312             if isSinglePlayer then
   313             if isSinglePlayer then
   313                 if distanceFromWater < 0 and not YouLost and not YouWon then
   314                 if distanceFromWater < 0 and not YouLost and not YouWon then
   314                     makeSinglePlayerLoserStats()
   315                     makeSinglePlayerLoserStats()
   315                     YouLost = true
   316                     YouLost = true
   316                 end
   317                 end
   349             --    WaterRise = AddGear(0,0,gtWaterUp, 0, 0, 0, 0)
   350             --    WaterRise = AddGear(0,0,gtWaterUp, 0, 0, 0, 0)
   350             --end
   351             --end
   351             if showWaterStats == true then
   352             if showWaterStats == true then
   352 	        SendStat(siClanHealth, tostring(getActualHeight(WaterLine)), " ")
   353 	        SendStat(siClanHealth, tostring(getActualHeight(WaterLine)), " ")
   353             end
   354             end
   354             SendStat(siClanHealth, tostring(getActualHeight(y)), GetHogTeamName(CurrentHedgehog))
   355 	    for t,i in pairs(teams) do
       
   356                 if currTeam == t then
       
   357                     SendStat(siClanHealth, tostring(getActualHeight(y)), t)
       
   358                 else
       
   359                     SendStat(siClanHealth, '0', t)
       
   360                 end
       
   361             end
   355     
   362     
   356             -- play taunts
   363             -- play taunts
   357             if not YouWon and not YouLost then
   364             if not YouWon and not YouLost then
   358                 local nooDistance = 500
   365                 local nooDistance = 500
   359                 if ((x < -nooDistance and vx < 0) or (x > LAND_WIDTH+nooDistance and vx > 0)) then
   366                 if ((x < -nooDistance and vx < 0) or (x > LAND_WIDTH+nooDistance and vx > 0)) then
   529     if actualHeight > 1500 then
   536     if actualHeight > 1500 then
   530         SendStat(siCustomAchievement, string.format(text, RecordHeightHogName, actualHeight))
   537         SendStat(siCustomAchievement, string.format(text, RecordHeightHogName, actualHeight))
   531     else
   538     else
   532         SendStat(siCustomAchievement, string.format(text, RecordHeightHogName))
   539         SendStat(siCustomAchievement, string.format(text, RecordHeightHogName))
   533     end
   540     end
   534     SendStat(siPointType, "points")
       
   535     SendStat(siPlayerKills, actualHeight, loc(GetHogTeamName(CurrentHedgehog)))
   541     SendStat(siPlayerKills, actualHeight, loc(GetHogTeamName(CurrentHedgehog)))
   536     EndGame()
   542     EndGame()
   537 end
   543 end
   538 
   544 
   539 function makeMultiPlayerLoserStat(gear)
   545 function makeMultiPlayerLoserStat(gear)
   580             SendStat(siCustomAchievement, string.format(text, loser.name))
   586             SendStat(siCustomAchievement, string.format(text, loser.name))
   581         end
   587         end
   582     end
   588     end
   583     checkAwards()
   589     checkAwards()
   584     for i = #ranking, 1, -1 do
   590     for i = #ranking, 1, -1 do
       
   591 	SendStat(siPointType, loc("points"))
   585         SendStat(siPlayerKills, tostring(ranking[i].score), ranking[i].name)
   592         SendStat(siPlayerKills, tostring(ranking[i].score), ranking[i].name)
   586         SendStat(siPointType, "points")
       
   587     end
   593     end
   588 end
   594 end
   589 
   595 
   590 function checkAwards()
   596 function checkAwards()
   591     if jokeAwardNavy ~= nil then
   597     if jokeAwardNavy ~= nil then