share/hedgewars/Data/Missions/Challenge/User_Mission_-_That_Sinking_Feeling.lua
changeset 14475 2113296b7a29
parent 14464 ead8928a59f8
child 14482 d4aa64f51c9f
equal deleted inserted replaced
14474:2c3fb87ad1c5 14475:2113296b7a29
     1 
     1 
     2 
     2 
     3 HedgewarsScriptLoad("/Scripts/Locale.lua")
     3 HedgewarsScriptLoad("/Scripts/Locale.lua")
       
     4 HedgewarsScriptLoad("/Scripts/Utils.lua")
     4 HedgewarsScriptLoad("/Scripts/Achievements.lua")
     5 HedgewarsScriptLoad("/Scripts/Achievements.lua")
     5 
     6 
     6 local player
     7 local player
     7 local hh = {}
     8 local hh = {}
     8 local hhCount = 8
     9 local hhCount = 8
    13 local waterPix = 0
    14 local waterPix = 0
    14 local frig = 0
    15 local frig = 0
    15 local watGear = nil
    16 local watGear = nil
    16 local cinematic = false
    17 local cinematic = false
    17 
    18 
       
    19 function printMission()
       
    20 	local highscore = tonumber(GetMissionVar("Highscore"))
       
    21 	local show = (type(highscore) == "number") and (highscore > 0)
       
    22 	local recordInfo = ""
       
    23 	if show then
       
    24 		recordInfo = getReadableChallengeRecord("Highscore")
       
    25 	end
       
    26 	ShowMission(loc("That Sinking Feeling"), loc("Challenge"), loc("Save as many hapless hogs as possible!")
       
    27 	.. "|" .. recordInfo, 4, 0)
       
    28 end
       
    29 
    18 -- allow skipping of the intro via hitting precise key
    30 -- allow skipping of the intro via hitting precise key
    19 function onPrecise()
    31 function onPrecise()
    20 	if introStage < 100 then
    32 	if introStage < 100 then
    21 		introStage = 110
    33 		introStage = 110
    22 		genCounter = 0
    34 		genCounter = 0
    23 		FollowGear(CurrentHedgehog)
    35 		FollowGear(CurrentHedgehog)
    24 		AddCaption(loc("Good luck out there!"))
    36 		AddCaption(loc("Good luck out there!"))
    25 		ShowMission(loc("That Sinking Feeling"), loc("Challenge"), loc("Save as many hapless hogs as possible!"), 4, 0)
    37 		printMission()
    26 		SetInputMask(0xFFFFFFFF)
    38 		SetInputMask(0xFFFFFFFF)
    27 	end
    39 	end
    28 end
    40 end
    29 
    41 
    30 function onGameInit()
    42 function onGameInit()
    68 	SetInputMask(gmPrecise)
    80 	SetInputMask(gmPrecise)
    69 end
    81 end
    70 
    82 
    71 
    83 
    72 function onGameStart()
    84 function onGameStart()
    73     cinematic = true
    85 	cinematic = true
    74     SetCinematicMode(true)
    86 	SetCinematicMode(true)
    75 	SendHealthStatsOff()
    87 	SendHealthStatsOff()
    76 
    88 
    77 	ShowMission(loc("That Sinking Feeling"), loc("Challenge"), loc("Save as many hapless hogs as possible!"), 4, 1)
    89 	printMission()
       
    90 	HideMission()
    78 
    91 
    79 	HogTurnLeft(hh[0], false)
    92 	HogTurnLeft(hh[0], false)
    80 	HogTurnLeft(hh[1], true)
    93 	HogTurnLeft(hh[1], true)
    81 
    94 
    82 	SpawnSupplyCrate(148,265,amLowGravity)
    95 	SpawnSupplyCrate(148,265,amLowGravity)
   239 					end
   252 					end
   240 				end
   253 				end
   241 
   254 
   242 				SendStat(siCustomAchievement, string.format(loc("You saved %d of 8 Hapless Hogs."), hhLeft))
   255 				SendStat(siCustomAchievement, string.format(loc("You saved %d of 8 Hapless Hogs."), hhLeft))
   243 
   256 
       
   257 				-- Update highscore
       
   258 				updateChallengeRecord("Highscore", hhLeft)
       
   259 
   244 				if hhLeft == 8 then
   260 				if hhLeft == 8 then
   245 					SaveMissionVar("Won", "true")
   261 					SaveMissionVar("Won", "true")
   246 					awardAchievement(loc("Lively Lifeguard"))
   262 					awardAchievement(loc("Lively Lifeguard"))
   247 				end
   263 				end
   248 				EndGame()
   264 				EndGame()
   291 		else
   307 		else
   292 			SendStat(siCustomAchievement, loc("You haven't rescued anyone."))
   308 			SendStat(siCustomAchievement, loc("You haven't rescued anyone."))
   293 		end
   309 		end
   294 		SendStat(siPointType, loc("points"))
   310 		SendStat(siPointType, loc("points"))
   295 		SendStat(siPlayerKills, "0", loc("Nameless Heroes"))
   311 		SendStat(siPlayerKills, "0", loc("Nameless Heroes"))
       
   312 		local highscore = tonumber(GetMissionVar("Highscore"))
       
   313 		show = (type(highscore) == "number") and (highscore > 0)
       
   314 		updateChallengeRecord("Highscore", 0, show)
   296 
   315 
   297 		SendStat(siGameResult, loc("Disqualified!"))
   316 		SendStat(siGameResult, loc("Disqualified!"))
   298 		GameOver = true
   317 		GameOver = true
   299 		EndGame()
   318 		EndGame()
   300 	end
   319 	end