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