# HG changeset patch # User Periklis Ntanasis # Date 1377486816 -10800 # Node ID 16139270448f7c1326ecab70be7ea81c3503efd4 # Parent 8d8bad7d78dea77c952b29ac9cde6e674130fb5e save main missions' status diff -r 8d8bad7d78de -r 16139270448f share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/cosmos.lua --- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/cosmos.lua Mon Aug 26 02:08:11 2013 +0300 +++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/cosmos.lua Mon Aug 26 06:13:36 2013 +0300 @@ -15,6 +15,7 @@ HedgewarsScriptLoad("/Scripts/Locale.lua") HedgewarsScriptLoad("/Scripts/Animate.lua") +HedgewarsScriptLoad("/Missions/Campaign/A_Space_Adventure/global_functions.lua") ----------------- VARIABLES -------------------- -- globals @@ -22,6 +23,7 @@ local timeForGuard1ToTurn = 1000 * 5 -- 5 sec local timeForGuard1ToTurnLeft = timeForGuard1ToTurn local saucerAcquired = false +local status local checkPointReached = 1 -- 1 is start of the game -- dialogs local dialog01 = {} @@ -30,11 +32,13 @@ local dialog04 = {} local dialog05 = {} local dialog06 = {} +local dialog07 = {} -- mission objectives local goals = { [dialog01] = {missionName, loc("Getting ready"), loc("Go and collect the crate").."|"..loc("Try not to get spotted by the guards!"), 1, 4500}, [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}, - [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} + [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}, + [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} } -- crates local saucerX = 3270 @@ -102,7 +106,8 @@ AnimSetGearPosition(guard1.gear, guard1.x, guard1.y) guard2.gear = AddHog(guard2.name, 1, 100, "policecap") AnimSetGearPosition(guard2.gear, guard2.x, guard2.y) - + -- completed main missions + status = getCompletedStatus() -- get the check point if tonumber(GetCampaignVar("CosmosCheckPoint")) then checkPointReached = tonumber(GetCampaignVar("CosmosCheckPoint")) @@ -128,6 +133,8 @@ AnimSetGearPosition(hero.gear, 2400, 375) elseif GetCampaignVar("Planet") == "icePlanet" then AnimSetGearPosition(hero.gear, 1440, 260) + elseif GetCampaignVar("Planet") == "deathPlanet" then + AnimSetGearPosition(hero.gear, 620, 530) end end @@ -282,7 +289,7 @@ end function onDeathPlanetLanding(gear) - if GetHealth(hero.gear) and GetX(gear) > 310 and GetX(gear) < 675 and GetY(gear) < 400 and StoppedGear(gear) then + if GetHealth(hero.gear) and GetX(gear) > 310 and GetX(gear) < 700 and GetY(gear) < 760 and StoppedGear(gear) then return true end return false @@ -383,6 +390,8 @@ function deathPlanetLanding(gear) if checkPointReached < 5 then AddAnim(dialog06) + elseif not (status.fruit02 and status.ice01 and status.deset01) then + AddAnim(dialog07) else AnimCaption(hero.gear,loc("Welcome to the Death Planet!")) SaveCampaignVar("Planet", "deathPlanet") @@ -464,6 +473,10 @@ table.insert(dialog06, {func = AnimCaption, args = {hero.gear, loc("You have to try again!"), 5000}}) table.insert(dialog06, {func = AnimSay, args = {hero.gear, loc("Hm... Now I run out of fuels..."), SAY_THINK, 3000}}) table.insert(dialog06, {func = EndGame, args = {hero.gear}}) + -- DIALOG 07 - Hero lands on Death Planet but isn't allowed yet to play this map + AddSkipFunction(dialog07, Skipanim, {dialog07}) + table.insert(dialog07, {func = AnimCaption, args = {hero.gear, loc("This planet seems dangerous!"), 5000}}) + 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}}) end ------------------- custom "animation" functions -------------------------- diff -r 8d8bad7d78de -r 16139270448f share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death01.lua --- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death01.lua Mon Aug 26 02:08:11 2013 +0300 +++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death01.lua Mon Aug 26 06:13:36 2013 +0300 @@ -7,6 +7,7 @@ HedgewarsScriptLoad("/Scripts/Locale.lua") HedgewarsScriptLoad("/Scripts/Animate.lua") +HedgewarsScriptLoad("/Missions/Campaign/A_Space_Adventure/global_functions.lua") ----------------- VARIABLES -------------------- -- globals @@ -249,6 +250,7 @@ end function enemiesDeath(gear) + saveCompletedStatus(6) SendStat('siGameResult', loc("Congratulations, you won!")) --1 SendStat('siCustomAchievement', loc("You have successfuly eliminated Professor Hogevil")) --11 SendStat('siCustomAchievement', loc("You have rescued H and Dr.Cornelius")) --11 diff -r 8d8bad7d78de -r 16139270448f share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert01.lua --- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert01.lua Mon Aug 26 02:08:11 2013 +0300 +++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert01.lua Mon Aug 26 06:13:36 2013 +0300 @@ -13,6 +13,7 @@ HedgewarsScriptLoad("/Scripts/Locale.lua") HedgewarsScriptLoad("/Scripts/Animate.lua") +HedgewarsScriptLoad("/Missions/Campaign/A_Space_Adventure/global_functions.lua") ----------------- VARIABLES -------------------- -- globals @@ -496,6 +497,7 @@ cratesFound = cratesFound + 1 elseif cratesFound == 1 then -- end game + saveCompletedStatus(5) AnimSay(hero.gear, loc("Hoo Ray!!!"), SAY_SHOUT, 5000) SendStat('siGameResult', loc("Congratulations, you won!")) --1 SendStat('siCustomAchievement', loc("To win the game you had to collect the 2 crates with no specific order")) --11 diff -r 8d8bad7d78de -r 16139270448f share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit01.lua --- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit01.lua Mon Aug 26 02:08:11 2013 +0300 +++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit01.lua Mon Aug 26 06:13:36 2013 +0300 @@ -21,6 +21,7 @@ HedgewarsScriptLoad("/Scripts/Locale.lua") HedgewarsScriptLoad("/Scripts/Animate.lua") +HedgewarsScriptLoad("/Missions/Campaign/A_Space_Adventure/global_functions.lua") ----------------- VARIABLES -------------------- -- globals @@ -326,6 +327,7 @@ function battleWin(gear) -- add stats + saveVariables() SendStat('siGameResult', loc("Green Bananas won!")) --1 SendStat('siCustomAchievement', loc("You have eliminated all the visible enemy hogs!")) --11 SendStat('siPlayerKills','1',teamA.name) @@ -336,6 +338,7 @@ function escapeWin(gear) -- add stats + saveVariables() SendStat('siGameResult', loc("Hog Solo escaped successfully!")) --1 SendStat('siCustomAchievement', loc("You have reached the flying area successfully!")) --11 SendStat('siPlayerKills','1',teamA.name) @@ -472,3 +475,11 @@ end end end + +function saveVariables() + saveCompletedStatus(2) + SaveCampaignVar("UnlockedMissions", "3") + SaveCampaignVar("Mission1", "3") + SaveCampaignVar("Mission2", "8") + SaveCampaignVar("Mission3", "1") +end diff -r 8d8bad7d78de -r 16139270448f share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit02.lua --- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit02.lua Mon Aug 26 02:08:11 2013 +0300 +++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit02.lua Mon Aug 26 06:13:36 2013 +0300 @@ -5,6 +5,7 @@ HedgewarsScriptLoad("/Scripts/Locale.lua") HedgewarsScriptLoad("/Scripts/Animate.lua") +HedgewarsScriptLoad("/Missions/Campaign/A_Space_Adventure/global_functions.lua") ----------------- VARIABLES -------------------- -- globals @@ -420,6 +421,7 @@ function captainLimeDeath(gear) -- hero win in scenario of escape in 1st part + saveCompletedStatus(3) SendStat('siGameResult', loc("Congratulations, you won!")) --1 SendStat('siCustomAchievement', loc("You retrieved the lost part")) --11 SendStat('siCustomAchievement', loc("You defended yourself against Captain Lime")) --11 @@ -430,6 +432,7 @@ function redTeamDeath(gear) -- hero win in battle scenario + saveCompletedStatus(3) SendStat('siGameResult', loc("Congratulations, you won!")) --1 SendStat('siCustomAchievement', loc("You retrieved the lost part")) --11 SendStat('siCustomAchievement', loc("You defended yourself against Strawberry Assasins")) --11 diff -r 8d8bad7d78de -r 16139270448f share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/global_functions.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/global_functions.lua Mon Aug 26 06:13:36 2013 +0300 @@ -0,0 +1,52 @@ +function saveCompletedStatus(planetNum) + -- 1 2 3 4 5 6 + -- order: moon01, fruit01, fruit02, ice01, desert01, death01 + local status = "000000" + if tonumber(GetCampaignVar("MainMissionsStatus")) then + status = GetCampaignVar("MainMissionsStatus") + end + if i == 1 then + status = "1"..status:sub(planetNum+1) + elseif i == status:len() then + status = status:sub(1,planetNum-1).."1" + else + status = status:sub(1,planetNum-1).."1"..status:sub(planetNum+1) + end + SaveCampaignVar("MainMissionsStatus",status) +end + +function getCompletedStatus() + local allStatus = "" + if tonumber(GetCampaignVar("MainMissionsStatus")) then + allStatus = GetCampaignVar("MainMissionsStatus") + end + local status = { + moon01 = false, + fruit01 = false, + fruit02 = false, + ice01 = false, + desert01 = false, + death01 = false + } + if allStatus ~= "" then + if allStatus:sub(1,1) == "1" then + status.moon01 = true + end + if allStatus:sub(2,2) == "1" then + status.fuit01 = true + end + if allStatus:sub(3,3) == "1" then + status.fruit02 = true + end + if allStatus:sub(4,4) == "1" then + status.ice01 = true + end + if allStatus:sub(5,5) == "1" then + status.desert01 = true + end + if allStatus:sub(6,6) == "1" then + status.death01 = true + end + end + return status +end diff -r 8d8bad7d78de -r 16139270448f share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice01.lua --- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice01.lua Mon Aug 26 02:08:11 2013 +0300 +++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice01.lua Mon Aug 26 06:13:36 2013 +0300 @@ -11,6 +11,7 @@ HedgewarsScriptLoad("/Scripts/Locale.lua") HedgewarsScriptLoad("/Scripts/Animate.lua") +HedgewarsScriptLoad("/Missions/Campaign/A_Space_Adventure/global_functions.lua") ----------------- VARIABLES -------------------- -- globals @@ -500,7 +501,7 @@ -------------- Other Functions ------------------- function actionsOnWin() - SaveCampaignVar("IcePlanetPartAcquired", "true") + saveCompletedStatus(4) SendStat('siGameResult', loc("Congratulations, you got the part!")) --1 SendStat('siCustomAchievement', loc("At the end of the game your health was ")..GetHealth(hero.gear)) --11 -- maybe add number of tries for each part? diff -r 8d8bad7d78de -r 16139270448f share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon01.lua --- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon01.lua Mon Aug 26 02:08:11 2013 +0300 +++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon01.lua Mon Aug 26 06:13:36 2013 +0300 @@ -17,6 +17,7 @@ HedgewarsScriptLoad("/Scripts/Locale.lua") HedgewarsScriptLoad("/Scripts/Animate.lua") +HedgewarsScriptLoad("/Missions/Campaign/A_Space_Adventure/global_functions.lua") ----------------- VARIABLES -------------------- -- globals @@ -364,6 +365,7 @@ AnimCaption(hero.gear, loc("Congrats! You made them run away!"), 6000) AnimWait(hero.gear,5000) + saveCompletedStatus(1) SendStat('siGameResult', loc("Hog Solo win, conrgatulations!")) --1 SendStat('siCustomAchievement', loc("Eliminated the professor Hogevil")) --11 SendStat('siCustomAchievement', loc("Drove the minions away")) --11 @@ -380,6 +382,7 @@ AnimCaption(hero.gear, loc("Congrats! You won!"), 6000) AnimWait(hero.gear,5000) + saveCompletedStatus(1) SendStat('siGameResult', loc("Congratulations, you won!")) --1 SendStat('siCustomAchievement', loc("Eliminated the evil minions")) --11 SendStat('siCustomAchievement', loc("Drove the professor away")) --11