add bonuses spacecampaign
authorPeriklis Ntanasis <pntanasis@gmail.com>
Mon, 16 Sep 2013 05:22:40 +0300
branchspacecampaign
changeset 9630 df942cfac4e6
parent 9629 1655c50d9c51
child 9631 a9b7bfac05ee
add bonuses
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death01.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death02.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert01.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert03.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit02.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit03.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/global_functions.lua
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death01.lua	Mon Sep 16 04:04:15 2013 +0300
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death01.lua	Mon Sep 16 05:22:40 2013 +0300
@@ -178,6 +178,12 @@
 	AddAmmo(hero.gear, amGrenade, 6)
 	AddAmmo(hero.gear, amDEagle, 4)
 	AddAmmo(hero.gear, amSkip, 100)
+	local bonus = tonumber(getBonus(3))
+	if bonus > 0 then
+		SetHealth(hero.gear, 120)
+		AddAmmo(hero.gear, amLaserSight, 1)
+		saveBonus(3, bonus-1)
+	end
 	-- evil ammo
 	AddAmmo(professor.gear, amRope, 4)
 	AddAmmo(professor.gear, amBazooka, 8)
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death02.lua	Mon Sep 16 04:04:15 2013 +0300
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death02.lua	Mon Sep 16 05:22:40 2013 +0300
@@ -185,6 +185,7 @@
 end
 
 function heroWin(gear)
+	saveBonus(3, 4)
 	SendStat('siGameResult', loc("Congratulations, you won!")) --1
 	SendStat('siCustomAchievement', loc("You complete the mission in "..TotalRounds.." rounds")) --11			
 	-- TODO SendStat('siCustomAchievement', loc("You have gained some extra life")) --11		
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert01.lua	Mon Sep 16 04:04:15 2013 +0300
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert01.lua	Mon Sep 16 05:22:40 2013 +0300
@@ -208,6 +208,7 @@
 		AddAmmo(hero.gear, amParachute, 1)
 		AddAmmo(hero.gear, amGrenade, 6)
 		AddAmmo(hero.gear, amDEagle, 4)
+		AddAmmo(hero.gear, amRCPlane, tonumber(getBonus(1)))
 	
 		AddAnim(dialog01)
 	elseif checkPointReached == 2 or checkPointReached == 3 then
@@ -472,10 +473,11 @@
 	-- save checkpoint
 	saveCheckpoint(cpoint)	
 	SaveCampaignVar("HeroHealth", GetHealth(hero.gear))
-	-- bazooka - grenade - rope - parachute - deagle - btorch - construct - portal
+	-- bazooka - grenade - rope - parachute - deagle - btorch - construct - portal - rcplane
 	SaveCampaignVar("HeroAmmo", GetAmmoCount(hero.gear, amBazooka)..GetAmmoCount(hero.gear, amGrenade)..
 			GetAmmoCount(hero.gear, amRope)..GetAmmoCount(hero.gear, amParachute)..GetAmmoCount(hero.gear, amDEagle)..
-			GetAmmoCount(hero.gear, amBlowTorch)..GetAmmoCount(hero.gear, amConstruction)..GetAmmoCount(hero.gear, amPortalGun))
+			GetAmmoCount(hero.gear, amBlowTorch)..GetAmmoCount(hero.gear, amConstruction)..
+			GetAmmoCount(hero.gear, amPortalGun)..GetAmmoCount(hero.gear, amRCPlane))
 	AnimCaption(hero.gear, loc("Checkpoint reached!"), 5000)
 end
 
@@ -493,6 +495,7 @@
 		AddAmmo(hero.gear, amConstruction, tonumber(ammo:sub(7,7)))
 	end
 	AddAmmo(hero.gear, amPortalGun, tonumber(ammo:sub(8,8)))
+	AddAmmo(hero.gear, amRCPlane, tonumber(ammo:sub(9,9)))
 end
 
 function checkForWin()
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert03.lua	Mon Sep 16 04:04:15 2013 +0300
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert03.lua	Mon Sep 16 05:22:40 2013 +0300
@@ -207,6 +207,7 @@
 end
 
 function win()
+	saveBonus(1, 1)
 	SendStat('siGameResult', loc("Congratulations, you are the best!")) --1
 	SendStat('siCustomAchievement', loc("You have destroyed all the targets")) --11	
 	SendStat('siCustomAchievement', loc("You are indeed the best PAotH pilot")) --11
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit02.lua	Mon Sep 16 04:04:15 2013 +0300
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit02.lua	Mon Sep 16 05:22:40 2013 +0300
@@ -278,8 +278,13 @@
 	SetAmmo(amDEagle, 0, 0, 0, 6)
 	SetAmmo(amGirder, 0, 0, 0, 2)
 	SetAmmo(amRope, 0, 0, 0, 1)
-	SetAmmo(amWatermelon, 0, 0, 0, 1)
-	SetAmmo(amSniperRifle, 0, 0, 0, 1)
+	if tonumber(getBonus(2)) == 1 then
+		SetAmmo(amWatermelon, 0, 0, 0, 2)
+		SetAmmo(amSniperRifle, 0, 0, 0, 2)
+	else
+		SetAmmo(amWatermelon, 0, 0, 0, 1)
+		SetAmmo(amSniperRifle, 0, 0, 0, 1)
+	end
 end
 
 function onPrecise()
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit03.lua	Mon Sep 16 04:04:15 2013 +0300
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit03.lua	Mon Sep 16 05:22:40 2013 +0300
@@ -211,6 +211,7 @@
 end
 
 function heroWin(gear)
+	saveBonus(2, 1)
 	SendStat('siGameResult', loc("Congratulations, you won!")) --1
 	SendStat('siCustomAchievement', loc("You complete the mission in "..TotalRounds.." rounds")) --11			
 	-- TODO SendStat('siCustomAchievement', loc("You will gain some extra ammo the next time you play the Getting to the device mission")) --11		
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/global_functions.lua	Mon Sep 16 04:04:15 2013 +0300
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/global_functions.lua	Mon Sep 16 05:22:40 2013 +0300
@@ -65,3 +65,31 @@
 function saveCheckpoint(cp)
 	SaveCampaignVar("CurrentMissionCheckpoint", cp)
 end
+
+-- saves what bonuses are available
+-- times is how many times the bonus will be available, this will be mission specific
+function saveBonus(index, times)
+	--        1         2        3
+	-- order: desert03, fruit03, death02
+	local bonus = "000"
+	if tonumber(GetCampaignVar("SideMissionsBonuses")) then
+		bonus = GetCampaignVar("SideMissionsBonuses")
+	end
+	if i == 1 then
+		bonus = times..bonus:sub(index+1)
+	elseif i == bonus:len() then
+		bonus = bonus:sub(1,index-1)..times
+	else
+		bonus = bonus:sub(1,index-1)..times..bonus:sub(index+1)
+	end
+	SaveCampaignVar("SideMissionsBonuses",bonus)
+end
+
+function getBonus(index)
+	local bonus = 0
+	if tonumber(GetCampaignVar("SideMissionsBonuses")) then
+		bonusString = GetCampaignVar("SideMissionsBonuses")
+		bonus = bonusString:sub(index,index)
+	end
+	return bonus
+end