share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/backstab.lua
changeset 14660 3e15412536c8
parent 14641 5c52013fd0aa
child 14682 0bba06a05d52
equal deleted inserted replaced
14659:593c7dee3c19 14660:3e15412536c8
    12 
    12 
    13 - Cut scene: startScene (traitor is revealed)
    13 - Cut scene: startScene (traitor is revealed)
    14 - Player is instructed to decide what to do with the traitor
    14 - Player is instructed to decide what to do with the traitor
    15 | Player kills traitor
    15 | Player kills traitor
    16     - Cut scene: afterChoiceAnim
    16     - Cut scene: afterChoiceAnim
    17 | Player spares traitor
    17 | Player spares traitor (skips turn or moves too far away)
    18     - Cut scene: afterChoiceAnim (different)
    18     - Cut scene: afterChoiceAnim (different)
    19 | Player kills any other hog or own hog
    19 | Player kills any other hog or own hog
    20     > Game over
    20     > Game over
    21 - First turn of cannibals
    21 - First turn of cannibals
    22 - TBS
    22 - TBS
   146 nativesTeamName = nil
   146 nativesTeamName = nil
   147 tribeTeamName = nil
   147 tribeTeamName = nil
   148 cyborgTeamName = nil
   148 cyborgTeamName = nil
   149 cannibalsTeamName1 = nil
   149 cannibalsTeamName1 = nil
   150 cannibalsTeamName2 = nil
   150 cannibalsTeamName2 = nil
       
   151 runawayX, runawayY = 1932, 829
   151 
   152 
   152 startAnim = {}
   153 startAnim = {}
   153 afterChoiceAnim = {}
   154 afterChoiceAnim = {}
   154 wave2Anim = {}
   155 wave2Anim = {}
   155 wave2DeadAnim = {}
   156 wave2DeadAnim = {}
   678   AnimSwitchHog(natives[leaksNum])
   679   AnimSwitchHog(natives[leaksNum])
   679   stage = spyKillStage
   680   stage = spyKillStage
   680   AddEvent(CheckChoice, {}, DoChoice, {}, 0)
   681   AddEvent(CheckChoice, {}, DoChoice, {}, 0)
   681   AddEvent(CheckKilledOther, {}, DoKilledOther, {}, 0)
   682   AddEvent(CheckKilledOther, {}, DoKilledOther, {}, 0)
   682   AddEvent(CheckChoiceRefuse, {}, DoChoiceRefuse, {}, 0)
   683   AddEvent(CheckChoiceRefuse, {}, DoChoiceRefuse, {}, 0)
       
   684   AddEvent(CheckChoiceRunaway, {}, DoChoiceRefuse, {}, 0)
   683   ShowMission(loc("Backstab"), loc("Judas"),
   685   ShowMission(loc("Backstab"), loc("Judas"),
   684     string.format(loc("Kill the traitor, %s, or spare his life!"), GetHogName(spyHog)) .. "|" ..
   686     string.format(loc("Kill the traitor, %s, or spare his life!"), GetHogName(spyHog)) .. "|" ..
   685     loc("Kill him or skip your turn."),
   687     loc("Kill him or skip your turn."),
   686     1, 8000)
   688     1, 8000)
   687 end
   689 end
   716   return false
   718   return false
   717 end
   719 end
   718 
   720 
   719 function DoChoice()
   721 function DoChoice()
   720   RemoveEventFunc(CheckChoiceRefuse)
   722   RemoveEventFunc(CheckChoiceRefuse)
       
   723   RemoveEventFunc(CheckChoiceRunaway)
   721   SetGearMessage(CurrentHedgehog, 0)
   724   SetGearMessage(CurrentHedgehog, 0)
   722   SetupAfterChoiceAnim()
   725   SetupAfterChoiceAnim()
   723   AddAnim(afterChoiceAnim)
   726   AddAnim(afterChoiceAnim)
   724   AddFunction({func = AfterAfterChoiceAnim, args = {}})
   727   AddFunction({func = AfterAfterChoiceAnim, args = {}})
   725 end
   728 end
   726 
   729 
   727 function CheckChoiceRefuse()
   730 function CheckChoiceRefuse()
   728   return highJumped == true and StoppedGear(CurrentHedgehog)
   731   return highJumped == true and StoppedGear(CurrentHedgehog)
       
   732 end
       
   733 
       
   734 function CheckChoiceRunaway()
       
   735   return CurrentHedgehog and band(GetState(CurrentHedgehog), gstHHDriven) ~= 0 and GetHogTeamName(CurrentHedgehog) == nativesTeamName and GetX(CurrentHedgehog) >= runawayX and GetY(CurrentHedgehog) >= runawayY and StoppedGear(CurrentHedgehog)
       
   736 end
       
   737 
       
   738 function CheckChoiceRunawayAll()
       
   739   for i= 1, 7 do
       
   740     local hog = natives[i]
       
   741     if hog ~= spyHog and GetX(hog) >= runawayX and GetY(hog) >= runawayY and StoppedGear(hog) then
       
   742       return true
       
   743     end
       
   744   end
       
   745   return false
   729 end
   746 end
   730 
   747 
   731 function DoChoiceRefuse()
   748 function DoChoiceRefuse()
   732   choice = choiceSpare
   749   choice = choiceSpare
   733 end
   750 end
  1148       if CurrentHedgehog == spyHog then
  1165       if CurrentHedgehog == spyHog then
  1149         AnimSwitchHog(natives[leaksNum])
  1166         AnimSwitchHog(natives[leaksNum])
  1150       end
  1167       end
  1151       SetGearMessage(CurrentHedgehog, 0)
  1168       SetGearMessage(CurrentHedgehog, 0)
  1152       SetTurnTimeLeft(MAX_TURN_TIME)
  1169       SetTurnTimeLeft(MAX_TURN_TIME)
       
  1170       if CheckChoiceRunawayAll() then
       
  1171         highJumped = true
       
  1172       end
  1153     end
  1173     end
  1154   else
  1174   else
  1155     if freshDead ~= nil and GetHogTeamName(CurrentHedgehog) == nativesTeamName then
  1175     if freshDead ~= nil and GetHogTeamName(CurrentHedgehog) == nativesTeamName then
  1156       SetupHogDeadAnim(freshDead)
  1176       SetupHogDeadAnim(freshDead)
  1157       AddAnim(hogDeadAnim)
  1177       AddAnim(hogDeadAnim)