ASA ice02: Clean up some subtle weirdness on timeout
authorWuzzy <Wuzzy2@mail.ru>
Thu, 03 Jan 2019 22:44:09 +0100
changeset 14515 b54ba97c02d7
parent 14514 5ac181cb2396
child 14516 f5487302d53b
ASA ice02: Clean up some subtle weirdness on timeout When time's up or player lost, do this: - Remove all rings - Don't give time or saucer bonus when touching ring *after* timeout - Prevent next turn from starting
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice02.lua
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice02.lua	Thu Jan 03 19:46:48 2019 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice02.lua	Thu Jan 03 22:44:09 2019 +0100
@@ -127,6 +127,12 @@
 	AddAnim(dialog01)
 end
 
+function onEndTurn()
+	if not hero.dead and CurrentHedgehog == hero.gear and challengeStarted then
+		heroLost()
+	end
+end
+
 function onNewTurn()
 	if not hero.dead and CurrentHedgehog == ally.gear and challengeStarted then
 		heroLost()
@@ -185,6 +191,13 @@
 		local time = totalTime - TurnTimeLeft
 		local timePrinted  = time / 1000
 		SetTeamLabel(teamA.name, string.format(loc("%.1fs"), timePrinted))
+		if TurnTimeLeft <= 0 then
+			local wp = waypoints[currentWaypoint-1]
+			if wp ~= nil then
+				DeleteVisualGear(wp.gear)
+				DeleteVisualGear(wp.gear2)
+			end
+		end
 	end
 end
 
@@ -251,6 +264,9 @@
 end
 
 function placeNextWaypoint()
+	if gameEnded then
+		return
+	end
 	if currentWaypoint > 1 then
 		local wp = waypoints[currentWaypoint-1]
 		DeleteVisualGear(wp.gear)
@@ -308,7 +324,7 @@
 end
 
 function checkIfHeroInWaypoint()
-	if not hero.dead then
+	if (not hero.dead) and (TurnTimeLeft > 0) then
 		local wp = waypoints[currentWaypoint-1]
 		if gearIsInCircle(hero.gear, wp.x, wp.y, radius+4, false) then
 			SetWind(GetRandom(201)-100)
@@ -325,5 +341,6 @@
 	SendStat(siCustomAchievement, loc("Green double rings also give you a new flying saucer."))
 	SendStat(siCustomAchievement, loc("Use the attack key twice to change the flying saucer while being in air."))
 	sendSimpleTeamRankings({teamA.name})
+	gameEnded = true
 	EndGame()
 end