share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/backstab.lua
changeset 14639 3e15412536c8
parent 14620 5c52013fd0aa
child 14661 0bba06a05d52
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/backstab.lua	Mon Jan 21 01:03:47 2019 +0100
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/backstab.lua	Mon Jan 21 02:09:30 2019 +0100
@@ -14,7 +14,7 @@
 - Player is instructed to decide what to do with the traitor
 | Player kills traitor
     - Cut scene: afterChoiceAnim
-| Player spares traitor
+| Player spares traitor (skips turn or moves too far away)
     - Cut scene: afterChoiceAnim (different)
 | Player kills any other hog or own hog
     > Game over
@@ -148,6 +148,7 @@
 cyborgTeamName = nil
 cannibalsTeamName1 = nil
 cannibalsTeamName2 = nil
+runawayX, runawayY = 1932, 829
 
 startAnim = {}
 afterChoiceAnim = {}
@@ -680,6 +681,7 @@
   AddEvent(CheckChoice, {}, DoChoice, {}, 0)
   AddEvent(CheckKilledOther, {}, DoKilledOther, {}, 0)
   AddEvent(CheckChoiceRefuse, {}, DoChoiceRefuse, {}, 0)
+  AddEvent(CheckChoiceRunaway, {}, DoChoiceRefuse, {}, 0)
   ShowMission(loc("Backstab"), loc("Judas"),
     string.format(loc("Kill the traitor, %s, or spare his life!"), GetHogName(spyHog)) .. "|" ..
     loc("Kill him or skip your turn."),
@@ -718,6 +720,7 @@
 
 function DoChoice()
   RemoveEventFunc(CheckChoiceRefuse)
+  RemoveEventFunc(CheckChoiceRunaway)
   SetGearMessage(CurrentHedgehog, 0)
   SetupAfterChoiceAnim()
   AddAnim(afterChoiceAnim)
@@ -728,6 +731,20 @@
   return highJumped == true and StoppedGear(CurrentHedgehog)
 end
 
+function CheckChoiceRunaway()
+  return CurrentHedgehog and band(GetState(CurrentHedgehog), gstHHDriven) ~= 0 and GetHogTeamName(CurrentHedgehog) == nativesTeamName and GetX(CurrentHedgehog) >= runawayX and GetY(CurrentHedgehog) >= runawayY and StoppedGear(CurrentHedgehog)
+end
+
+function CheckChoiceRunawayAll()
+  for i= 1, 7 do
+    local hog = natives[i]
+    if hog ~= spyHog and GetX(hog) >= runawayX and GetY(hog) >= runawayY and StoppedGear(hog) then
+      return true
+    end
+  end
+  return false
+end
+
 function DoChoiceRefuse()
   choice = choiceSpare
 end
@@ -1150,6 +1167,9 @@
       end
       SetGearMessage(CurrentHedgehog, 0)
       SetTurnTimeLeft(MAX_TURN_TIME)
+      if CheckChoiceRunawayAll() then
+        highJumped = true
+      end
     end
   else
     if freshDead ~= nil and GetHogTeamName(CurrentHedgehog) == nativesTeamName then