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