share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/cosmos.lua
changeset 12524 a5ddc6b4abbd
parent 12523 f2a19a6056be
child 12538 952afc3d2df2
equal deleted inserted replaced
12523:f2a19a6056be 12524:a5ddc6b4abbd
    53 local teamA = {}
    53 local teamA = {}
    54 local teamB = {}
    54 local teamB = {}
    55 local teamC = {}
    55 local teamC = {}
    56 -- to check if flying saucer is active
    56 -- to check if flying saucer is active
    57 local saucerGear = nil
    57 local saucerGear = nil
       
    58 -- if player abandoned any incomplete planet mission
       
    59 local abandonedPlanetMission = false
    58 -- hedgehogs values
    60 -- hedgehogs values
    59 hero.name = loc("Hog Solo")
    61 hero.name = loc("Hog Solo")
    60 hero.x = 1450
    62 hero.x = 1450
    61 hero.y = 1550
    63 hero.y = 1550
    62 director.name = loc("H")
    64 director.name = loc("H")
   154 		elseif GetCampaignVar("Planet") == "meteorite" then
   156 		elseif GetCampaignVar("Planet") == "meteorite" then
   155 			AnimSetGearPosition(hero.gear, 3080, 850)
   157 			AnimSetGearPosition(hero.gear, 3080, 850)
   156 		end
   158 		end
   157 	end
   159 	end
   158 	AnimInit(startSequence)
   160 	AnimInit(startSequence)
       
   161 
       
   162 	-- Reset checkpoint of other missions when entering this mission.
       
   163 	-- The player has left the planet, so we count that “abandoning” any incomplete missions.
       
   164 	-- This also allows the player (indirectly) to reset the checkpointed missions.
       
   165 	abandonedPlanetMission = resetCheckpoint()
       
   166 
   159 	AnimationSetup()
   167 	AnimationSetup()
   160 end
   168 end
   161 
   169 
   162 function onGameStart()
   170 function onGameStart()
   163 	-- wait for the first turn to start
   171 	-- wait for the first turn to start
   189 	elseif checkPointReached == 5 then
   197 	elseif checkPointReached == 5 then
   190 		-- Hero has visited a planet, he has plenty of fuels and can change planet
   198 		-- Hero has visited a planet, he has plenty of fuels and can change planet
   191 		AddAmmo(hero.gear, amJetpack, 100)
   199 		AddAmmo(hero.gear, amJetpack, 100)
   192 	end
   200 	end
   193 
   201 
   194 	-- Reset checkpoint of other missions when entering this mission.
       
   195 	-- The player has left the planet, so we count that “abandoning” any incomplete missions.
       
   196 	-- This also allows the player (indirectly) to reset the checkpointed missions.
       
   197 	abandoned = resetCheckpoint()
       
   198 
       
   199 	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
   202 	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
   200 	AddEvent(onNoFuelAtLand, {hero.gear}, noFuelAtLand, {hero.gear}, 0)
   203 	AddEvent(onNoFuelAtLand, {hero.gear}, noFuelAtLand, {hero.gear}, 0)
   201 	-- always check for landings
   204 	-- always check for landings
   202 	if GetCampaignVar("Planet") ~= "moon" then
   205 	if GetCampaignVar("Planet") ~= "moon" then
   203 		AddEvent(onMoonLanding, {hero.gear}, moonLanding, {hero.gear}, 0)
   206 		AddEvent(onMoonLanding, {hero.gear}, moonLanding, {hero.gear}, 0)
   253 
   256 
   254 function onAmmoStoreInit()
   257 function onAmmoStoreInit()
   255 	SetAmmo(amJetpack, 0, 0, 0, 1)
   258 	SetAmmo(amJetpack, 0, 0, 0, 1)
   256 end
   259 end
   257 
   260 
       
   261 local abandonCheck = false
       
   262 
   258 function onNewTurn()
   263 function onNewTurn()
       
   264 	if not abandonCheck and checkPointReached == 5 then
       
   265 		if abandonedPlanetMission then
       
   266 			HogSay(hero.gear, loc("I just forgot all checkpoints of incomplete missions."), SAY_THINK)
       
   267 		end
       
   268 		abandonCheck = false
       
   269 	end
       
   270 
   259 	if guard1.keepTurning then
   271 	if guard1.keepTurning then
   260 		AnimSwitchHog(hero.gear)
   272 		AnimSwitchHog(hero.gear)
   261 		TurnTimeLeft = -1
   273 		TurnTimeLeft = -1
   262 	end
   274 	end
   263 end
   275 end
   596 	table.insert(dialog04, {func = AnimSay, args = {guard2.gear, loc("We should better report this and continue our watch!"), SAY_SAY, 5000}})
   608 	table.insert(dialog04, {func = AnimSay, args = {guard2.gear, loc("We should better report this and continue our watch!"), SAY_SAY, 5000}})
   597 	table.insert(dialog04, {func = AnimSwitchHog, args = {hero.gear}})
   609 	table.insert(dialog04, {func = AnimSwitchHog, args = {hero.gear}})
   598 	-- DIALOG 05 - Hero returned from moon without fuels
   610 	-- DIALOG 05 - Hero returned from moon without fuels
   599 	AddSkipFunction(dialog05, Skipanim, {dialog05})
   611 	AddSkipFunction(dialog05, Skipanim, {dialog05})
   600 	table.insert(dialog05, {func = AnimSay, args = {hero.gear, loc("I guess I can't go far without fuel!"), SAY_THINK, 6000}})
   612 	table.insert(dialog05, {func = AnimSay, args = {hero.gear, loc("I guess I can't go far without fuel!"), SAY_THINK, 6000}})
       
   613 	if abandonedPlanetMission then
       
   614 		-- Hog solo is mad he has to play the moon main mission from start. Very sarcastic tone. ;-)
       
   615 		table.insert(dialog05, {func = AnimSay, args = {hero.gear, loc("And I just forgot the checkpoint of my main mission. Great, just great!"), SAY_THINK, 7000}})
       
   616 	end
   601 	table.insert(dialog05, {func = AnimSay, args = {hero.gear, loc("Got to go back."), SAY_THINK, 2000}})
   617 	table.insert(dialog05, {func = AnimSay, args = {hero.gear, loc("Got to go back."), SAY_THINK, 2000}})
   602 	table.insert(dialog05, {func = sendStatsOnRetry, args = {hero.gear}})
   618 	table.insert(dialog05, {func = sendStatsOnRetry, args = {hero.gear}})
   603 	-- DIALOG 06 - Landing on wrong planet or on earth if not enough fuels
   619 	-- DIALOG 06 - Landing on wrong planet or on earth if not enough fuels
   604 	AddSkipFunction(dialog06, Skipanim, {dialog06})
   620 	AddSkipFunction(dialog06, Skipanim, {dialog06})
   605 	table.insert(dialog06, {func = AnimSay, args = {hero.gear, loc("Hm ... Now I ran out of fuel."), SAY_THINK, 3000}})
   621 	table.insert(dialog06, {func = AnimSay, args = {hero.gear, loc("Hm ... Now I ran out of fuel."), SAY_THINK, 3000}})