some changes regarding hp save in cosmos and moon spacecampaign
authorPeriklis Ntanasis <pntanasis@gmail.com>
Wed, 18 Sep 2013 04:24:10 +0300
branchspacecampaign
changeset 9640 a6a903a6c2b3
parent 9639 6b2ae2eaf1b2
child 9641 b08c8bde57e3
some changes regarding hp save in cosmos and moon
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/cosmos.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon01.lua
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/cosmos.lua	Wed Sep 18 04:02:13 2013 +0300
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/cosmos.lua	Wed Sep 18 04:24:10 2013 +0300
@@ -370,6 +370,7 @@
 			SaveCampaignVar("HeroHealth",GetHealth(hero.gear))
 		end
 		AnimCaption(hero.gear,loc("Welcome to the moon!"))
+		SaveCampaignVar("HeroHealth", GetHealth(hero.gear))
 		SaveCampaignVar("Planet", "moon")
 		SaveCampaignVar("UnlockedMissions", "3")
 		SaveCampaignVar("Mission1", "2")
@@ -447,6 +448,7 @@
 end
 
 function meteoriteLanding(gear)
+	-- first two conditionals are not possible but I'll leave it there...
 	if checkPointReached < 5 then
 		AddAnim(dialog06)
 	elseif not (status.fruit02 and status.ice01 and status.desert01) then
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon01.lua	Wed Sep 18 04:02:13 2013 +0300
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon01.lua	Wed Sep 18 04:24:10 2013 +0300
@@ -107,7 +107,7 @@
 	Theme = "Cheese" -- Because ofc moon is made of cheese :)
 	-- Hog Solo
 	AddTeam(teamD.name, teamD.color, "Bone", "Island", "HillBilly", "cm_birdy")
-	if GetCampaignVar("HeroHealth") and string.len(GetCampaignVar("HeroHealth")) > 0 then
+	if tonumber(GetCampaignVar("HeroHealth")) then
 		hero.gear = AddHog(hero.name, 0, tonumber(GetCampaignVar("HeroHealth")), "war_desertgrenadier1")
 	else
 		hero.gear = AddHog(hero.name, 0, 100, "war_desertgrenadier1")
@@ -150,6 +150,11 @@
 		-- Start of the game
 	elseif checkPointReached == 2 then
 		AnimSetGearPosition(hero.gear, parachuteX, weaponsY)
+		if GetHealth(hero.gear) + 5 > 100 then			
+			SaveCampaignVar("HeroHealth", 100)
+		else
+			SaveCampaignVar("HeroHealth", GetHealth(hero.gear) + 5)
+		end
 	end
 	
 	AnimInit()