share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/shadow.lua
changeset 15085 cd60866e6efb
parent 15073 6f51c75994a4
child 15172 9d4a6ab60dec
equal deleted inserted replaced
15084:424e3b132dd3 15085:cd60866e6efb
   755 
   755 
   756 function CheckBrainiacDead()
   756 function CheckBrainiacDead()
   757   return brainiacDead
   757   return brainiacDead
   758 end
   758 end
   759 
   759 
   760 function isHogAlive(hog)
       
   761   if GetHealth(hog) == nil or GetHealth(hog) <= 0 then
       
   762     return false
       
   763   else
       
   764     local _,_,_,_,_,_,_,_,_,_,_,damage = GetGearValues(hog)
       
   765     if damage > GetHealth(hog)  then
       
   766       return false
       
   767     end
       
   768   end
       
   769   return true
       
   770 end
       
   771 
       
   772 function DoBrainiacDead()
   760 function DoBrainiacDead()
   773   if stage == loseStage then
   761   if stage == loseStage then
   774     return
   762     return
   775   end
   763   end
   776   if (not isHogAlive(dense)) or (not isHogAlive(leaks)) then
   764   if (not IsHogAlive(dense)) or (not IsHogAlive(leaks)) then
   777     return
   765     return
   778   end
   766   end
   779 
   767 
   780   EndTurn(true)
   768   EndTurn(true)
   781   SetGearMessage(CurrentHedgehog, 0)
   769   SetGearMessage(CurrentHedgehog, 0)
   795 
   783 
   796 function DoWeaklingsKilled()
   784 function DoWeaklingsKilled()
   797   if stage == loseStage then
   785   if stage == loseStage then
   798     return
   786     return
   799   end
   787   end
   800   if (not isHogAlive(dense)) or (not isHogAlive(leaks)) then
   788   if (not IsHogAlive(dense)) or (not IsHogAlive(leaks)) then
   801     return
   789     return
   802   end
   790   end
   803   SetGearMessage(CurrentHedgehog, 0)
   791   SetGearMessage(CurrentHedgehog, 0)
   804   AddAnim(stronglingsAnim)
   792   AddAnim(stronglingsAnim)
   805   AddFunction({func = AfterStronglingsAnim, args = {}})
   793   AddFunction({func = AfterStronglingsAnim, args = {}})
   806   stage = interWeakStage
   794   stage = interWeakStage
   807   DismissTeam(weaklingsTeamName)
   795   DismissTeam(weaklingsTeamName)
   808 end
   796 end
   809 
   797 
   810 function CheckRefuse()
   798 function CheckRefuse()
   811   return isHogAlive(dense) and GetX(dense) > 1400 and StoppedGear(dense)
   799   return IsHogAlive(dense) and GetX(dense) > 1400 and StoppedGear(dense)
   812 end
   800 end
   813 
   801 
   814 function DoRefuse()
   802 function DoRefuse()
   815   if stage == loseStage then
   803   if stage == loseStage then
   816     return
   804     return
   817   end
   805   end
   818   choice = choiceRefuse
   806   choice = choiceRefuse
   819 end
   807 end
   820 
   808 
   821 function CheckAccept()
   809 function CheckAccept()
   822   if not isHogAlive(dense) then
   810   if not IsHogAlive(dense) then
   823     return false
   811     return false
   824   end
   812   end
   825   if GetX(dense) < 1300 then
   813   if GetX(dense) < 1300 then
   826     -- When close to cyborg, wait for a short time before accepting,
   814     -- When close to cyborg, wait for a short time before accepting,
   827     -- to allow player to attack with melee weapons.
   815     -- to allow player to attack with melee weapons.
   841   end
   829   end
   842   choice = choiceAccept
   830   choice = choiceAccept
   843 end
   831 end
   844 
   832 
   845 function CheckConfront()
   833 function CheckConfront()
   846   return cyborgAttacked and isHogAlive(dense) and StoppedGear(dense)
   834   return cyborgAttacked and IsHogAlive(dense) and StoppedGear(dense)
   847 end
   835 end
   848 
   836 
   849 function DoConfront()
   837 function DoConfront()
   850   if stage == loseStage then
   838   if stage == loseStage then
   851     return
   839     return
   905 
   893 
   906 function CheckReadyForStronglings()
   894 function CheckReadyForStronglings()
   907   if stage == loseStage then
   895   if stage == loseStage then
   908     return false
   896     return false
   909   end
   897   end
   910   if not isHogAlive(dense) then
   898   if not IsHogAlive(dense) then
   911     return false
   899     return false
   912   end
   900   end
   913   return (shotgunTaken and grenadeTaken) or GetX(dense) > 2700
   901   return (shotgunTaken and grenadeTaken) or GetX(dense) > 2700
   914 end
   902 end
   915 
   903 
   943 
   931 
   944 function DoStronglingsDead()
   932 function DoStronglingsDead()
   945   if stage == loseStage then
   933   if stage == loseStage then
   946     return
   934     return
   947   end
   935   end
   948   if not isHogAlive(leaks) then
   936   if not IsHogAlive(leaks) then
   949     return
   937     return
   950   end
   938   end
   951   SetGearMessage(CurrentHedgehog, 0)
   939   SetGearMessage(CurrentHedgehog, 0)
   952   if denseDead == true then
   940   if denseDead == true then
   953     AddAnim(acceptedDiedFinalAnim)
   941     AddAnim(acceptedDiedFinalAnim)