ACF2: Prevent cut scene from playing when own hogs are dead or about to die
authorWuzzy <Wuzzy2@mail.ru>
Wed, 22 May 2019 23:30:10 +0200
changeset 15051 2e89487540d8
parent 15050 09c63d4bcf53
child 15052 8cde6fb2fabd
ACF2: Prevent cut scene from playing when own hogs are dead or about to die
share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/shadow.lua
--- 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)