Get rid of some incorrect timeout messages in ACF, by using EndTurn(true)
authorWuzzy <almikes@aol.com>
Thu, 27 Apr 2017 23:47:44 +0200
changeset 12369 5857936921ec
parent 12368 6ad1f86e0c81
child 12370 92b4bab79c26
Get rid of some incorrect timeout messages in ACF, by using EndTurn(true)
share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/backstab.lua
share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/enemy.lua
share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/epil.lua
share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/family.lua
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/backstab.lua	Thu Apr 27 22:47:14 2017 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/backstab.lua	Thu Apr 27 23:47:44 2017 +0200
@@ -581,7 +581,7 @@
   AddEvent(CheckTurnsOver, {}, DoTurnsOver, {3}, 0)
   AddEvent(CheckWaveDead, {3}, DoWaveDead, {3}, 0)
   AddEvent(CheckDeployedDead, {}, DoDeployedDead, {}, 0)
-  TurnTimeLeft = 0
+  EndTurn(true)
   ShowMission(loc("Backstab"), loc("Drills"), loc("You have 7 turns until the next wave arrives.|Make sure the arriving cannibals are greeted appropriately!|If the hog dies, the cause is lost.|Hint: you might want to use some mines..."), 1, 12000)
 end
 
@@ -610,7 +610,7 @@
 
 function AfterStartAnim()
   AnimSwitchHog(natives[leaksNum])
-  TurnTimeLeft = 0
+  EndTurn(true)
   stage = spyKillStage
   AddEvent(CheckChoice, {}, DoChoice, {}, 0)
   AddEvent(CheckKilledOther, {}, DoKilledOther, {}, 0)
@@ -632,7 +632,7 @@
   DismissTeam(loc("Natives"))
   DismissTeam(loc("Tribe"))
   DismissTeam(loc("011101001"))
-  TurnTimeLeft = 0
+  EndTurn(true)
 end
 
 function CheckChoice()
@@ -676,7 +676,7 @@
   ShowMission(loc("Backstab"), loc("Brutus"), loc("You have killed an innocent hedgehog!"), 0, 6000)
   DismissTeam(loc("Natives"))
   DismissTeam(loc("Tribe"))
-  TurnTimeLeft = 0
+  EndTurn(true)
 end
 
 function CheckWaveDead(index)
@@ -689,7 +689,7 @@
 end
 
 function DoWaveDead(index)
-  TurnTimeLeft = 0
+  EndTurn(true)
   needToAct = index
 end
 
@@ -786,7 +786,7 @@
   DismissTeam(loc("Assault Team"))
   DismissTeam(loc("Reinforcements"))
   DismissTeam(loc("011101001"))
-  TurnTimeLeft = 0
+  EndTurn(true)
 end
 
 -----------------------------Misc--------------------------------------
@@ -1059,7 +1059,7 @@
   end
 
   if GetHogTeamName(CurrentHedgehog) == loc("Tribe") then
-    TurnTimeLeft = 0
+    EndTurn(true)
     return
   end
   TurnsLeft = TurnsLeft - 1
@@ -1070,7 +1070,7 @@
 
   if stage == spyKillStage then
     if CurrentHedgehog == spyHog or GetHogTeamName(CurrentHedgehog) ~= loc("Natives") then
-      TurnTimeLeft = 0
+      EndTurn(true)
     else
       SetGearMessage(CurrentHedgehog, 0)
       --AnimSwitchHog(natives[leaksNum])
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/enemy.lua	Thu Apr 27 22:47:14 2017 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/enemy.lua	Thu Apr 27 23:47:44 2017 +0200
@@ -286,7 +286,7 @@
   ShowMission(loc("The Enemy Of My Enemy"), loc("The Union"), loc("Defeat the cyborgs!"), 1, 0)
   PutWeaponCrates()
   PutHealthCrates()
-  TurnTimeLeft = 0
+  EndTurn(true)
 end
 
 function PutHealthCrates()
@@ -331,12 +331,12 @@
 
 function DoNativesDead()
   nativesDeadFresh = true
-  TurnTimeLeft = 0
+  EndTurn(true)
 end
 
 function DoCannibalsDead()
   cannibalsDeadFresh = true
-  TurnTimeLeft = 0
+  EndTurn(true)
 end
 
 function DoPlayersDead()
