ACF: Add some checks before calling StoppedGear
authorWuzzy <Wuzzy2@mail.ru>
Wed, 22 May 2019 11:31:55 +0200
changeset 15050 09c63d4bcf53
parent 15049 20c80919d97d
child 15051 2e89487540d8
ACF: Add some checks before calling StoppedGear
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/first_blood.lua
share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/journey.lua
share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/shadow.lua
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/backstab.lua	Wed May 22 10:45:35 2019 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/backstab.lua	Wed May 22 11:31:55 2019 +0200
@@ -735,11 +735,11 @@
 end
 
 function CheckChoiceRefuse()
-  return highJumped == true and StoppedGear(CurrentHedgehog)
+  return GetHealth(CurrentHedgehog) and highJumped == true and StoppedGear(CurrentHedgehog)
 end
 
 function CheckChoiceRunaway()
-  return CurrentHedgehog and band(GetState(CurrentHedgehog), gstHHDriven) ~= 0 and GetHogTeamName(CurrentHedgehog) == nativesTeamName and GetX(CurrentHedgehog) >= runawayX and GetY(CurrentHedgehog) >= runawayY and StoppedGear(CurrentHedgehog)
+  return GetHealth(CurrentHedgehog) and band(GetState(CurrentHedgehog), gstHHDriven) ~= 0 and GetHogTeamName(CurrentHedgehog) == nativesTeamName and GetX(CurrentHedgehog) >= runawayX and GetY(CurrentHedgehog) >= runawayY and StoppedGear(CurrentHedgehog)
 end
 
 function CheckChoiceRunawayAll()
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/enemy.lua	Wed May 22 10:45:35 2019 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/enemy.lua	Wed May 22 11:31:55 2019 +0200
@@ -104,7 +104,10 @@
 finalAnim = {}
 -----------------------------Animations--------------------------------
 function CondNeedToTurn(hog1, hog2)
-  xl, xd = GetX(hog1), GetX(hog2)
+  if (not GetHealth(hog1)) or (not GetHealth(hog2)) then
+    return
+  end
+  local xl, xd = GetX(hog1), GetX(hog2)
   if xl > xd then
     AnimInsertStepNext({func = AnimTurn, args = {hog1, "Left"}})
     AnimInsertStepNext({func = AnimTurn, args = {hog2, "Right"}})
@@ -115,7 +118,10 @@
 end
 
 function CondNeedToTurn2(hog1, hog2)
-  xl, xd = GetX(hog1), GetX(hog2)
+  if (not GetHealth(hog1)) or (not GetHealth(hog2)) then
+    return
+  end
+  local xl, xd = GetX(hog1), GetX(hog2)
   if xl > xd then
     AnimTurn(hog1, "Left")
     AnimTurn(hog2, "Right")
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/first_blood.lua	Wed May 22 10:45:35 2019 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/first_blood.lua	Wed May 22 11:31:55 2019 +0200
@@ -420,7 +420,7 @@
 end
 
 function CheckMovedUntilJump()
-   return GetX(youngh) >= 2343
+   return GetHealth(youngh) and GetX(youngh) >= 2343
 end
 
 function DoMovedUntilJump()
@@ -435,7 +435,7 @@
 end
 
 function CheckOnShroom()
-  return GetX(youngh) >= 2461 and StoppedGear(youngh)
+  return GetHealth(youngh) and GetX(youngh) >= 2461 and StoppedGear(youngh)
 end
 
 function DoOnShroom()
@@ -473,11 +473,17 @@
 end
 
 function CheckOnMoleHead()
+  if not GetHealth(youngh) then
+    return false
+  end
   local x = GetX(youngh)
   return x >= 3005 and x <= 3126 and StoppedGear(youngh)
 end
 
 function CheckPastMoleHead()
+  if not GetHealth(youngh) then
+    return false
+  end
   local x = GetX(youngh)
   local y = GetY(youngh)
   return x < 3005 and y > 1500 and StoppedGear(youngh)
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/journey.lua	Wed May 22 10:45:35 2019 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/journey.lua	Wed May 22 11:31:55 2019 +0200
@@ -991,7 +991,7 @@
 end
 
 function CheckTookSniper2()
-  return sniperTaken and StoppedGear(leaks) and StoppedGear(dense)
+  return sniperTaken and leaksDead == false and StoppedGear(leaks) and denseDead == false and StoppedGear(dense)
 end
 
 function DoTookSniper2()
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/shadow.lua	Wed May 22 10:45:35 2019 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/shadow.lua	Wed May 22 11:31:55 2019 +0200
@@ -809,7 +809,7 @@
     -- When close to cyborg, wait for a short time before accepting,
     -- to allow player to attack with melee weapons.
     checkAcceptTimer = checkAcceptTimer + 1
-    if checkAcceptTimer > 2000 and StoppedGear(dense) then
+    if checkAcceptTimer > 2000 and denseDead == false and StoppedGear(dense) then
       return true
     end
   else
@@ -826,7 +826,7 @@
 end
 
 function CheckConfront()
-  return cyborgAttacked and GetHealth(dense) and StoppedGear(dense)
+  return cyborgAttacked and denseDead == false and StoppedGear(dense)
 end
 
 function DoConfront()
@@ -854,7 +854,7 @@
   if stage == loseStage then
     return false
   end
-  return GetX(dense) > 1640 and StoppedGear(dense)
+  return denseDead == false and GetX(dense) > 1640 and StoppedGear(dense)
 end
 
 function DoNeedGirder()
@@ -874,7 +874,7 @@
   if stage == loseStage then
     return false
   end
-  return GetX(dense) > 2522 and StoppedGear(dense)
+  return denseDead == false and GetX(dense) > 2522 and StoppedGear(dense)
 end
 
 function DoNeedWeapons()