ACF5: Fix crash when skipping wave2 cut sequence with cyborg
authorWuzzy <Wuzzy2@mail.ru>
Mon, 08 Apr 2019 20:58:41 +0200
changeset 14779 d0ad9fd923fd
parent 14778 a9f32ff53389
child 14780 09d46ab83361
ACF5: Fix crash when skipping wave2 cut sequence with cyborg
share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/backstab.lua
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/backstab.lua	Mon Apr 08 19:16:02 2019 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/backstab.lua	Mon Apr 08 20:58:41 2019 +0200
@@ -410,9 +410,11 @@
       table.insert(wave2DeadAnim, {func = AnimCustomFunction, args = {natives[wiseNum], RestoreCyborg, {}}})
       table.insert(wave2DeadAnim, {func = AnimOutOfNowhere, swh = false, args = {cyborg, cyborgPos2[1], cyborgPos2[2]}})
       table.insert(wave2DeadAnim, {func = AnimTurn, args = {cyborg, "Left"}})
-      table.insert(wave2DeadAnim, {func = AnimCustomFunction, args = {cyborg, IsolateNatives, {}}})
-      table.insert(wave2DeadAnim, {func = AnimCustomFunction, args = {cyborg, PutCGI, {}}})
-      table.insert(wave2DeadAnim, {func = AnimSay, args = {cyborg, loc("I want to see how it handles this!"), SAY_SAY, 6000}})
+      if nativesNum > 1 then
+        table.insert(wave2DeadAnim, {func = AnimCustomFunction, args = {cyborg, IsolateNatives, {}}})
+        table.insert(wave2DeadAnim, {func = AnimCustomFunction, args = {cyborg, PutCGI, {}}})
+        table.insert(wave2DeadAnim, {func = AnimSay, args = {cyborg, loc("I want to see how it handles this!"), SAY_SAY, 6000}})
+      end
       table.insert(wave2DeadAnim, {func = AnimSwitchHog, args = {deployedHog}})
       table.insert(wave2DeadAnim, {func = AnimDisappear, args = {cyborg, 0, 0}})
 --      table.insert(wave2DeadAnim, {func = AnimCustomFunction, args = {cyborg, DeployHog, {}}})
@@ -623,10 +625,12 @@
 
 function SkipWave2DeadAnim()
   TeleportNatives()
+  TurnNatives()
   PutCircles()
   DeployHog()
-  IsolateNatives()
-  HideCyborg()
+  if nativesNum > 1 then
+    IsolateNatives()
+  end
 end
 
 function SpawnPlatformCrates()
@@ -646,6 +650,7 @@
   AddEvent(CheckTurnsOver, {}, DoTurnsOver, {3}, 0)
   AddEvent(CheckWaveDead, {3}, DoWaveDead, {3}, 0)
   AddEvent(CheckDeployedDead, {}, DoDeployedDead, {}, 0)
+  HideCyborg()
   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