share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/cosmos.lua
branchspacecampaign
changeset 9578 16139270448f
parent 9574 da3d39667881
child 9580 49db7a78c2bd
equal deleted inserted replaced
9576:8d8bad7d78de 9578:16139270448f
    13 -- PROBLEM : What if one makes a bad choice and wants to replay it map, how to reset?
    13 -- PROBLEM : What if one makes a bad choice and wants to replay it map, how to reset?
    14 -- POSSIBLE SOLUTIONS: In game function keys, frontend button...
    14 -- POSSIBLE SOLUTIONS: In game function keys, frontend button...
    15 
    15 
    16 HedgewarsScriptLoad("/Scripts/Locale.lua")
    16 HedgewarsScriptLoad("/Scripts/Locale.lua")
    17 HedgewarsScriptLoad("/Scripts/Animate.lua")
    17 HedgewarsScriptLoad("/Scripts/Animate.lua")
       
    18 HedgewarsScriptLoad("/Missions/Campaign/A_Space_Adventure/global_functions.lua")
    18 
    19 
    19 ----------------- VARIABLES --------------------
    20 ----------------- VARIABLES --------------------
    20 -- globals
    21 -- globals
    21 local missionName = loc("Spacetrip")
    22 local missionName = loc("Spacetrip")
    22 local timeForGuard1ToTurn = 1000 * 5 -- 5 sec
    23 local timeForGuard1ToTurn = 1000 * 5 -- 5 sec
    23 local timeForGuard1ToTurnLeft = timeForGuard1ToTurn
    24 local timeForGuard1ToTurnLeft = timeForGuard1ToTurn
    24 local saucerAcquired = false
    25 local saucerAcquired = false
       
    26 local status
    25 local checkPointReached = 1 -- 1 is start of the game
    27 local checkPointReached = 1 -- 1 is start of the game
    26 -- dialogs
    28 -- dialogs
    27 local dialog01 = {}
    29 local dialog01 = {}
    28 local dialog02 = {}
    30 local dialog02 = {}
    29 local dialog03 = {}
    31 local dialog03 = {}
    30 local dialog04 = {}
    32 local dialog04 = {}
    31 local dialog05 = {}
    33 local dialog05 = {}
    32 local dialog06 = {}
    34 local dialog06 = {}
       
    35 local dialog07 = {}
    33 -- mission objectives
    36 -- mission objectives
    34 local goals = {
    37 local goals = {
    35 	[dialog01] = {missionName, loc("Getting ready"), loc("Go and collect the crate").."|"..loc("Try not to get spotted by the guards!"), 1, 4500},
    38 	[dialog01] = {missionName, loc("Getting ready"), loc("Go and collect the crate").."|"..loc("Try not to get spotted by the guards!"), 1, 4500},
    36 	[dialog02] = {missionName, loc("The adventure begins!"), loc("Use the saucer and fly to the moon").."|"..loc("Travel carefully as your fuels are limited"), 1, 4500},
    39 	[dialog02] = {missionName, loc("The adventure begins!"), loc("Use the saucer and fly to the moon").."|"..loc("Travel carefully as your fuels are limited"), 1, 4500},
    37 	[dialog03] = {missionName, loc("An unexpected event!"), loc("Use the saucer and fly away").."|"..loc("Beware, any damage taken will stay until you complete the moon mission"), 1, 7000}
    40 	[dialog03] = {missionName, loc("An unexpected event!"), loc("Use the saucer and fly away").."|"..loc("Beware, any damage taken will stay until you complete the moon mission"), 1, 7000},
       
    41 	[dialog07] = {missionName, loc("Searching the stars!"), loc("Use the saucer and fly away").."|"..loc("Visit first the planets of Ice, Desert and Fruit"), 1, 6000}
    38 }
    42 }
    39 -- crates
    43 -- crates
    40 local saucerX = 3270
    44 local saucerX = 3270
    41 local saucerY = 1500
    45 local saucerY = 1500
    42 -- hogs
    46 -- hogs
   100 	AddTeam(teamB.name, teamB.color, "Bone", "Island", "HillBilly", "cm_birdy")
   104 	AddTeam(teamB.name, teamB.color, "Bone", "Island", "HillBilly", "cm_birdy")
   101 	guard1.gear = AddHog(guard1.name, 1, 100, "policecap")
   105 	guard1.gear = AddHog(guard1.name, 1, 100, "policecap")
   102 	AnimSetGearPosition(guard1.gear, guard1.x, guard1.y)
   106 	AnimSetGearPosition(guard1.gear, guard1.x, guard1.y)
   103 	guard2.gear = AddHog(guard2.name, 1, 100, "policecap")
   107 	guard2.gear = AddHog(guard2.name, 1, 100, "policecap")
   104 	AnimSetGearPosition(guard2.gear, guard2.x, guard2.y)
   108 	AnimSetGearPosition(guard2.gear, guard2.x, guard2.y)
   105 	
   109 	-- completed main missions
       
   110 	status = getCompletedStatus()
   106 	-- get the check point
   111 	-- get the check point
   107 	if tonumber(GetCampaignVar("CosmosCheckPoint")) then
   112 	if tonumber(GetCampaignVar("CosmosCheckPoint")) then
   108 		checkPointReached = tonumber(GetCampaignVar("CosmosCheckPoint"))
   113 		checkPointReached = tonumber(GetCampaignVar("CosmosCheckPoint"))
   109 	end
   114 	end
   110 	-- do checkpoint stuff needed before game starts
   115 	-- do checkpoint stuff needed before game starts
   126 			AnimSetGearPosition(hero.gear, 3670, 270)
   131 			AnimSetGearPosition(hero.gear, 3670, 270)
   127 		elseif GetCampaignVar("Planet") == "fruitPlanet" then
   132 		elseif GetCampaignVar("Planet") == "fruitPlanet" then
   128 			AnimSetGearPosition(hero.gear, 2400, 375)
   133 			AnimSetGearPosition(hero.gear, 2400, 375)
   129 		elseif GetCampaignVar("Planet") == "icePlanet" then
   134 		elseif GetCampaignVar("Planet") == "icePlanet" then
   130 			AnimSetGearPosition(hero.gear, 1440, 260)
   135 			AnimSetGearPosition(hero.gear, 1440, 260)
       
   136 		elseif GetCampaignVar("Planet") == "deathPlanet" then
       
   137 			AnimSetGearPosition(hero.gear, 620, 530)
   131 		end
   138 		end
   132 	end
   139 	end
   133 	
   140 	
   134 	AnimInit()
   141 	AnimInit()
   135 	AnimationSetup()
   142 	AnimationSetup()
   280 	end
   287 	end
   281 	return false
   288 	return false
   282 end
   289 end
   283 
   290 
   284 function onDeathPlanetLanding(gear)
   291 function onDeathPlanetLanding(gear)
   285 	if GetHealth(hero.gear) and GetX(gear) > 310 and GetX(gear) < 675  and GetY(gear) < 400 and StoppedGear(gear) then
   292 	if GetHealth(hero.gear) and GetX(gear) > 310 and GetX(gear) < 700  and GetY(gear) < 760 and StoppedGear(gear) then
   286 		return true
   293 		return true
   287 	end
   294 	end
   288 	return false
   295 	return false
   289 end
   296 end
   290 
   297 
   381 end
   388 end
   382 
   389 
   383 function deathPlanetLanding(gear)
   390 function deathPlanetLanding(gear)
   384 	if checkPointReached < 5 then
   391 	if checkPointReached < 5 then
   385 		AddAnim(dialog06)
   392 		AddAnim(dialog06)
       
   393 	elseif not (status.fruit02 and status.ice01 and status.deset01) then
       
   394 		AddAnim(dialog07)
   386 	else
   395 	else
   387 		AnimCaption(hero.gear,loc("Welcome to the Death Planet!"))
   396 		AnimCaption(hero.gear,loc("Welcome to the Death Planet!"))
   388 		SaveCampaignVar("Planet", "deathPlanet")
   397 		SaveCampaignVar("Planet", "deathPlanet")
   389 		SaveCampaignVar("UnlockedMissions", "2")
   398 		SaveCampaignVar("UnlockedMissions", "2")
   390 		SaveCampaignVar("Mission1", "9")
   399 		SaveCampaignVar("Mission1", "9")
   462 	-- DIALOG 06 - Landing on wrong planet or on earth if not enough fuels
   471 	-- DIALOG 06 - Landing on wrong planet or on earth if not enough fuels
   463 	AddSkipFunction(dialog06, Skipanim, {dialog06})
   472 	AddSkipFunction(dialog06, Skipanim, {dialog06})
   464 	table.insert(dialog06, {func = AnimCaption, args = {hero.gear, loc("You have to try again!"),  5000}})
   473 	table.insert(dialog06, {func = AnimCaption, args = {hero.gear, loc("You have to try again!"),  5000}})
   465 	table.insert(dialog06, {func = AnimSay, args = {hero.gear, loc("Hm... Now I run out of fuels..."), SAY_THINK, 3000}})
   474 	table.insert(dialog06, {func = AnimSay, args = {hero.gear, loc("Hm... Now I run out of fuels..."), SAY_THINK, 3000}})
   466 	table.insert(dialog06, {func = EndGame, args = {hero.gear}})
   475 	table.insert(dialog06, {func = EndGame, args = {hero.gear}})
       
   476 	-- DIALOG 07 - Hero lands on Death Planet but isn't allowed yet to play this map
       
   477 	AddSkipFunction(dialog07, Skipanim, {dialog07})
       
   478 	table.insert(dialog07, {func = AnimCaption, args = {hero.gear, loc("This planet seems dangerous!"),  5000}})
       
   479 	table.insert(dialog07, {func = AnimSay, args = {hero.gear, loc("I am not ready for this planet yet. I should visit it when I have found all the other parts"), SAY_THINK, 4000}})
   467 end
   480 end
   468 
   481 
   469 ------------------- custom "animation" functions --------------------------
   482 ------------------- custom "animation" functions --------------------------
   470 
   483 
   471 function startCombat()
   484 function startCombat()