ASA, ice02: Display current flying time next to team bar
authorWuzzy <Wuzzy2@mail.ru>
Sat, 29 Sep 2018 22:20:19 +0200
changeset 13820 bf8c454a9f93
parent 13819 25de751feb02
child 13821 373813316812
ASA, ice02: Display current flying time next to team bar
ChangeLog.txt
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice02.lua
--- a/ChangeLog.txt	Sat Sep 29 21:59:36 2018 +0200
+++ b/ChangeLog.txt	Sat Sep 29 22:20:19 2018 +0200
@@ -90,6 +90,7 @@
 Campaigns and missions:
  * A Classic Fairytale: Fix clan membership of princess in some missions
  * A Classic Fairytale, Mission 5: Tribe was not in same clan as Natives, screwing up stats a bit
+ * A Space Adventure, Hard Flying: Display current flying time next to team bar
  + A Space Adventure, final mission: Terrain types are easier to distinguish
  * A Space Adventure, Searching in the Dust: Fix display error when destroying device crate
  * A Space Adventure, Searching in the Dust: Don't take away control right above the pit near Sandy
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice02.lua	Sat Sep 29 21:59:36 2018 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice02.lua	Sat Sep 29 22:20:19 2018 +0200
@@ -13,10 +13,11 @@
 local missionName = loc("Hard flying")
 local challengeStarted = false
 local currentWaypoint = 1
-local radius = 75
-local totalTime = 15000
+local radius = 75 -- Ring radius. Will become smaller and smaller
+local totalTime = 15000 -- Total available time. Initial value is start time; is added to later when player wins extra time
 local totalSaucers = 3
 local gameEnded = false
+local heroTurn = false
 local RED = 0xff0000ff
 local GREEN = 0x00ff00ff
 local challengeObjectives = loc("To win the game you have to pass into the rings in time.")..
@@ -45,7 +46,6 @@
 teamB.name = loc("Allies")
 teamB.color = -6
 -- way points
-local current waypoint = 1
 local waypoints = {
 	[1] = {x=1450, y=140},
 	[2] = {x=990, y=580},
@@ -69,7 +69,7 @@
 function onGameInit()
 	GameFlags = gfInvulnerable + gfOneClanMode
 	Seed = 1
-	TurnTime = 15000
+	TurnTime = totalTime
 	Ready = 25000
 	CaseFreq = 0
 	MinesNum = 0
@@ -132,6 +132,7 @@
 	elseif not hero.dead and CurrentHedgehog == hero.gear and challengeStarted then
 		SetWeapon(amJetpack)
 	end
+	heroTurn = CurrentHedgehog == hero.gear
 end
 
 function onGameTick()
@@ -152,6 +153,7 @@
 			local totalTimePrinted  = totalTime / 1000
 			local saucersLeft = GetAmmoCount(hero.gear, amJetpack)
 			local saucersUsed = totalSaucers - saucersLeft
+			SetTeamLabel(teamA.name, string.format(loc("%.3f s"), totalTimePrinted))
 			SendStat(siGameResult, loc("Hooray! You are a champion!"))
 			SendStat(siCustomAchievement, string.format(loc("You completed the mission in %.3f seconds."), totalTimePrinted))
 			if timeRecord ~= nil and totalTime >= timeRecord then
@@ -175,9 +177,15 @@
 			SendStat(siPlayerKills, totalTime, GetHogTeamName(hero.gear))
 			SaveCampaignVar("Mission6Won", "true")
 			checkAllMissionsCompleted()
+			SetTurnTimeLeft(MAX_TURN_TIME)
 			EndGame()
 		end
 	end
+	if heroTurn and challengeStarted and not gameEnded and not hero.dead and ReadyTimeLeft == 0 then
+		local time = totalTime - TurnTimeLeft
+		local timePrinted  = time / 1000
+		SetTeamLabel(teamA.name, string.format(loc("%.1f s"), timePrinted))
+	end
 end
 
 function onGearDelete(gear)