share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert02.lua
changeset 13839 373813316812
parent 13583 141cdfe0f3ca
child 14422 6c21bd8547dd
equal deleted inserted replaced
13838:bf8c454a9f93 13839:373813316812
     3 -- Hero has to get to the surface as soon as possible.
     3 -- Hero has to get to the surface as soon as possible.
     4 -- Tunnel is about to get flooded.
     4 -- Tunnel is about to get flooded.
     5 
     5 
     6 HedgewarsScriptLoad("/Scripts/Locale.lua")
     6 HedgewarsScriptLoad("/Scripts/Locale.lua")
     7 HedgewarsScriptLoad("/Scripts/Animate.lua")
     7 HedgewarsScriptLoad("/Scripts/Animate.lua")
       
     8 HedgewarsScriptLoad("/Scripts/Achievements.lua")
     8 HedgewarsScriptLoad("/Missions/Campaign/A_Space_Adventure/global_functions.lua")
     9 HedgewarsScriptLoad("/Missions/Campaign/A_Space_Adventure/global_functions.lua")
     9 
    10 
    10 ----------------- VARIABLES --------------------
    11 ----------------- VARIABLES --------------------
    11 -- globals
    12 -- globals
    12 local missionName = loc("Running for survival")
    13 local missionName = loc("Running for survival")
    15 local dialog01 = {}
    16 local dialog01 = {}
    16 -- mission objectives
    17 -- mission objectives
    17 local goals = {
    18 local goals = {
    18 	[dialog01] = {missionName, loc("Getting ready"), loc("Use the rope to quickly get to the surface!") .. "|" .. loc("Mines time: 1 second"), 1, 4500},
    19 	[dialog01] = {missionName, loc("Getting ready"), loc("Use the rope to quickly get to the surface!") .. "|" .. loc("Mines time: 1 second"), 1, 4500},
    19 }
    20 }
       
    21 -- For an achievement/award (see below)
       
    22 local cratesCollected = 0
       
    23 local totalCrates = 0
       
    24 local damageTaken = false
    20 -- health crates
    25 -- health crates
    21 healthX = 565
    26 healthX = 565
    22 health1Y = 1400
    27 health1Y = 1400
    23 health2Y = 850
    28 health2Y = 850
    24 -- hogs
    29 -- hogs
   119 end
   124 end
   120 
   125 
   121 function onGearAdd(gear)
   126 function onGearAdd(gear)
   122 	if GetGearType(gear) == gtRope then
   127 	if GetGearType(gear) == gtRope then
   123 		HideMission()
   128 		HideMission()
       
   129 	elseif GetGearType(gear) == gtCase then
       
   130 		totalCrates = totalCrates + 1
   124 	end
   131 	end
   125 end
   132 end
   126 
   133 
   127 function onGearDelete(gear)
   134 function onGearDelete(gear)
   128 	if gear == hero.gear then
   135 	if gear == hero.gear then
   129 		hero.dead = true
   136 		hero.dead = true
       
   137 		damageTaken = true
       
   138 	end
       
   139 	-- Crate collected
       
   140 	if GetGearType(gear) == gtCase and band(GetGearMessage(gear), gmDestroy) ~= 0 then
       
   141 		cratesCollected = cratesCollected + 1
       
   142 	end
       
   143 end
       
   144 
       
   145 function onGearDamage(gear)
       
   146 	if gear == hero.gear then
       
   147 		damageTaken = true
   130 	end
   148 	end
   131 end
   149 end
   132 
   150 
   133 function onPrecise()
   151 function onPrecise()
   134 	if GameTime > 3000 then
   152 	if GameTime > 3000 then
   174 	if record == nil or TotalRounds < record then
   192 	if record == nil or TotalRounds < record then
   175 		SaveCampaignVar("FastestMineEscape", tostring(TotalRounds))
   193 		SaveCampaignVar("FastestMineEscape", tostring(TotalRounds))
   176 		if record ~= nil then
   194 		if record ~= nil then
   177 			SendStat(siCustomAchievement, loc("This is a new personal best, congratulations!"))
   195 			SendStat(siCustomAchievement, loc("This is a new personal best, congratulations!"))
   178 		end
   196 		end
       
   197 	end
       
   198 	-- Achievement awarded for escaping with all crates collected and no damage taken
       
   199 	if (not damageTaken) and (cratesCollected >= totalCrates) then
       
   200 		awardAchievement(loc("Better Safe Than Sorry"))
   179 	end
   201 	end
   180 	sendSimpleTeamRankings({teamA.name})
   202 	sendSimpleTeamRankings({teamA.name})
   181 	SaveCampaignVar("Mission7Won", "true")
   203 	SaveCampaignVar("Mission7Won", "true")
   182 	checkAllMissionsCompleted()
   204 	checkAllMissionsCompleted()
   183 	EndGame()
   205 	EndGame()