ACF, mission 3: Fix victory causing a lot of loser message being displayed. Also add EndTurn()
authorWuzzy <almikes@aol.com>
Fri, 28 Apr 2017 04:42:04 +0200
changeset 12380 3126214d0e7d
parent 12379 ad481d9d48fb
child 12381 c80c51f59a98
ACF, mission 3: Fix victory causing a lot of loser message being displayed. Also add EndTurn()
share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/journey.lua
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/journey.lua	Fri Apr 28 03:02:15 2017 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/journey.lua	Fri Apr 28 04:42:04 2017 +0200
@@ -45,6 +45,7 @@
 denseDead = false
 princessDead = false
 cyborgDead = false
+victory = false
 cannibalDead = {}
 hedgeHidden = {}
 
@@ -81,7 +82,7 @@
 --/////////////////////////Animation Functions///////////////////////
 function AfterMidFailAnim()
   DismissTeam(loc("Natives"))
-  TurnTimeLeft = 0
+  EndTurn(0)
 end
 
 function AfterMidAnimAlone()
@@ -221,7 +222,7 @@
   AddEvent(CheckTookGirder2, {}, DoTookGirder2, {}, 0)
   SetGearMessage(leaks, 0)
   SetGearMessage(dense, 0)
-  TurnTimeLeft = 0
+  EndTurn(0)
   ShowMission(loc("The Journey Back"), loc("The Savior"), loc("Get Dense Cloud out of the pit!"), 1, 5000)
 end
 
@@ -240,7 +241,7 @@
   AddEvent(CheckTookFire, {}, DoTookFire, {}, 0)
   SetGearMessage(leaks, 0)
   SetGearMessage(dense, 0)
-  TurnTimeLeft = 0
+  EndTurn(true)
   ShowMission(loc("The Journey Back"), loc("They never learn"), loc("Free Dense Cloud and continue the mission!"), 1, 5000)
 end
 
@@ -569,7 +570,7 @@
 
 function KillPrincess()
   DismissTeam(loc("Cannibal Sentry"))
-  TurnTimeLeft = 0
+  EndTurn(true)
 end
 --/////////////////////////////Misc Functions////////////////////////
 
@@ -778,7 +779,7 @@
 end
 
 function DoDensePit()
-  TurnTimeLeft = 0
+  EndTurn(0)
   RestoreHedge(cyborg)
   AnimWait(cyborg, 1)
   AddFunction({func = AddAnim, args = {outPitAnim}})
@@ -794,7 +795,7 @@
 end
 
 function DoPastFlower()
-  TurnTimeLeft = 0
+  EndTurn(true)
   RestoreHedge(cyborg)
   AnimWait(cyborg, 1)
   AddFunction({func = AddAnim, args = {pastFlowerAnim}})
@@ -843,7 +844,7 @@
 end
 
 function DoOnBridge()
-  TurnTimeLeft = 0
+  EndTurn(true)
   RestoreHedge(cyborg)
   RestoreHedge(princess)
   AnimWait(cyborg, 1)
@@ -874,7 +875,7 @@
 end
 
 function DoTookSniper()
-  TurnTimeLeft = 0
+  EndTurn(true)
   RestoreHedge(cyborg)
   RestoreHedge(princess)
   AnimWait(cyborg, 1)
@@ -887,7 +888,7 @@
 end
 
 function DoTookSniper2()
-  TurnTimeLeft = 0
+  EndTurn(true)
   RestoreHedge(cyborg)
   RestoreHedge(princess)
   AnimWait(cyborg, 1)
@@ -909,6 +910,7 @@
 end
 
 function DoWon()
+  victory = true
   if progress and progress<3 then
     SaveCampaignVar("Progress", "3")
   end
@@ -920,7 +922,7 @@
   SwitchHog(leaks)
   DismissTeam(loc("Cannibal Sentry"))
   DismissTeam(loc("011101001"))
-  TurnTimeLeft = 0
+  EndTurn(true)
 end
 
 function CheckFailedCourse()
@@ -928,7 +930,7 @@
 end
 
 function DoFailedCourse()
-  TurnTimeLeft = 0
+  EndTurn(true)
   RestoreHedge(cyborg)
   RestoreHedge(princess)
   AnimWait(cyborg, 1)
@@ -1007,13 +1009,13 @@
     fireTaken = true
   elseif gear == gravityCrate then
     gravityTaken = true
-  elseif gear == leaks then
+  elseif gear == leaks and not victory then
     leaksDead = true
-  elseif gear == dense then
+  elseif gear == dense and not victory then
     denseDead = true
   elseif gear == cyborg then
     cyborgDead = true
-  elseif gear == princess then
+  elseif gear == princess and not victory then
     princessDead = true
   elseif gear == girderCrate then
     girderTaken = true
@@ -1046,11 +1048,14 @@
   SetAmmo(amSniperRifle, 0, 0, 0, 1)
   SetAmmo(amDynamite, 0, 0, 0, 1)
   SetAmmo(amPickHammer, 0, 0, 0, 1)
+  SetAmmo(amTeleport, 9, 0, 0, 1)
 end
 
 function onNewTurn()
   if AnimInProgress() then
     TurnTimeLeft = -1
+  elseif victory then
+    EndTurn(true)
   elseif stage == endStage and CurrentHedgehog ~= leaks then
     AnimSwitchHog(leaks)
     SetGearMessage(leaks, 0)