Complete space campaign's spacetrip mission if all main+side missions are completed
authorWuzzy <almikes@aol.com>
Sun, 20 Nov 2016 04:08:21 +0100
changeset 11970 72be38f6d0c0
parent 11969 f3c1679694d3
child 11971 5d0e25bd876a
Complete space campaign's spacetrip mission if all main+side missions are completed
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/cosmos.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death02.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert02.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert03.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/final.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit03.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/global_functions.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice02.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon02.lua
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/cosmos.lua	Sun Nov 20 03:43:27 2016 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/cosmos.lua	Sun Nov 20 04:08:21 2016 +0100
@@ -606,6 +606,9 @@
 	SendStat(siCustomAchievement, loc("You can choose another planet by replaying this mission."))
 	SendStat(siCustomAchievement, loc("Planets with completed main missions will be marked with a flower."))
 	SendStat(siCustomAchievement, loc("Planets with all missions completed will be marked with two flowers."))
+	if GetCampaignVar("Won") == "true" and GetCampaignVar("Mission1Won") ~= "true" then
+		SendStat(siCustomAchievement, loc("Complete all main and side missions to complete the spacetrip mission."))
+	end
 	SendStat(siPlayerKills,'1',teamC.name)
 	EndGame()
 end
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death02.lua	Sun Nov 20 03:43:27 2016 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death02.lua	Sun Nov 20 04:08:21 2016 +0100
@@ -201,6 +201,7 @@
 	SendStat(siCustomAchievement, loc("The next 4 times you play the \"The last encounter\" mission you'll get 20 more hit points and a laser sight."))
 	SendStat(siPlayerKills,'1',teamA.name)
 	SaveCampaignVar("Mission11Won", "true")
+	checkAllMissionsCompleted()
 	EndGame()
 end
 
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert02.lua	Sun Nov 20 03:43:27 2016 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert02.lua	Sun Nov 20 04:08:21 2016 +0100
@@ -167,6 +167,7 @@
 	end
 	SendStat(siPlayerKills,'0',teamA.name)
 	SaveCampaignVar("Mission7Won", "true")
+	checkAllMissionsCompleted()
 	EndGame()
 end
 
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert03.lua	Sun Nov 20 03:43:27 2016 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert03.lua	Sun Nov 20 04:08:21 2016 +0100
@@ -214,6 +214,7 @@
 	SendStat(siCustomAchievement, loc("Next time you play \"Searching in the dust\" you'll have an RC plane available."))
 	SendStat(siPlayerKills,'1',teamA.name)
 	SaveCampaignVar("Mission12Won", "true")
+	checkAllMissionsCompleted()
 	EndGame()
 end
 
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/final.lua	Sun Nov 20 03:43:27 2016 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/final.lua	Sun Nov 20 04:08:21 2016 +0100
@@ -151,8 +151,8 @@
 
 function heroWin(gear)
 	saveCompletedStatus(7)
-	SaveCampaignVar("Mission1Won", "true")
 	SaveCampaignVar("Won", "true")
+	checkAllMissionsCompleted()
 	SendStat(siGameResult, loc("Congratulations, you have saved Hogera!"))
 	SendStat(siCustomAchievement, loc("Hogera is safe!"))
 	SendStat(siPlayerKills,'1',teamA.name)
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit03.lua	Sun Nov 20 03:43:27 2016 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit03.lua	Sun Nov 20 04:08:21 2016 +0100
@@ -227,6 +227,7 @@
 	SendStat(siCustomAchievement, loc("You will gain some extra ammo from the crates the next time you play the \"Getting to the device\" mission."))
 	SendStat(siPlayerKills,'1',teamA.name)
 	SaveCampaignVar("Mission10Won", "true")
+	checkAllMissionsCompleted()
 	EndGame()
 end
 
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/global_functions.lua	Sun Nov 20 03:43:27 2016 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/global_functions.lua	Sun Nov 20 04:08:21 2016 +0100
@@ -1,3 +1,5 @@
+local missionsNum = 14
+
 function saveCompletedStatus(planetNum)
 	--        1       2        3        4      5         6        7
 	-- order: moon01, fruit01, fruit02, ice01, desert01, death01, final
@@ -29,6 +31,21 @@
 		status = status:sub(1,planetNum-1).."1"..status:sub(planetNum+1)
 	end
 	SaveCampaignVar("MainMissionsStatus",status)
+
+	checkAllMissionsCompleted()
+end
+
+function checkAllMissionsCompleted()
+	local allMissions = true
+	for i=2, missionsNum do
+		if GetCampaignVar("Mission"..i.."Won") ~= "true" then
+			allMissions = false
+			break
+		end
+	end
+	if allMissions then
+		SaveCampaignVar("Mission1Won", "true")
+	end
 end
 
 function getCompletedStatus()
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice02.lua	Sun Nov 20 03:43:27 2016 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice02.lua	Sun Nov 20 04:08:21 2016 +0100
@@ -160,6 +160,7 @@
 
 			SendStat(siPlayerKills,'0',teamA.name)
 			SaveCampaignVar("Mission6Won", "true")
+			checkAllMissionsCompleted()
 			EndGame()
 		end
 	end
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon02.lua	Sun Nov 20 03:43:27 2016 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon02.lua	Sun Nov 20 04:08:21 2016 +0100
@@ -255,5 +255,6 @@
 	-- siCustomAchievements were added earlier
 	SendStat(siPlayerKills,'0',teamA.name)
 	SaveCampaignVar("Mission13Won", "true")
+	checkAllMissionsCompleted()
 	EndGame()
 end