share/hedgewars/Data/Maps/ClimbHome/map.lua
changeset 12760 5acf6b91df76
parent 12754 c7224d202e8b
child 12825 b986a8b8cd56
equal deleted inserted replaced
12759:df9d9d19406a 12760:5acf6b91df76
    32 local tauntNoo = false
    32 local tauntNoo = false
    33 local jokeAwardNavy = nil
    33 local jokeAwardNavy = nil
    34 local jokeAwardSpeed = nil
    34 local jokeAwardSpeed = nil
    35 local jokeAwardDamage = nil
    35 local jokeAwardDamage = nil
    36 local recordBroken = false
    36 local recordBroken = false
    37 local ready = false
       
    38 local dummyHog = nil
    37 local dummyHog = nil
    39 local dummySkip = 0
    38 local dummySkip = 0
    40 local baseWaterSpeed = 2
    39 local baseWaterSpeed = 2
    41 local waterSpeed = 0
    40 local waterSpeed = 0
    42 local waterAccel = 0
    41 local waterAccel = 0
   116     elseif gear == Cake then
   115     elseif gear == Cake then
   117         Cake = nil
   116         Cake = nil
   118     elseif GetGearType(gear) == gtHedgehog then
   117     elseif GetGearType(gear) == gtHedgehog then
   119 	onGameTick20()
   118 	onGameTick20()
   120 	onGearDamage(gear, 0)
   119 	onGearDamage(gear, 0)
   121         ready = false
       
   122         HH[gear] = nil
   120         HH[gear] = nil
   123     end
   121     end
   124 end
   122 end
   125 
   123 
   126 function onGameStart()
   124 function onGameStart()
   169                 AddGear(airMineX[a],airMineY[a], gtAirMine, gsttmpFlag, 0, 0, 0)
   167                 AddGear(airMineX[a],airMineY[a], gtAirMine, gsttmpFlag, 0, 0, 0)
   170             end
   168             end
   171         end
   169         end
   172     end
   170     end
   173         
   171         
   174     ready = false
       
   175     startTime = GameTime
   172     startTime = GameTime
   176     --disable to preserve highest over multiple turns
   173     --disable to preserve highest over multiple turns
   177     --will need to change water check too ofc
   174     --will need to change water check too ofc
   178     MaxHeight = 32640
   175     MaxHeight = 32640
   179     hTagHeight = 33000
   176     hTagHeight = 33000
   189             HogTurnLeft(CurrentHedgehog, true)
   186             HogTurnLeft(CurrentHedgehog, true)
   190             if not HogsAreInvulnerable then SetEffect(CurrentHedgehog,heInvulnerable,0) end
   187             if not HogsAreInvulnerable then SetEffect(CurrentHedgehog,heInvulnerable,0) end
   191             AddVisualGear(1951,32640,vgtExplosion,0,false)
   188             AddVisualGear(1951,32640,vgtExplosion,0,false)
   192             SetState(CurrentHedgehog,band(GetState(CurrentHedgehog),bnot(gstInvisible)))
   189             SetState(CurrentHedgehog,band(GetState(CurrentHedgehog),bnot(gstInvisible)))
   193             SetWeapon(amRope)
   190             SetWeapon(amRope)
   194             ready = true
       
   195         else
   191         else
   196             dummySkip = GameTime+1
   192             dummySkip = GameTime+1
   197         end
   193         end
   198     end
   194     end
   199     for hog, _ in pairs(multiplayerWinningHogs) do
   195     for hog, _ in pairs(multiplayerWinningHogs) do
   277         --    if g5 > 360 then g5 = 0 end
   273         --    if g5 > 360 then g5 = 0 end
   278         --    SetVisualGearValues(s, g1, g2, g3, g4, g5, g6, g7, g8, g9, g10)
   274         --    SetVisualGearValues(s, g1, g2, g3, g4, g5, g6, g7, g8, g9, g10)
   279         --end
   275         --end
   280     end
   276     end
   281 
   277 
   282     if not ready then 
       
   283         return
       
   284     end
       
   285 
       
   286     -- This will be executed if a player reached home in multiplayer
   278     -- This will be executed if a player reached home in multiplayer
   287     if multiplayerVictoryDelay > 0 then
   279     if multiplayerVictoryDelay > 0 then
   288         multiplayerVictoryDelay = multiplayerVictoryDelay - 20
   280         multiplayerVictoryDelay = multiplayerVictoryDelay - 20
   289         if multiplayerVictoryDelay <= 0 then
   281         if multiplayerVictoryDelay <= 0 then
   290             -- If delay's over, the game will continue with the next hog
   282             -- If delay's over, the game will continue with the next hog
   324             Cake = nil
   316             Cake = nil
   325         end
   317         end
   326 
   318 
   327         if Cake ~= nil and GetHealth(Cake) < 999980 and gearIsInCircle(CurrentHedgehog,cx,cy,450) then
   319         if Cake ~= nil and GetHealth(Cake) < 999980 and gearIsInCircle(CurrentHedgehog,cx,cy,450) then
   328             FireBoom(cx,cy,200) -- todo animate
   320             FireBoom(cx,cy,200) -- todo animate
       
   321             DeleteGear(Cake)
       
   322             Cake = nil
       
   323         end
       
   324     end
       
   325     
       
   326     if CurrentHedgehog ~= nil and band(GetState(CurrentHedgehog),gstHHDriven) == 0 then
       
   327         for f,i in pairs(Fire) do -- takes too long to fall otherwise
       
   328             DeleteGear(f)
       
   329         end
       
   330         if Cake ~= nil then
   329             DeleteGear(Cake)
   331             DeleteGear(Cake)
   330             Cake = nil
   332             Cake = nil
   331         end
   333         end
   332     end
   334     end
   333 
   335 
   353                 999999999, -- frameticks
   355                 999999999, -- frameticks
   354                 sprStar, -- star
   356                 sprStar, -- star
   355                 0, c)
   357                 0, c)
   356                 --,  0xFFCC00FF) -- could be fun to make colour shift as you rise...
   358                 --,  0xFFCC00FF) -- could be fun to make colour shift as you rise...
   357             Stars[s] = 1
   359             Stars[s] = 1
   358         end    
   360         end
   359     end
   361 
   360     
       
   361     if CurrentHedgehog ~= nil and band(GetState(CurrentHedgehog),gstHHDriven) == 0 then
       
   362         for f,i in pairs(Fire) do -- takes too long to fall otherwise
       
   363             DeleteGear(f)
       
   364         end
       
   365         if Cake ~= nil then
       
   366             DeleteGear(Cake)
       
   367             Cake = nil
       
   368         end
       
   369     end
       
   370 
       
   371     if CurrentHedgehog ~= nil and TurnTimeLeft > 0 then
       
   372         local vx, vy = GetGearVelocity(CurrentHedgehog)
   362         local vx, vy = GetGearVelocity(CurrentHedgehog)
   373 	local distanceFromWater = WaterLine - y
   363         local distanceFromWater = WaterLine - y
   374 	
   364 	
   375         --[[ check joke awards ]]
   365         --[[ check joke awards ]]
   376         -- navy award: when distance from main map is over 1000
   366         -- navy award: when distance from main map is over 1000
   377         local navyDistance = 1250
   367         local navyDistance = 1250
   378         if x < -navyDistance or x > LAND_WIDTH+navyDistance then
   368         if x < -navyDistance or x > LAND_WIDTH+navyDistance then
   411                     teamName = GetHogTeamName(CurrentHedgehog),
   401                     teamName = GetHogTeamName(CurrentHedgehog),
   412                     distance = distanceFromWater
   402                     distance = distanceFromWater
   413                 }
   403                 }
   414             end
   404             end
   415         end
   405         end
   416             local finishTime = (GameTime-startTime)/1000
   406 
   417             local roundedFinishTime = math.ceil(math.floor(finishTime+0.5))
   407         local finishTime = (GameTime-startTime)/1000
   418             if isSinglePlayer then
   408         local roundedFinishTime = math.ceil(math.floor(finishTime+0.5))
   419                 if distanceFromWater < 0 and not YouLost and not YouWon then
   409         if isSinglePlayer then
   420                     makeSinglePlayerLoserStats()
   410             if distanceFromWater < 0 and not YouLost and not YouWon then
   421                     YouLost = true
   411                 makeSinglePlayerLoserStats()
   422                     ready = false
   412                 YouLost = true
   423                 end
   413             end
   424                 -- FIXME: Hog is also in winning box if it just walks into the chair from the left, touching it. Intentional?
   414             -- FIXME: Hog is also in winning box if it just walks into the chair from the left, touching it. Intentional?
   425                 if not YouWon and not YouLost and gearIsInBox(CurrentHedgehog, 1920, 252, 50, 50) then
   415             if not YouWon and not YouLost and gearIsInBox(CurrentHedgehog, 1920, 252, 50, 50) then
   426                     AddCaption(loc("Victory!"))
   416                 AddCaption(loc("Victory!"))
   427                     ShowMission(loc("Climb Home"),
   417                 ShowMission(loc("Climb Home"),
   428                                 loc("Made it!"),
   418                             loc("Made it!"),
   429                                 string.format(loc("Ahhh, home, sweet home. Made it in %d seconds."), roundedFinishTime),
   419                             string.format(loc("Ahhh, home, sweet home. Made it in %d seconds."), roundedFinishTime),
   430                                 -amRope, 0)
   420                             -amRope, 0)
   431                     PlaySound(sndVictory,CurrentHedgehog)
   421                 PlaySound(sndVictory,CurrentHedgehog)
   432                     SetState(CurrentHedgehog, gstWinner)
   422                 SetState(CurrentHedgehog, gstWinner)
   433                     SendStat(siGameResult, loc("You have beaten the challenge!"))
   423                 SendStat(siGameResult, loc("You have beaten the challenge!"))
   434                     SendStat(siGraphTitle, loc("Your height over time"))
   424                 SendStat(siGraphTitle, loc("Your height over time"))
   435                     SendStat(siCustomAchievement, string.format(loc("%s reached home in %.3f seconds. Congratulations!"), GetHogName(CurrentHedgehog), finishTime))
   425                 SendStat(siCustomAchievement, string.format(loc("%s reached home in %.3f seconds. Congratulations!"), GetHogName(CurrentHedgehog), finishTime))
   436                     SendStat(siCustomAchievement, string.format(loc("%s bravely climbed up to a dizzy height of %d to reach home."), GetHogName(CurrentHedgehog), getActualHeight(RecordHeight)))
   426                 SendStat(siCustomAchievement, string.format(loc("%s bravely climbed up to a dizzy height of %d to reach home."), GetHogName(CurrentHedgehog), getActualHeight(RecordHeight)))
   437                     SendStat(siPointType, loc("seconds"))
   427                 SendStat(siPointType, loc("seconds"))
   438                     SendStat(siPlayerKills, tostring(roundedFinishTime), GetHogTeamName(CurrentHedgehog))
   428                 SendStat(siPlayerKills, tostring(roundedFinishTime), GetHogTeamName(CurrentHedgehog))
   439 
   429 
       
   430                 EndGame()
       
   431                 onAchievementsDeclaration()
       
   432                 YouWon = true
       
   433             end
       
   434         else
       
   435             if distanceFromWater < 0 and not YouLost and not YouWon then
       
   436                 makeMultiPlayerLoserStat(CurrentHedgehog)
       
   437                 deadHedgehogs = deadHedgehogs + 1
       
   438                 YouLost = true
       
   439                 if deadHedgehogs >= totalHedgehogs then
       
   440                     makeFinalMultiPlayerStats()
   440                     EndGame()
   441                     EndGame()
   441                     onAchievementsDeclaration()
   442                     onAchievementsDeclaration()
   442                     YouWon = true
   443                 end
   443                     ready = false
   444             end
   444                 end
   445             -- Check victory
   445             else
   446             if not YouWon and not YouLost and gearIsInBox(CurrentHedgehog, 1920, 252, 50, 50) and
   446                 if distanceFromWater < 0 and not YouLost and not YouWon then
   447                     -- Delay victory if MrMine is triggered
   447                     makeMultiPlayerLoserStat(CurrentHedgehog)
   448                     (not MrMine or (MrMine and band(GetState(MrMine), gstAttacking) == 0)) then
   448                     deadHedgehogs = deadHedgehogs + 1
   449                 -- Player managed to reach home in multiplayer.
   449                     YouLost = true
   450                 -- Stop hog, disable controls, celebrate victory and continue the game after 4 seconds.
   450                     ready = false
   451                 AddCaption(string.format(loc("%s climbed home in %d seconds!"), GetHogName(CurrentHedgehog), roundedFinishTime))
   451                     if deadHedgehogs >= totalHedgehogs then
   452                 SendStat(siCustomAchievement, string.format(loc("%s (%s) reached home in %.3f seconds."), GetHogName(CurrentHedgehog), GetHogTeamName(CurrentHedgehog), finishTime))
   452                         makeFinalMultiPlayerStats()
   453                 makeMultiPlayerWinnerStat(CurrentHedgehog)
   453                         EndGame()
   454                 PlaySound(sndVictory, CurrentHedgehog)
   454                         onAchievementsDeclaration()
   455                 -- TODO: Unselect weapon.
   455                     end
   456                 -- Note: SetWeapon(amNothing) does not work. :-(
   456                 end
   457                 SetGearMessage(CurrentHedgehog, band(GetGearMessage(CurrentHedgehog), bnot(gmLeft+gmRight+gmUp+gmDown+gmHJump+gmLJump+gmPrecise)))
   457                 -- Check victory
   458                 SetInputMask(0x00)
   458                 if not YouWon and not YouLost and gearIsInBox(CurrentHedgehog, 1920, 252, 50, 50) and
   459                 -- TODO: Add stupid winner grin.
   459                         -- Delay victory if MrMine is triggered
   460                 multiplayerVictoryDelay = 4000
   460                         (not MrMine or (MrMine and band(GetState(MrMine), gstAttacking) == 0)) then
   461                 YouWon = true
   461                     -- Player managed to reach home in multiplayer.
   462             end
   462                     -- Stop hog, disable controls, celebrate victory and continue the game after 4 seconds.
   463         end
   463                     AddCaption(string.format(loc("%s climbed home in %d seconds!"), GetHogName(CurrentHedgehog), roundedFinishTime))
       
   464                     SendStat(siCustomAchievement, string.format(loc("%s (%s) reached home in %.3f seconds."), GetHogName(CurrentHedgehog), GetHogTeamName(CurrentHedgehog), finishTime))
       
   465                     makeMultiPlayerWinnerStat(CurrentHedgehog)
       
   466                     PlaySound(sndVictory, CurrentHedgehog)
       
   467                     -- TODO: Unselect weapon.
       
   468                     -- Note: SetWeapon(amNothing) does not work. :-(
       
   469                     SetGearMessage(CurrentHedgehog, band(GetGearMessage(CurrentHedgehog), bnot(gmLeft+gmRight+gmUp+gmDown+gmHJump+gmLJump+gmPrecise)))
       
   470                     SetInputMask(0x00)
       
   471                     -- TODO: Add stupid winner grin.
       
   472                     multiplayerVictoryDelay = 4000
       
   473                     YouWon = true
       
   474                     ready = false
       
   475                 end
       
   476             end
       
   477 
   464 
   478         if GameTime % 500 == 0 then
   465         if GameTime % 500 == 0 then
   479             if not isSinglePlayer then
   466             if not isSinglePlayer then
   480 	        for t,i in pairs(teams) do
   467 	        for t,i in pairs(teams) do
   481                     if currTeam == t then
   468                     if currTeam == t then
   482                         SendStat(siClanHealth, tostring(getActualHeight(y)), t)
   469                         SendStat(siClanHealth, tostring(getActualHeight(y)), t)
   483                     else
   470                     else
   484                         SendStat(siClanHealth, '0', t)
   471                         SendStat(siClanHealth, '0', t)
   485                     end
   472                     end
   486                 end
   473                 end
   487             elseif CurrentHedgehog ~= nil then
   474             else
   488                 SendStat(siClanHealth, tostring(getActualHeight(y)), GetHogTeamName(CurrentHedgehog))
   475                 SendStat(siClanHealth, tostring(getActualHeight(y)), GetHogTeamName(CurrentHedgehog))
   489             end
   476             end
   490     
   477     
   491             -- play taunts
   478             -- play taunts
   492             if not YouWon and not YouLost then
   479             if not YouWon and not YouLost then
   631                 EndGame()
   618                 EndGame()
   632                 onAchievementsDeclaration()
   619                 onAchievementsDeclaration()
   633             end
   620             end
   634         end
   621         end
   635         YouLost = true
   622         YouLost = true
   636         ready = false
       
   637     end
   623     end
   638 end
   624 end
   639 
   625 
   640 function makeLoserComment()
   626 function makeLoserComment()
   641     local m
   627     local m