@@ -344,14 +344,14 @@
   RemoveEventFunc(CheckCannibalsDead)
   RemoveEventFunc(CheckCyborgsDead)
   playersDeadFresh = true
-  TurnTimeLeft = 0
+  EndTurn(true)
 end
 
 function DoCyborgsDead()
 --  RemoveEventFunc(CheckNativesDead)
 --  RemoveEventFunc(CheckCannibalsDead)
   cyborgsDeadFresh= true
-  TurnTimeLeft = 0
+  EndTurn(true)
 end
 
 function CheckGearsDead(gearList)
@@ -388,7 +388,7 @@
   DismissTeam(loc("Natives"))
   DismissTeam(loc("Cannibals"))
   DismissTeam(loc("011101001"))
-  TurnTimeLeft = 0
+  EndTurn(true)
 end
 
 function WonMission()
@@ -404,7 +404,7 @@
     SaveCampaignVar("Progress", "9")
   end
   DismissTeam(loc("011101001"))
-  TurnTimeLeft = 0
+  EndTurn(true)
 end
 -----------------------------Misc--------------------------------------
 function HideHedge(hedge)
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/epil.lua	Thu Apr 27 22:47:14 2017 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/epil.lua	Thu Apr 27 23:47:44 2017 +0200
@@ -81,7 +81,7 @@
   crate = SpawnHealthCrate(0, 0)
   SetGearMessage(CurrentHedgehog, 0)
   AddNewEvent(CheckCrateTaken, {}, DoCrateTaken, {}, 1)
-  TurnTimeLeft = 0
+  EndTurn(true)
   ShowMission(loc("Epilogue"), loc("That's all, folks!"),
     loc("You have successfully finished the campaign!").."|"..
     loc("If you wish to replay, there are other possible endings, too!").."|"..
@@ -427,7 +427,7 @@
     return
   end
   if CurrentHedgehog == traitor then
-    TurnTimeLeft = 0
+    EndTurn(true)
   else
     TurnTimeLeft = -1
   end
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/family.lua	Thu Apr 27 22:47:14 2017 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/family.lua	Thu Apr 27 23:47:44 2017 +0200
@@ -100,6 +100,8 @@
 freshDead = nil
 crates = {}
 cratesNum = 0
+
+princessFreed = false
 -----------------------------Animations--------------------------------
 function EmitDenseClouds(dir)
   local dif
@@ -185,7 +187,7 @@
   SetupPlace3()
   SetGearMessage(natives[1], 0)
   AddNewEvent(CheckPrincessFreed, {}, DoPrincessFreed, {}, 0)
-  TurnTimeLeft = 0
+  EndTurn(true)
   ShowMission(loc("Family Reunion"), loc("Salvation"), loc("Get your teammates out of their natural prison and save the princess!|Hint: Drilling holes should solve everything.|Hint: It might be a good idea to place a girder before starting to drill. Just saying.|Hint: All your hedgehogs need to be above the marked height!|Hint: Leaks A Lot needs to get really close to the princess!"), 1, 7000)
   vCirc = AddVisualGear(0,0,vgtCircle,0,true)
   SetVisualGearValues(vCirc, 2625, 1500, 100, 255, 1, 10, 0, 120, 3, 0xff00ffff)
@@ -287,8 +289,9 @@
   if progress and progress<7 then
     SaveCampaignVar("Progress", "7")
   end
+  princessFreed = true
   DismissTeam(loc("011101001"))
-  TurnTimeLeft = 0
+  EndTurn(true)
 end
 
 function CheckCyborgsDead()
@@ -337,11 +340,13 @@
 end
 
 function EndMission()
-  RemoveEventFunc(CheckPrincessFreed)
-  AddCaption(loc("So the princess was never heard of again ..."))
-  DismissTeam(loc("Natives"))
-  DismissTeam(loc("011101001"))
-  TurnTimeLeft = 0
+  if not princessFreed then
+    RemoveEventFunc(CheckPrincessFreed)
+    AddCaption(loc("So the princess was never heard of again ..."))
+    DismissTeam(loc("Natives"))
+    DismissTeam(loc("011101001"))
+    EndTurn(true)
+  end
 end
 
 function CheckOutOfCluster()
@@ -546,7 +551,7 @@
         end
       end
     end
-    TurnTimeLeft = 0
+    EndTurn(true)
   else
     for i = 1, 3 do
       if gearDead[natives[i]] ~= true then