share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/shadow.lua
changeset 15051 2e89487540d8
parent 15050 09c63d4bcf53
child 15054 1bce780e55ac
equal deleted inserted replaced
15050:09c63d4bcf53 15051:2e89487540d8
   754 
   754 
   755 function CheckBrainiacDead()
   755 function CheckBrainiacDead()
   756   return brainiacDead
   756   return brainiacDead
   757 end
   757 end
   758 
   758 
       
   759 function isHogAlive(hog)
       
   760   if GetHealth(hog) == nil or GetHealth(hog) <= 0 then
       
   761     return false
       
   762   else
       
   763     local _,_,_,_,_,_,_,_,_,_,_,damage = GetGearValues(hog)
       
   764     if damage > GetHealth(hog)  then
       
   765       return false
       
   766     end
       
   767   end
       
   768   return true
       
   769 end
       
   770 
   759 function DoBrainiacDead()
   771 function DoBrainiacDead()
   760   if stage == loseStage then
   772   if stage == loseStage then
   761     return
   773     return
   762   end
   774   end
       
   775   if (not isHogAlive(dense)) or (not isHogAlive(leaks)) then
       
   776     return
       
   777   end
       
   778 
   763   EndTurn(true)
   779   EndTurn(true)
   764   SetGearMessage(CurrentHedgehog, 0)
   780   SetGearMessage(CurrentHedgehog, 0)
   765   AddAnim(weaklingsAnim)
   781   AddAnim(weaklingsAnim)
   766   AddFunction({func = AfterWeaklingsAnim, args = {}})
   782   AddFunction({func = AfterWeaklingsAnim, args = {}})
   767   stage = interSpyStage
   783   stage = interSpyStage
   778 
   794 
   779 function DoWeaklingsKilled()
   795 function DoWeaklingsKilled()
   780   if stage == loseStage then
   796   if stage == loseStage then
   781     return
   797     return
   782   end
   798   end
   783   if denseDead or GetHealth(dense) == 0 or leaksDead or GetHealth(leaks) == 0 then
   799   if (not isHogAlive(dense)) or (not isHogAlive(leaks)) then
   784     return
   800     return
   785   end
   801   end
   786   SetGearMessage(CurrentHedgehog, 0)
   802   SetGearMessage(CurrentHedgehog, 0)
   787   AddAnim(stronglingsAnim)
   803   AddAnim(stronglingsAnim)
   788   AddFunction({func = AfterStronglingsAnim, args = {}})
   804   AddFunction({func = AfterStronglingsAnim, args = {}})
   922 
   938 
   923 function DoStronglingsDead()
   939 function DoStronglingsDead()
   924   if stage == loseStage then
   940   if stage == loseStage then
   925     return
   941     return
   926   end
   942   end
   927   if leaksDead or GetHealth(leaks) == 0 then
   943   if not isHogAlive(leaks) then
   928     return
   944     return
   929   end
   945   end
   930   SetGearMessage(CurrentHedgehog, 0)
   946   SetGearMessage(CurrentHedgehog, 0)
   931   if denseDead == true then
   947   if denseDead == true then
   932     AddAnim(acceptedDiedFinalAnim)
   948     AddAnim(acceptedDiedFinalAnim)