share/hedgewars/Data/Maps/ClimbHome/map.lua
changeset 13155 25de976a7b9a
parent 13023 acba432d34b1
child 13170 98a0edb4bb5a
equal deleted inserted replaced
13154:44351ea57b71 13155:25de976a7b9a
    24 local YouWon = false
    24 local YouWon = false
    25 local YouLost = false
    25 local YouLost = false
    26 local HogsAreInvulnerable = false
    26 local HogsAreInvulnerable = false
    27 local WaterRise = nil
    27 local WaterRise = nil
    28 local Cake = nil
    28 local Cake = nil
       
    29 local CakeWarning = false
       
    30 local CakeFireWarning = false
    29 local CakeTries = 0
    31 local CakeTries = 0
    30 local addCake = true
    32 local addCake = true
       
    33 local takeASeat = false
    31 local Stars = {}
    34 local Stars = {}
    32 local tauntNoo = false
    35 local tauntNoo = false
    33 local jokeAwardNavy = nil
    36 local jokeAwardNavy = nil
    34 local jokeAwardSpeed = nil
    37 local jokeAwardSpeed = nil
    35 local jokeAwardDamage = nil
    38 local jokeAwardDamage = nil
   108     end
   111     end
   109 end
   112 end
   110 
   113 
   111 function onGearDelete(gear)
   114 function onGearDelete(gear)
   112     if gear == MrMine then
   115     if gear == MrMine then
   113         AddCaption(loc("Once you set off the proximity trigger, Mr. Mine is not your friend"), 0xFFFFFFFF, capgrpMessage)
   116         AddCaption(loc("Once you set off the proximity trigger, Mr. Mine is not your friend"), 0xFFFFFFFF, capgrpMessage2)
   114         MrMine = nil
   117         MrMine = nil
   115     elseif GetGearType(gear) == gtCake then
   118     elseif GetGearType(gear) == gtCake then
   116         Cake = nil
   119         Cake = nil
       
   120         CakeWarning = false
   117     elseif GetGearType(gear) == gtHedgehog then
   121     elseif GetGearType(gear) == gtHedgehog then
   118 	onGameTick20()
   122 	onGameTick20()
   119 	onGearDamage(gear, 0)
   123 	onGearDamage(gear, 0)
   120         HH[gear] = nil
   124         HH[gear] = nil
   121     end
   125     end
   179     hTagHeight = 33000
   183     hTagHeight = 33000
   180     SetWaterLine(32768)
   184     SetWaterLine(32768)
   181     YouWon = false
   185     YouWon = false
   182     YouLost = false
   186     YouLost = false
   183     tauntNoo = false
   187     tauntNoo = false
       
   188     takeASeat = false
   184     recordBroken = false
   189     recordBroken = false
   185     currTeam = GetHogTeamName(CurrentHedgehog)
   190     currTeam = GetHogTeamName(CurrentHedgehog)
   186     if CurrentHedgehog ~= nil then
   191     if CurrentHedgehog ~= nil then
   187         if CurrentHedgehog ~= dummyHog or multiplayerWinningHogs[CurrentHedgehog] == true then
   192         if CurrentHedgehog ~= dummyHog or multiplayerWinningHogs[CurrentHedgehog] == true then
   188             SetGearPosition(CurrentHedgehog, 1951,32640)
   193             SetGearPosition(CurrentHedgehog, 1951,32640)
   222 --        WaterRise = AddGear(0,0,gtWaterUp, 0, 0, 0, 0)
   227 --        WaterRise = AddGear(0,0,gtWaterUp, 0, 0, 0, 0)
   223 --    end
   228 --    end
   224 --end
   229 --end
   225 
   230 
   226 function FireBoom(x,y,d) -- going to add for rockets too
   231 function FireBoom(x,y,d) -- going to add for rockets too
       
   232     PlaySound(sndExplosion)
   227     AddVisualGear(x,y,vgtExplosion,0,false)
   233     AddVisualGear(x,y,vgtExplosion,0,false)
   228     -- should approximate circle by removing corners
   234     -- should approximate circle by removing corners
   229     --if BoomFire == nil then BoomFire = {} end
   235     --if BoomFire == nil then BoomFire = {} end
   230     for i = 0,50 do
   236     for i = 0,50 do
   231 	fx = GetRandom(d)-div(d,2)
   237 	fx = GetRandom(d)-div(d,2)
   315         x,y = GetGearPosition(CurrentHedgehog)
   321         x,y = GetGearPosition(CurrentHedgehog)
   316         if Cake ~= nil then
   322         if Cake ~= nil then
   317             local cx,cy = GetGearPosition(Cake)
   323             local cx,cy = GetGearPosition(Cake)
   318             if y < cy-1500 then DeleteGear(Cake) end
   324             if y < cy-1500 then DeleteGear(Cake) end
   319 
   325 
   320             if Cake ~= nil and GetHealth(Cake) < 999980 and gearIsInCircle(CurrentHedgehog,cx,cy,450) then
   326             if Cake ~= nil and GetHealth(Cake) < 999980 then
   321                 FireBoom(cx,cy,200) -- todo animate
   327                 if not CakeWarning and gearIsInCircle(CurrentHedgehog,cx,cy,1350) then
   322                 DeleteGear(Cake)
   328                     AddCaption(loc("Warning: Fire cake detected"))
       
   329                     CakeWarning = true
       
   330                 end
       
   331                 if gearIsInCircle(CurrentHedgehog,cx,cy,450) then
       
   332                     if not CakeFireWarning then
       
   333                         AddCaption(loc("Don't touch the flames!"))
       
   334                         CakeFireWarning = true
       
   335                     end
       
   336                     FireBoom(cx,cy,200) -- todo animate
       
   337                     DeleteGear(Cake)
       
   338                 end
   323             end
   339             end
   324         end
   340         end
   325         if band(GetState(CurrentHedgehog),gstHHDriven) == 0 then
   341         if band(GetState(CurrentHedgehog),gstHHDriven) == 0 then
   326             for f,i in pairs(Fire) do -- takes too long to fall otherwise
   342             for f,i in pairs(Fire) do -- takes too long to fall otherwise
   327                 DeleteGear(f)
   343                 DeleteGear(f)
   411                 makeSinglePlayerLoserStats()
   427                 makeSinglePlayerLoserStats()
   412                 YouLost = true
   428                 YouLost = true
   413             end
   429             end
   414             -- FIXME: Hog is also in winning box if it just walks into the chair from the left, touching it. Intentional?
   430             -- FIXME: Hog is also in winning box if it just walks into the chair from the left, touching it. Intentional?
   415             if not YouWon and not YouLost and gearIsInBox(CurrentHedgehog, 1920, 252, 50, 50) then
   431             if not YouWon and not YouLost and gearIsInBox(CurrentHedgehog, 1920, 252, 50, 50) then
   416                 AddCaption(loc("Victory!"))
   432                 AddCaption(loc("Victory!"), 0xFFFFFFFF, capgrpGameState)
   417                 ShowMission(loc("Climb Home"),
   433                 ShowMission(loc("Climb Home"),
   418                             loc("Made it!"),
   434                             loc("Made it!"),
   419                             string.format(loc("Ahhh, home, sweet home. Made it in %d seconds."), roundedFinishTime),
   435                             string.format(loc("Ahhh, home, sweet home. Made it in %d seconds."), roundedFinishTime),
   420                             -amRope, 0)
   436                             -amRope, 0)
   421                 PlaySound(sndVictory,CurrentHedgehog)
   437                 PlaySound(sndVictory,CurrentHedgehog)
   446             if not YouWon and not YouLost and gearIsInBox(CurrentHedgehog, 1920, 252, 50, 50) and
   462             if not YouWon and not YouLost and gearIsInBox(CurrentHedgehog, 1920, 252, 50, 50) and
   447                     -- Delay victory if MrMine is triggered
   463                     -- Delay victory if MrMine is triggered
   448                     (not MrMine or (MrMine and band(GetState(MrMine), gstAttacking) == 0)) then
   464                     (not MrMine or (MrMine and band(GetState(MrMine), gstAttacking) == 0)) then
   449                 -- Player managed to reach home in multiplayer.
   465                 -- Player managed to reach home in multiplayer.
   450                 -- Stop hog, disable controls, celebrate victory and continue the game after 4 seconds.
   466                 -- Stop hog, disable controls, celebrate victory and continue the game after 4 seconds.
   451                 AddCaption(string.format(loc("%s climbed home in %d seconds!"), GetHogName(CurrentHedgehog), roundedFinishTime))
   467                 AddCaption(string.format(loc("%s climbed home in %d seconds!"), GetHogName(CurrentHedgehog), roundedFinishTime), 0xFFFFFFFF, capgrpGameState)
   452                 SendStat(siCustomAchievement, string.format(loc("%s (%s) reached home in %.3f seconds."), GetHogName(CurrentHedgehog), GetHogTeamName(CurrentHedgehog), finishTime))
   468                 SendStat(siCustomAchievement, string.format(loc("%s (%s) reached home in %.3f seconds."), GetHogName(CurrentHedgehog), GetHogTeamName(CurrentHedgehog), finishTime))
   453                 makeMultiPlayerWinnerStat(CurrentHedgehog)
   469                 makeMultiPlayerWinnerStat(CurrentHedgehog)
   454                 PlaySound(sndVictory, CurrentHedgehog)
   470                 PlaySound(sndVictory, CurrentHedgehog)
   455 		SetWeapon(amNothing)
   471 		SetWeapon(amNothing)
   456                 SetGearMessage(CurrentHedgehog, band(GetGearMessage(CurrentHedgehog), bnot(gmLeft+gmRight+gmUp+gmDown+gmHJump+gmLJump+gmPrecise)))
   472                 SetGearMessage(CurrentHedgehog, band(GetGearMessage(CurrentHedgehog), bnot(gmLeft+gmRight+gmUp+gmDown+gmHJump+gmLJump+gmPrecise)))
   470                         SendStat(siClanHealth, '0', t)
   486                         SendStat(siClanHealth, '0', t)
   471                     end
   487                     end
   472                 end
   488                 end
   473             else
   489             else
   474                 SendStat(siClanHealth, tostring(getActualHeight(y)), GetHogTeamName(CurrentHedgehog))
   490                 SendStat(siClanHealth, tostring(getActualHeight(y)), GetHogTeamName(CurrentHedgehog))
       
   491             end
       
   492             -- If player is inside home, tell player to take a seat.
       
   493             if not takeASeat and gearIsInBox(CurrentHedgehog, 1765, 131, 244, 189) then
       
   494                 AddCaption(loc("Welcome home! Please take a seat"))
       
   495                 takeASeat = true
   475             end
   496             end
   476     
   497     
   477             -- play taunts
   498             -- play taunts
   478             if not YouWon and not YouLost then
   499             if not YouWon and not YouLost then
   479                 local nooDistance = 500
   500                 local nooDistance = 500