share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/backstab.lua
changeset 14485 f37910a73c19
parent 14445 12940929cb66
child 14486 f8c2b995c009
equal deleted inserted replaced
14484:764ba6182389 14485:f37910a73c19
   141 stage = 0
   141 stage = 0
   142 choice = 0
   142 choice = 0
   143 highJumped = false
   143 highJumped = false
   144 TurnsLeft = 0
   144 TurnsLeft = 0
   145 startNativesNum = 0
   145 startNativesNum = 0
       
   146 nativesTeamName = nil
       
   147 tribeTeamName = nil
       
   148 cyborgTeamName = nil
       
   149 cannibalsTeamName1 = nil
       
   150 cannibalsTeamName2 = nil
   146 
   151 
   147 startAnim = {}
   152 startAnim = {}
   148 afterChoiceAnim = {}
   153 afterChoiceAnim = {}
   149 wave2Anim = {}
   154 wave2Anim = {}
   150 wave2DeadAnim = {}
   155 wave2DeadAnim = {}
   678   return deployedDead
   683   return deployedDead
   679 end
   684 end
   680 
   685 
   681 function DoDeployedDead()
   686 function DoDeployedDead()
   682   ShowMission(loc("Backstab"), loc("Brutus"), loc("You have failed to save the tribe!"), 0, 6000)
   687   ShowMission(loc("Backstab"), loc("Brutus"), loc("You have failed to save the tribe!"), 0, 6000)
   683   DismissTeam(loc("Natives"))
   688   DismissTeam(nativesTeamName)
   684   DismissTeam(loc("Tribe"))
   689   DismissTeam(tribeTeamName)
   685   DismissTeam(loc("011101001"))
   690   DismissTeam(cyborgTeamName)
   686   EndTurn(true)
   691   EndTurn(true)
   687 end
   692 end
   688 
   693 
   689 function CheckChoice()
   694 function CheckChoice()
   690   return choice ~= 0 and tmpVar == 0
   695   return choice ~= 0 and tmpVar == 0
   723           (nativesNum < startNativesNum - 1 and choice == choiceEliminate)
   728           (nativesNum < startNativesNum - 1 and choice == choiceEliminate)
   724 end
   729 end
   725 
   730 
   726 function DoKilledOther()
   731 function DoKilledOther()
   727   ShowMission(loc("Backstab"), loc("Brutus"), loc("You have killed an innocent hedgehog!"), 0, 6000)
   732   ShowMission(loc("Backstab"), loc("Brutus"), loc("You have killed an innocent hedgehog!"), 0, 6000)
   728   DismissTeam(loc("Natives"))
   733   DismissTeam(nativesTeamName)
   729   DismissTeam(loc("Tribe"))
   734   DismissTeam(tribeTeamName)
   730   EndTurn(true)
   735   EndTurn(true)
   731 end
   736 end
   732 
   737 
   733 function CheckWaveDead(index)
   738 function CheckWaveDead(index)
   734   for i = (index - 1) * 3 + 1, index * 3 do
   739   for i = (index - 1) * 3 + 1, index * 3 do
   831     if natives[i] == deployedHog then
   836     if natives[i] == deployedHog then
   832       SaveCampaignVar("M5DeployedNum", "" .. i)
   837       SaveCampaignVar("M5DeployedNum", "" .. i)
   833     end
   838     end
   834   end
   839   end
   835 
   840 
   836   DismissTeam(loc("Tribe"))
   841   DismissTeam(tribeTeamName)
   837   DismissTeam(loc("Assault Team"))
   842   DismissTeam(cannibalsTeamName1)
   838   DismissTeam(loc("Reinforcements"))
   843   DismissTeam(cannibalsTeamName2)
   839   DismissTeam(loc("011101001"))
   844   DismissTeam(cyborgTeamName)
   840   EndTurn(true)
   845   EndTurn(true)
   841 end
   846 end
   842 
   847 
   843 -----------------------------Misc--------------------------------------
   848 -----------------------------Misc--------------------------------------
   844 
   849 
   954 function SetupAmmo()
   959 function SetupAmmo()
   955   AddAmmo(natives[girlNum], amSwitch, 0)
   960   AddAmmo(natives[girlNum], amSwitch, 0)
   956 end
   961 end
   957 
   962 
   958 function AddHogs()
   963 function AddHogs()
   959   AddTeam(loc("Tribe"), -2, "Bone", "Island", "HillBilly", "cm_birdy")
   964   tribeTeamName = AddTeam(loc("Tribe"), -2, "Bone", "Island", "HillBilly", "cm_birdy")
   960   for i = 8, 9 do
   965   for i = 8, 9 do
   961     natives[i] = AddHog(nativeNames[i], 0, 100, nativeHats[i])
   966     natives[i] = AddHog(nativeNames[i], 0, 100, nativeHats[i])
   962   end
   967   end
   963 
   968 
   964   AddTeam(loc("Natives"), -2, "Bone", "Island", "HillBilly", "cm_birdy")
   969   nativesTeamName = AddTeam(loc("Natives"), -2, "Bone", "Island", "HillBilly", "cm_birdy")
   965   for i = 1, 7 do
   970   for i = 1, 7 do
   966     natives[i] = AddHog(nativeNames[i], 0, 100, nativeHats[i])
   971     natives[i] = AddHog(nativeNames[i], 0, 100, nativeHats[i])
   967   end
   972   end
   968   nativesNum = 7
   973   nativesNum = 7
   969 
   974 
   970   AddTeam(loc("Assault Team"), -1, "skull", "Island", "Pirate", "cm_vampire")
   975   cannibalsTeamName1 = AddTeam(loc("Assault Team"), -1, "skull", "Island", "Pirate", "cm_vampire")
   971   for i = 1, 6 do
   976   for i = 1, 6 do
   972     cannibals[i] = AddHog(cannibalNames[i], 3, 50, "vampirichog")
   977     cannibals[i] = AddHog(cannibalNames[i], 3, 50, "vampirichog")
   973   end
   978   end
   974 
   979 
   975   AddTeam(loc("Reinforcements"), -1, "skull", "Island", "Pirate", "cm_vampire")
   980   cannibalsTeamName2 = AddTeam(loc("Reinforcements"), -1, "skull", "Island", "Pirate", "cm_vampire")
   976   for i = 7, 9 do
   981   for i = 7, 9 do
   977     cannibals[i] = AddHog(cannibalNames[i], 2, 50, "vampirichog")
   982     cannibals[i] = AddHog(cannibalNames[i], 2, 50, "vampirichog")
   978   end
   983   end
   979 
   984 
   980   AddTeam(loc("011101001"), -1, "ring", "UFO", "Robot", "cm_binary")
   985   cyborgTeamName = AddTeam(loc("011101001"), -1, "ring", "UFO", "Robot", "cm_binary")
   981   cyborg = AddHog(loc("Unit 334a$7%;.*"), 0, 200, "cyborg1")
   986   cyborg = AddHog(loc("Unit 334a$7%;.*"), 0, 200, "cyborg1")
   982 
   987 
   983   for i = 1, 9 do
   988   for i = 1, 9 do
   984     AnimSetGearPosition(natives[i], unpack(nativePos[i]))
   989     AnimSetGearPosition(natives[i], unpack(nativePos[i]))
   985     AnimTurn(natives[i], nativeDir[i])
   990     AnimTurn(natives[i], nativeDir[i])
  1116   
  1121   
  1117   if stage == platformStage then
  1122   if stage == platformStage then
  1118     AddCaption(string.format(loc("Turns until arrival: %d"), TurnsLeft))
  1123     AddCaption(string.format(loc("Turns until arrival: %d"), TurnsLeft))
  1119   end
  1124   end
  1120   if deployedHog then
  1125   if deployedHog then
  1121     if GetHogTeamName(CurrentHedgehog) == loc("Natives") then
  1126     if GetHogTeamName(CurrentHedgehog) == nativesTeamName then
  1122       AnimSwitchHog(deployedHog)
  1127       AnimSwitchHog(deployedHog)
  1123     end
  1128     end
  1124   end
  1129   end
  1125 
  1130 
  1126   if stage == spyKillStage then
  1131   if stage == spyKillStage then
  1127     if GetHogTeamName(CurrentHedgehog) ~= loc("Natives") then
  1132     if GetHogTeamName(CurrentHedgehog) ~= nativesTeamName then
  1128       EndTurn(true)
  1133       EndTurn(true)
  1129     else
  1134     else
  1130       if CurrentHedgehog == spyHog then
  1135       if CurrentHedgehog == spyHog then
  1131         AnimSwitchHog(natives[leaksNum])
  1136         AnimSwitchHog(natives[leaksNum])
  1132       end
  1137       end
  1133       SetGearMessage(CurrentHedgehog, 0)
  1138       SetGearMessage(CurrentHedgehog, 0)
  1134       SetTurnTimeLeft(MAX_TURN_TIME)
  1139       SetTurnTimeLeft(MAX_TURN_TIME)
  1135     end
  1140     end
  1136   else
  1141   else
  1137     if freshDead ~= nil and GetHogTeamName(CurrentHedgehog) == loc("Natives") then
  1142     if freshDead ~= nil and GetHogTeamName(CurrentHedgehog) == nativesTeamName then
  1138       SetupHogDeadAnim(freshDead)
  1143       SetupHogDeadAnim(freshDead)
  1139       AddAnim(hogDeadAnim)
  1144       AddAnim(hogDeadAnim)
  1140       AddFunction({func = AfterHogDeadAnim, args = {}})
  1145       AddFunction({func = AfterHogDeadAnim, args = {}})
  1141     end
  1146     end
  1142   end
  1147   end