share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/queen.lua
changeset 7443 a7f861f1c3b8
child 7448 d0521a3a4358
equal deleted inserted replaced
7438:195f9cbd6df6 7443:a7f861f1c3b8
       
     1 loadfile(GetDataPath() .. "Scripts/Locale.lua")()
       
     2 loadfile(GetDataPath() .. "Scripts/Animate.lua")()
       
     3 
       
     4 
       
     5 -----------------------------Map--------------------------------------
       
     6 local map =
       
     7 {
       
     8 	"\16\7\0\225\132\15\200\1\40\0\15\200\1\40\132\15\105\8\81\0\16\14\1\64\143\15\200\7\249\0\13\50\7\252\132\12\243\7\172\0",
       
     9 	"\12\236\7\168\132\12\127\6\192\0\12\127\6\192\132\11\52\6\223\0\11\52\6\223\132\10\62\8\35\0\8\201\8\4\132\8\63\7\126\0",
       
    10 	"\8\63\7\126\132\8\4\6\58\0\8\0\6\65\132\7\147\6\241\0\7\133\6\195\132\7\20\4\151\0\7\143\6\195\132\7\140\6\234\0",
       
    11 	"\7\17\4\151\132\5\191\4\222\0\5\191\4\222\132\3\136\3\252\0\3\136\3\252\132\2\12\4\151\0\2\12\4\151\132\1\138\5\15\0",
       
    12 	"\1\138\5\15\132\1\54\5\156\0\1\54\5\156\132\0\130\5\64\0\0\130\5\64\132\255\214\5\135\0\8\141\1\85\179\8\141\1\85\0",
       
    13 	"\10\30\2\220\139\10\30\2\220\0\11\77\1\142\131\11\77\1\142\0\10\188\0\113\129\10\188\0\113\0\255\235\0\162\132\0\130\0\225\0",
       
    14 	"\0\130\0\229\0\0\127\0\236\132\255\231\0\250\0\0\28\0\215\136\0\4\0\211\0\0\95\5\212\154\0\95\7\238\0\0\246\6\2\154",
       
    15 	"\1\71\8\0\0\1\205\5\145\154\2\132\4\239\0\3\98\4\141\154\1\135\5\216\0\3\179\4\151\154\6\213\5\247\0\6\223\5\124\151",
       
    16 	"\6\185\5\22\0\6\181\5\29\151\6\37\5\64\0\0\179\5\198\148\0\179\5\198\0\6\216\4\253\148\6\216\4\253\0\1\230\7\147\153",
       
    17 	"\8\32\8\18\0\1\187\6\174\153\7\179\7\108\0\2\199\5\177\179\6\128\6\167\0\7\231\7\10\143\7\231\6\202\0\12\148\8\4\156",
       
    18 	"\10\241\8\11\0\11\112\7\101\156\12\56\7\91\0\1\89\5\223\199\4\11\5\208\0\4\67\5\212\200\4\172\6\58\0\4\172\6\58\200",
       
    19 	"\5\36\5\212\0\5\40\5\194\200\4\169\5\57\0\4\169\5\57\200\4\42\5\205\0\4\130\5\142\200\4\218\5\205\0\4\137\5\194\200",
       
    20 	"\4\179\5\251\0\255\245\1\198\133\0\77\1\198\0\0\77\1\198\133\0\102\1\226\0\0\102\1\230\133\255\221\1\244\0\255\245\0\148\195",
       
    21 	"\255\231\1\11\0\0\32\0\162\195\255\231\0\169\0\0\60\0\158\195\0\32\0\172\0\0\21\0\176\195\255\242\0\222\0\255\245\0\215\195",
       
    22 	"\0\7\0\246\0\255\245\0\243\195\0\11\1\33\0\0\4\1\4\195\0\56\1\36\0\255\245\1\173\195\0\35\1\110\0\255\242\1\180\195",
       
    23 	"\255\224\2\9\0\255\238\1\240\195\0\28\2\30\0\0\21\2\19\195\0\102\2\23\0\16\18\1\1\195\16\35\0\222\0\16\14\1\11\195",
       
    24 	"\16\7\2\9\0\16\0\2\16\195\16\35\3\34\0\16\11\2\252\195\16\11\4\208\0\16\11\4\208\195\16\0\6\55\0\16\0\6\55\195",
       
    25 	"\16\14\8\25\0",
       
    26 }
       
    27 
       
    28 --------------------------------------------Constants------------------------------------
       
    29 choiceAccepted = 1
       
    30 choiceRefused = 2
       
    31 choiceAttacked = 3
       
    32 
       
    33 choiceEliminate = 1
       
    34 choiceSpare = 2
       
    35 
       
    36 leaksNum = 1
       
    37 denseNum = 2
       
    38 waterNum = 3
       
    39 buffaloNum = 4
       
    40 chiefNum = 5
       
    41 girlNum = 6
       
    42 wiseNum = 7
       
    43 
       
    44 denseScene = 1
       
    45 princessScene = 2
       
    46 waterScene = 3
       
    47 cyborgScene = 4
       
    48 
       
    49 nativeNames = {loc("Leaks A Lot"), loc("Dense Cloud"), loc("Fiery Water"), 
       
    50                loc("Raging Buffalo"), loc("Righteous Beard"), loc("Fell From Grace"),
       
    51                loc("Wise Oak"), loc("Ramon"), loc("Spiky Cheese")
       
    52               }
       
    53 nativeSaveNames = {"M8DeployedDead", "M8RamonDead", "M8SpikyDead", "M8PrincessDead"}
       
    54 
       
    55 nativeUnNames = {loc("Zork"), loc("Steve"), loc("Jack"),
       
    56                  loc("Lee"), loc("Elmo"), loc("Rachel"),
       
    57                  loc("Muriel")}
       
    58 
       
    59 nativeHats = {"Rambo", "RobinHood", "pirate_jack", "zoo_Bunny", "IndianChief",
       
    60               "tiara", "AkuAku", "rasta", "hair_yellow"}
       
    61 
       
    62 nativePos = {{1474, 1188}, {923, 986}, {564, 1120}, {128, 1315}}
       
    63 nativesNum = 4
       
    64 nativesLeft = 4
       
    65 
       
    66 cyborgNames = {loc("Artur Detour"), loc("Led Heart"), loc("Orlando Boom!"), loc("Nilarian"), 
       
    67                loc("Steel Eye"), loc("Rusty Joe"), loc("Hatless Jerry"), loc("Gas Gargler")}
       
    68 
       
    69 cyborgsDif = {2, 2, 2, 2, 2, 2, 2, 2}
       
    70 cyborgsHealth = {100, 100, 100, 100, 100, 100, 100, 100}
       
    71 cyborgPos = {1765, 1145}
       
    72 cyborgsTeamNum = {4, 3}
       
    73 cyborgsNum = 7
       
    74 cyborgsPos = {{2893, 1717}, {2958, 1701}, {3027, 1696}, {3096, 1698},
       
    75               {2584, 655},  {2047, 1534}, {115, 179}, {2162, 1916}}
       
    76 cyborgsDir = {"Left", "Left", "Left", "Left", "Left", "Left", "Right", "Left"}
       
    77 
       
    78 crateConsts = {}
       
    79 reactions = {}
       
    80 
       
    81 enemyPos = {4078, 195}
       
    82 
       
    83 -----------------------------Variables---------------------------------
       
    84 natives = {}
       
    85 origNatives = {}
       
    86 
       
    87 cyborgs = {}
       
    88 cyborg = nil
       
    89 
       
    90 gearDead = {}
       
    91 hedgeHidden = {}
       
    92 
       
    93 scene = 0
       
    94 enemyFled = "0"
       
    95 
       
    96 deployedLeader = "0"
       
    97 princessLeader = "0"
       
    98 
       
    99 startAnim = {}
       
   100 fleeAnim = {}
       
   101 finalAnim = {}
       
   102 leaderDeadAnim = {}
       
   103 -----------------------------Animations--------------------------------
       
   104 function EmitDenseClouds(dir)
       
   105   local dif
       
   106   if dir == "Left" then
       
   107     dif = 10
       
   108   else
       
   109     dif = -10
       
   110   end
       
   111   if dir == nil then
       
   112     dx, dy = GetGearVelocity(dense)
       
   113     if dx < 0 then 
       
   114       dif = 10
       
   115     else 
       
   116       dif = -10
       
   117     end
       
   118   end
       
   119   AnimInsertStepNext({func = AnimVisualGear, args = {dense, GetX(dense) + dif, GetY(dense) + dif, vgtSteam, 0, true}, swh = false})
       
   120   AnimInsertStepNext({func = AnimVisualGear, args = {dense, GetX(dense) + dif, GetY(dense) + dif, vgtSteam, 0, true}, swh = false})
       
   121   AnimInsertStepNext({func = AnimVisualGear, args = {dense, GetX(dense) + dif, GetY(dense) + dif, vgtSteam, 0, true}, swh = false})
       
   122   AnimInsertStepNext({func = AnimWait, args = {dense, 800}})
       
   123   AnimInsertStepNext({func = AnimVisualGear, args = {dense, GetX(dense) + dif, GetY(dense) + dif, vgtSteam, 0, true}, swh = false})
       
   124   AnimInsertStepNext({func = AnimVisualGear, args = {dense, GetX(dense) + dif, GetY(dense) + dif, vgtSteam, 0, true}, swh = false})
       
   125   AnimInsertStepNext({func = AnimWait, args = {dense, 800}})
       
   126   AnimInsertStepNext({func = AnimVisualGear, args = {dense, GetX(dense) + dif, GetY(dense) + dif, vgtSteam, 0, true}, swh = false})
       
   127 end
       
   128 
       
   129 function AnimationSetup()
       
   130   table.insert(startAnim, {func = AnimWait, args = {enemy, 3000}})
       
   131   table.insert(startAnim, {func = AnimCaption, swh = false, args = {natives[1], "The team continued their quest of finding the rest of the tribe.", 4000}})
       
   132   table.insert(startAnim, {func = AnimCaption, swh = false, args = {natives[1], "They stumbled upon a pile of weapons, they seemed to be getting closer.", 4500}})
       
   133   if scene == denseScene then
       
   134     if m5DeployedNum == denseNum then
       
   135       deployedLeader = "1"
       
   136       SetupDenseAnimDeployed()
       
   137     else
       
   138       SetupDenseAnim()
       
   139     end
       
   140   elseif scene == waterScene then
       
   141     if m5DeployedNum == waterNum then
       
   142       deployedLeader = "1"
       
   143       SetupWaterAnimDeployed()
       
   144     else
       
   145       SetupWaterAnim()
       
   146     end
       
   147   elseif scene == princessScene then
       
   148     princessLeader = "1"
       
   149     SetupPrincessAnim()
       
   150   else
       
   151     SetupCyborgAnim()
       
   152   end
       
   153 
       
   154   AddSkipFunction(startAnim, SkipAnim, {})
       
   155   AddSkipFunction(fleeAnim, SkipAnim, {})
       
   156   AddSkipFunction(leaderDeadAnim, SkipAnim, {})
       
   157 end
       
   158 
       
   159 function SetupLeaderDeadAnim()
       
   160   local gear = nil
       
   161   if CheckCyborgsDead() then
       
   162     return
       
   163   end
       
   164   for i = nativesLeft, 1, -1 do
       
   165     if band(GetState(natives[i]), gstDrowning) == 0 then
       
   166       gear = natives[i]
       
   167     end
       
   168   end
       
   169   if gear == nil then
       
   170     return
       
   171   end
       
   172   table.insert(leaderDeadAnim, {func = AnimSay, args = {gear, "That traitor won't be killing us anymore!", SAY_THINK, 6000}})
       
   173 end
       
   174 
       
   175 function SetupDenseAnim()
       
   176   table.insert(startAnim, {func = AnimSay, args = {enemy, "Yo, dude! Get away from our weapons!", SAY_SHOUT, 5500}})
       
   177   table.insert(startAnim, {func = AnimSay, args = {natives[1], "Dense Cloud?! What are you doing?!", SAY_SHOUT, 5500}})
       
   178   table.insert(startAnim, {func = AnimSay, args = {enemy, "What does it look like?", SAY_SHOUT, 3500}})
       
   179   table.insert(startAnim, {func = AnimSay, args = {natives[1], "Are you helping the aliens?!", SAY_SHOUT, 4000}})
       
   180   table.insert(startAnim, {func = AnimSay, args = {enemy, "Lolz, I love the look on your face!", SAY_SHOUT, 5000}})
       
   181   table.insert(startAnim, {func = AnimSay, args = {enemy, "Did you really think that I'd changed?", SAY_SHOUT, 5500}})
       
   182   table.insert(startAnim, {func = AnimSay, args = {natives[1], "But why did you betray us?!", SAY_SHOUT, 4000}})
       
   183   table.insert(startAnim, {func = AnimSay, args = {enemy, "Yo, the aliens gave me plants...medicinal plants...lots of it.", SAY_SHOUT, 6500}})
       
   184   table.insert(startAnim, {func = AnimSay, args = {enemy, "You never give me plants!", SAY_SHOUT, 5500}})
       
   185   table.insert(startAnim, {func = AnimSay, args = {enemy, "Besides, why would I choose certain death?", SAY_SHOUT, 5500}})
       
   186   table.insert(startAnim, {func = AnimSay, args = {enemy, "Do you have any idea how bad an exploding arrow hurts?", SAY_SHOUT, 5500}})
       
   187   table.insert(startAnim, {func = AnimSay, args = {enemy, "Dude, it's unbearable!", SAY_SHOUT, 5500}})
       
   188   table.insert(startAnim, {func = AnimSay, args = {natives[1], "You're a coward!", SAY_SHOUT, 3000}})
       
   189   table.insert(startAnim, {func = AnimSay, args = {natives[1], "You endangered your whole tribe, you bastard!", SAY_SHOUT, 7000}})
       
   190   table.insert(startAnim, {func = AnimSay, args = {enemy, "Yeah, well, for some dude to be happy, some other dude has to suffer.", SAY_SHOUT, 11000}})
       
   191   table.insert(startAnim, {func = AnimSay, args = {enemy, "That's just the way it works, you know.", SAY_SHOUT, 6500}})
       
   192   table.insert(startAnim, {func = AnimSay, args = {natives[1], "You're some piece of hypocrite junkie!", SAY_SHOUT, 6000}})
       
   193   table.insert(startAnim, {func = AnimSay, args = {enemy, "Why do you always have to call me names?", SAY_SHOUT, 6000}})
       
   194   table.insert(startAnim, {func = AnimCustomFunction, args = {enemy, EmitDenseClouds, {}}})
       
   195   table.insert(startAnim, {func = AnimSay, args = {enemy, "Make fun of me when I fart...", SAY_SHOUT, 5000}})
       
   196   table.insert(startAnim, {func = AnimSay, args = {enemy, "IT'S A SERIOUS MEDICAL CONDITION!", SAY_SHOUT, 5000}})
       
   197   table.insert(startAnim, {func = AnimSay, args = {enemy, "You don't deserve my sacrifice!", SAY_SHOUT, 5000}})
       
   198   table.insert(startAnim, {func = AnimSay, args = {natives[1], "I won't let you kill the tribe!", SAY_SHOUT, 5000}})
       
   199 
       
   200   table.insert(fleeAnim, {func = AnimSay, args = {enemy, "Dude, this is boring!", SAY_SAY, 3000}})
       
   201   table.insert(fleeAnim, {func = AnimSay, args = {enemy, "I ain't gonna sit around no more!", SAY_SAY, 5000}})
       
   202   table.insert(fleeAnim, {func = AnimTurn, args = {enemy, "Right"}})
       
   203   table.insert(fleeAnim, {func = AnimSay, args = {enemy, "Yo, escort my buttocks!", SAY_SHOUT, 3500}})
       
   204   table.insert(fleeAnim, {func = AnimSwitchHog, args = {natives[1]}})
       
   205   table.insert(fleeAnim, {func = AnimWait, args = {natives[1], 1}})
       
   206   table.insert(fleeAnim, {func = AnimDisappear, swh = false, args = {enemy, 0, 0}})
       
   207 end
       
   208 
       
   209 function SetupDenseAnimDeployed()
       
   210   table.insert(startAnim, {func = AnimCustomFunction, args = {enemy, EmitDenseClouds, {}}})
       
   211   table.insert(startAnim, {func = AnimCustomFunction, args = {enemy, CondNeedToTurn, {natives[3], enemy}}})
       
   212   table.insert(startAnim, {func = AnimCustomFunction, args = {enemy, CondNeedToTurn, {natives[2], enemy}}})
       
   213   table.insert(startAnim, {func = AnimCustomFunction, args = {enemy, CondNeedToTurn, {natives[1], enemy}}})
       
   214   table.insert(startAnim, {func = AnimSay, args = {enemy, "I'm afraid I can't let you proceed!", SAY_SHOUT, 5000}})
       
   215   table.insert(startAnim, {func = AnimSay, args = {natives[1], "???", SAY_THINK, 0}})
       
   216   table.insert(startAnim, {func = AnimSay, args = {natives[2], "???", SAY_THINK, 0}})
       
   217   table.insert(startAnim, {func = AnimSay, args = {natives[3], "???", SAY_THINK, 1000}})
       
   218   table.insert(startAnim, {func = AnimSay, args = {enemy, "Dude, wow, you're so cute!", SAY_SHOUT, 4000}})
       
   219   table.insert(startAnim, {func = AnimSay, args = {enemy, "Did you really think I'd change?", SAY_SHOUT, 4500}})
       
   220   table.insert(startAnim, {func = AnimSay, args = {enemy, "I'm still with the aliens.", SAY_SHOUT, 4000}})
       
   221   table.insert(startAnim, {func = AnimTeleportGear, args = {enemy, unpack(enemyPos)}})
       
   222   table.insert(startAnim, {func = AnimCustomFunction, args = {enemy, CondNeedToTurn, {natives[1], enemy}}})
       
   223   table.insert(startAnim, {func = AnimSay, args = {natives[1], "WHAT?!", SAY_THINK, 1000}})
       
   224   table.insert(startAnim, {func = AnimSay, args = {natives[3], "But you saved me!", SAY_THINK, 2500}})
       
   225   table.insert(startAnim, {func = AnimSay, args = {enemy, "Haha, that was just a coincidence!", SAY_SHOUT, 4000}})
       
   226   table.insert(startAnim, {func = AnimSay, args = {enemy, "I was heading home, you see!", SAY_SHOUT, 3500}})
       
   227   table.insert(startAnim, {func = AnimSay, args = {natives[1], "We were your home! Your family...", SAY_SHOUT, 4000}})
       
   228   table.insert(startAnim, {func = AnimSay, args = {natives[1], "How could you betray us?!", SAY_SHOUT, 4000}})
       
   229   table.insert(startAnim, {func = AnimSay, args = {enemy, "Yo, the aliens gave me plants...medicinal plants...lots of it.", SAY_SHOUT, 6500}})
       
   230   table.insert(startAnim, {func = AnimSay, args = {enemy, "You never give me plants!", SAY_SHOUT, 5500}})
       
   231   table.insert(startAnim, {func = AnimSay, args = {enemy, "Besides, why would I choose certain death?", SAY_SHOUT, 5500}})
       
   232   table.insert(startAnim, {func = AnimSay, args = {enemy, "Do you have any idea how bad an exploding arrow hurts?", SAY_SHOUT, 5500}})
       
   233   table.insert(startAnim, {func = AnimSay, args = {enemy, "Dude, it's unbearable!", SAY_SHOUT, 5500}})
       
   234   table.insert(startAnim, {func = AnimSay, args = {natives[1], "You're a coward!", SAY_SHOUT, 3000}})
       
   235   table.insert(startAnim, {func = AnimSay, args = {natives[1], "You endangered your whole tribe, you bastard!", SAY_SHOUT, 7000}})
       
   236   table.insert(startAnim, {func = AnimSay, args = {enemy, "Yeah, well, for some dude to be happy, some other dude has to suffer.", SAY_SHOUT, 11000}})
       
   237   table.insert(startAnim, {func = AnimSay, args = {enemy, "That's just the way it works, you know.", SAY_SHOUT, 6500}})
       
   238   table.insert(startAnim, {func = AnimSay, args = {natives[1], "You're some piece of hypocrite junkie!", SAY_SHOUT, 6000}})
       
   239   table.insert(startAnim, {func = AnimSay, args = {enemy, "Why do you always have to call me names?", SAY_SHOUT, 6000}})
       
   240   table.insert(startAnim, {func = AnimCustomFunction, args = {enemy, EmitDenseClouds, {}}})
       
   241   table.insert(startAnim, {func = AnimSay, args = {enemy, "Make fun of me when I fart...", SAY_SHOUT, 5000}})
       
   242   table.insert(startAnim, {func = AnimSay, args = {enemy, "IT'S A SERIOUS MEDICAL CONDITION!", SAY_SHOUT, 5000}})
       
   243   table.insert(startAnim, {func = AnimSay, args = {enemy, "You don't deserve my sacrifice!", SAY_SHOUT, 5000}})
       
   244   table.insert(startAnim, {func = AnimSay, args = {natives[1], "I won't let you kill the tribe!", SAY_SHOUT, 5000}})
       
   245 
       
   246   table.insert(fleeAnim, {func = AnimSay, args = {enemy, "Dude, this is boring!", SAY_SAY, 3000}})
       
   247   table.insert(fleeAnim, {func = AnimSay, args = {enemy, "I ain't gonna sit around no more!", SAY_SAY, 5000}})
       
   248   table.insert(fleeAnim, {func = AnimTurn, args = {enemy, "Right"}})
       
   249   table.insert(fleeAnim, {func = AnimSay, args = {enemy, "Yo, escort my buttocks!", SAY_SHOUT, 3500}})
       
   250   table.insert(fleeAnim, {func = AnimSwitchHog, args = {natives[1]}})
       
   251   table.insert(fleeAnim, {func = AnimWait, args = {natives[1], 1}})
       
   252   table.insert(fleeAnim, {func = AnimDisappear, swh = false, args = {enemy, 0, 0}})
       
   253 end
       
   254 
       
   255 function SetupWaterAnim()
       
   256   table.insert(startAnim, {func = AnimSay, args = {enemy, "Stay there, comrades!", SAY_SHOUT, 2500}})
       
   257   table.insert(startAnim, {func = AnimSay, args = {enemy, "Come closer and die...burp!", SAY_SHOUT, 4000}})
       
   258   table.insert(startAnim, {func = AnimSay, args = {natives[1], "Fiery Water?! Are you drunk again?", SAY_SHOUT, 5000}})
       
   259   table.insert(startAnim, {func = AnimSay, args = {enemy, "Drunk with power, perhappss!", SAY_SHOUT, 4000}})
       
   260   table.insert(startAnim, {func = AnimSay, args = {enemy, "The power of love! No, wait, the power of the aliens!", SAY_SHOUT, 7500}})
       
   261   table.insert(startAnim, {func = AnimSay, args = {natives[1], "We trusted you, you fool!", SAY_SHOUT, 4000}})
       
   262   table.insert(startAnim, {func = AnimSay, args = {natives[1], "Why do you keep betraying us?", SAY_SHOUT, 4000}})
       
   263   table.insert(startAnim, {func = AnimSay, args = {enemy, "Why, why, why, why!", SAY_SHOUT, 4000}})
       
   264   table.insert(startAnim, {func = AnimSay, args = {enemy, "I grew sick of the oppression! I brock free!", SAY_SHOUT, 6500}})
       
   265   table.insert(startAnim, {func = AnimSay, args = {natives[1], "What oppression?! You were the most unoppressed member of the tribe!", SAY_SHOUT, 10000}})
       
   266   table.insert(startAnim, {func = AnimSay, args = {enemy, "The opression of the elders, of course!", SAY_SHOUT, 6500}})
       
   267   if m5DeployedNum == leaksNum then
       
   268     table.insert(startAnim, {func = AnimSay, args = {enemy, "You should know this more than anyone, Leaks!", SAY_SHOUT, 7000}})
       
   269   elseif m5LeaksDead == 1 then
       
   270     table.insert(startAnim, {func = AnimSay, args = {enemy, "Just look at Leaks, may he rest in peace!", SAY_SHOUT, 6500}})
       
   271   end
       
   272   table.insert(startAnim, {func = AnimSay, args = {enemy, "We, the youth, have to constantly prove our value...", SAY_SHOUT, 7000}})
       
   273   table.insert(startAnim, {func = AnimSay, args = {enemy, "We work and work until we sweat blood...", SAY_SHOUT, 5000}})
       
   274   table.insert(startAnim, {func = AnimSay, args = {enemy, "We risk our lives going through challenges...", SAY_SHOUT, 6000}})
       
   275   table.insert(startAnim, {func = AnimSay, args = {enemy, "All this to please our beloved 'elders'...hick...", SAY_SHOUT, 6000}})
       
   276   table.insert(startAnim, {func = AnimSay, args = {enemy, "And what do they do in the meantime? NOTHING!", SAY_SHOUT, 6000}})
       
   277   table.insert(startAnim, {func = AnimSay, args = {enemy, "All they do is sit around and judge us!", SAY_SHOUT, 6000}})
       
   278   table.insert(startAnim, {func = AnimSay, args = {natives[1], "You have never worked a bit in your life!", SAY_SHOUT, 6000}})
       
   279   table.insert(startAnim, {func = AnimSay, args = {natives[1], "All *you* do is take long walks when everyone else works.", SAY_SHOUT, 9000}})
       
   280   table.insert(startAnim, {func = AnimSay, args = {enemy, "Anyway, the aliens accept me for who I am.", SAY_SHOUT, 7000}})
       
   281   table.insert(startAnim, {func = AnimSay, args = {natives[1], "We won't accept you destroying our village!", SAY_SHOUT, 7000}})
       
   282 
       
   283   table.insert(fleeAnim, {func = AnimSay, args = {enemy, "Argh, the borrdommm!", SAY_SAY, 3000}})
       
   284   table.insert(fleeAnim, {func = AnimSay, args = {enemy, "I have more important things to do!", SAY_SAY, 5000}})
       
   285   table.insert(fleeAnim, {func = AnimTurn, args = {enemy, "Right"}})
       
   286   table.insert(fleeAnim, {func = AnimSay, args = {enemy, "Comrades! Sail me away!", SAY_SHOUT, 3500}})
       
   287   table.insert(fleeAnim, {func = AnimSwitchHog, args = {natives[1]}})
       
   288   table.insert(fleeAnim, {func = AnimWait, args = {natives[1], 1}})
       
   289   table.insert(fleeAnim, {func = AnimDisappear, swh = false, args = {enemy, 0, 0}})
       
   290 end
       
   291 
       
   292 function SetupWaterAnimDeployed()
       
   293   table.insert(startAnim, {func = AnimCustomFunction, args = {enemy, CondNeedToTurn, {natives[3], enemy}}})
       
   294   table.insert(startAnim, {func = AnimCustomFunction, args = {enemy, CondNeedToTurn, {natives[2], enemy}}})
       
   295   table.insert(startAnim, {func = AnimCustomFunction, args = {enemy, CondNeedToTurn, {natives[1], enemy}}})
       
   296   table.insert(startAnim, {func = AnimSay, args = {enemy, "Stop, comrades!", SAY_SHOUT, 2500}})
       
   297   table.insert(startAnim, {func = AnimSay, args = {enemy, "I cannot let you go any farther...burp!", SAY_SHOUT, 5500}})
       
   298   table.insert(startAnim, {func = AnimSay, args = {natives[1], "Fiery Water?! Are you drunk again?", SAY_SHOUT, 5000}})
       
   299   table.insert(startAnim, {func = AnimSay, args = {enemy, "Drunk with power, perhappss!", SAY_SHOUT, 4000}})
       
   300   table.insert(startAnim, {func = AnimSay, args = {enemy, "The power of love! No, wait, the power of the aliens!", SAY_SHOUT, 7500}})
       
   301   table.insert(startAnim, {func = AnimTeleportGear, args = {enemy, unpack(enemyPos)}})
       
   302   table.insert(startAnim, {func = AnimCustomFunction, args = {enemy, CondNeedToTurn, {natives[3], enemy}}})
       
   303   table.insert(startAnim, {func = AnimCustomFunction, args = {enemy, CondNeedToTurn, {natives[2], enemy}}})
       
   304   table.insert(startAnim, {func = AnimCustomFunction, args = {enemy, CondNeedToTurn, {natives[1], enemy}}})
       
   305   table.insert(startAnim, {func = AnimSay, args = {natives[1], "We trusted you, you fool!", SAY_SHOUT, 4000}})
       
   306   table.insert(startAnim, {func = AnimSay, args = {natives[1], "Why do you keep betraying us?", SAY_SHOUT, 4000}})
       
   307   table.insert(startAnim, {func = AnimSay, args = {enemy, "Why, why, why, why!", SAY_SHOUT, 4000}})
       
   308   table.insert(startAnim, {func = AnimSay, args = {enemy, "I grew sick of the oppression! I brock free!", SAY_SHOUT, 6500}})
       
   309   table.insert(startAnim, {func = AnimSay, args = {natives[1], "What oppression?! You were the most unoppressed member of the tribe!", SAY_SHOUT, 10000}})
       
   310   table.insert(startAnim, {func = AnimSay, args = {enemy, "The opression of the elders, of course!", SAY_SHOUT, 6500}})
       
   311   table.insert(startAnim, {func = AnimSay, args = {enemy, "Just look at Leaks, may he rest in peace!", SAY_SHOUT, 6500}})
       
   312   table.insert(startAnim, {func = AnimSay, args = {enemy, "We, the youth, have to constantly prove our value...", SAY_SHOUT, 7000}})
       
   313   table.insert(startAnim, {func = AnimSay, args = {enemy, "We work and work until we sweat blood...", SAY_SHOUT, 5000}})
       
   314   table.insert(startAnim, {func = AnimSay, args = {enemy, "We risk our lives going through challenges...", SAY_SHOUT, 6000}})
       
   315   table.insert(startAnim, {func = AnimSay, args = {enemy, "All this to please our beloved 'elders'...hick...", SAY_SHOUT, 6000}})
       
   316   table.insert(startAnim, {func = AnimSay, args = {enemy, "And what do they do in the meantime? NOTHING!", SAY_SHOUT, 6000}})
       
   317   table.insert(startAnim, {func = AnimSay, args = {enemy, "All they do is sit around and judge us!", SAY_SHOUT, 6000}})
       
   318   table.insert(startAnim, {func = AnimSay, args = {natives[1], "You have never worked a bit in your life!", SAY_SHOUT, 6000}})
       
   319   table.insert(startAnim, {func = AnimSay, args = {natives[1], "All *you* do is take long walks when everyone else works.", SAY_SHOUT, 9000}})
       
   320   table.insert(startAnim, {func = AnimSay, args = {enemy, "Anyway, the aliens accept me for who I am.", SAY_SHOUT, 7000}})
       
   321   table.insert(startAnim, {func = AnimSay, args = {natives[1], "We won't accept you destroying our village!", SAY_SHOUT, 7000}})
       
   322 
       
   323   table.insert(fleeAnim, {func = AnimSay, args = {enemy, "Argh, the borrdommm!", SAY_SAY, 3000}})
       
   324   table.insert(fleeAnim, {func = AnimSay, args = {enemy, "I have more important things to do!", SAY_SAY, 5000}})
       
   325   table.insert(fleeAnim, {func = AnimTurn, args = {enemy, "Right"}})
       
   326   table.insert(fleeAnim, {func = AnimSay, args = {enemy, "Comrades! Sail me away!", SAY_SHOUT, 3500}})
       
   327   table.insert(fleeAnim, {func = AnimSwitchHog, args = {natives[1]}})
       
   328   table.insert(fleeAnim, {func = AnimWait, args = {natives[1], 1}})
       
   329   table.insert(fleeAnim, {func = AnimDisappear, swh = false, args = {enemy, 0, 0}})
       
   330 end
       
   331 
       
   332 function SetupPrincessAnim()
       
   333   table.insert(startAnim, {func = AnimCustomFunction, args = {enemy, CondNeedToTurn, {natives[3], enemy}}})
       
   334   table.insert(startAnim, {func = AnimCustomFunction, args = {enemy, CondNeedToTurn, {natives[2], enemy}}})
       
   335   table.insert(startAnim, {func = AnimCustomFunction, args = {enemy, CondNeedToTurn, {natives[1], enemy}}})
       
   336   table.insert(startAnim, {func = AnimSay, args = {enemy, "Oh, my! I forgot something!", SAY_SHOUT, 4000}})
       
   337   table.insert(startAnim, {func = AnimSay, args = {enemy, "We need to go back!", SAY_SHOUT, 3000}})
       
   338   table.insert(startAnim, {func = AnimSay, args = {natives[1], "What could you possibly forget in that cage?", SAY_SHOUT, 7000}})
       
   339   table.insert(startAnim, {func = AnimSay, args = {enemy, "I don't like your tone! You're hurting me!", SAY_SHOUT, 4000}})
       
   340   table.insert(startAnim, {func = AnimSay, args = {natives[1], "I'm terribly sorry!", SAY_SHOUT, 4000}})
       
   341   table.insert(startAnim, {func = AnimSay, args = {natives[1], "What is it that you forgot?", SAY_SHOUT, 4000}})
       
   342   table.insert(startAnim, {func = AnimSay, args = {enemy, "Uhmm, it's...uhm...my ring!", SAY_SHOUT, 4000}})
       
   343   table.insert(startAnim, {func = AnimSay, args = {enemy, "It's precious to me!", SAY_SHOUT, 3000}})
       
   344   table.insert(startAnim, {func = AnimSay, args = {natives[1], "We don't have time for that now!", SAY_SHOUT, 5000}})
       
   345   table.insert(startAnim, {func = AnimSay, args = {natives[1], "We have to find our folk!", SAY_SHOUT, 4000}})
       
   346   table.insert(startAnim, {func = AnimSay, args = {enemy, "But I want my sandals!", SAY_SHOUT, 3000}})
       
   347   table.insert(startAnim, {func = AnimSay, args = {natives[1], "Sandals?! I thought you left your ring!", SAY_SHOUT, 6000}})
       
   348   table.insert(startAnim, {func = AnimSay, args = {enemy, "All right, you got me...", SAY_SHOUT, 3000}})
       
   349   table.insert(startAnim, {func = AnimSay, args = {natives[1], "Got you? You're acting weird...", SAY_SHOUT, 4000}})
       
   350   table.insert(startAnim, {func = AnimSay, args = {enemy, "You just can't let it go, can you!", SAY_SHOUT, 5000}})
       
   351   table.insert(startAnim, {func = AnimSay, args = {enemy, "All right, I'll admit it!", SAY_SHOUT, 4000}})
       
   352   table.insert(startAnim, {func = AnimSay, args = {natives[1], "Admit what?", SAY_SHOUT, 2000}})
       
   353   table.insert(startAnim, {func = AnimSay, args = {enemy, "You give me no choice!", SAY_SHOUT, 4000}})
       
   354   table.insert(startAnim, {func = AnimSay, args = {enemy, "I can't let you go further because...", SAY_SHOUT, 6000}})
       
   355   table.insert(startAnim, {func = AnimSay, args = {enemy, "I'm the spy! I've been giving you out!", SAY_SHOUT, 6000}})
       
   356   table.insert(startAnim, {func = AnimTeleportGear, args = {enemy, unpack(enemyPos)}})
       
   357   table.insert(startAnim, {func = AnimCustomFunction, args = {enemy, CondNeedToTurn, {natives[3], enemy}}})
       
   358   table.insert(startAnim, {func = AnimCustomFunction, args = {enemy, CondNeedToTurn, {natives[2], enemy}}})
       
   359   table.insert(startAnim, {func = AnimCustomFunction, args = {enemy, CondNeedToTurn, {natives[1], enemy}}})
       
   360   table.insert(startAnim, {func = AnimSay, args = {natives[1], "But...they kidnapped you!", SAY_SHOUT, 4000}})
       
   361   table.insert(startAnim, {func = AnimSay, args = {enemy, "Oh, that. We were just having fun!", SAY_SHOUT, 5000}})
       
   362   table.insert(startAnim, {func = AnimSay, args = {enemy, "It's an ancient ritual of theirs.", SAY_SHOUT, 5000}})
       
   363   table.insert(startAnim, {func = AnimSay, args = {natives[1], "Why did you do this?", SAY_SHOUT, 4000}})
       
   364   if m5ChiefDead == 1 then
       
   365     table.insert(startAnim, {func = AnimSay, args = {natives[1], "Why did you kill your father?", SAY_SHOUT, 5000}})
       
   366   end
       
   367   table.insert(startAnim, {func = AnimSay, args = {enemy, "Do you have any idea what it's like in the village for a woman?", SAY_SHOUT, 10000}})
       
   368   table.insert(startAnim, {func = AnimSay, args = {enemy, "How would you like being discriminated against?", SAY_SHOUT, 7000}})
       
   369   table.insert(startAnim, {func = AnimSay, args = {enemy, "Not being able to fight, hunt...", SAY_SHOUT, 5000}})
       
   370   table.insert(startAnim, {func = AnimSay, args = {enemy, "Gathering fruits all day long...", SAY_SHOUT, 5000}})
       
   371   table.insert(startAnim, {func = AnimSay, args = {enemy, "Doing stuff a monkey could do...", SAY_SHOUT, 5000}})
       
   372   table.insert(startAnim, {func = AnimSay, args = {enemy, "Always being considered weak and fragile...", SAY_SHOUT, 6000}})
       
   373   if m5DeployedNum == girlNum then
       
   374     table.insert(startAnim, {func = AnimSay, args = {natives[1], "In case you haven't noticed, I'm a woman, too!", SAY_SHOUT, 8000}})
       
   375     table.insert(startAnim, {func = AnimSay, args = {enemy, "Yes, but you're...different!", SAY_SHOUT, 6000}})
       
   376     table.insert(startAnim, {func = AnimSay, args = {natives[1], "Of course I am...", SAY_SHOUT, 3000}})
       
   377   end
       
   378   table.insert(startAnim, {func = AnimSay, args = {enemy, "The aliens respect me, even worship me!", SAY_SHOUT, 6000}})
       
   379   table.insert(startAnim, {func = AnimSay, args = {enemy, "I'm living a dream!", SAY_SHOUT, 3000}})
       
   380   table.insert(startAnim, {func = AnimSay, args = {natives[1], "Well, you're about to wake up!", SAY_SHOUT, 5000}})
       
   381 
       
   382   table.insert(fleeAnim, {func = AnimSay, args = {enemy, "Hmm...it's going slower than expected.", SAY_SAY, 5000}})
       
   383   table.insert(fleeAnim, {func = AnimSay, args = {enemy, "I am going to leave the kids play by themselves.", SAY_SAY, 6000}})
       
   384   table.insert(fleeAnim, {func = AnimTurn, args = {enemy, "Right"}})
       
   385   table.insert(fleeAnim, {func = AnimSay, args = {enemy, "Alien! I wish to be moved!", SAY_SHOUT, 4000}})
       
   386   table.insert(fleeAnim, {func = AnimSwitchHog, args = {natives[1]}})
       
   387   table.insert(fleeAnim, {func = AnimWait, args = {natives[1], 1}})
       
   388   table.insert(fleeAnim, {func = AnimDisappear, swh = false, args = {enemy, 0, 0}})
       
   389 end
       
   390 
       
   391 function SetupCyborgAnim()
       
   392   table.insert(startAnim, {func = AnimSay, args = {enemy, "Stop right there, puny worms!", SAY_SHOUT, 4000}})
       
   393   table.insert(startAnim, {func = AnimSay, args = {enemy, "Stay away from our weapons!", SAY_SHOUT, 4000}})
       
   394   table.insert(startAnim, {func = AnimSay, args = {natives[1], "We come in peace! Just let our friends go!", SAY_SHOUT, 5500}})
       
   395   table.insert(startAnim, {func = AnimSay, args = {enemy, "I'm afraid we cannot afford that...", SAY_SHOUT, 4500}})
       
   396   table.insert(startAnim, {func = AnimSay, args = {enemy, "You see, hedgehog spikes are very very valuable.", SAY_SHOUT, 6500}})
       
   397   table.insert(startAnim, {func = AnimSay, args = {enemy, "Very valuable, haha!", SAY_SHOUT, 3500}})
       
   398   table.insert(startAnim, {func = AnimSay, args = {natives[1], "Don't you dare harm our tribe!", SAY_SHOUT, 5000}})
       
   399   table.insert(startAnim, {func = AnimSay, args = {enemy, "It's a shame, really!", SAY_SHOUT, 4000}})
       
   400   table.insert(startAnim, {func = AnimSay, args = {enemy, "I regret to end your little odyssey.", SAY_SHOUT, 5000}})
       
   401   table.insert(startAnim, {func = AnimSay, args = {enemy, "It was fun to watch...", SAY_SHOUT, 3500}})
       
   402   table.insert(startAnim, {func = AnimSay, args = {enemy, "The way you handled your little inside conflicts...", SAY_SHOUT, 6500}})
       
   403   table.insert(startAnim, {func = AnimSay, args = {enemy, "Did you really think that we needed the help of one of you?", SAY_SHOUT, 7500}})
       
   404   table.insert(startAnim, {func = AnimSay, args = {enemy, "You should have known that we don't rely on 'blood needers'!", SAY_SHOUT, 7500}})
       
   405   table.insert(startAnim, {func = AnimSay, args = {enemy, "It was fun to watch though...", SAY_SHOUT, 3500}})
       
   406   if m5Choice == choiceEliminate then
       
   407     table.insert(startAnim, {func = AnimSay, args = {enemy, "Heck, you even executed one of you!", SAY_SHOUT, 6000}})
       
   408   end
       
   409   table.insert(startAnim, {func = AnimSay, args = {natives[1], "It was all a trick?!", SAY_SHOUT, 3000}})
       
   410   table.insert(startAnim, {func = AnimSay, args = {natives[1], "Some sick game of yours?!", SAY_SHOUT, 4000}})
       
   411   table.insert(startAnim, {func = AnimSay, args = {natives[1], "We won't let you hurt any more of us!", SAY_SHOUT, 6000}})
       
   412 
       
   413   table.insert(fleeAnim, {func = AnimSay, args = {enemy, "Entered boredom phase! Discrepancies detected...", SAY_SAY, 5000}})
       
   414   table.insert(fleeAnim, {func = AnimSay, args = {enemy, "Initiate escape wish!", SAY_SAY, 6000}})
       
   415   table.insert(fleeAnim, {func = AnimTurn, args = {enemy, "Right"}})
       
   416   table.insert(fleeAnim, {func = AnimSay, args = {enemy, "Running displacement algorithm...", SAY_SHOUT, 4000}})
       
   417   table.insert(fleeAnim, {func = AnimSwitchHog, args = {natives[1]}})
       
   418   table.insert(fleeAnim, {func = AnimWait, args = {natives[1], 1}})
       
   419   table.insert(fleeAnim, {func = AnimDisappear, swh = false, args = {enemy, 0, 0}})
       
   420 end
       
   421 
       
   422 function SetupFinalAnim()
       
   423   local found = 0
       
   424   local gears = {}
       
   425   for i = nativesLeft, 1, -1 do
       
   426     if band(GetState(natives[i]), gstDrowning) == 0 then
       
   427       found = found + 1
       
   428       gears[found] = natives[i]
       
   429     end
       
   430   end
       
   431   if found == 0 then
       
   432     return
       
   433   end
       
   434   if found == 1 then
       
   435     table.insert(finalAnim, {func = AnimTurn, args = {gears[1], "Right"}})
       
   436     table.insert(finalAnim, {func = AnimSay, args = {gears[1], "Pfew...that was close!", SAY_SAY, 0}})
       
   437   elseif found == 1 then
       
   438     table.insert(finalAnim, {func = AnimCustomFunction, args = {gears[1], CondNeedToTurn, {gears[1], gears[2]}}})
       
   439     table.insert(finalAnim, {func = AnimSay, args = {gears[1], "Pfew...that was close!", SAY_SAY, 0}})
       
   440     table.insert(finalAnim, {func = AnimSay, args = {gears[2], "Come, we need to hurry!", SAY_SAY, 0}})
       
   441   end
       
   442 end
       
   443 
       
   444 
       
   445 --------------------------Anim skip functions--------------------------
       
   446 function AfterStartAnim()
       
   447   SetGearMessage(natives[1], 0)
       
   448   ShowMission("Long Live The Queen", "Closing in", "Defeat the enemy!|The leader seems scared, he will probably flee.", 1, 0)
       
   449   SetHealth(SpawnHealthCrate(2207, 44), 25)
       
   450   SetHealth(SpawnHealthCrate(519, 1519), 25)
       
   451   SetHealth(SpawnHealthCrate(826, 895), 25)
       
   452   SpawnUtilityCrate(701, 1046, amGirder, 3)
       
   453   TurnTimeLeft = TurnTime
       
   454 end
       
   455 
       
   456 function SkipAnim()
       
   457   if GetHogTeamName(CurrentHedgehog) ~= loc("Natives") then
       
   458     TurnTimeLeft = 0
       
   459   end
       
   460   AnimWait(enemy, 1)
       
   461 end
       
   462 
       
   463 function AfterFleeAnim()
       
   464   SetHealth(SpawnHealthCrate(130, 455), 25)
       
   465   SetHealth(SpawnHealthCrate(2087, 50), 25)
       
   466   SetHealth(SpawnHealthCrate(2143, 54), 25)
       
   467   SetHealth(SpawnHealthCrate(70, 1308), 25)
       
   468   SetGearMessage(CurrentHedgehog, 0)
       
   469   HideHedge(enemy)
       
   470   ShowMission("Long Live The Queen", "Coward", "The leader escaped. Defeat the rest of the aliens!", 1, 0)
       
   471   TurnTimeLeft = TurnTime
       
   472 end
       
   473 
       
   474 function AfterLeaderDeadAnim()
       
   475   SetHealth(SpawnHealthCrate(130, 455), 25)
       
   476   SetHealth(SpawnHealthCrate(2087, 50), 25)
       
   477   SetHealth(SpawnHealthCrate(2143, 54), 25)
       
   478   SetHealth(SpawnHealthCrate(70, 1308), 25)
       
   479   ShowMission("Long Live The Queen", "Bullseye", "Good Job! Defeat the rest of the aliens!", 1, 0)
       
   480   TurnTimeLeft = 0
       
   481 end
       
   482 -----------------------------Events------------------------------------
       
   483 function CheckTurnsOver()
       
   484   return TotalRounds > 6
       
   485 end
       
   486 
       
   487 function DoTurnsOver()
       
   488   SetGearMessage(CurrentHedgehog, 0)
       
   489   enemyFled = "1"
       
   490   AddAnim(fleeAnim)
       
   491   AddFunction({func = AfterFleeAnim, args = {}})
       
   492   RemoveEventFunc(CheckGearDead, {enemy})
       
   493 end
       
   494 
       
   495 function CheckNativesDead()
       
   496   return nativesLeft == 0
       
   497 end
       
   498 
       
   499 function DoNativesDead()
       
   500   RemoveEventFunc(CheckTurnsOver)
       
   501   RemoveEventFunc(CheckGearDead)
       
   502   RemoveEventFunc(CheckCyborgsDead)
       
   503   AddCaption("...and the cyborgs took over the island.")
       
   504   TurnTimeLeft = 0
       
   505 end
       
   506 
       
   507 function CheckCyborgsDead()
       
   508   return cyborgsLeft == 0
       
   509 end
       
   510 
       
   511 function DoCyborgsDead()
       
   512   SaveCampaignVariables()
       
   513   SetupFinalAnim()
       
   514   AddAnim(finalAnim)
       
   515   if enemyFled == "1" then
       
   516     ParseCommand("teamgone " .. loc("Leaderbot"))
       
   517   end
       
   518 end
       
   519 
       
   520 function DoLeaderDead()
       
   521   leaderDead = true
       
   522   SetGearMessage(CurrentHedgehog, 0)
       
   523   SetupLeaderDeadAnim()
       
   524   AddAnim(leaderDeadAnim)
       
   525   AddFunction({func = AfterLeaderDeadAnim, args = {}})
       
   526   RemoveEventFunc(CheckTurnsOver)
       
   527 end
       
   528 
       
   529 function CheckGearsDead(gearList)
       
   530   for i = 1, # gearList do
       
   531     if gearDead[gearList[i]] ~= true then
       
   532       return false
       
   533     end
       
   534   end
       
   535   return true
       
   536 end
       
   537 
       
   538 function CheckGearDead(gear)
       
   539   return gearDead[gear]
       
   540 end
       
   541 
       
   542 -----------------------------Misc--------------------------------------
       
   543 function HideHedge(hedge)
       
   544   if hedgeHidden[hedge] ~= true then
       
   545     HideHog(hedge)
       
   546     hedgeHidden[hedge] = true
       
   547   end
       
   548 end
       
   549 
       
   550 function RestoreHedge(hedge)
       
   551   if hedgeHidden[hedge] == true then
       
   552     RestoreHog(hedge)
       
   553     hedgeHidden[hedge] = false
       
   554   end
       
   555 end
       
   556 
       
   557 function GetVariables()
       
   558   m5DeployedNum = tonumber(GetCampaignVar("M5DeployedNum"))
       
   559   m2Choice = tonumber(GetCampaignVar("M2Choice"))
       
   560   m5Choice = tonumber(GetCampaignVar("M5Choice"))
       
   561   m2DenseDead = tonumber(GetCampaignVar("M2DenseDead"))
       
   562   m4DenseDead = tonumber(GetCampaignVar("M4DenseDead"))
       
   563   m5DenseDead = tonumber(GetCampaignVar("M4DenseDead"))
       
   564   m4LeaksDead = tonumber(GetCampaignVar("M4LeaksDead"))
       
   565   m5LeaksDead = tonumber(GetCampaignVar("M4LeaksDead"))
       
   566   m4ChiefDead = tonumber(GetCampaignVar("M4ChiefDead"))
       
   567   m5ChiefDead = tonumber(GetCampaignVar("M4ChiefDead"))
       
   568   m4WaterDead = tonumber(GetCampaignVar("M4WaterDead"))
       
   569   m5WaterDead = tonumber(GetCampaignVar("M4WaterDead"))
       
   570   m4BuffaloDead = tonumber(GetCampaignVar("M4BuffaloDead"))
       
   571   m5BuffaloDead = tonumber(GetCampaignVar("M4BuffaloDead"))
       
   572   m5WiseDead = tonumber(GetCampaignVar("M4BuffaloDead"))
       
   573   m5GirlDead = tonumber(GetCampaignVar("M4BuffaloDead"))
       
   574 end
       
   575 
       
   576 function SaveCampaignVariables()
       
   577   for i = 1, 4 do
       
   578     if gearDead[origNatives[i]] ~= true then
       
   579       SaveCampaignVar(nativeSaveNames[i], "0")
       
   580     else
       
   581       SaveCampaignVar(nativeSaveNames[i], "1")
       
   582     end
       
   583   end
       
   584 
       
   585   SaveCampaignVar("M8DeployedLeader", deployedLeader)
       
   586   SaveCampaignVar("M8PrincessLeader", princessLeader)
       
   587   SaveCampaignVar("M8EnemyFled", enemyFled)
       
   588   SaveCampaignVar("Progress", "8")
       
   589 end
       
   590 
       
   591 function SetupPlace()
       
   592   SetHogHat(natives[1], nativeHats[m5DeployedNum])
       
   593   SetHogName(natives[1], nativeNames[m5DeployedNum])
       
   594 
       
   595   if m5DeployedNum == denseNum then
       
   596     dense = natives[1]
       
   597   else
       
   598     dense = enemy
       
   599   end
       
   600 
       
   601   if m2Choice == choiceAccepted and m5Choice ~= choiceEliminate then
       
   602     scene = denseScene
       
   603     SetHogHat(enemy, nativeHats[denseNum])
       
   604     SetHogName(enemy, nativeNames[denseNum])
       
   605     dense = enemy
       
   606   elseif m2Choice == choiceAccepted then
       
   607     scene = cyborgScene
       
   608     SetHogHat(enemy, "cyborg2")
       
   609     SetHogName(enemy, loc("Nancy Screw"))
       
   610   elseif m5Choice == choiceEliminate then
       
   611     scene = princessScene
       
   612     SetHogHat(enemy, "tiara")
       
   613     SetHogName(enemy, loc("Fell From Heaven"))
       
   614   else
       
   615     scene = waterScene
       
   616     SetHogHat(enemy, nativeHats[waterNum])
       
   617     SetHogName(enemy, nativeNames[waterNum])
       
   618   end
       
   619   for i = 1, 4 do 
       
   620     if GetHogName(natives[i]) == GetHogName(enemy) then
       
   621       SetGearPosition(enemy, GetGearPosition(natives[i]))
       
   622       DeleteGear(natives[i])
       
   623       DeleteGear(cyborgs[cyborgsLeft])
       
   624     end
       
   625   end
       
   626 
       
   627   SpawnAmmoCrate(34, 395, amBee, 2)
       
   628   SpawnAmmoCrate(33, 374, amRCPlane, 1)
       
   629   SpawnAmmoCrate(74, 393, amAirAttack, 3)
       
   630   SpawnAmmoCrate(1313, 1481, amBazooka, 8)
       
   631   SpawnAmmoCrate(80, 360, amSniperRifle, 4)
       
   632   SpawnAmmoCrate(1037, 1494, amShotgun, 7)
       
   633   SpawnAmmoCrate(1037, 1472, amMolotov, 3)
       
   634   SpawnAmmoCrate(1146, 1503, amMortar, 8)
       
   635 
       
   636   SpawnUtilityCrate(1147, 1431, amPortalGun, 2)
       
   637   SpawnUtilityCrate(1219, 1542, amRope, 5)
       
   638   SpawnUtilityCrate(1259, 1501, amJetpack, 2)
       
   639 end
       
   640 
       
   641 function SetupEvents()
       
   642   AddNewEvent(CheckNativesDead, {}, DoNativesDead, {}, 0)
       
   643   AddNewEvent(CheckGearDead, {enemy}, DoLeaderDead, {}, 0)
       
   644   AddNewEvent(CheckTurnsOver, {}, DoTurnsOver, {}, 0)
       
   645   AddNewEvent(CheckCyborgsDead, {}, DoCyborgsDead, {}, 0)
       
   646 end
       
   647 
       
   648 function SetupAmmo()
       
   649   AddAmmo(natives[1], amPickHammer, 2)
       
   650   AddAmmo(natives[1], amBazooka, 0)
       
   651   AddAmmo(natives[1], amGrenade, 0)
       
   652   AddAmmo(natives[1], amShotgun, 0)
       
   653   AddAmmo(natives[1], amAirStrike, 0)
       
   654   AddAmmo(natives[1], amMolotov, 0)
       
   655 end
       
   656 
       
   657 function AddHogs()
       
   658 	AddTeam(loc("Natives"), 29439, "Bone", "Island", "HillBilly", "cm_birdy")
       
   659   for i = 7, 9 do
       
   660     natives[i-6] = AddHog(nativeNames[i], 0, 100, nativeHats[i])
       
   661     origNatives[i-6] = natives[i-6]
       
   662   end
       
   663   natives[4] = AddHog(loc("Fell From Heaven"), 0, 133, "tiara")
       
   664   origNatives[4] = natives[4]
       
   665   nativesLeft = nativesNum
       
   666 
       
   667   AddTeam(loc("Beep Loopers"), 14483456, "ring", "UFO", "Robot", "cm_star")
       
   668   for i = 1, cyborgsTeamNum[1] do
       
   669     cyborgs[i] = AddHog(cyborgNames[i], cyborgsDif[i], cyborgsHealth[i], "cyborg2")
       
   670   end
       
   671 
       
   672   AddTeam(loc("Corporationals"), 14483456, "ring", "UFO", "Robot", "cm_star")
       
   673   for i = cyborgsTeamNum[1] + 1, cyborgsNum do
       
   674     cyborgs[i] = AddHog(cyborgNames[i], cyborgsDif[i], cyborgsHealth[i], "cyborg2")
       
   675   end
       
   676   cyborgsLeft = cyborgsTeamNum[1] + cyborgsTeamNum[2]
       
   677 
       
   678   AddTeam(loc("Leaderbot"), 14483456, "ring", "UFO", "Robot", "cm_star")
       
   679   enemy = AddHog(loc("Name"), 2, 200, "cyborg1")
       
   680 
       
   681   for i = 1, nativesNum do
       
   682     SetGearPosition(natives[i], unpack(nativePos[i]))
       
   683   end
       
   684 
       
   685   SetGearPosition(enemy, unpack(enemyPos))
       
   686   AnimTurn(enemy, "Left")
       
   687 
       
   688   for i = 1, cyborgsNum do
       
   689     SetGearPosition(cyborgs[i], unpack(cyborgsPos[i]))
       
   690     AnimTurn(cyborgs[i], cyborgsDir[i])
       
   691   end
       
   692 end
       
   693 
       
   694 function CondNeedToTurn(hog1, hog2)
       
   695   xl, xd = GetX(hog1), GetX(hog2)
       
   696   if xl > xd then
       
   697     AnimInsertStepNext({func = AnimTurn, args = {hog1, "Left"}})
       
   698     AnimInsertStepNext({func = AnimTurn, args = {hog2, "Right"}})
       
   699   elseif xl < xd then
       
   700     AnimInsertStepNext({func = AnimTurn, args = {hog2, "Left"}})
       
   701     AnimInsertStepNext({func = AnimTurn, args = {hog1, "Right"}})
       
   702   end
       
   703 end
       
   704 
       
   705 -----------------------------Main Functions----------------------------
       
   706 
       
   707 function onGameInit()
       
   708 	Seed = 0
       
   709 	GameFlags = gfDisableGirders + gfDisableLandObjects
       
   710 	TurnTime = 60000 
       
   711 	CaseFreq = 0
       
   712 	MinesNum = 0
       
   713 	MinesTime = 3000
       
   714 	Explosives = 0
       
   715 	Delay = 10 
       
   716   MapGen = 2
       
   717 	Theme = "Hell"
       
   718   SuddenDeathTurns = 20
       
   719 
       
   720 	for i = 1, #map do
       
   721 		ParseCommand('draw ' .. map[i])
       
   722 	end
       
   723 
       
   724   GetVariables()
       
   725   AnimInit()
       
   726   AddHogs()
       
   727 end
       
   728 
       
   729 function onGameStart()
       
   730   SetupAmmo()
       
   731   SetupPlace()
       
   732   AnimationSetup()
       
   733   SetupEvents()
       
   734   AddAnim(startAnim)
       
   735   AddFunction({func = AfterStartAnim, args = {}})
       
   736 end
       
   737 
       
   738 function onGameTick()
       
   739   AnimUnWait()
       
   740   if ShowAnimation() == false then
       
   741     return
       
   742   end
       
   743   ExecuteAfterAnimations()
       
   744   CheckEvents()
       
   745 end
       
   746 
       
   747 function onGearDelete(gear)
       
   748   local toRemove = nil
       
   749   gearDead[gear] = true
       
   750   if GetGearType(gear) == gtHedgehog then
       
   751     if GetHogTeamName(gear) == loc("Beep Loopers") or GetHogTeamName(gear) == loc("Corporationals") then
       
   752       cyborgsLeft = cyborgsLeft - 1
       
   753     elseif GetHogTeamName(gear) == loc("Natives") then
       
   754       for i = 1, nativesLeft do
       
   755         if natives[i] == gear then
       
   756           toRemove = i
       
   757         end
       
   758       end
       
   759       table.remove(natives, toRemove)
       
   760       nativesLeft = nativesLeft - 1
       
   761     end
       
   762   end
       
   763 end
       
   764 
       
   765 function onGearAdd(gear)
       
   766 end
       
   767 
       
   768 function onAmmoStoreInit()
       
   769   SetAmmo(amBaseballBat, 9, 0, 0, 0)
       
   770   SetAmmo(amFirePunch, 9, 0, 0, 0)
       
   771   SetAmmo(amDEagle, 9, 0, 0, 0)
       
   772   SetAmmo(amSkip, 9, 0, 0, 0)
       
   773   SetAmmo(amSwitch, 9, 0, 0, 0)
       
   774   SetAmmo(amBazooka, 9, 0, 0, 0)
       
   775   SetAmmo(amGrenade, 9, 0, 0, 0)
       
   776   SetAmmo(amAirStrike, 1, 0, 0, 0)
       
   777   SetAmmo(amMolotov, 5, 0, 0, 0)
       
   778   SetAmmo(amShotgun, 9, 0, 0, 0)
       
   779 end
       
   780 
       
   781 function onNewTurn()
       
   782   if AnimInProgress() then
       
   783     TurnTimeLeft = -1
       
   784     return
       
   785   end
       
   786   if GetHogTeamName(CurrentHedgehog) == loc("011101001") then
       
   787     TurnTimeLeft = 0
       
   788   end
       
   789 end
       
   790 
       
   791 function onGearDamage(gear, damage)
       
   792 end
       
   793 
       
   794 function onPrecise()
       
   795   if GameTime > 2500 and AnimInProgress() then
       
   796     SetAnimSkip(true)
       
   797   end
       
   798 end