stats in case of win spacecampaign
authorPeriklis Ntanasis <pntanasis@gmail.com>
Mon, 05 Aug 2013 16:44:56 +0300
branchspacecampaign
changeset 9463 653af9cec589
parent 9461 0058a9863724
child 9465 38c9982e6556
stats in case of win
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice02.lua
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice02.lua	Sat Aug 03 04:02:43 2013 +0300
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice02.lua	Mon Aug 05 16:44:56 2013 +0300
@@ -13,6 +13,9 @@
 local challengeStarted = false
 local currentWaypoint = 1
 local radius = 75
+local totalTime = 15000
+local totalSaucers = 3
+local gameEnded = false
 -- dialogs
 local dialog01 = {}
 -- mission objectives
@@ -90,7 +93,7 @@
 	
 	AddEvent(onHeroDeath, {hero.gear}, heroDeath, {hero.gear}, 0)
 	
-	AddAmmo(hero.gear, amJetpack, 2)
+	AddAmmo(hero.gear, amJetpack, 3)
 	
 	-- place a waypoint
 	placeNextWaypoint()
@@ -116,8 +119,18 @@
 
 function onGameTick20()
 	if checkIfHeroInWaypoint() then
-		if not placeNextWaypoint() then
+		if not gameEnded and not placeNextWaypoint() then
+			gameEnded = true
 			-- GAME OVER, WIN!
+			totalTime = totalTime - TurnTimeLeft
+			totalTime = totalTime / 1000
+			local saucersLeft = GetAmmoCount(hero.gear, amJetpack)
+			local saucersUsed = totalSaucers - saucersLeft
+			SendStat('siGameResult', loc("Hoo Ray! You are a champion!")) --1
+			SendStat('siCustomAchievement', loc("You complete the mission in "..totalTime.." seconds")) --11			
+			SendStat('siCustomAchievement', loc("You have used "..saucersUsed.." flying saucers")) --11			
+			SendStat('siCustomAchievement', loc("You had "..saucersLeft.." more flying saucers left")) --11			
+			SendStat('siPlayerKills','1',teamA.name)
 			EndGame()
 		end
 	end
@@ -193,12 +206,15 @@
 		-- add bonus time and "fuel"
 		if currentWaypoint % 2 == 0 then
 			AddAmmo(hero.gear, amJetpack, GetAmmoCount(hero.gear, amJetpack)+1)
-			if TurnTimeLeft <= 20000 then
+			totalSaucers = totalSaucers + 1
+			if TurnTimeLeft <= 22000 then
 				TurnTimeLeft = TurnTimeLeft + 8000
+				totalTime = totalTime + 8000
 			end		
 		else
-			if TurnTimeLeft <= 14000 then
+			if TurnTimeLeft <= 16000 then
 				TurnTimeLeft = TurnTimeLeft + 6000
+				totalTime = totalTime + 6000
 			end
 		end	
 		radius = radius - 4