share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/journey.lua
changeset 9306 c9978ada9a3d
parent 8979 860836494821
child 9308 4bddcc1a1450
equal deleted inserted replaced
9305:8e5140875ab5 9306:c9978ada9a3d
       
     1 HedgewarsScriptLoad("/Scripts/Locale.lua")
       
     2 HedgewarsScriptLoad("/Scripts/Animate.lua")
       
     3 
       
     4 --///////////////////////////////CONSTANTS///////////////////////////
       
     5 
       
     6 choiceAccepted = 1
       
     7 choiceRefused = 2
       
     8 choiceAttacked = 3
       
     9 
       
    10 endStage = 1
       
    11 
       
    12 cannibalNum = 8
       
    13 cannibalNames = {loc("John"), loc("Flesh for Brainz"), loc("Eye Chewer"), loc("Torn Muscle"),
       
    14                  loc("Nom-Nom"), loc("Vedgies"), loc("Brain Blower"), loc("Gorkij")}
       
    15 cannibalPos = {{2471, 1174}, {939, 1019}, {1953, 902}, {3055, 1041},
       
    16                {1121, 729}, {1150, 718}, {1149, 680}, {1161, 773}}
       
    17 
       
    18 startLeaksPosDuo = {3572, 1426}
       
    19 startEventXDuo = 3300
       
    20 startDensePosDuo = {3454, 1471}
       
    21 startCyborgPosDuo = {3202, 1307}
       
    22 midDensePosDuo = {1464, 1410}
       
    23 midCyborgPosDuo = {1264, 1390}
       
    24 
       
    25 --///////////////////////////////VARIABLES///////////////////////////
       
    26 
       
    27 m2Choice = 0
       
    28 m2DenseDead = 0
       
    29 m2RamonDead = 0
       
    30 m2SpikyDead = 0
       
    31 
       
    32 TurnsLeft = 0
       
    33 stage = 0
       
    34 
       
    35 --cyborgHidden = false
       
    36 --princessHidden = false
       
    37 blowTaken = false
       
    38 fireTaken = false
       
    39 gravityTaken = false
       
    40 sniperTaken = false
       
    41 girderTaken = false
       
    42 girder1Taken = false
       
    43 girder2Taken = false
       
    44 leaksDead = false
       
    45 denseDead = false
       
    46 princessDead = false
       
    47 cyborgDead = false
       
    48 cannibalDead = {}
       
    49 hedgeHidden = {}
       
    50 
       
    51 startAnim = {}
       
    52 startAnimAD = {}
       
    53 startAnimAL = {}
       
    54 startAnimRL = {}
       
    55 
       
    56 pastFlowerAnimAL = {}
       
    57 pastFlowerAnimRL = {}
       
    58 pastFlowerAnim = {}
       
    59 
       
    60 outPitAnimAL = {}
       
    61 outPitAnimRL = {}
       
    62 outPitAnim = {}
       
    63 
       
    64 midAnim = {}
       
    65 midAnimAD = {}
       
    66 
       
    67 failAnim = {}
       
    68 failAnimAD = {}
       
    69 
       
    70 endAnim = {}
       
    71 endAnimAD = {}
       
    72 endAnimAL = {}
       
    73 endAnimRL = {}
       
    74 
       
    75 endFailAnim = {}
       
    76 endFailAnimAD = {}
       
    77 
       
    78 winAnim = {}
       
    79 winAnimAD = {}
       
    80 
       
    81 --/////////////////////////Animation Functions///////////////////////
       
    82 function AfterMidFailAnim()
       
    83   ParseCommand("teamgone " .. loc("Natives"))
       
    84   TurnTimeLeft = 0
       
    85 end
       
    86 
       
    87 function AfterMidAnimAlone()
       
    88   SetupCourse()
       
    89   for i = 5, 8 do
       
    90     RestoreHedge(cannibals[i])
       
    91     AnimSetGearPosition(cannibals[i], unpack(cannibalPos[i]))
       
    92   end
       
    93 
       
    94   AddAmmo(cannibals[5], amDEagle, 0)
       
    95 
       
    96   AddEvent(CheckGirderTaken, {}, DoGirderTaken, {}, 0)
       
    97   AddEvent(CheckOnFirstGirder, {}, DoOnFirstGirder, {}, 0)
       
    98   AddEvent(CheckTookSniper, {}, DoTookSniper, {}, 0)
       
    99   AddEvent(CheckFailedCourse, {}, DoFailedCourse, {}, 0)
       
   100   SetGearMessage(leaks, 0)
       
   101   TurnsLeft = 12
       
   102   TurnTimeLeft = TurnTime
       
   103   ShowMission(loc("The Journey Back"), loc("Collateral Damage"), loc("Save the princess by collecting the crate in under 12 turns!"), 0, 6000)
       
   104   -----------------------///////////////------------
       
   105   --AnimSetGearPosition(leaks, 417, 1800)
       
   106 end
       
   107 
       
   108 function SkipEndAnimAlone()
       
   109   RestoreHedge(cyborg)
       
   110   RestoreHedge(princess)
       
   111   AnimSetGearPosition(cyborg, 437, 1700)
       
   112   AnimSetGearPosition(princess, 519, 1722)
       
   113 end
       
   114 
       
   115 function SkipEndAnimDuo()
       
   116   RestoreHedge(cyborg)
       
   117   RestoreHedge(princess)
       
   118   if princessHidden then
       
   119     RestoreHog(princess)
       
   120     princessHidden = false
       
   121   end
       
   122   AnimSetGearPosition(cyborg, 437, 1700)
       
   123   AnimSetGearPosition(princess, 519, 1722)
       
   124   AnimSetGearPosition(leaks, 763, 1760)
       
   125   AnimSetGearPosition(dense, 835, 1519)
       
   126   HogTurnLeft(leaks, true)
       
   127   HogTurnLeft(dense, true)
       
   128 end
       
   129 
       
   130 function AfterEndAnimAlone()
       
   131   stage = endStage
       
   132   SwitchHog(leaks)
       
   133   SetGearMessage(leaks, 0)
       
   134   TurnTimeLeft = -1
       
   135   ShowMission(loc("The Journey Back"), loc("Collateral Damage II"), loc("Save Fell From Heaven!"), 1, 4000)
       
   136   AddEvent(CheckLost, {}, DoLost, {}, 0)
       
   137   AddEvent(CheckWon, {}, DoWon, {}, 0)
       
   138   RemoveEventFunc(CheckFailedCourse)
       
   139 end
       
   140 
       
   141 function AfterEndAnimDuo()
       
   142   stage = endStage
       
   143   SwitchHog(leaks)
       
   144   SetGearMessage(leaks, 0)
       
   145   SetGearMessage(dense, 0)
       
   146   TurnTimeLeft = -1
       
   147   ShowMission(loc("The Journey Back"), loc("Collateral Damage II"), loc("Save Fell From Heaven!"), 1, 4000)
       
   148   AddEvent(CheckLost, {}, DoLost, {}, 0)
       
   149   AddEvent(CheckWon, {}, DoWon, {}, 0)
       
   150 end
       
   151 
       
   152 function SkipMidAnimAlone()
       
   153   AnimSetGearPosition(leaks, 2656, 1842)
       
   154   AnimSwitchHog(leaks)
       
   155   SetInputMask(0xFFFFFFFF)
       
   156   AnimWait(dense, 1)
       
   157   AddFunction({func = HideHedge, args = {princess}})
       
   158   AddFunction({func = HideHedge, args = {cyborg}})
       
   159 end
       
   160 
       
   161 function AfterStartAnim()
       
   162   SetGearMessage(leaks, 0)
       
   163   TurnTimeLeft = TurnTime
       
   164   local goal = loc("Get the crate on the other side of the island!|")
       
   165   local hint = loc("Hint: you might want to stay out of sight and take all the crates...|")
       
   166   local stuck = loc("If you get stuck, use your Desert Eagle or restart the mission!|")
       
   167   local conds = loc("Leaks A Lot must survive!")
       
   168   if m2DenseDead == 0 then
       
   169     conds = loc("Your hogs must survive!")
       
   170   end
       
   171   ShowMission(loc("The Journey Back"), loc("Adventurous"), goal .. hint .. stuck .. conds, 0, 7000)
       
   172 end
       
   173 
       
   174 function SkipStartAnim()
       
   175   AnimSwitchHog(leaks)
       
   176 end
       
   177 
       
   178 function PlaceCratesDuo()
       
   179   SpawnAmmoCrate(3090, 827, amBaseballBat)
       
   180   girderCrate1 = SpawnUtilityCrate(2466, 1814, amGirder)
       
   181   girderCrate2 = SpawnUtilityCrate(2630, 1278, amGirder)
       
   182   SpawnUtilityCrate(2422, 1810, amParachute)
       
   183   SpawnUtilityCrate(3157, 1009, amLowGravity)
       
   184   sniperCrate = SpawnAmmoCrate(784, 1715, amSniperRifle)
       
   185 end
       
   186 
       
   187 function PlaceMinesDuo()
       
   188   SetTimer(AddGear(2920, 1448, gtMine, 0, 0, 0, 0), 5000)
       
   189   SetTimer(AddGear(2985, 1338, gtMine, 0, 0, 0, 0), 5000)
       
   190   SetTimer(AddGear(3005, 1302, gtMine, 0, 0, 0, 0), 5000)
       
   191   SetTimer(AddGear(3030, 1270, gtMine, 0, 0, 0, 0), 5000)
       
   192   SetTimer(AddGear(3046, 1257, gtMine, 0, 0, 0, 0), 5000)
       
   193   SetTimer(AddGear(2954, 1400, gtMine, 0, 0, 0, 0), 5000)
       
   194   SetTimer(AddGear(2967, 1385, gtMine, 0, 0, 0, 0), 5000)
       
   195   SetTimer(AddGear(2849, 1449, gtMine, 0, 0, 0, 0), 5000)
       
   196   SetTimer(AddGear(2811, 1436, gtMine, 0, 0, 0, 0), 5000)
       
   197   SetTimer(AddGear(2773, 1411, gtMine, 0, 0, 0, 0), 5000)
       
   198   SetTimer(AddGear(2732, 1390, gtMine, 0, 0, 0, 0), 5000)
       
   199   SetTimer(AddGear(2700, 1362, gtMine, 0, 0, 0, 0), 5000)
       
   200   SetTimer(AddGear(2642, 1321, gtMine, 0, 0, 0, 0), 5000)
       
   201   SetTimer(AddGear(2172, 1417, gtMine, 0, 0, 0, 0), 5000)
       
   202   SetTimer(AddGear(2190, 1363, gtMine, 0, 0, 0, 0), 5000)
       
   203   SetTimer(AddGear(2219, 1332, gtMine, 0, 0, 0, 0), 5000)
       
   204   SetTimer(AddGear(1201, 1207, gtMine, 0, 0, 0, 0), 5000)
       
   205   SetTimer(AddGear(1247, 1205, gtMine, 0, 0, 0, 0), 5000)
       
   206   SetTimer(AddGear(1295, 1212, gtMine, 0, 0, 0, 0), 5000)
       
   207   SetTimer(AddGear(1356, 1209, gtMine, 0, 0, 0, 0), 5000)
       
   208   SetTimer(AddGear(1416, 1201, gtMine, 0, 0, 0, 0), 5000)
       
   209   SetTimer(AddGear(1466, 1201, gtMine, 0, 0, 0, 0), 5000)
       
   210   SetTimer(AddGear(1678, 1198, gtMine, 0, 0, 0, 0), 5000)
       
   211   SetTimer(AddGear(1738, 1198, gtMine, 0, 0, 0, 0), 5000)
       
   212   SetTimer(AddGear(1796, 1198, gtMine, 0, 0, 0, 0), 5000)
       
   213   SetTimer(AddGear(1637, 1217, gtMine, 0, 0, 0, 0), 5000)
       
   214   SetTimer(AddGear(1519, 1213, gtMine, 0, 0, 0, 0), 5000)
       
   215 end
       
   216 
       
   217 function AfterPastFlowerAnim()
       
   218   PlaceMinesDuo()
       
   219   AddEvent(CheckDensePit, {}, DoDensePit, {}, 0)
       
   220   AddEvent(CheckTookGirder1, {}, DoTookGirder1, {}, 0)
       
   221   AddEvent(CheckTookGirder2, {}, DoTookGirder2, {}, 0)
       
   222   SetGearMessage(leaks, 0)
       
   223   SetGearMessage(dense, 0)
       
   224   TurnTimeLeft = 0
       
   225   ShowMission(loc("The Journey Back"), loc("The Savior"), loc("Get Dense Cloud out of the pit!"), 1, 5000)
       
   226 end
       
   227 
       
   228 function SkipPastFlowerAnim()
       
   229   AnimSetGearPosition(dense, 2656, 1842)
       
   230   AnimSwitchHog(dense)
       
   231   AnimWait(dense, 1)
       
   232   AddFunction({func = HideHedge, args = {cyborg}})
       
   233 end
       
   234 
       
   235 function AfterOutPitAnim()
       
   236   SetupCourseDuo()
       
   237   RestoreHedge(cannibals[5])
       
   238   AddAmmo(cannibals[5], amDEagle, 0)
       
   239   HideHedge(cannibals[5])
       
   240   AddEvent(CheckTookFire, {}, DoTookFire, {}, 0)
       
   241   SetGearMessage(leaks, 0)
       
   242   SetGearMessage(dense, 0)
       
   243   TurnTimeLeft = 0
       
   244   ShowMission(loc("The Journey Back"), loc("They never learn"), loc("Free Dense Cloud and continue the mission!"), 1, 5000)
       
   245 end
       
   246 
       
   247 function SkipOutPitAnim()
       
   248   AnimSetGearPosition(dense, unpack(midDensePosDuo))
       
   249   AnimSwitchHog(dense)
       
   250   AnimWait(dense, 1)
       
   251   AddFunction({func = HideHedge, args = {cyborg}})
       
   252 end
       
   253 
       
   254 function RestoreCyborg(x, y, xx, yy)
       
   255   RestoreHedge(cyborg)
       
   256   RestoreHedge(princess)
       
   257   AnimOutOfNowhere(cyborg, x, y)
       
   258   AnimOutOfNowhere(princess, xx, yy)
       
   259   HogTurnLeft(princess, false)
       
   260   return true
       
   261 end
       
   262 
       
   263 function RestoreCyborgOnly(x, y)
       
   264   RestoreHedge(cyborg)
       
   265   SetState(cyborg, 0)
       
   266   AnimOutOfNowhere(cyborg, x, y)
       
   267   return true
       
   268 end
       
   269 
       
   270 function TargetPrincess()
       
   271   ParseCommand("setweap " .. string.char(amDEagle))
       
   272   SetGearMessage(cyborg, gmUp)
       
   273   return true
       
   274 end
       
   275 
       
   276 function HideCyborg()
       
   277   HideHedge(cyborg)
       
   278   HideHedge(princess)
       
   279 end
       
   280 
       
   281 function HideCyborgOnly()
       
   282   HideHedge(cyborg)
       
   283 end
       
   284 
       
   285 function SetupKillRoom()
       
   286   PlaceGirder(2342, 1814, 2)
       
   287   PlaceGirder(2294, 1783, 0)
       
   288   PlaceGirder(2245, 1814, 2)
       
   289 end
       
   290 
       
   291 function SetupCourseDuo()
       
   292   PlaceGirder(1083, 1152, 6)
       
   293   PlaceGirder(1087, 1150, 6)
       
   294   PlaceGirder(1133, 1155, 0)
       
   295   PlaceGirder(1135, 1152, 0)
       
   296   PlaceGirder(1135, 1078, 0)
       
   297   PlaceGirder(1087, 1016, 2)
       
   298   PlaceGirder(1018, 921, 5)
       
   299   PlaceGirder(1016, 921, 5)
       
   300   PlaceGirder(962, 782, 6)
       
   301   PlaceGirder(962, 662, 2)
       
   302   PlaceGirder(962, 661, 2)
       
   303   PlaceGirder(962, 650, 2)
       
   304   PlaceGirder(962, 630, 2)
       
   305   PlaceGirder(1033, 649, 0)
       
   306   PlaceGirder(952, 650, 0)
       
   307 
       
   308   fireCrate = SpawnAmmoCrate(1846, 1100, amFirePunch)
       
   309   SpawnUtilityCrate(1900, 1100, amPickHammer)
       
   310   SpawnAmmoCrate(950, 674, amDynamite)
       
   311   SpawnUtilityCrate(994, 825, amRope)
       
   312   SpawnUtilityCrate(570, 1357, amLowGravity)
       
   313 end
       
   314 
       
   315 function DumpMines()
       
   316   SetTimer(AddGear(2261, 1835, gtMine, 0, 0, 0, 0), 5000)
       
   317   SetTimer(AddGear(2280, 1831, gtMine, 0, 0, 0, 0), 5000)
       
   318   SetTimer(AddGear(2272, 1809, gtMine, 0, 0, 0, 0), 5000)
       
   319   SetTimer(AddGear(2290, 1815, gtMine, 0, 0, 0, 0), 5000)
       
   320   SetTimer(AddGear(2278, 1815, gtMine, 0, 0, 0, 0), 5000)
       
   321   SetTimer(AddGear(2307, 1811, gtMine, 0, 0, 0, 0), 5000)
       
   322   SetTimer(AddGear(2286, 1820, gtMine, 0, 0, 0, 0), 5000)
       
   323   SetTimer(AddGear(2309, 1813, gtMine, 0, 0, 0, 0), 5000)
       
   324   SetTimer(AddGear(2303, 1822, gtMine, 0, 0, 0, 0), 5000)
       
   325   SetTimer(AddGear(2317, 1827, gtMine, 0, 0, 0, 0), 5000)
       
   326   SetTimer(AddGear(2312, 1816, gtMine, 0, 0, 0, 0), 5000)
       
   327   SetTimer(AddGear(2316, 1812, gtMine, 0, 0, 0, 0), 5000)
       
   328   SetTimer(AddGear(2307, 1802, gtMine, 0, 0, 0, 0), 5000)
       
   329   SetTimer(AddGear(2276, 1818, gtMine, 0, 0, 0, 0), 5000)
       
   330   SetTimer(AddGear(2284, 1816, gtMine, 0, 0, 0, 0), 5000)
       
   331   SetTimer(AddGear(2292, 1811, gtMine, 0, 0, 0, 0), 5000)
       
   332   SetTimer(AddGear(2295, 1814, gtMine, 0, 0, 0, 0), 5000)
       
   333   SetTimer(AddGear(2306, 1811, gtMine, 0, 0, 0, 0), 5000)
       
   334   SetTimer(AddGear(2292, 1815, gtMine, 0, 0, 0, 0), 5000)
       
   335   SetTimer(AddGear(2314, 1815, gtMine, 0, 0, 0, 0), 5000)
       
   336   SetTimer(AddGear(2286, 1813, gtMine, 0, 0, 0, 0), 5000)
       
   337   SetTimer(AddGear(2275, 1813, gtMine, 0, 0, 0, 0), 5000)
       
   338   SetTimer(AddGear(2269, 1814, gtMine, 0, 0, 0, 0), 5000)
       
   339   SetTimer(AddGear(2273, 1812, gtMine, 0, 0, 0, 0), 5000)
       
   340   SetTimer(AddGear(2300, 1808, gtMine, 0, 0, 0, 0), 5000)
       
   341   SetTimer(AddGear(2322, 1812, gtMine, 0, 0, 0, 0), 5000)
       
   342   SetTimer(AddGear(2323, 1813, gtMine, 0, 0, 0, 0), 5000)
       
   343   SetTimer(AddGear(2311, 1811, gtMine, 0, 0, 0, 0), 5000)
       
   344   SetTimer(AddGear(2303, 1809, gtMine, 0, 0, 0, 0), 5000)
       
   345   SetTimer(AddGear(2287, 1808, gtMine, 0, 0, 0, 0), 5000)
       
   346   SetTimer(AddGear(2282, 1808, gtMine, 0, 0, 0, 0), 5000)
       
   347   SetTimer(AddGear(2277, 1809, gtMine, 0, 0, 0, 0), 5000)
       
   348   SetTimer(AddGear(2296, 1809, gtMine, 0, 0, 0, 0), 5000)
       
   349   SetTimer(AddGear(2314, 1818, gtMine, 0, 0, 0, 0), 5000)
       
   350 end
       
   351 
       
   352 function SetupAnimRefusedDied()
       
   353   SetupAnimAcceptedDied()
       
   354   table.insert(startAnim, {func = AnimSay, args = {leaks, loc("I just wonder where Ramon and Spiky disappeared..."), SAY_THINK, 6000}})
       
   355 end
       
   356 
       
   357 function SetupAnimAttacked()
       
   358   SetupAnimAcceptedDied()
       
   359   startAnim = {}
       
   360   table.insert(startAnim, {func = AnimWait, args = {leaks, 3000}})
       
   361   table.insert(startAnim, {func = AnimTurn, args = {leaks, "Left"}})
       
   362   table.insert(startAnim, {func = AnimSay, args = {leaks, loc("I wonder where Dense Cloud is..."), SAY_THINK, 4000}})
       
   363   table.insert(startAnim, {func = AnimSay, args = {leaks, loc("He must be in the village already."), SAY_THINK, 4000}})
       
   364   table.insert(startAnim, {func = AnimSay, args = {leaks, loc("I'd better get going myself."), SAY_THINK, 4000}})
       
   365 
       
   366   midAnim = {}
       
   367   table.insert(midAnim, {func = AnimWait, args = {leaks, 500}})
       
   368   table.insert(midAnim, {func = AnimCustomFunction, swh = false, args = {leaks, RestoreCyborg, {1300, 1200, 1390, 1200}}})
       
   369   table.insert(midAnim, {func = AnimSwitchHog, args = {cyborg}})
       
   370   table.insert(midAnim, {func = AnimCustomFunction, args = {cyborg, TargetPrincess, {}}})
       
   371   table.insert(midAnim, {func = AnimSay, args = {cyborg, loc("Welcome, Leaks A Lot!"), SAY_SAY, 3000}})
       
   372   table.insert(midAnim, {func = AnimSay, args = {cyborg, loc("I want to play a game..."), SAY_SAY, 3000}})
       
   373   table.insert(midAnim, {func = AnimSay, args = {princess, loc("Help me, please!!!"), SAY_SHOUT, 3000}})
       
   374   table.insert(midAnim, {func = AnimSay, args = {cyborg, loc("If you can get that crate fast enough, your beloved \"princess\" may go free."), SAY_SAY, 7000}})
       
   375   table.insert(midAnim, {func = AnimSay, args = {cyborg, loc("However, if you fail to do so, she dies a most violent death! Muahahaha!"), SAY_SAY, 8000}})
       
   376   table.insert(midAnim, {func = AnimSay, args = {cyborg, loc("Good luck...or else!"), SAY_SAY, 4000}})
       
   377   table.insert(midAnim, {func = AnimTeleportGear, args = {leaks, 2656, 1842}})
       
   378   table.insert(midAnim, {func = AnimCustomFunction, args = {cyborg, HideCyborg, {}}, swh = false})
       
   379   table.insert(midAnim, {func = AnimSay, args = {leaks, loc("Hey! This is cheating!"), SAY_SHOUT, 4000}})
       
   380   AddSkipFunction(midAnim, SkipMidAnimAlone, {})
       
   381 end
       
   382 
       
   383 function SetupAnimAcceptedDied()
       
   384   table.insert(startAnimAD, {func = AnimWait, args = {leaks, 3000}})
       
   385   table.insert(startAnimAD, {func = AnimTurn, args = {leaks, "Left"}})
       
   386   table.insert(startAnimAD, {func = AnimSay, args = {leaks, loc("I need to get to the other side of this island, fast!"), SAY_THINK, 5000}})
       
   387   table.insert(startAnimAD, {func = AnimSay, args = {leaks, loc("With Dense Cloud on the land of shadows, I'm the village's only hope..."), SAY_THINK, 7000}})
       
   388 
       
   389   table.insert(midAnimAD, {func = AnimWait, args = {leaks, 500}})
       
   390   table.insert(midAnimAD, {func = AnimCustomFunction, swh = false, args = {leaks, RestoreCyborg, {1300, 1200, 1390, 1200}}})
       
   391   table.insert(midAnimAD, {func = AnimSwitchHog, args = {cyborg}})
       
   392   table.insert(midAnimAD, {func = AnimCustomFunction, args = {cyborg, TargetPrincess, {}}})
       
   393   table.insert(midAnimAD, {func = AnimSay, args = {cyborg, loc("Welcome, Leaks A Lot!"), SAY_SAY, 3000}})
       
   394   table.insert(midAnimAD, {func = AnimSay, args = {cyborg, loc("I want to play a game..."), SAY_SAY, 3000}})
       
   395   table.insert(midAnimAD, {func = AnimSay, args = {princess, loc("Help me, please!!!"), SAY_SHOUT, 3000}})
       
   396   table.insert(midAnimAD, {func = AnimSay, args = {cyborg, loc("If you can get that crate fast enough, your beloved \"princess\" may go free."), SAY_SAY, 7000}})
       
   397   table.insert(midAnimAD, {func = AnimSay, args = {cyborg, loc("However, if you fail to do so, she dies a most violent death, just like your friend! Muahahaha!"), SAY_SAY, 8000}})
       
   398   table.insert(midAnimAD, {func = AnimSay, args = {cyborg, loc("Good luck...or else!"), SAY_SAY, 4000}})
       
   399   table.insert(midAnimAD, {func = AnimTeleportGear, args = {leaks, 2656, 1842}})
       
   400   table.insert(midAnimAD, {func = AnimCustomFunction, args = {cyborg, HideCyborg, {}}, swh = false})
       
   401   table.insert(midAnimAD, {func = AnimSay, args = {leaks, loc("Hey! This is cheating!"), SAY_SHOUT, 4000}})
       
   402   AddSkipFunction(midAnimAD, SkipMidAnimAlone, {})
       
   403 
       
   404   table.insert(failAnimAD, {func = AnimCustomFunction, swh = false, args = {leaks, RestoreCyborg, {2299, 1687, 2294, 1841}}})
       
   405   table.insert(failAnimAD, {func = AnimTeleportGear, args = {leaks, 2090, 1841}})
       
   406   table.insert(failAnimAD, {func = AnimCustomFunction, swh = false, args = {cyborg, SetupKillRoom, {}}})
       
   407   table.insert(failAnimAD, {func = AnimTurn, swh = false, args = {cyborg, "Left"}})
       
   408   table.insert(failAnimAD, {func = AnimTurn, swh = false, args = {princess, "Left"}})
       
   409   table.insert(failAnimAD, {func = AnimTurn, swh = false, args = {leaks, "Right"}})
       
   410   table.insert(failAnimAD, {func = AnimWait, args = {cyborg, 1000}})
       
   411   table.insert(failAnimAD, {func = AnimSay, args = {cyborg, loc("You have failed to complete your task, young one!"), SAY_SAY, 6000}})
       
   412   table.insert(failAnimAD, {func = AnimSay, args = {cyborg, loc("It's time you learned that your actions have consequences!"), SAY_SAY, 7000}})
       
   413   table.insert(failAnimAD, {func = AnimSay, args = {princess, loc("No! Please, help me!"), SAY_SAY, 4000}})
       
   414   table.insert(failAnimAD, {func = AnimSwitchHog, args = {cyborg}})
       
   415   table.insert(failAnimAD, {func = AnimCustomFunction, args = {cyborg, DumpMines, {}}})
       
   416   table.insert(failAnimAD, {func = AnimCustomFunction, args = {cyborg, KillPrincess, {}}})
       
   417   table.insert(failAnimAD, {func = AnimWait, args = {cyborg, 12000}})
       
   418   table.insert(failAnimAD, {func = AnimSay, args = {leaks, loc("No! What have I done?! What have YOU done?!"), SAY_SHOUT, 6000}})
       
   419 
       
   420   table.insert(endAnimAD, {func = AnimCustomFunction, swh = false, args = {leaks, RestoreCyborg, {437, 1700, 519, 1722}}})
       
   421   table.insert(endAnimAD, {func = AnimTurn, swh = false, args = {cyborg, "Right"}})
       
   422   table.insert(endAnimAD, {func = AnimTurn, swh = false, args = {princess, "Right"}})
       
   423   table.insert(endAnimAD, {func = AnimSay, args = {princess, loc("Help me, Leaks!"), SAY_SHOUT, 3000}})
       
   424   table.insert(endAnimAD, {func = AnimSay, args = {leaks, loc("But you said you'd let her go!"), SAY_SHOUT, 5000}})
       
   425   table.insert(endAnimAD, {func = AnimSay, args = {cyborg, loc("And you believed me? Oh, god, that's cute!"), SAY_SHOUT, 7000}})
       
   426   table.insert(endAnimAD, {func = AnimSay, args = {leaks, loc("I won't let you kill her!"), SAY_SHOUT, 4000}})
       
   427   AddSkipFunction(endAnimAD, SkipEndAnimAlone, {})
       
   428   
       
   429   table.insert(endFailAnim, {func = AnimCaption, args = {leaks, loc("Leaks A Lot, depressed for killing his loved one, failed to save the village..."), 3000}})
       
   430 
       
   431   table.insert(winAnimAD, {func = AnimCustomFunction, args = {princess, CondNeedToTurn, {leaks, princess}}})
       
   432   table.insert(winAnimAD, {func = AnimSay, args = {princess, loc("Thank you, oh, thank you, Leaks A Lot!"), SAY_SAY, 5000}})
       
   433   table.insert(winAnimAD, {func = AnimSay, args = {princess, loc("How can I ever repay you for saving my life?"), SAY_SAY, 6000}})
       
   434   table.insert(winAnimAD, {func = AnimSay, args = {leaks, loc("There's nothing more satisfying for me than seeing you share your beauty with the world every morning, my princess!"), SAY_SAY, 10000}})
       
   435   table.insert(winAnimAD, {func = AnimSay, args = {leaks, loc("Let's go home!"), SAY_SAY, 3000}})
       
   436   table.insert(winAnimAD, {func = AnimCaption, args = {leaks, loc("And so they discovered that cyborgs weren't invulnerable..."), 2000}})
       
   437 
       
   438   startAnim = startAnimAD
       
   439   midAnim = midAnimAD
       
   440   failAnim = failAnimAD
       
   441   endAnim = endAnimAD
       
   442   endFailAnim = endFailAnimAD
       
   443   winAnim = winAnimAD
       
   444 end
       
   445 
       
   446 function SetupAnimAcceptedLived()
       
   447   table.insert(startAnimAL, {func = AnimWait, args = {leaks, 3000}})
       
   448   table.insert(startAnimAL, {func = AnimCustomFunction, args = {dense, CondNeedToTurn, {leaks, dense}}})
       
   449   table.insert(startAnimAL, {func = AnimSay, args = {leaks, loc("All right, we just need to get to the other side of the island!"), SAY_SAY, 8000}})
       
   450   table.insert(startAnimAL, {func = AnimSay, args = {dense, loc("We have no time to waste..."), SAY_SAY, 4000}})
       
   451   table.insert(startAnimAL, {func = AnimSwitchHog, args = {leaks}})
       
   452   AddSkipFunction(startAnimAL, SkipStartAnim, {})
       
   453 
       
   454   table.insert(pastFlowerAnimAL, {func = AnimCustomFunction, args = {dense, RestoreCyborgOnly, {unpack(startCyborgPosDuo)}}, swh = false})
       
   455   table.insert(pastFlowerAnimAL, {func = AnimTurn, args = {cyborg, "Right"}})
       
   456   table.insert(pastFlowerAnimAL, {func = AnimSay, args = {cyborg, loc("Well, well! Isn't that the cutest thing you've ever seen?"), SAY_SAY, 7000}})
       
   457   table.insert(pastFlowerAnimAL, {func = AnimSay, args = {cyborg, loc("Two little hogs cooperating, getting past obstacles..."), SAY_SAY, 7000}})
       
   458   table.insert(pastFlowerAnimAL, {func = AnimSay, args = {cyborg, loc("Let me test your skills a little, will you?"), SAY_SAY, 6000}})
       
   459   table.insert(pastFlowerAnimAL, {func = AnimTeleportGear, args = {cyborg, 2456, 1842}})
       
   460   table.insert(pastFlowerAnimAL, {func = AnimTeleportGear, args = {dense, 2656, 1842}})
       
   461   table.insert(pastFlowerAnimAL, {func = AnimCustomFunction, args = {dense, CondNeedToTurn, {cyborg, dense}}})
       
   462   table.insert(pastFlowerAnimAL, {func = AnimSay, args = {dense, loc("Why are you doing this?"), SAY_SAY, 4000}})
       
   463   table.insert(pastFlowerAnimAL, {func = AnimSay, args = {cyborg, loc("To help you, of course!"), SAY_SAY, 4000}})
       
   464   table.insert(pastFlowerAnimAL, {func = AnimSwitchHog, args = {dense}})
       
   465   table.insert(pastFlowerAnimAL, {func = AnimDisappear, swh = false, args = {cyborg, 3781, 1583}})
       
   466   table.insert(pastFlowerAnimAL, {func = AnimCustomFunction, swh = false, args = {cyborg, HideCyborgOnly, {}}})
       
   467   AddSkipFunction(pastFlowerAnimAL, SkipPastFlowerAnim, {})
       
   468 
       
   469   table.insert(outPitAnimAL, {func = AnimCustomFunction, args = {dense, RestoreCyborgOnly, {unpack(midCyborgPosDuo)}}, swh = false})
       
   470   table.insert(outPitAnimAL, {func = AnimTurn, args = {cyborg, "Right"}})
       
   471   table.insert(outPitAnimAL, {func = AnimTeleportGear, args = {dense, unpack(midDensePosDuo)}})
       
   472   table.insert(outPitAnimAL, {func = AnimTurn, args = {dense, "Left"}})
       
   473   table.insert(outPitAnimAL, {func = AnimSay, args = {dense, loc("OH, COME ON!"), SAY_SHOUT, 3000}})
       
   474   table.insert(outPitAnimAL, {func = AnimSay, args = {cyborg, loc("Let's see what your comrade does now!"), SAY_SAY, 5000}})
       
   475   table.insert(outPitAnimAL, {func = AnimSwitchHog, args = {dense}})
       
   476   table.insert(outPitAnimAL, {func = AnimDisappear, swh = false, args = {cyborg, 3781, 1583}})
       
   477   table.insert(outPitAnimAL, {func = AnimCustomFunction, swh = false, args = {cyborg, HideCyborgOnly, {}}})
       
   478   AddSkipFunction(outPitAnimAL, SkipOutPitAnim, {})
       
   479 
       
   480   table.insert(endAnim, {func = AnimCustomFunction, swh = false, args = {leaks, RestoreCyborg, {437, 1700, 519, 1722}}})
       
   481   table.insert(endAnim, {func = AnimTeleportGear, args = {leaks, 763, 1760}})
       
   482   table.insert(endAnim, {func = AnimTeleportGear, args = {dense, 835, 1519}})
       
   483   table.insert(endAnim, {func = AnimTurn, swh = false, args = {leaks, "Left"}})
       
   484   table.insert(endAnim, {func = AnimTurn, swh = false, args = {dense, "Left"}})
       
   485   table.insert(endAnim, {func = AnimTurn, swh = false, args = {cyborg, "Right"}})
       
   486   table.insert(endAnim, {func = AnimTurn, swh = false, args = {princess, "Right"}})
       
   487   table.insert(endAnim, {func = AnimSay, args = {princess, loc("Help me, please!"), SAY_SHOUT, 3000}})
       
   488   table.insert(endAnim, {func = AnimSay, args = {leaks, loc("What are you doing? Let her go!"), SAY_SHOUT, 5000}})
       
   489   table.insert(endAnim, {func = AnimSay, args = {cyborg, loc("Yeah? Watcha gonna do? Cry?"), SAY_SHOUT, 5000}})
       
   490   table.insert(endAnim, {func = AnimSay, args = {leaks, loc("We won't let you hurt her!"), SAY_SHOUT, 4000}})
       
   491   AddSkipFunction(endAnim, SkipEndAnimDuo, {})
       
   492   
       
   493   table.insert(endFailAnim, {func = AnimCaption, args = {leaks, loc("Leaks A Lot, depressed for killing his loved one, failed to save the village..."), 3000}})
       
   494 
       
   495   table.insert(winAnim, {func = AnimCustomFunction, args = {princess, CondNeedToTurn, {leaks, princess}}})
       
   496   table.insert(winAnim, {func = AnimSay, args = {princess, loc("Thank you, oh, thank you, my heroes!"), SAY_SAY, 5000}})
       
   497   table.insert(winAnim, {func = AnimSay, args = {princess, loc("How can I ever repay you for saving my life?"), SAY_SAY, 6000}})
       
   498   table.insert(winAnim, {func = AnimSay, args = {leaks, loc("There's nothing more satisfying to us than seeing you share your beauty..."), SAY_SAY, 7000}})
       
   499   table.insert(winAnim, {func = AnimSay, args = {leaks, loc("... share your beauty with the world every morning, my princess!"), SAY_SAY, 7000}})
       
   500   table.insert(winAnim, {func = AnimSay, args = {leaks, loc("Let's go home!"), SAY_SAY, 3000}})
       
   501   table.insert(winAnim, {func = AnimCaption, args = {leaks, loc("And so they discovered that cyborgs weren't invulnerable..."), 2000}})
       
   502 
       
   503   startAnim = startAnimAL
       
   504   pastFlowerAnim = pastFlowerAnimAL
       
   505   outPitAnim = outPitAnimAL
       
   506 end
       
   507 
       
   508 function SetupAnimRefusedLived()
       
   509   table.insert(startAnimRL, {func = AnimWait, args = {leaks, 3000}})
       
   510   table.insert(startAnimRL, {func = AnimCustomFunction, args = {dense, CondNeedToTurn, {leaks, dense}}})
       
   511   table.insert(startAnimRL, {func = AnimSay, args = {leaks, loc("All right, we just need to get to the other side of the island!"), SAY_SAY, 7000}})
       
   512   table.insert(startAnimRL, {func = AnimSay, args = {dense, loc("Dude, can you see Ramon and Spiky?"), SAY_SAY, 5000}})
       
   513   table.insert(startAnimRL, {func = AnimSay, args = {leaks, loc("No...I wonder where they disappeared?!"), SAY_SAY, 5000}})
       
   514   AddSkipFunction(startAnimRL, SkipStartAnim, {})
       
   515 
       
   516   table.insert(pastFlowerAnimRL, {func = AnimCustomFunction, args = {dense, RestoreCyborgOnly, {unpack(startCyborgPosDuo)}}, swh = false})
       
   517   table.insert(pastFlowerAnimRL, {func = AnimTurn, args = {cyborg, "Right"}})
       
   518   table.insert(pastFlowerAnimRL, {func = AnimSay, args = {cyborg, loc("Well, well! Isn't that the cutest thing you've ever seen?"), SAY_SAY, 7000}})
       
   519   table.insert(pastFlowerAnimRL, {func = AnimSay, args = {cyborg, loc("Two little hogs cooperating, getting past obstacles..."), SAY_SAY, 7000}})
       
   520   table.insert(pastFlowerAnimRL, {func = AnimSay, args = {cyborg, loc("Let me test your skills a little, will you?"), SAY_SAY, 6000}})
       
   521   table.insert(pastFlowerAnimRL, {func = AnimTeleportGear, args = {cyborg, 2456, 1842}})
       
   522   table.insert(pastFlowerAnimRL, {func = AnimTeleportGear, args = {dense, 2656, 1842}})
       
   523   table.insert(pastFlowerAnimRL, {func = AnimCustomFunction, args = {dense, CondNeedToTurn, {cyborg, dense}}})
       
   524   table.insert(pastFlowerAnimRL, {func = AnimSay, args = {dense, loc("Why are you doing this?"), SAY_SAY, 4000}})
       
   525   table.insert(pastFlowerAnimRL, {func = AnimSay, args = {cyborg, loc("You couldn't possibly believe that after refusing my offer I'd just let you go!"), SAY_SAY, 9000}})
       
   526   table.insert(pastFlowerAnimRL, {func = AnimSay, args = {cyborg, loc("You're funny!"), SAY_SAY, 4000}})
       
   527   table.insert(pastFlowerAnimRL, {func = AnimSwitchHog, args = {dense}})
       
   528   table.insert(pastFlowerAnimRL, {func = AnimDisappear, swh = false, args = {cyborg, 3781, 1583}})
       
   529   table.insert(pastFlowerAnimRL, {func = AnimCustomFunction, swh = false, args = {cyborg, HideCyborgOnly, {}}})
       
   530   AddSkipFunction(pastFlowerAnimRL, SkipPastFlowerAnim, {})
       
   531 
       
   532   table.insert(outPitAnimRL, {func = AnimCustomFunction, args = {dense, RestoreCyborgOnly, {unpack(midCyborgPosDuo)}}, swh = false})
       
   533   table.insert(outPitAnimRL, {func = AnimTurn, args = {cyborg, "Right"}})
       
   534   table.insert(outPitAnimRL, {func = AnimTeleportGear, args = {dense, unpack(midDensePosDuo)}})
       
   535   table.insert(outPitAnimRL, {func = AnimTurn, args = {dense, "Left"}})
       
   536   table.insert(outPitAnimRL, {func = AnimSay, args = {dense, loc("OH, COME ON!"), SAY_SHOUT, 3000}})
       
   537   table.insert(outPitAnimRL, {func = AnimSay, args = {cyborg, loc("Let's see what your comrade does now!"), SAY_SAY, 5000}})
       
   538   table.insert(outPitAnimRL, {func = AnimSwitchHog, args = {dense}})
       
   539   table.insert(outPitAnimRL, {func = AnimDisappear, swh = false, args = {cyborg, 3781, 1583}})
       
   540   table.insert(outPitAnimRL, {func = AnimCustomFunction, swh = false, args = {cyborg, HideCyborgOnly, {}}})
       
   541   AddSkipFunction(outPitAnimRL, SkipOutPitAnim, {})
       
   542 
       
   543   table.insert(endAnim, {func = AnimCustomFunction, args = {leaks, RestoreCyborg, {437, 1700, 519, 1722}}})
       
   544   table.insert(endAnim, {func = AnimTeleportGear, args = {leaks, 763, 1760}})
       
   545   table.insert(endAnim, {func = AnimTeleportGear, args = {dense, 835, 1519}})
       
   546   table.insert(endAnim, {func = AnimTurn, swh = false, args = {leaks, "Left"}})
       
   547   table.insert(endAnim, {func = AnimTurn, swh = false, args = {dense, "Left"}})
       
   548   table.insert(endAnim, {func = AnimTurn, swh = false, args = {cyborg, "Right"}})
       
   549   table.insert(endAnim, {func = AnimTurn, swh = false, args = {princess, "Right"}})
       
   550   table.insert(endAnim, {func = AnimSay, args = {princess, loc("Help me, please!"), SAY_SHOUT, 3000}})
       
   551   table.insert(endAnim, {func = AnimSay, args = {leaks, loc("What are you doing? Let her go!"), SAY_SHOUT, 5000}})
       
   552   table.insert(endAnim, {func = AnimSay, args = {cyborg, loc("Yeah? Watcha gonna do? Cry?"), SAY_SHOUT, 5000}})
       
   553   table.insert(endAnim, {func = AnimSay, args = {leaks, loc("We won't let you hurt her!"), SAY_SHOUT, 4000}})
       
   554   AddSkipFunction(endAnim, SkipEndAnimDuo, {})
       
   555   
       
   556   table.insert(endFailAnim, {func = AnimCaption, args = {leaks, loc("Leaks A Lot, depressed for killing his loved one, failed to save the village..."), 3000}})
       
   557 
       
   558   table.insert(winAnim, {func = AnimCustomFunction, args = {princess, CondNeedToTurn, {leaks, princess}}})
       
   559   table.insert(winAnim, {func = AnimSay, args = {princess, loc("Thank you, oh, thank you, my heroes!"), SAY_SAY, 5000}})
       
   560   table.insert(winAnim, {func = AnimSay, args = {princess, loc("How can I ever repay you for saving my life?"), SAY_SAY, 6000}})
       
   561   table.insert(winAnim, {func = AnimSay, args = {leaks, loc("There's nothing more satisfying to us than seeing you share your beauty with the world every morning, my princess!"), SAY_SAY, 10000}})
       
   562   table.insert(winAnim, {func = AnimSay, args = {leaks, loc("Let's go home!"), SAY_SAY, 3000}})
       
   563   table.insert(winAnim, {func = AnimCaption, args = {leaks, loc("And so they discovered that cyborgs weren't invulnerable..."), 2000}})
       
   564 
       
   565   startAnim = startAnimRL
       
   566   pastFlowerAnim = pastFlowerAnimRL
       
   567   outPitAnim = outPitAnimRL
       
   568 end
       
   569 
       
   570 function KillPrincess()
       
   571   ParseCommand("teamgone " .. loc("Cannibal Sentry"))
       
   572   TurnTimeLeft = 0
       
   573 end
       
   574 --/////////////////////////////Misc Functions////////////////////////
       
   575 
       
   576 function HideHedge(hedge)
       
   577   if hedgeHidden[hedge] ~= true then
       
   578     HideHog(hedge)
       
   579     hedgeHidden[hedge] = true
       
   580   end
       
   581 end
       
   582 
       
   583 function RestoreHedge(hedge)
       
   584   if hedgeHidden[hedge] == true then
       
   585     RestoreHog(hedge)
       
   586     hedgeHidden[hedge] = false
       
   587   end
       
   588 end
       
   589 
       
   590 function CondNeedToTurn(hog1, hog2)
       
   591   xl, xd = GetX(hog1), GetX(hog2)
       
   592   if xl > xd then
       
   593     AnimInsertStepNext({func = AnimTurn, args = {hog1, "Left"}})
       
   594     AnimInsertStepNext({func = AnimTurn, args = {hog2, "Right"}})
       
   595   elseif xl < xd then
       
   596     AnimInsertStepNext({func = AnimTurn, args = {hog2, "Left"}})
       
   597     AnimInsertStepNext({func = AnimTurn, args = {hog1, "Right"}})
       
   598   end
       
   599 end
       
   600 
       
   601 function SetupPlaceAlone()
       
   602   ------ AMMO CRATE LIST ------
       
   603   --SpawnAmmoCrate(3122, 994, amShotgun)
       
   604   SpawnAmmoCrate(3124, 952, amBaseballBat)
       
   605   SpawnAmmoCrate(2508, 1110, amFirePunch)
       
   606   ------ UTILITY CRATE LIST ------
       
   607   blowCrate = SpawnUtilityCrate(3675, 1480, amBlowTorch)
       
   608   gravityCrate = SpawnUtilityCrate(3448, 1349, amLowGravity)
       
   609   SpawnUtilityCrate(3212, 1256, amGirder)
       
   610   SpawnUtilityCrate(3113, 911, amParachute)
       
   611   sniperCrate = SpawnAmmoCrate(784, 1715, amSniperRifle)
       
   612   ------ MINE LIST ------
       
   613   SetTimer(AddGear(3328, 1399, gtMine, 0, 0, 0, 0), 3000)
       
   614   SetTimer(AddGear(3028, 1262, gtMine, 0, 0, 0, 0), 3000)
       
   615   SetTimer(AddGear(2994, 1274, gtMine, 0, 0, 0, 0), 3000)
       
   616   SetTimer(AddGear(2956, 1277, gtMine, 0, 0, 0, 0), 3000)
       
   617   SetTimer(AddGear(2925, 1282, gtMine, 0, 0, 0, 0), 3000)
       
   618   SetTimer(AddGear(2838, 1276, gtMine, 0, 0, 0, 0), 3000)
       
   619   SetTimer(AddGear(2822, 1278, gtMine, 0, 0, 0, 0), 3000)
       
   620   SetTimer(AddGear(2786, 1283, gtMine, 0, 0, 0, 0), 3000)
       
   621   SetTimer(AddGear(2766, 1270, gtMine, 0, 0, 0, 0), 3000)
       
   622   SetTimer(AddGear(2749, 1231, gtMine, 0, 0, 0, 0), 3000)
       
   623   SetTimer(AddGear(2717, 1354, gtMine, 0, 0, 0, 0), 3000)
       
   624   SetTimer(AddGear(2167, 1330, gtMine, 0, 0, 0, 0), 3000)
       
   625   SetTimer(AddGear(2201, 1321, gtMine, 0, 0, 0, 0), 3000)
       
   626   SetTimer(AddGear(2239, 1295, gtMine, 0, 0, 0, 0), 3000)
       
   627 
       
   628   AnimSetGearPosition(leaks, 3781, 1583)
       
   629   --AnimSetGearPosition(leaks, 1650, 1583)
       
   630   AddAmmo(cannibals[1], amShotgun, 100)
       
   631   AddAmmo(leaks, amSwitch, 0)
       
   632 end
       
   633 
       
   634 function SetupPlaceDuo()
       
   635   PlaceCratesDuo()
       
   636   AnimSetGearPosition(leaks, unpack(startLeaksPosDuo))
       
   637   AnimSetGearPosition(dense, unpack(startDensePosDuo))
       
   638 end
       
   639 
       
   640 function SetupEventsDuo()
       
   641   AddEvent(CheckPastFlower, {}, DoPastFlower, {}, 0)
       
   642   AddEvent(CheckLeaksDead, {}, DoLeaksDead, {}, 0)
       
   643   AddEvent(CheckDenseDead, {}, DoDenseDead, {}, 0)
       
   644   AddEvent(CheckTookSniper2, {}, DoTookSniper2, {}, 0)
       
   645 end
       
   646 
       
   647 function SetupEventsAlone()
       
   648   AddEvent(CheckLeaksDead, {}, DoLeaksDead, {}, 0)
       
   649   AddEvent(CheckTookBlowTorch, {}, DoTookBlowTorch, {}, 0)
       
   650   AddEvent(CheckTookLowGravity, {}, DoTookLowGravity, {}, 0)
       
   651   AddEvent(CheckOnBridge, {}, DoOnBridge, {}, 0)
       
   652 end
       
   653 
       
   654 function StartMission()
       
   655   if m2DenseDead == 1 then
       
   656     DeleteGear(dense)
       
   657     if m2Choice == choiceAccepted then
       
   658       SetupAnimAcceptedDied()
       
   659     elseif m2Choice == choiceRefused then
       
   660       SetupAnimRefusedDied()
       
   661     else
       
   662       SetupAnimAttacked()
       
   663     end
       
   664     SetupPlaceAlone()
       
   665     SetupEventsAlone()
       
   666     AddAnim(startAnim)
       
   667     AddFunction({func = AfterStartAnim, args = {}})
       
   668   else
       
   669     if m2Choice == choiceAccepted then
       
   670       SetupAnimAcceptedLived()
       
   671     else
       
   672       SetupAnimRefusedLived()
       
   673     end
       
   674     SetupPlaceDuo()
       
   675     SetupEventsDuo()
       
   676     AddAnim(startAnim)
       
   677     AddFunction({func = AfterStartAnim, args = {}})
       
   678   end
       
   679   HideHedge(cyborg)
       
   680   HideHedge(princess)
       
   681   for i = 5, 8 do
       
   682     HideHedge(cannibals[i])
       
   683   end
       
   684 
       
   685 end
       
   686   
       
   687 function SetupCourse()
       
   688 
       
   689   ------ GIRDER LIST ------
       
   690   PlaceGirder(1091, 1150, 6)
       
   691   PlaceGirder(1091, 989, 6)
       
   692   PlaceGirder(1091, 829, 6)
       
   693   PlaceGirder(1091, 669, 6)
       
   694   PlaceGirder(1091, 668, 6)
       
   695   PlaceGirder(1091, 669, 6)
       
   696   PlaceGirder(1088, 667, 6)
       
   697   PlaceGirder(1091, 658, 6)
       
   698   PlaceGirder(1091, 646, 6)
       
   699   PlaceGirder(1091, 607, 6)
       
   700   PlaceGirder(1091, 571, 6)
       
   701   PlaceGirder(1376, 821, 6)
       
   702   PlaceGirder(1145, 1192, 1)
       
   703   PlaceGirder(1169, 1076, 3)
       
   704   PlaceGirder(1351, 1082, 4)
       
   705   PlaceGirder(1469, 987, 3)
       
   706   PlaceGirder(1386, 951, 0)
       
   707   PlaceGirder(1465, 852, 3)
       
   708   PlaceGirder(1630, 913, 0)
       
   709   PlaceGirder(1733, 856, 7)
       
   710   PlaceGirder(1688, 713, 5)
       
   711   PlaceGirder(1556, 696, 2)
       
   712   PlaceGirder(1525, 696, 2)
       
   713   PlaceGirder(1457, 697, 2)
       
   714   PlaceGirder(1413, 700, 3)
       
   715   PlaceGirder(1270, 783, 2)
       
   716   PlaceGirder(1207, 825, 2)
       
   717   PlaceGirder(1135, 775, 1)
       
   718 
       
   719   ------ UTILITY CRATE LIST ------
       
   720   SpawnUtilityCrate(1590, 628, amParachute)
       
   721   SpawnAmmoCrate(1540, 100, amDynamite)
       
   722   SpawnUtilityCrate(2175, 1815, amLowGravity)
       
   723   SpawnUtilityCrate(2210, 1499, amFirePunch)
       
   724   girderCrate = SpawnUtilityCrate(2300, 1663, amGirder)
       
   725   SpawnUtilityCrate(610, 1394, amPickHammer)
       
   726   
       
   727   ------ BARREL LIST ------
       
   728   SetHealth(AddGear(1148, 736, gtExplosives, 0, 0, 0, 0), 20)
       
   729 
       
   730 end
       
   731 
       
   732 function PlaceCourseMines()
       
   733   SetTimer(AddGear(1215, 1193, gtMine, 0, 0, 0, 0), 5000)
       
   734   SetTimer(AddGear(1259, 1199, gtMine, 0, 0, 0, 0), 5000)
       
   735   SetTimer(AddGear(1310, 1198, gtMine, 0, 0, 0, 0), 5000)
       
   736   SetTimer(AddGear(1346, 1196, gtMine, 0, 0, 0, 0), 5000)
       
   737   SetTimer(AddGear(1383, 1192, gtMine, 0, 0, 0, 0), 5000)
       
   738   SetTimer(AddGear(1436, 1196, gtMine, 0, 0, 0, 0), 5000)
       
   739   SetTimer(AddGear(1487, 1199, gtMine, 0, 0, 0, 0), 5000)
       
   740   SetTimer(AddGear(1651, 1209, gtMine, 0, 0, 0, 0), 5000)
       
   741   SetTimer(AddGear(1708, 1209, gtMine, 0, 0, 0, 0), 5000)
       
   742   SetTimer(AddGear(1759, 1190, gtMine, 0, 0, 0, 0), 5000)
       
   743   SetTimer(AddGear(1815, 1184, gtMine, 0, 0, 0, 0), 5000)
       
   744 end
       
   745 
       
   746 
       
   747 --////////////////////////////Event Functions////////////////////////
       
   748 function CheckTookFire()
       
   749   return fireTaken
       
   750 end
       
   751 
       
   752 function DoTookFire()
       
   753   AddAmmo(leaks, amFirePunch, 100)
       
   754 end
       
   755 
       
   756 function CheckTookGirder1()
       
   757   return girder1Taken
       
   758 end
       
   759 
       
   760 function CheckTookGirder2()
       
   761   return girder2Taken
       
   762 end
       
   763 
       
   764 function DoTookGirder1()
       
   765   AddAmmo(dense, amGirder, 2)
       
   766 end
       
   767 
       
   768 function DoTookGirder2()
       
   769   AddAmmo(dense, amGirder, 3)
       
   770 end
       
   771 
       
   772 function CheckDensePit()
       
   773   return GetY(dense) < 1250 and StoppedGear(dense)
       
   774 end
       
   775 
       
   776 function DoDensePit()
       
   777   TurnTimeLeft = 0
       
   778   RestoreHedge(cyborg)
       
   779   AnimWait(cyborg, 1)
       
   780   AddFunction({func = AddAnim, args = {outPitAnim}})
       
   781   AddFunction({func = AddFunction, args = {{func = AfterOutPitAnim, args = {}}}})
       
   782 end
       
   783 
       
   784 function CheckPastFlower()
       
   785   if denseDead == true or leaksDead == true then
       
   786     return false
       
   787   end
       
   788   return (GetX(dense) < startEventXDuo and StoppedGear(dense))
       
   789       or (GetX(leaks) < startEventXDuo and StoppedGear(leaks))
       
   790 end
       
   791 
       
   792 function DoPastFlower()
       
   793   TurnTimeLeft = 0
       
   794   RestoreHedge(cyborg)
       
   795   AnimWait(cyborg, 1)
       
   796   AddFunction({func = AddAnim, args = {pastFlowerAnim}})
       
   797   AddFunction({func = AddFunction, args = {{func = AfterPastFlowerAnim, args = {}}}})
       
   798 end
       
   799 
       
   800 
       
   801 function CheckLeaksDead()
       
   802   return leaksDead
       
   803 end
       
   804 
       
   805 function DoLeaksDead()
       
   806   AddCaption(loc("The village, unprepared, was destroyed by the cyborgs..."))
       
   807   ParseCommand("teamgone " .. loc("Natives"))
       
   808 end
       
   809 
       
   810 function CheckDenseDead()
       
   811   return denseDead
       
   812 end
       
   813 
       
   814 function DoDenseDead()
       
   815   AddCaption(loc("The village, unprepared, was destroyed by the cyborgs..."))
       
   816   ParseCommand("teamgone " .. loc("Natives"))
       
   817 end
       
   818 
       
   819 function CheckTookBlowTorch()
       
   820   return blowTaken
       
   821 end
       
   822 
       
   823 function DoTookBlowTorch()
       
   824   ShowMission(loc("The Journey Back"), loc("The Tunnel Maker"), loc("Hint: Select the BlowTorch, aim and press [Fire]. Press [Fire] again to stop.|Don't blow up the crate."), 0, 6000)
       
   825 end
       
   826 
       
   827 function CheckTookLowGravity()
       
   828   return gravityTaken
       
   829 end
       
   830 
       
   831 function DoTookLowGravity()
       
   832   ShowMission(loc("The Journey Back"), loc("The Moonwalk"), loc("Hint: Select the LowGravity and press [Fire]."), 0, 6000)
       
   833 end
       
   834 
       
   835 function CheckOnBridge()
       
   836   return leaksDead == false and GetX(leaks) < 1651 and StoppedGear(leaks)
       
   837 end
       
   838 
       
   839 function DoOnBridge()
       
   840   TurnTimeLeft = 0
       
   841   RestoreHedge(cyborg)
       
   842   RestoreHedge(princess)
       
   843   AnimWait(cyborg, 1)
       
   844   AddFunction({func = AddAnim, args = {midAnim}})
       
   845   AddFunction({func = AddFunction, args = {{func = AfterMidAnimAlone, args = {}}}})
       
   846 end
       
   847 
       
   848 function CheckGirderTaken()
       
   849   return girderTaken
       
   850 end
       
   851 
       
   852 function DoGirderTaken()
       
   853   AddAmmo(leaks, amGirder, 2)
       
   854 --  AddAmmo(leaks, amGirder, 3)
       
   855 end
       
   856 
       
   857 function CheckOnFirstGirder()
       
   858   return leaksDead == false and GetX(leaks) < 1160 and StoppedGear(leaks)
       
   859 end
       
   860 
       
   861 function DoOnFirstGirder()
       
   862   PlaceCourseMines()
       
   863   ShowMission(loc("The Journey Back"), loc("Slippery"), loc("You'd better watch your steps..."), 0, 4000)
       
   864 end
       
   865 
       
   866 function CheckTookSniper()
       
   867   return sniperTaken and StoppedGear(leaks)
       
   868 end
       
   869 
       
   870 function DoTookSniper()
       
   871   TurnTimeLeft = 0
       
   872   RestoreHedge(cyborg)
       
   873   RestoreHedge(princess)
       
   874   AnimWait(cyborg, 1)
       
   875   AddFunction({func = AddAnim, args = {endAnim}})
       
   876   AddFunction({func = AddFunction, args = {{func = AfterEndAnimAlone, args = {}}}})
       
   877 end
       
   878 
       
   879 function CheckTookSniper2()
       
   880   return sniperTaken and StoppedGear(leaks) and StoppedGear(dense)
       
   881 end
       
   882 
       
   883 function DoTookSniper2()
       
   884   TurnTimeLeft = 0
       
   885   RestoreHedge(cyborg)
       
   886   RestoreHedge(princess)
       
   887   AnimWait(cyborg, 1)
       
   888   AddFunction({func = AddAnim, args = {endAnim}})
       
   889   AddFunction({func = AddFunction, args = {{func = AfterEndAnimDuo, args = {}}}})
       
   890 end
       
   891 
       
   892 function CheckLost()
       
   893   return princessDead
       
   894 end
       
   895 
       
   896 function DoLost()
       
   897   AddAnim(endFailAnim)
       
   898   AddFunction({func = ParseCommand, args = {'teamgone ' .. loc('Natives')}})
       
   899 end
       
   900 
       
   901 function CheckWon()
       
   902   return cyborgDead and not princessDead
       
   903 end
       
   904 
       
   905 function DoWon()
       
   906   if progress and progress<3 then
       
   907     SaveCampaignVar("Progress", "3")
       
   908   end
       
   909   AddAnim(winAnim)
       
   910   AddFunction({func = FinishWon, args = {}})
       
   911 end
       
   912 
       
   913 function FinishWon()
       
   914   SwitchHog(leaks)
       
   915   ParseCommand("teamgone " .. loc("Cannibal Sentry"))
       
   916   ParseCommand("teamgone " .. loc("011101001"))
       
   917   TurnTimeLeft = 0
       
   918 end
       
   919 
       
   920 function CheckFailedCourse()
       
   921   return TurnsLeft == 0
       
   922 end
       
   923 
       
   924 function DoFailedCourse()
       
   925   TurnTimeLeft = 0
       
   926   RestoreHedge(cyborg)
       
   927   RestoreHedge(princess)
       
   928   AnimWait(cyborg, 1)
       
   929   AddFunction({func = AddAnim, args = {failAnim}})
       
   930   AddFunction({func = AddFunction, args = {{func = AfterMidFailAnim, args = {}}}})
       
   931 end
       
   932 
       
   933 --////////////////////////////Main Functions/////////////////////////
       
   934 
       
   935 function onGameInit()
       
   936 	Seed = 0
       
   937 	GameFlags = gfSolidLand + gfDisableWind
       
   938 	TurnTime = 40000 
       
   939 	CaseFreq = 0
       
   940 	MinesNum = 0
       
   941 	MinesTime = 3000
       
   942 	Explosives = 0
       
   943 	Delay = 5
       
   944     Map = "A_Classic_Fairytale_journey"
       
   945     Theme = "Nature"
       
   946 
       
   947     SuddenDeathTurns = 3000
       
   948 
       
   949 	AddTeam(loc("Natives"), 29439, "Bone", "Island", "HillBilly", "cm_birdy")
       
   950 	leaks = AddHog(loc("Leaks A Lot"), 0, 100, "Rambo")
       
   951   dense = AddHog(loc("Dense Cloud"), 0, 100, "RobinHood")
       
   952 
       
   953   AddTeam(loc("Cannibal Sentry"), 14483456, "Skull", "Island", "Pirate","cm_vampire")
       
   954   cannibals = {}
       
   955   for i = 1, 4 do
       
   956     cannibals[i] = AddHog(cannibalNames[i], 3, 40, "Zombi")
       
   957     AnimSetGearPosition(cannibals[i], unpack(cannibalPos[i]))
       
   958   end
       
   959 
       
   960   for i = 5, 8 do
       
   961     cannibals[i] = AddHog(cannibalNames[i], 3, 40, "Zombi")
       
   962     AnimSetGearPosition(cannibals[i], 0, 0)
       
   963   end
       
   964 
       
   965   AddTeam(loc("011101001"), 14483456, "ring", "UFO", "Robot", "cm_star")
       
   966   cyborg = AddHog(loc("Y3K1337"), 0, 200, "cyborg1")
       
   967   princess = AddHog(loc("Fell From Heaven"), 0, 200, "tiara")
       
   968 
       
   969   AnimSetGearPosition(dense, 0, 0)
       
   970   AnimSetGearPosition(leaks, 0, 0)
       
   971   AnimSetGearPosition(cyborg, 0, 0)
       
   972   AnimSetGearPosition(princess, 0, 0)
       
   973   
       
   974   AnimInit()
       
   975 end
       
   976 
       
   977 function onGameStart()
       
   978   progress = tonumber(GetCampaignVar("Progress"))
       
   979   m2Choice = tonumber(GetCampaignVar("M2Choice"))
       
   980   m2DenseDead = tonumber(GetCampaignVar("M2DenseDead"))
       
   981   m2RamonDead = tonumber(GetCampaignVar("M2RamonDead"))
       
   982   m2SpikyDead = tonumber(GetCampaignVar("M2SpikyDead"))
       
   983   StartMission()
       
   984 end
       
   985 
       
   986 function onGameTick()
       
   987   AnimUnWait()
       
   988   if ShowAnimation() == false then
       
   989     return
       
   990   end
       
   991   ExecuteAfterAnimations()
       
   992   CheckEvents()
       
   993 end
       
   994 
       
   995 function onGearDelete(gear)
       
   996   if gear == blowCrate then
       
   997     blowTaken = true
       
   998   elseif gear == fireCrate then
       
   999     fireTaken = true
       
  1000   elseif gear == gravityCrate then
       
  1001     gravityTaken = true
       
  1002   elseif gear == leaks then
       
  1003     leaksDead = true
       
  1004   elseif gear == dense then
       
  1005     denseDead = true
       
  1006   elseif gear == cyborg then
       
  1007     cyborgDead = true
       
  1008   elseif gear == princess then
       
  1009     princessDead = true
       
  1010   elseif gear == girderCrate then
       
  1011     girderTaken = true
       
  1012   elseif gear == girderCrate1 then
       
  1013     girder1Taken = true
       
  1014   elseif gear == girderCrate2 then
       
  1015     girder2Taken = true
       
  1016   elseif gear == sniperCrate then
       
  1017     sniperTaken = true
       
  1018   else
       
  1019     for i = 1, 4 do
       
  1020       if gear == cannibals[i] then
       
  1021         cannibalDead[i] = true
       
  1022       end
       
  1023     end
       
  1024   end
       
  1025 end
       
  1026 
       
  1027 function onAmmoStoreInit()
       
  1028   SetAmmo(amBlowTorch, 0, 0, 0, 1)
       
  1029   SetAmmo(amParachute, 0, 0, 0, 1)
       
  1030   SetAmmo(amGirder, 0, 0, 0, 3)
       
  1031   SetAmmo(amLowGravity, 0, 0, 0, 1)
       
  1032   SetAmmo(amBaseballBat, 0, 0, 0, 1)
       
  1033   SetAmmo(amFirePunch, 1, 0, 0, 1)
       
  1034   SetAmmo(amSkip, 9, 0, 0, 0)
       
  1035   SetAmmo(amSwitch, 9, 0, 0, 0)
       
  1036   SetAmmo(amDEagle, 9, 0, 0, 0)
       
  1037   SetAmmo(amRope, 0, 0, 0, 1)
       
  1038   SetAmmo(amSniperRifle, 0, 0, 0, 1)
       
  1039   SetAmmo(amDynamite, 0, 0, 0, 1)
       
  1040   SetAmmo(amPickHammer, 0, 0, 0, 1)
       
  1041 end
       
  1042 
       
  1043 function onNewTurn()
       
  1044   if AnimInProgress() then
       
  1045     TurnTimeLeft = -1
       
  1046   elseif stage == endStage and CurrentHedgehog ~= leaks then
       
  1047     AnimSwitchHog(leaks)
       
  1048     SetGearMessage(leaks, 0)
       
  1049     TurnTimeLeft = -1
       
  1050   elseif GetHogTeamName(CurrentHedgehog) ~= loc("Natives") then
       
  1051     for i = 1, 4 do
       
  1052       if cannibalDead[i] ~= true then
       
  1053         if GetX(cannibals[i]) < GetX(leaks) then
       
  1054           HogTurnLeft(cannibals[i], false)
       
  1055         else
       
  1056           HogTurnLeft(cannibals[i], true)
       
  1057         end
       
  1058       end
       
  1059     end
       
  1060     SetInputMask(band(0xFFFFFFFF, bnot(gmLeft + gmRight + gmLJump + gmHJump)))
       
  1061     TurnTimeLeft = 20000
       
  1062   else
       
  1063     SetInputMask(0xFFFFFFFF)
       
  1064     TurnsLeft = TurnsLeft - 1
       
  1065   end
       
  1066 end
       
  1067 
       
  1068 function onPrecise()
       
  1069   if GameTime > 2500 and AnimInProgress() then
       
  1070     SetAnimSkip(true)
       
  1071     return
       
  1072   end
       
  1073 --  AddAmmo(leaks, amRope, 100)
       
  1074 --  RemoveEventFunc(CheckPastFlower)
       
  1075 --  DeleteGear(sniperCrate)
       
  1076 end
       
  1077