share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/shadow.lua
changeset 15035 2e89487540d8
parent 15034 09c63d4bcf53
child 15038 1bce780e55ac
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/shadow.lua	Wed May 22 11:31:55 2019 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/shadow.lua	Wed May 22 23:30:10 2019 +0200
@@ -756,10 +756,26 @@
   return brainiacDead
 end
 
+function isHogAlive(hog)
+  if GetHealth(hog) == nil or GetHealth(hog) <= 0 then
+    return false
+  else
+    local _,_,_,_,_,_,_,_,_,_,_,damage = GetGearValues(hog)
+    if damage > GetHealth(hog)  then
+      return false
+    end
+  end
+  return true
+end
+
 function DoBrainiacDead()
   if stage == loseStage then
     return
   end
+  if (not isHogAlive(dense)) or (not isHogAlive(leaks)) then
+    return
+  end
+
   EndTurn(true)
   SetGearMessage(CurrentHedgehog, 0)
   AddAnim(weaklingsAnim)
@@ -780,7 +796,7 @@
   if stage == loseStage then
     return
   end
-  if denseDead or GetHealth(dense) == 0 or leaksDead or GetHealth(leaks) == 0 then
+  if (not isHogAlive(dense)) or (not isHogAlive(leaks)) then
     return
   end
   SetGearMessage(CurrentHedgehog, 0)
@@ -924,7 +940,7 @@
   if stage == loseStage then
     return
   end
-  if leaksDead or GetHealth(leaks) == 0 then
+  if not isHogAlive(leaks) then
     return
   end
   SetGearMessage(CurrentHedgehog, 0)