share/hedgewars/Data/Missions/Challenge/User_Mission_-_That_Sinking_Feeling.lua
changeset 14487 d4aa64f51c9f
parent 14480 2113296b7a29
child 14489 764ba6182389
equal deleted inserted replaced
14486:65b25ca6ff31 14487:d4aa64f51c9f
     3 HedgewarsScriptLoad("/Scripts/Locale.lua")
     3 HedgewarsScriptLoad("/Scripts/Locale.lua")
     4 HedgewarsScriptLoad("/Scripts/Utils.lua")
     4 HedgewarsScriptLoad("/Scripts/Utils.lua")
     5 HedgewarsScriptLoad("/Scripts/Achievements.lua")
     5 HedgewarsScriptLoad("/Scripts/Achievements.lua")
     6 
     6 
     7 local player
     7 local player
       
     8 local playerTeamName, haplessTeamName
     8 local hh = {}
     9 local hh = {}
     9 local hhCount = 8
    10 local hhCount = 8
    10 local GameOver = false
    11 local GameOver = false
    11 local introStage = 0
    12 local introStage = 0
    12 local genCounter = 0
    13 local genCounter = 0
    21 	local show = (type(highscore) == "number") and (highscore > 0)
    22 	local show = (type(highscore) == "number") and (highscore > 0)
    22 	local recordInfo = ""
    23 	local recordInfo = ""
    23 	if show then
    24 	if show then
    24 		recordInfo = getReadableChallengeRecord("Highscore")
    25 		recordInfo = getReadableChallengeRecord("Highscore")
    25 	end
    26 	end
    26 	ShowMission(loc("That Sinking Feeling"), loc("Challenge"), loc("Save as many hapless hogs as possible!")
    27 	ShowMission(loc("That Sinking Feeling"), loc("Challenge"), loc("Save as many hogs as possible!")
    27 	.. "|" .. recordInfo, 4, 0)
    28 	.. "|" .. recordInfo, 4, 0)
    28 end
    29 end
    29 
    30 
    30 -- allow skipping of the intro via hitting precise key
    31 -- allow skipping of the intro via hitting precise key
    31 function onPrecise()
    32 function onPrecise()
    51 	Map = "Islands"
    52 	Map = "Islands"
    52 	Theme = "City"
    53 	Theme = "City"
    53 	HealthDecrease = 0
    54 	HealthDecrease = 0
    54 	WaterRise = 0
    55 	WaterRise = 0
    55 
    56 
    56 	AddTeam(loc("Hapless Hogs"), -1, "Simple", "Island", "Default")
    57 	local idx = AddTeam(loc("Hapless Hogs"), -1, "Simple", "Island", "Default")
       
    58 	haplessTeamName = GetTeamName(idx)
    57 	hh[0] = AddHog(loc("Sinky"), 1, 100, "fr_lemon")
    59 	hh[0] = AddHog(loc("Sinky"), 1, 100, "fr_lemon")
    58 	hh[1] = AddHog(loc("Drowner"), 1, 100, "fr_orange")
    60 	hh[1] = AddHog(loc("Drowner"), 1, 100, "fr_orange")
    59 	hh[2] = AddHog(loc("Heavy"), 1, 100, "dish_Teapot")
    61 	hh[2] = AddHog(loc("Heavy"), 1, 100, "dish_Teapot")
    60 	hh[3] = AddHog(loc("Clumsy"), 1, 100, "dish_SauceBoatSilver")
    62 	hh[3] = AddHog(loc("Clumsy"), 1, 100, "dish_SauceBoatSilver")
    61 	hh[4] = AddHog(loc("Silly"), 1, 100, "dish_Ladle")
    63 	hh[4] = AddHog(loc("Silly"), 1, 100, "dish_Ladle")
    62 	hh[5] = AddHog(loc("Careless"), 1, 100, "StrawHatEyes")
    64 	hh[5] = AddHog(loc("Careless"), 1, 100, "StrawHatEyes")
    63 	hh[6] = AddHog(loc("Sponge"), 1, 100, "sf_chunli")
    65 	hh[6] = AddHog(loc("Sponge"), 1, 100, "sf_chunli")
    64 	hh[7] = AddHog(loc("Deadweight"), 1, 100, "dish_Teacup")
    66 	hh[7] = AddHog(loc("Deadweight"), 1, 100, "dish_Teacup")
    65 
    67 
    66 	AddTeam(loc("Nameless Heroes"), -1, "Simple", "Island", "Default", "cm_crossedswords")
    68 	idx = AddMissionTeam(-1)
    67 	player = AddHog(loc("The Nameless One"), 0, 1, "NoHat")
    69 	playerTeamName = GetTeamName(idx)
       
    70 	player = AddMissionHog(1)
    68 
    71 
    69 	SetGearPosition(player, 3992, 733)
    72 	SetGearPosition(player, 3992, 733)
    70 	SetGearPosition(hh[0], 938, 1369)
    73 	SetGearPosition(hh[0], 938, 1369)
    71 	SetGearPosition(hh[1], 1301, 1439)
    74 	SetGearPosition(hh[1], 1301, 1439)
    72 	SetGearPosition(hh[2], 2093, 447)
    75 	SetGearPosition(hh[2], 2093, 447)
   211 		elseif introStage == 7 then
   214 		elseif introStage == 7 then
   212 
   215 
   213 			if genCounter == 2000 then
   216 			if genCounter == 2000 then
   214 				introStage = 110
   217 				introStage = 110
   215 				FollowGear(CurrentHedgehog)
   218 				FollowGear(CurrentHedgehog)
   216 				ShowMission(loc("That Sinking Feeling"), loc("User Challenge"), loc("Save as many hapless hogs as possible!"), 4, 0)
   219 				ShowMission(loc("That Sinking Feeling"), loc("User Challenge"), loc("Save as many hogs as possible!"), 4, 0)
   217 				SetInputMask(0xFFFFFFFF)
   220 				SetInputMask(0xFFFFFFFF)
   218 			end
   221 			end
   219 
   222 
   220 		end
   223 		end
   221 
   224 
   239 			if (waterPix >= 1615) and (GameOver == false) then
   242 			if (waterPix >= 1615) and (GameOver == false) then
   240 				GameOver = true
   243 				GameOver = true
   241 				AddCaption(loc("The flood has stopped! Challenge over."))
   244 				AddCaption(loc("The flood has stopped! Challenge over."))
   242 				SendStat(siGameResult, loc("Challenge completed!"))
   245 				SendStat(siGameResult, loc("Challenge completed!"))
   243 				SendStat(siPointType, loc("rescues"))
   246 				SendStat(siPointType, loc("rescues"))
   244 				SendStat(siPlayerKills, tostring(hhCount), loc("Nameless Heroes"))
   247 				SendStat(siPlayerKills, tostring(hhCount), playerTeamName)
   245 
   248 
   246 				-- Do not count drowning hedgehogs
   249 				-- Do not count drowning hedgehogs
   247 				local hhLeft = hhCount
   250 				local hhLeft = hhCount
   248 				for i=1,#hh do
   251 				for i=1,#hh do
   249 					local isDrowning = band(GetState(hh[i]),gstDrowning) ~= 0
   252 					local isDrowning = band(GetState(hh[i]),gstDrowning) ~= 0
   250 					if isDrowning then
   253 					if isDrowning then
   251 						hhLeft = hhLeft - 1
   254 						hhLeft = hhLeft - 1
   252 					end
   255 					end
   253 				end
   256 				end
   254 
   257 
   255 				SendStat(siCustomAchievement, string.format(loc("You saved %d of 8 Hapless Hogs."), hhLeft))
   258 				SendStat(siCustomAchievement, string.format(loc("You saved %d of 8 hegehogs."), hhLeft))
   256 
   259 
   257 				-- Update highscore
   260 				-- Update highscore
   258 				updateChallengeRecord("Highscore", hhLeft)
   261 				updateChallengeRecord("Highscore", hhLeft)
   259 
   262 
   260 				if hhLeft == 8 then
   263 				if hhLeft == 8 then
   290 end
   293 end
   291 
   294 
   292 function onGearDelete(gear)
   295 function onGearDelete(gear)
   293 
   296 
   294 	if GetGearType(gear) == gtHedgehog then
   297 	if GetGearType(gear) == gtHedgehog then
   295 		if GetHogTeamName(gear) == loc("Hapless Hogs") then
   298 		if GetHogTeamName(gear) == haplessTeamName then
   296 			hhCount = hhCount - 1
   299 			hhCount = hhCount - 1
   297 			AddCaption(string.format(loc("%d Hapless Hogs left"), hhCount))
   300 			AddCaption(string.format(loc("Hedgehogs left: %d"), hhCount))
   298 		end
   301 		end
   299 	end
   302 	end
   300 
   303 
   301 	if ((gear == player) or (hhCount == 0)) and (GameOver == false) then
   304 	if ((gear == player) or (hhCount == 0)) and (GameOver == false) then
   302 		SetHealth(player, 0)
   305 		SetHealth(player, 0)
   306 			SendStat(siCustomAchievement, loc("You must survive the flood in order to score."))
   309 			SendStat(siCustomAchievement, loc("You must survive the flood in order to score."))
   307 		else
   310 		else
   308 			SendStat(siCustomAchievement, loc("You haven't rescued anyone."))
   311 			SendStat(siCustomAchievement, loc("You haven't rescued anyone."))
   309 		end
   312 		end
   310 		SendStat(siPointType, loc("points"))
   313 		SendStat(siPointType, loc("points"))
   311 		SendStat(siPlayerKills, "0", loc("Nameless Heroes"))
   314 		SendStat(siPlayerKills, "0", playerTeamName)
   312 		local highscore = tonumber(GetMissionVar("Highscore"))
   315 		local highscore = tonumber(GetMissionVar("Highscore"))
   313 		show = (type(highscore) == "number") and (highscore > 0)
   316 		show = (type(highscore) == "number") and (highscore > 0)
   314 		updateChallengeRecord("Highscore", 0, show)
   317 		updateChallengeRecord("Highscore", 0, show)
   315 
   318 
   316 		SendStat(siGameResult, loc("Disqualified!"))
   319 		SendStat(siGameResult, loc("Disqualified!"))