ACF5: Register is as "spare traitor" if player walks too far away
authorWuzzy <Wuzzy2@mail.ru>
Mon, 21 Jan 2019 02:09:30 +0100
changeset 14660 3e15412536c8
parent 14659 593c7dee3c19
child 14661 e6363b84b3fe
ACF5: Register is as "spare traitor" if player walks too far away This is done to prevent free attacks at cannibals, which don't get a turn before the choice was made.
ChangeLog.txt
share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/backstab.lua
--- a/ChangeLog.txt	Mon Jan 21 01:03:47 2019 +0100
+++ b/ChangeLog.txt	Mon Jan 21 02:09:30 2019 +0100
@@ -27,6 +27,7 @@
 
 A Classic Fairytale:
  + Backstab: Disable utilities before traitor has been dealt with
+ * Backstab: Prevent attacking the cannibals before making the choice
  * First blood: Fix Lua error when hitting Attack after failing the rope challenge
  * Various minor tweaks and bugfixes
 
--- 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