share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/journey.lua
changeset 14485 f37910a73c19
parent 14444 d084fc76c566
child 14486 f8c2b995c009
equal deleted inserted replaced
14484:764ba6182389 14485:f37910a73c19
   133 m2SpikyDead = 0
   133 m2SpikyDead = 0
   134 
   134 
   135 TurnsLeft = 0
   135 TurnsLeft = 0
   136 stage = 0
   136 stage = 0
   137 
   137 
       
   138 nativesTeamName = nil
       
   139 princessTeamName = nil
       
   140 cannibalsTeamName = nil
       
   141 cyborgTeamName = nil
       
   142 
   138 startAnimStarted = false
   143 startAnimStarted = false
   139 blowTaken = false
   144 blowTaken = false
   140 fireTaken = false
   145 fireTaken = false
   141 gravityTaken = false
   146 gravityTaken = false
   142 sniperTaken = false
   147 sniperTaken = false
   177 winAnim = {}
   182 winAnim = {}
   178 winAnimAD = {}
   183 winAnimAD = {}
   179 
   184 
   180 --/////////////////////////Animation Functions///////////////////////
   185 --/////////////////////////Animation Functions///////////////////////
   181 function AfterMidFailAnim()
   186 function AfterMidFailAnim()
   182   DismissTeam(loc("Natives"))
   187   DismissTeam(nativesTeamName)
   183   DismissTeam(loc("Princess"))
   188   DismissTeam(princessTeamName)
   184   EndTurn(true)
   189   EndTurn(true)
   185 end
   190 end
   186 
   191 
   187 function AfterMidAnimAlone()
   192 function AfterMidAnimAlone()
   188   SetupCourse()
   193   SetupCourse()
   908 
   913 
   909 function DoLeaksDead()
   914 function DoLeaksDead()
   910   if not princessDead then
   915   if not princessDead then
   911     EndTurn(true)
   916     EndTurn(true)
   912     AddCaption(loc("The village, unprepared, was destroyed by the cyborgs..."))
   917     AddCaption(loc("The village, unprepared, was destroyed by the cyborgs..."))
   913     DismissTeam(loc("Natives"))
   918     DismissTeam(nativesTeamName)
   914     DismissTeam(loc("Princess"))
   919     DismissTeam(princessTeamName)
   915   end
   920   end
   916 end
   921 end
   917 
   922 
   918 function CheckDenseDead()
   923 function CheckDenseDead()
   919   return denseDead
   924   return denseDead
   921 
   926 
   922 function DoDenseDead()
   927 function DoDenseDead()
   923   if not princessDead then
   928   if not princessDead then
   924     EndTurn(true)
   929     EndTurn(true)
   925     AddCaption(loc("The village, unprepared, was destroyed by the cyborgs..."))
   930     AddCaption(loc("The village, unprepared, was destroyed by the cyborgs..."))
   926     DismissTeam(loc("Natives"))
   931     DismissTeam(nativesTeamName)
   927     DismissTeam(loc("Princess"))
   932     DismissTeam(princessTeamName)
   928   end
   933   end
   929 end
   934 end
   930 
   935 
   931 function CheckTookBlowTorch()
   936 function CheckTookBlowTorch()
   932   return blowTaken
   937   return blowTaken
  1010     SwitchHog(cyborg)
  1015     SwitchHog(cyborg)
  1011   end
  1016   end
  1012   if not (leaksDead or denseDead) then
  1017   if not (leaksDead or denseDead) then
  1013     AddAnim(endFailAnim)
  1018     AddAnim(endFailAnim)
  1014   end
  1019   end
  1015   AddFunction({func = DismissTeam, args = {loc("Natives")}})
  1020   AddFunction({func = DismissTeam, args = {nativesTeamName}})
  1016   AddFunction({func = DismissTeam, args = {loc("Princess")}})
  1021   AddFunction({func = DismissTeam, args = {princessTeamName}})
  1017   AddFunction({func = EndTurn, args = {true}})
  1022   AddFunction({func = EndTurn, args = {true}})
  1018 end
  1023 end
  1019 
  1024 
  1020 function CheckWon()
  1025 function CheckWon()
  1021   return cyborgDead and not princessDead
  1026   return cyborgDead and not princessDead
  1030   AddFunction({func = FinishWon, args = {}})
  1035   AddFunction({func = FinishWon, args = {}})
  1031 end
  1036 end
  1032 
  1037 
  1033 function FinishWon()
  1038 function FinishWon()
  1034   SwitchHog(leaks)
  1039   SwitchHog(leaks)
  1035   DismissTeam(loc("Cannibal Sentry"))
  1040   DismissTeam(cannibalsTeamName)
  1036   DismissTeam(loc("011101001"))
  1041   DismissTeam(cyborgTeamName)
  1037   EndTurn(true)
  1042   EndTurn(true)
  1038 end
  1043 end
  1039 
  1044 
  1040 function CheckFailedCourse()
  1045 function CheckFailedCourse()
  1041   return TurnsLeft == 0
  1046   return TurnsLeft == 0
  1084     HealthDecrease = 0
  1089     HealthDecrease = 0
  1085     WaterRise = 0
  1090     WaterRise = 0
  1086 
  1091 
  1087   AnimInit(true)
  1092   AnimInit(true)
  1088 
  1093 
  1089   AddTeam(loc("Natives"), -2, "Bone", "Island", "HillBilly", "cm_birdy")
  1094   nativesTeamName = AddTeam(loc("Natives"), -2, "Bone", "Island", "HillBilly", "cm_birdy")
  1090   leaks = AddHog(loc("Leaks A Lot"), 0, 100, "Rambo")
  1095   leaks = AddHog(loc("Leaks A Lot"), 0, 100, "Rambo")
  1091   dense = AddHog(loc("Dense Cloud"), 0, 100, "RobinHood")
  1096   dense = AddHog(loc("Dense Cloud"), 0, 100, "RobinHood")
  1092 
  1097 
  1093   AddTeam(loc("Princess"), -2, "Bone", "Island", "HillBilly", "cm_birdy")
  1098   princessTeamName = AddTeam(loc("Princess"), -2, "Bone", "Island", "HillBilly", "cm_birdy")
  1094   princess = AddHog(loc("Fell From Heaven"), 0, 200, "tiara")
  1099   princess = AddHog(loc("Fell From Heaven"), 0, 200, "tiara")
  1095 
  1100 
  1096   AddTeam(loc("Cannibal Sentry"), -1, "skull", "Island", "Pirate","cm_vampire")
  1101   cannibalsTeamName = AddTeam(loc("Cannibal Sentry"), -1, "skull", "Island", "Pirate","cm_vampire")
  1097   cannibals = {}
  1102   cannibals = {}
  1098   for i = 1, 4 do
  1103   for i = 1, 4 do
  1099     cannibals[i] = AddHog(cannibalNames[i], 3, 40, "Zombi")
  1104     cannibals[i] = AddHog(cannibalNames[i], 3, 40, "Zombi")
  1100     AnimSetGearPosition(cannibals[i], unpack(cannibalPos[i]))
  1105     AnimSetGearPosition(cannibals[i], unpack(cannibalPos[i]))
  1101     SetEffect(cannibals[i], heArtillery, 1)
  1106     SetEffect(cannibals[i], heArtillery, 1)
  1105     cannibals[i] = AddHog(cannibalNames[i], 3, 40, "Zombi")
  1110     cannibals[i] = AddHog(cannibalNames[i], 3, 40, "Zombi")
  1106     AnimSetGearPosition(cannibals[i], 0, 0)
  1111     AnimSetGearPosition(cannibals[i], 0, 0)
  1107     SetEffect(cannibals[i], heArtillery, 1)
  1112     SetEffect(cannibals[i], heArtillery, 1)
  1108   end
  1113   end
  1109 
  1114 
  1110   AddTeam(loc("011101001"), -1, "ring", "UFO", "Robot", "cm_binary")
  1115   cyborgTeamName = AddTeam(loc("011101001"), -1, "ring", "UFO", "Robot", "cm_binary")
  1111   cyborg = AddHog(loc("Y3K1337"), 0, 200, "cyborg1")
  1116   cyborg = AddHog(loc("Y3K1337"), 0, 200, "cyborg1")
  1112 
  1117 
  1113   AnimSetGearPosition(dense, 0, 0)
  1118   AnimSetGearPosition(dense, 0, 0)
  1114   AnimSetGearPosition(leaks, 0, 0)
  1119   AnimSetGearPosition(leaks, 0, 0)
  1115   AnimSetGearPosition(cyborg, 0, 0)
  1120   AnimSetGearPosition(cyborg, 0, 0)
  1194     EndTurn(true)
  1199     EndTurn(true)
  1195   elseif stage == endStage and CurrentHedgehog ~= leaks then
  1200   elseif stage == endStage and CurrentHedgehog ~= leaks then
  1196     AnimSwitchHog(leaks)
  1201     AnimSwitchHog(leaks)
  1197     SetGearMessage(leaks, 0)
  1202     SetGearMessage(leaks, 0)
  1198     SetTurnTimeLeft(MAX_TURN_TIME)
  1203     SetTurnTimeLeft(MAX_TURN_TIME)
  1199   elseif GetHogTeamName(CurrentHedgehog) ~= loc("Natives") then
  1204   elseif GetHogTeamName(CurrentHedgehog) ~= nativesTeamName then
  1200     SetTurnTimeLeft(20000)
  1205     SetTurnTimeLeft(20000)
  1201   else
  1206   else
  1202     TurnsLeft = TurnsLeft - 1
  1207     TurnsLeft = TurnsLeft - 1
  1203     if TurnsLeft >= 1 then
  1208     if TurnsLeft >= 1 then
  1204       AddCaption(string.format(loc("Turns left: %d"), TurnsLeft), capcolDefault, capgrpGameState)
  1209       AddCaption(string.format(loc("Turns left: %d"), TurnsLeft), capcolDefault, capgrpGameState)