share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/shadow.lua
changeset 7203 37661b2a7b64
child 7211 a1e9335f1d50
equal deleted inserted replaced
7201:dc17ffdf0702 7203:37661b2a7b64
       
     1 loadfile(GetDataPath() .. "Scripts/Animate.lua")()
       
     2 
       
     3 -----------------------------Constants---------------------------------
       
     4 startStage = 0
       
     5 spyStage = 1
       
     6 wave1Stage = 2
       
     7 wave2Stage = 3
       
     8 cyborgStage = 4
       
     9 ramonStage = 5
       
    10 aloneStage = 6
       
    11 duoStage = 7
       
    12 interSpyStage = 8
       
    13 interWeakStage = 9
       
    14 acceptedReturnStage = 10
       
    15 refusedReturnStage = 11
       
    16 attackedReturnStage = 12
       
    17 loseStage = 13
       
    18 
       
    19 ourTeam = 0
       
    20 weakTeam = 1
       
    21 strongTeam = 2
       
    22 cyborgTeam = 3
       
    23 
       
    24 leaksNr = 0
       
    25 denseNr = 1
       
    26 
       
    27 choiceAccept = 1
       
    28 choiceRefuse = 2
       
    29 choiceAttack = 3
       
    30 
       
    31 HogNames = {"Brainiac", "Corpsemonger", "Femur Lover", "Glark", "Bonely", "Rot Molester", "Bloodrocutor", "Muscle Dissolver", "Bloodsucker"}
       
    32 
       
    33 ---POSITIONS---
       
    34 
       
    35 cannibalPos = {{3108, 1127}, 
       
    36                {2559, 1080}, {3598, 1270}, {3293, 1177}, {2623, 1336}, 
       
    37                {3418, 1336}, {3447, 1335}, {3481, 1340}, {3507, 1324}} 
       
    38 densePos = {2776, 1177}
       
    39 leaksPos = {2941, 1172}
       
    40 cyborgPos = {1113, 1818}
       
    41 
       
    42 ---Animations
       
    43 
       
    44 startDialogue = {}
       
    45 weaklingsAnim = {}
       
    46 stronglingsAnim = {}
       
    47 acceptedAnim = {}
       
    48 acceptedSurvivedFinalAnim = {}
       
    49 acceptedDiedFinalAnim = {}
       
    50 refusedAnim = {}
       
    51 refusedFinalAnim = {}
       
    52 attackedAnim = {}
       
    53 attackedFinalAnim = {}
       
    54 
       
    55 -----------------------------Variables---------------------------------
       
    56 lastHogTeam = ourTeam
       
    57 lastOurHog = leaksNr
       
    58 lastEnemyHog = 0
       
    59 stage = 0
       
    60 choice = 0
       
    61 
       
    62 brainiacDead = false
       
    63 cyborgHidden = false
       
    64 leaksHidden = false
       
    65 denseHidden = false
       
    66 cyborgAttacked = false
       
    67 retryReturn = false
       
    68 shotgunTaken = false
       
    69 grenadeTaken = false
       
    70 spikyDead = false
       
    71 ramonDead = false
       
    72 denseDead = false
       
    73 leaksDead = false
       
    74 ramonHidden = false
       
    75 spikyHidden = false
       
    76 
       
    77 
       
    78 hogNr = {}
       
    79 cannibalDead = {}
       
    80 isHidden = {}
       
    81 
       
    82 
       
    83 --------------------------Anim skip functions--------------------------
       
    84 function AfterRefusedAnim()
       
    85   SpawnUtilityCrate(2045, 1575, amSwitch)
       
    86   SpawnUtilityCrate(2365, 1495, amShotgun)
       
    87   SpawnUtilityCrate(2495, 1519, amGrenade)
       
    88   SpawnUtilityCrate(2620, 1524, amRope)
       
    89   ShowMission("The Shadow Falls", "The Showdown", "Save Leaks A Lot!|Hint: The Switch utility might be of help to you.", 1, 6000)
       
    90   RemoveEventFunc(CheckDenseDead)
       
    91   AddEvent(CheckStronglingsDead, {}, DoStronglingsDeadRefused, {}, 0)
       
    92   AddAmmo(cannibals[6], amGrenade, 5)
       
    93   stage = ramonStage
       
    94   SwitchHog(cannibals[9])
       
    95   FollowGear(ramon)
       
    96   TurnTimeLeft = 0
       
    97   SetGearMessage(ramon, 0)
       
    98   HideHog(cyborg)
       
    99   cyborgHidden = true
       
   100   SetGearMessage(leaks, 0)
       
   101 end
       
   102 
       
   103 function SkipRefusedAnim()
       
   104   RefusedStart()
       
   105   SetGearPosition(dense, 2645, 1146)
       
   106   SetGearPosition(ramon, 2218, 1675)
       
   107   SetGearPosition(spiky, 2400, 1675)
       
   108 end
       
   109 
       
   110 function AfterStartDialogue()
       
   111   stage = spyStage
       
   112   ShowMission("The Shadow Falls", "Play with me!", "Defend yourself!|Hint: You can get tips on using weapons by moving your mouse over them in the weapon selection menu", 1, 6000)
       
   113   TurnTimeLeft = TurnTime
       
   114 end
       
   115 
       
   116 
       
   117 function StartSkipFunc()
       
   118   SetState(cannibals[1], 0)
       
   119   AnimTurn(leaks, "Right")
       
   120   AnimSwitchHog(leaks)
       
   121   SetInputMask(0xFFFFFFFF)
       
   122 end
       
   123 
       
   124 function AfterWeaklingsAnim()
       
   125   AddAmmo(cannibals[2], amShotgun, 4)
       
   126   AddAmmo(cannibals[2], amGrenade, 3)
       
   127   AddAmmo(leaks, amSkip, 4)
       
   128   AddEvent(CheckWeaklingsKilled, {}, DoWeaklingsKilled, {}, 0)
       
   129   SetHealth(SpawnHealthCrate(2757, 1030), 50)
       
   130   SetHealth(SpawnHealthCrate(2899, 1009), 50)
       
   131   stage = wave1Stage
       
   132   SwitchHog(dense)
       
   133   SetGearMessage(dense, 0)
       
   134   SetGearMessage(leaks, 0)
       
   135   TurnTimeLeft = TurnTime
       
   136   ShowMission("The Shadow Falls", "Why do you not like me?", "Obliterate them!|Hint: You might want to take cover...", 1, 6000)
       
   137 end
       
   138 
       
   139 function SkipWeaklingsAnim()
       
   140   for i = 2, 5 do
       
   141     if isHidden[cannibals[i]] == true then
       
   142       RestoreHog(cannibals[i])
       
   143       isHidden[cannibals[i]] = false
       
   144     end
       
   145     SetGearPosition(cannibals[i], unpack(cannibalPos[i]))
       
   146     SetState(cannibals[i], 0)
       
   147   end
       
   148   SetInputMask(0xFFFFFFFF)
       
   149 end
       
   150 
       
   151 function AfterStronglingsAnim()
       
   152   stage = cyborgStage
       
   153   TurnTimeLeft = 0
       
   154   ShowMission("The Shadow Falls", "The Dilemma", "Choose your side! If you want to join the strange man, walk up to him.|Otherwise, walk away from him. If you decide to att...nevermind...", 1, 8000)
       
   155   AddEvent(CheckChoice, {}, DoChoice, {}, 0)
       
   156   AddEvent(CheckRefuse, {}, DoRefuse, {}, 0)
       
   157   AddEvent(CheckAccept, {}, DoAccept, {}, 0)
       
   158   AddEvent(CheckConfront, {}, DoConfront, {}, 0)
       
   159   AddAmmo(dense, amSwitch, 0)
       
   160   AddAmmo(dense, amSkip, 0)
       
   161   SetHealth(SpawnHealthCrate(2557, 1030), 50)
       
   162   SetHealth(SpawnHealthCrate(3599, 1009), 50)
       
   163 end
       
   164 
       
   165 function SkipStronglingsAnim()
       
   166   for i = 6, 9 do
       
   167     if isHidden[cannibals[i]] == true then
       
   168       RestoreHog(cannibals[i])
       
   169       isHidden[cannibals[i]] = false
       
   170     end
       
   171     SetGearPosition(cannibals[i], unpack(cannibalPos[i]))
       
   172     SetState(cannibals[i], 0)
       
   173   end
       
   174   if cyborgHidden == true then
       
   175     RestoreHog(cyborg)
       
   176     cyborgHidden = false
       
   177   end
       
   178   SetState(cyborg, 0)
       
   179   SetState(dense, 0)
       
   180   SetGearPosition(dense, 1350, 1310)
       
   181   FollowGear(dense)
       
   182   HogTurnLeft(dense, true)
       
   183   SetGearPosition(cyborg, 1250, 1310)
       
   184   SwitchHog(dense)
       
   185   SetInputMask(0xFFFFFFFF)
       
   186 end
       
   187 
       
   188 function RestartReturnAccepted()
       
   189   retryReturn = false
       
   190   SetGearPosition(dense, 1350, 1310)
       
   191   AddAmmo(dense, amGirder, 2)
       
   192   AddAmmo(dense, amParachute, 2)
       
   193   ShowMission("The Shadow Falls", "The walk of Fame", "Return to Leaks A Lot! If you get stuck, press [Precise] to try again!", 1, 6000)
       
   194   RemoveEventFunc(CheckNeedGirder)
       
   195   RemoveEventFunc(CheckNeedWeapons)
       
   196   AddEvent(CheckNeedGirder, {}, DoNeedGirder, {}, 0)
       
   197   AddEvent(CheckNeedWeapons, {}, DoNeedWeapons, {}, 0)
       
   198 end
       
   199 
       
   200 
       
   201 function AfterAcceptedAnim()
       
   202   stage = acceptedReturnStage
       
   203   SpawnAmmoCrate(1300, 810, amGirder)
       
   204   SpawnAmmoCrate(1300, 810 - 60, amParachute)
       
   205   ShowMission("The Shadow Falls", "The walk of Fame", "Return to Leaks A Lot! If you get stuck, press [Precise] to try again!", 1, 6000)
       
   206   HideHog(cyborg)
       
   207   AddEvent(CheckTookWeapons, {}, DoTookWeapons, {}, 0)
       
   208   AddEvent(CheckNeedGirder, {}, DoNeedGirder, {}, 0)
       
   209   AddEvent(CheckNeedWeapons, {}, DoNeedWeapons, {}, 0)
       
   210   AddEvent(CheckRestartReturnAccepted, {}, RestartReturnAccepted, {}, 1)
       
   211   RemoveEventFunc(CheckDenseDead)
       
   212 end
       
   213 
       
   214 function SkipAcceptedAnim()
       
   215   SetGearPosition(cyborg, unpack(cyborgPos))
       
   216   SetState(cyborg, gstInvisible)
       
   217   AnimSwitchHog(dense)
       
   218   SetInputMask(0xFFFFFFFF)
       
   219 end
       
   220 
       
   221 function AfterAttackedAnim()
       
   222   stage = aloneStage
       
   223   HideHog(cyborg)
       
   224   ShowMission("The Shadow Falls", "The Individualist", "Defeat the cannibals!|Grenade hint: set the timer with [1-5], aim with [Up]/[Down] and hold [Space] to set power", 1, 8000)
       
   225   SpawnAmmoCrate(2551, 994, amGrenade)
       
   226   SpawnAmmoCrate(3551, 994, amGrenade)
       
   227   SpawnAmmoCrate(3392, 1101, amShotgun)
       
   228   SpawnAmmoCrate(3192, 1101, amShotgun)
       
   229   AddAmmo(cannibals[6], amGrenade, 5)
       
   230   SetGearMessage(leaks, 0)
       
   231   TurnTimeLeft = TurnTime
       
   232   AddEvent(CheckStronglingsDead, {}, DoStronglingsDeadAttacked, {}, 0)
       
   233 end
       
   234 
       
   235 function SkipAttackedAnim()
       
   236   if denseDead == false then
       
   237     SetHealth(dense)
       
   238   end
       
   239   SetGearPosition(cyborg, unpack(cyborgPos))
       
   240   SetState(cyborg, gstInvisible)
       
   241   AnimSwitchHog(leaks)
       
   242   SetInputMask(0xFFFFFFFF)
       
   243 end
       
   244 
       
   245   
       
   246 -----------------------------Animations--------------------------------
       
   247 
       
   248 function EmitDenseClouds(anim, dir)
       
   249   local dif
       
   250   if dir == "left" then 
       
   251     dif = 10
       
   252   else
       
   253     dif = -10
       
   254   end
       
   255   AnimInsertStepNext({func = AnimVisualGear, args = {dense, GetX(dense) + dif, GetY(dense) + dif, vgtSteam, 0, true}, swh = false})
       
   256   AnimInsertStepNext({func = AnimVisualGear, args = {dense, GetX(dense) + dif, GetY(dense) + dif, vgtSteam, 0, true}, swh = false})
       
   257   AnimInsertStepNext({func = AnimVisualGear, args = {dense, GetX(dense) + dif, GetY(dense) + dif, vgtSteam, 0, true}, swh = false})
       
   258   AnimInsertStepNext({func = AnimWait, args = {dense, 800}})
       
   259   AnimInsertStepNext({func = AnimVisualGear, args = {dense, GetX(dense) + dif, GetY(dense) + dif, vgtSteam, 0, true}, swh = false})
       
   260   AnimInsertStepNext({func = AnimVisualGear, args = {dense, GetX(dense) + dif, GetY(dense) + dif, vgtSteam, 0, true}, swh = false})
       
   261   AnimInsertStepNext({func = AnimWait, args = {dense, 800}})
       
   262   AnimInsertStepNext({func = AnimVisualGear, args = {dense, GetX(dense) + dif, GetY(dense) + dif, vgtSteam, 0, true}, swh = false})
       
   263 end
       
   264 
       
   265 function BlowDenseCloud()
       
   266   AnimInsertStepNext({func = DeleteGear, args = {dense}, swh = false}) 
       
   267   AnimInsertStepNext({func = AnimVisualGear, args = {dense, GetX(dense), GetY(dense), vgtBigExplosion, 0, true}, swh = false})
       
   268   AnimInsertStepNext({func = AnimWait, args = {dense, 1200}})
       
   269   AnimInsertStepNext({func = AnimVisualGear, args = {dense, GetX(dense) + 20, GetY(dense), vgtExplosion, 0, true}, swh = false})
       
   270   AnimInsertStepNext({func = AnimWait, args = {dense, 100}})
       
   271   AnimInsertStepNext({func = AnimVisualGear, args = {dense, GetX(dense) + 10, GetY(dense), vgtExplosion, 0, true}, swh = false})
       
   272   AnimInsertStepNext({func = AnimWait, args = {dense, 100}})
       
   273   AnimInsertStepNext({func = AnimVisualGear, args = {dense, GetX(dense) - 10, GetY(dense), vgtExplosion, 0, true}, swh = false})
       
   274   AnimInsertStepNext({func = AnimWait, args = {dense, 100}})
       
   275   AnimInsertStepNext({func = AnimVisualGear, args = {dense, GetX(dense) - 20, GetY(dense), vgtExplosion, 0, true}, swh = false})
       
   276 end
       
   277 
       
   278 function AnimationSetup()
       
   279   table.insert(startDialogue, {func = AnimWait, args = {dense, 4000}})
       
   280   table.insert(startDialogue, {func = AnimCaption, args = {leaks, "After the shock caused by the enemy spy, Leaks A Lot and Dense Cloud went hunting to relax.", 6000}})
       
   281   table.insert(startDialogue, {func = AnimCaption, args = {leaks, "Little did they know that this hunt will mark them forever...", 4000}})
       
   282   table.insert(startDialogue, {func = AnimSay, args = {leaks, "I have no idea where that mole disappeared...Can you see it?", SAY_SAY, 9000}})
       
   283   table.insert(startDialogue, {func = AnimSay, args = {dense, "Nope. It was one fast mole, that's for sure.", SAY_SAY, 5000}}) 
       
   284   table.insert(startDialogue, {func = AnimCustomFunction, args = {dense, EmitDenseClouds, {startDialogue, "right"}}})
       
   285   table.insert(startDialogue, {func = AnimWait, args = {dense, 2000}})
       
   286   table.insert(startDialogue, {func = AnimSay, args = {leaks, "Please, stop releasing your \"smoke signals\"!", SAY_SAY, 5000}})
       
   287   table.insert(startDialogue, {func = AnimSay, args = {leaks, "You're terrorizing the forest...We won't catch anything like this!", SAY_SAY, 6000}})
       
   288   table.insert(startDialogue, {func = AnimSay, args = {leaks, "...", SAY_THINK, 1000}})
       
   289   table.insert(startDialogue, {func = AnimGiveState, args = {cannibals[1], 0}, swh = false})
       
   290   table.insert(startDialogue, {func = AnimOutOfNowhere, args = {cannibals[1], unpack(cannibalPos[1])}, swh = false})
       
   291   table.insert(startDialogue, {func = AnimTurn, args = {leaks, "Right"}})
       
   292   table.insert(startDialogue, {func = AnimTurn, args = {cannibals[1], "Right"}})
       
   293   table.insert(startDialogue, {func = AnimWait, args = {cannibals[1], 1000}})
       
   294   table.insert(startDialogue, {func = AnimTurn, args = {cannibals[1], "Left"}})
       
   295   table.insert(startDialogue, {func = AnimWait, args = {cannibals[1], 1000}})
       
   296   table.insert(startDialogue, {func = AnimTurn, args = {cannibals[1], "Right"}})
       
   297   table.insert(startDialogue, {func = AnimSay, args = {cannibals[1], "I can't believe it worked!", SAY_THINK, 3500}})
       
   298   table.insert(startDialogue, {func = AnimSay, args = {cannibals[1], "That shaman sure knows what he/she's doing!", SAY_THINK, 6000}})
       
   299   table.insert(startDialogue, {func = AnimSay, args = {leaks, "It wants our brains!", SAY_SHOUT, 3000}})
       
   300   table.insert(startDialogue, {func = AnimTurn, args = {cannibals[1], "Left"}})
       
   301   table.insert(startDialogue, {func = AnimSay, args = {cannibals[1], "Not you again! My head still hurts from last time!", SAY_SHOUT, 6000}})
       
   302   table.insert(startDialogue, {func = AnimSwitchHog, args = {leaks}})
       
   303   AddSkipFunction(startDialogue, StartSkipFunc, {})
       
   304 
       
   305   table.insert(weaklingsAnim, {func = AnimGearWait, args = {leaks, 1000}})
       
   306   table.insert(weaklingsAnim, {func = AnimCustomFunction, args = {leaks, UnHideWeaklings, {}}})
       
   307   table.insert(weaklingsAnim, {func = AnimCustomFunction, args = {leaks, CondNeedToTurn, {leaks, dense}}})
       
   308   table.insert(weaklingsAnim, {func = AnimSay, args = {leaks, "Did you see him coming?", SAY_SAY, 3500}})
       
   309   table.insert(weaklingsAnim, {func = AnimSay, args = {dense, "No. Where did he come from?", SAY_SAY, 3500}})
       
   310   table.insert(weaklingsAnim, {func = AnimOutOfNowhere, args = {cannibals[2], unpack(cannibalPos[2])}})
       
   311   table.insert(weaklingsAnim, {func = AnimGiveState, args = {cannibals[2], 0}})
       
   312   table.insert(weaklingsAnim, {func = AnimWait, args = {leaks, 400}})
       
   313   table.insert(weaklingsAnim, {func = AnimGiveState, args = {cannibals[3], 0}})
       
   314   table.insert(weaklingsAnim, {func = AnimOutOfNowhere, args = {cannibals[3], unpack(cannibalPos[3])}})
       
   315   table.insert(weaklingsAnim, {func = AnimWait, args = {leaks, 400}})
       
   316   table.insert(weaklingsAnim, {func = AnimGiveState, args = {cannibals[4], 0}})
       
   317   table.insert(weaklingsAnim, {func = AnimOutOfNowhere, args = {cannibals[4], unpack(cannibalPos[4])}})
       
   318   table.insert(weaklingsAnim, {func = AnimWait, args = {leaks, 400}})
       
   319   table.insert(weaklingsAnim, {func = AnimGiveState, args = {cannibals[5], 0}})
       
   320   table.insert(weaklingsAnim, {func = AnimOutOfNowhere, args = {cannibals[5], unpack(cannibalPos[5])}})
       
   321   table.insert(weaklingsAnim, {func = AnimWait, args = {leaks, 400}})
       
   322   table.insert(weaklingsAnim, {func = AnimSay, args = {cannibals[3], "Are we there yet?", SAY_SAY, 4000}}) 
       
   323   table.insert(weaklingsAnim, {func = AnimSay, args = {dense, "This must be some kind of sorcery!", SAY_SHOUT, 3500}})
       
   324   table.insert(weaklingsAnim, {func = AnimSwitchHog, args = {leaks}})
       
   325   AddSkipFunction(weaklingsAnim, SkipWeaklingsAnim, {})
       
   326 
       
   327   table.insert(stronglingsAnim, {func = AnimGearWait, args = {leaks, 1000}})
       
   328   table.insert(stronglingsAnim, {func = AnimCustomFunction, args = {leaks, UnHideStronglings, {}}})
       
   329   table.insert(stronglingsAnim, {func = AnimCustomFunction, args = {leaks, CondNeedToTurn, {leaks, dense}}})
       
   330   table.insert(stronglingsAnim, {func = AnimGiveState, args = {leaks, 0}})
       
   331   table.insert(stronglingsAnim, {func = AnimGiveState, args = {dense, 0}})
       
   332   table.insert(stronglingsAnim, {func = AnimSay, args = {leaks, "I thought their shaman died when he tried our medicine!", SAY_SAY, 7000}})
       
   333   table.insert(stronglingsAnim, {func = AnimSay, args = {dense, "I saw it with my own eyes!", SAY_SAY, 4000}})
       
   334   table.insert(stronglingsAnim, {func = AnimSay, args = {leaks, "Then how do they keep appearing?", SAY_SAY, 4000}})
       
   335   table.insert(stronglingsAnim, {func = AnimSay, args = {leaks, "It's impossible to communicate with the spirits without a shaman.", SAY_SAY, 7000}})
       
   336   table.insert(stronglingsAnim, {func = AnimSay, args = {dense, "We need to warn the village.", SAY_SAY, 3500}})
       
   337   table.insert(stronglingsAnim, {func = AnimGiveState, args = {cannibals[6], 0}})
       
   338   table.insert(stronglingsAnim, {func = AnimOutOfNowhere, args = {cannibals[6], unpack(cannibalPos[6])}})
       
   339   table.insert(stronglingsAnim, {func = AnimWait, args = {leaks, 400}})
       
   340   table.insert(stronglingsAnim, {func = AnimGiveState, args = {cannibals[7], 0}})
       
   341   table.insert(stronglingsAnim, {func = AnimOutOfNowhere, args = {cannibals[7], unpack(cannibalPos[7])}})
       
   342   table.insert(stronglingsAnim, {func = AnimWait, args = {leaks, 400}})
       
   343   table.insert(stronglingsAnim, {func = AnimGiveState, args = {cannibals[8], 0}})
       
   344   table.insert(stronglingsAnim, {func = AnimOutOfNowhere, args = {cannibals[8], unpack(cannibalPos[8])}})
       
   345   table.insert(stronglingsAnim, {func = AnimWait, args = {leaks, 400}})
       
   346   table.insert(stronglingsAnim, {func = AnimGiveState, args = {cannibals[9], 0}})
       
   347   table.insert(stronglingsAnim, {func = AnimOutOfNowhere, args = {cannibals[9], unpack(cannibalPos[9])}})
       
   348   table.insert(stronglingsAnim, {func = AnimWait, args = {leaks, 400}})
       
   349   table.insert(stronglingsAnim, {func = AnimSay, args = {cannibals[7], "What a ride!", SAY_SHOUT, 2000}})
       
   350   table.insert(stronglingsAnim, {func = AnimTurn, args = {leaks, "Right"}})
       
   351   table.insert(stronglingsAnim, {func = AnimWait, args = {leaks, 700}})
       
   352   table.insert(stronglingsAnim, {func = AnimTurn, args = {leaks, "Left"}})
       
   353   table.insert(stronglingsAnim, {func = AnimSay, args = {leaks, "We can't defeat them!", SAY_THINK, 3000}})
       
   354   table.insert(stronglingsAnim, {func = AnimSay, args = {leaks, "I'll hold them up while you return to the village!", SAY_SAY, 6000}})
       
   355   table.insert(stronglingsAnim, {func = AnimFollowGear, args = {cyborg}, swh = false})
       
   356   table.insert(stronglingsAnim, {func = AnimWait, args = {cyborg, 1000}})
       
   357   table.insert(stronglingsAnim, {func = AnimSetGearPosition, args = {dense, 1420, 1315}})
       
   358   table.insert(stronglingsAnim, {func = AnimMove, args = {dense, "left", 1400, 0}})
       
   359   table.insert(stronglingsAnim, {func = AnimCustomFunction, args = {dense, EmitDenseClouds, {stronglingsAnim, "left"}}})
       
   360   table.insert(stronglingsAnim, {func = AnimMove, args = {dense, "left", 1350, 0}})
       
   361   table.insert(stronglingsAnim, {func = AnimOutOfNowhere, args = {cyborg, 1250, 1320}})
       
   362   table.insert(stronglingsAnim, {func = AnimRemoveState, args = {cyborg, gstInvisible}})
       
   363   table.insert(stronglingsAnim, {func = AnimGearWait, args = {cyborg, 2000}})
       
   364   table.insert(stronglingsAnim, {func = AnimSay, args = {cyborg, "Greetings, cloudy one!", SAY_SAY, 3000}})
       
   365   table.insert(stronglingsAnim, {func = AnimSay, args = {cyborg, "I have come to make you an offering...", SAY_SAY, 6000}})
       
   366   table.insert(stronglingsAnim, {func = AnimSay, args = {cyborg, "You are given the chance to turn your life around...", SAY_SAY, 6000}})
       
   367   table.insert(stronglingsAnim, {func = AnimSay, args = {cyborg, "If you agree to provide the information we need, you will be spared!", SAY_SAY, 7000}})
       
   368   table.insert(stronglingsAnim, {func = AnimSay, args = {cyborg, "Have no illusions, your tribe is dead, indifferent of your choice.", SAY_SAY, 7000}})
       
   369   table.insert(stronglingsAnim, {func = AnimSay, args = {cyborg, "If you decide to help us, though, we will no longer need to find a new governor for the island.", SAY_SAY, 8000}})
       
   370   table.insert(stronglingsAnim, {func = AnimSay, args = {cyborg, "If you know what I mean...", SAY_SAY, 3000}})
       
   371   table.insert(stronglingsAnim, {func = AnimSay, args = {cyborg, "So? What will it be?", SAY_SAY, 3000}})
       
   372   table.insert(stronglingsAnim, {func = AnimSwitchHog, args = {dense}})
       
   373   AddSkipFunction(stronglingsAnim, SkipStronglingsAnim, {})
       
   374 
       
   375   table.insert(acceptedAnim, {func = AnimSay, args = {cyborg, "Great choice, Steve! Mind if I call you that?", SAY_SAY, 7000}})
       
   376   table.insert(acceptedAnim, {func = AnimSay, args = {dense, "Whatever floats your boat...", SAY_SAY, 4500}})
       
   377   table.insert(acceptedAnim, {func = AnimSay, args = {cyborg, "Great! You will be contacted soon for assistance.", SAY_SAY, 6000}})
       
   378   table.insert(acceptedAnim, {func = AnimSay, args = {cyborg, "In the meantime, take these and return to your \"friend\"!", SAY_SAY, 6000}})
       
   379   table.insert(acceptedAnim, {func = AnimGiveState, args = {cyborg, gstInvisible}})
       
   380   table.insert(acceptedAnim, {func = AnimDisappear, args = {cyborg, unpack(cyborgPos)}})
       
   381   table.insert(acceptedAnim, {func = AnimSwitchHog, args = {dense}})
       
   382   AddSkipFunction(acceptedAnim, SkipAcceptedAnim, {}) 
       
   383 
       
   384   table.insert(acceptedSurvivedFinalAnim, {func = AnimCustomFunction, args = {dense, CondNeedToTurn, {leaks, dense}}})
       
   385   table.insert(acceptedSurvivedFinalAnim, {func = AnimSay, args = {leaks, "Pfew! That was close!", SAY_SAY, 3000}})
       
   386   table.insert(acceptedSurvivedFinalAnim, {func = AnimSay, args = {leaks, "Where did you get the exploding apples and the magic bow that shoots many arrows?", SAY_SAY, 9000}})
       
   387   table.insert(acceptedSurvivedFinalAnim, {func = AnimSay, args = {dense, "Uhm...I met one of them and took his weapons.", SAY_SAY, 5000}})
       
   388   table.insert(acceptedSurvivedFinalAnim, {func = AnimSay, args = {dense, "We should head back to the village now.", SAY_SAY, 5000}})
       
   389 
       
   390   table.insert(acceptedDiedFinalAnim, {func = AnimSay, args = {leaks, "Pfew! That was close!", SAY_THINK, 3000}})
       
   391   table.insert(acceptedDiedFinalAnim, {func = AnimSay, args = {leaks, "Your death will not be in vain, Dense Cloud!", SAY_THINK, 5000}})
       
   392   table.insert(acceptedDiedFinalAnim, {func = AnimSay, args = {dense, "You will be avenged!", SAY_SAY, 3000}})
       
   393 
       
   394   table.insert(refusedAnim, {func = AnimSay, args = {cyborg, "I see...", SAY_SAY, 2000}})
       
   395   table.insert(refusedAnim, {func = AnimSay, args = {cyborg, "Remember this, pathetic animal: when the day comes, you will regret your blind loyalty!", SAY_SAY, 8000}})
       
   396   table.insert(refusedAnim, {func = AnimSay, args = {cyborg, "You just committed suicide...", SAY_SAY, 5000}})
       
   397   table.insert(refusedAnim, {func = AnimDisappear, args = {cyborg, unpack(cyborgPos)}})
       
   398   table.insert(refusedAnim, {func = AnimGiveState, args = {cyborg, gstInvisible}})
       
   399   table.insert(refusedAnim, {func = AnimSay, args = {dense, "If you say so...", SAY_THINK, 3000}})
       
   400   table.insert(refusedAnim, {func = AnimFollowGear, args = {cyborg}, swh = false})
       
   401   table.insert(refusedAnim, {func = AnimWait, args = {cyborg, 700}})
       
   402   table.insert(refusedAnim, {func = AnimCustomFunction, args = {dense, RefusedStart, {}}})
       
   403   table.insert(refusedAnim, {func = AnimOutOfNowhere, args = {dense, 2645, 1146}})
       
   404   table.insert(refusedAnim, {func = AnimOutOfNowhere, args = {ramon, 2218, 1675}})
       
   405   table.insert(refusedAnim, {func = AnimOutOfNowhere, args = {spiky, 2400, 1675}})
       
   406   table.insert(refusedAnim, {func = AnimTurn, args = {spiky, "left"}})
       
   407   table.insert(refusedAnim, {func = AnimWait, args = {cyborg, 1700}})
       
   408   table.insert(refusedAnim, {func = AnimTurn, args = {spiky, "right"}})
       
   409   table.insert(refusedAnim, {func = AnimWait, args = {cyborg, 1700}})
       
   410   table.insert(refusedAnim, {func = AnimTurn, args = {spiky, "left"}})
       
   411   table.insert(refusedAnim, {func = AnimSay, args = {spiky, "Dude, we really need a new shaman...", SAY_SAY, 4000}})
       
   412   AddSkipFunction(refusedAnim, SkipRefusedAnim, {})
       
   413 
       
   414   table.insert(refusedFinalAnim, {func = AnimSay, args = {leaks, "It's over...", SAY_SAY, 2000}})
       
   415   table.insert(refusedFinalAnim, {func = AnimSay, args = {leaks, "Let's head back to the village!", SAY_SAY, 4000}})
       
   416 
       
   417   table.insert(attackedAnim, {func = AnimCustomFunction, args = {dense, CondNeedToTurn, {cyborg, dense}}})
       
   418   table.insert(attackedAnim, {func = AnimCustomFunction, args = {cyborg, SetHealth, {cyborg, 200}}})
       
   419   table.insert(attackedAnim, {func = AnimWait, args = {cyborg, 2000}})
       
   420   table.insert(attackedAnim, {func = AnimSay, args = {cyborg, "Really?! You thought you could harm me with your little toys?", SAY_SAY, 7000}})
       
   421   table.insert(attackedAnim, {func = AnimSay, args = {cyborg, "You're pathetic! You are not worthy of my attention...", SAY_SAY, 6000}})
       
   422   table.insert(attackedAnim, {func = AnimSay, args = {cyborg, "Actually, you aren't worthy of life! Take this...", SAY_SAY, 5000}})
       
   423   table.insert(attackedAnim, {func = AnimCustomFunction, args = {dense, BlowDenseCloud, {}}, swh = false})
       
   424   table.insert(attackedAnim, {func = AnimWait, args = {cyborg, 2000}})
       
   425   table.insert(attackedAnim, {func = AnimSay, args = {cyborg, "Incredible...", SAY_SAY, 3000}})
       
   426   table.insert(attackedAnim, {func = AnimDisappear, args = {cyborg, unpack(cyborgPos)}})
       
   427   table.insert(attackedAnim, {func = AnimGiveState, args = {cyborg, gstInvisible}})
       
   428   table.insert(attackedAnim, {func = AnimSwitchHog, args = {leaks}})
       
   429   table.insert(attackedAnim, {func = AnimSay, args = {leaks, "I wonder where Dense Cloud is...", SAY_THINK, 4000}})
       
   430   table.insert(attackedAnim, {func = AnimSay, args = {leaks, "I can't wait any more, I have to save myself!", SAY_THINK, 5000}})
       
   431   AddSkipFunction(attackedAnim, SkipAttackedAnim, {})
       
   432   
       
   433   table.insert(attackedFinalAnim, {func = AnimSay, args = {leaks, "I have to get back to the village!", SAY_THINK, 5000}})
       
   434   table.insert(attackedFinalAnim, {func = AnimSay, args = {leaks, "Dense Cloud must have already told them everything...", SAY_THINK, 7000}})
       
   435 
       
   436 end
       
   437 
       
   438 
       
   439 -----------------------------Misc--------------------------------------
       
   440 
       
   441 
       
   442 function RefusedStart()
       
   443   if ramonHidden == true then
       
   444     RestoreHog(ramon)
       
   445     ramonHidden = false
       
   446   end
       
   447   if spikyHidden == true then
       
   448     RestoreHog(spiky)
       
   449     spikyHidden = false
       
   450   end
       
   451   SetState(ramon, 0)
       
   452   SetState(spiky, 0)
       
   453   SetGearMessage(dense, 0)
       
   454   SetGearMessage(ramon, 0)
       
   455   SetGearMessage(spiky, 0)
       
   456 end
       
   457 
       
   458 function AddHogs()
       
   459 	AddTeam("Natives", 1117585, "Bone", "Island", "HillBilly", "cm_birdy")
       
   460   ramon = AddHog("Ramon", 0, 100, "rasta")
       
   461 	leaks = AddHog("Leaks A Lot", 0, 100, "Rambo")
       
   462   dense = AddHog("Dense Cloud", 0, 100, "RobinHood")
       
   463   spiky = AddHog("Spiky Cheese", 0, 100, "hair_yellow")
       
   464 
       
   465   AddTeam("Weaklings", 14483456, "Skull", "Island", "Pirate","cm_vampire")
       
   466   cannibals = {}
       
   467   cannibals[1] = AddHog("Brainiac", 5, 20, "Zombi")
       
   468 
       
   469   for i = 2, 5 do
       
   470     cannibals[i] = AddHog(HogNames[i], 1, 20, "Zombi")
       
   471     hogNr[cannibals[i]] = i - 2
       
   472   end
       
   473 
       
   474   AddTeam("Stronglings", 14483456, "Skull", "Island", "Pirate","cm_vampire")
       
   475 
       
   476   for i = 6, 9 do
       
   477     cannibals[i] = AddHog(HogNames[i], 2, 30, "vampirichog")
       
   478     hogNr[cannibals[i]] = i - 2
       
   479   end
       
   480 
       
   481   AddTeam("011101001", 14483456, "ring", "UFO", "Robot", "cm_star")
       
   482   cyborg = AddHog("Y3K1337", 0, 200, "cyborg1")
       
   483 end
       
   484 
       
   485 function PlaceHogs()
       
   486   HogTurnLeft(leaks, true)
       
   487 
       
   488   for i = 2, 9 do
       
   489     SetGearPosition(cannibals[i], unpack(cyborgPos))
       
   490     AnimTurn(cannibals[i], "left")
       
   491     cannibalDead[i] = false
       
   492   end
       
   493 
       
   494   SetGearPosition(cannibals[1], cannibalPos[1][1], cannibalPos[1][2])
       
   495   AnimTurn(cannibals[1], "left")
       
   496 
       
   497   SetGearPosition(cyborg, cyborgPos[1], cyborgPos[2])
       
   498   SetGearPosition(ramon, 2218, 1675)
       
   499   SetGearPosition(skiky, 2400, 1675)
       
   500   SetGearPosition(dense, densePos[1], densePos[2])
       
   501   SetGearPosition(leaks, leaksPos[1], leaksPos[2]) 
       
   502 end
       
   503 
       
   504 function VisiblizeHogs()
       
   505   for i = 1, 9 do
       
   506     SetState(cannibals[i], gstInvisible)
       
   507   end
       
   508   SetState(cyborg, gstInvisible)
       
   509   SetState(ramon, gstInvisible)
       
   510   SetState(spiky, gstInvisible)
       
   511 end
       
   512 
       
   513 function CondNeedToTurn(hog1, hog2)
       
   514   xl, xd = GetX(hog1), GetX(hog2)
       
   515   if xl > xd then
       
   516     AnimInsertStepNext({func = AnimTurn, args = {hog1, "Left"}})
       
   517     AnimInsertStepNext({func = AnimTurn, args = {hog2, "Right"}})
       
   518   elseif xl < xd then
       
   519     AnimInsertStepNext({func = AnimTurn, args = {hog2, "Left"}})
       
   520     AnimInsertStepNext({func = AnimTurn, args = {hog1, "Right"}})
       
   521   end
       
   522 end
       
   523 
       
   524 function HideHogs()
       
   525   for i = 2, 9 do
       
   526     HideHog(cannibals[i])
       
   527     isHidden[cannibals[i]] = true
       
   528   end
       
   529   HideHog(cyborg)
       
   530   cyborgHidden = true
       
   531   HideHog(ramon)
       
   532   HideHog(spiky)
       
   533   ramonHidden = true
       
   534   spikyHidden = true
       
   535 end
       
   536 
       
   537 function HideStronglings()
       
   538   for i = 6, 9 do
       
   539     HideHog(cannibals[i])
       
   540     isHidden[cannibals[i]] = true
       
   541   end
       
   542 end
       
   543 
       
   544 function UnHideWeaklings()
       
   545   for i = 2, 5 do
       
   546     RestoreHog(cannibals[i])
       
   547     isHidden[cannibals[i]] = false
       
   548     SetState(cannibals[i], gstInvisible)
       
   549   end
       
   550 end
       
   551 
       
   552 function UnHideStronglings()
       
   553   for i = 6, 9 do
       
   554     RestoreHog(cannibals[i])
       
   555     isHidden[cannibals[i]] = false
       
   556     SetState(cannibals[i], gstInvisible)
       
   557   end
       
   558   RestoreHog(cyborg)
       
   559   cyborgHidden = false
       
   560   SetState(cyborg, gstInvisible)
       
   561 end
       
   562 
       
   563 function ChoiceTaken()
       
   564   if choice == choiceAccept then
       
   565     AddAnim(acceptedAnim)
       
   566     AddFunction({func = AfterAcceptedAnim, args = {}})
       
   567   elseif choice == choiceRefuse then
       
   568     AddAnim(refusedAnim)
       
   569     AddFunction({func = AfterRefusedAnim, args = {}})
       
   570   else
       
   571     AddAnim(attackedAnim)
       
   572     AddFunction({func = AfterAttackedAnim, args = {}})
       
   573   end
       
   574 end
       
   575 
       
   576 function KillCyborg()
       
   577   RestoreHog(cyborg)
       
   578   DeleteGear(cyborg)
       
   579   TurnTimeLeft = 0
       
   580 end
       
   581 -----------------------------Events------------------------------------
       
   582 
       
   583 function CheckBrainiacDead()
       
   584   return brainiacDead
       
   585 end
       
   586 
       
   587 function DoBrainiacDead()
       
   588   TurnTimeLeft = 0
       
   589   AddAnim(weaklingsAnim)
       
   590   AddFunction({func = AfterWeaklingsAnim, args = {}})
       
   591   stage = interSpyStage
       
   592 end
       
   593   
       
   594 function CheckWeaklingsKilled()
       
   595   for i = 2, 5 do
       
   596     if cannibalDead[i] == false then
       
   597       return false
       
   598     end
       
   599   end
       
   600   return true
       
   601 end
       
   602 
       
   603 function DoWeaklingsKilled()
       
   604   TurnTimeLeft = 0
       
   605   AddAnim(stronglingsAnim)
       
   606   AddFunction({func = AfterStronglingsAnim, args = {}})
       
   607   stage = interWeakStage
       
   608 end
       
   609 
       
   610 function CheckRefuse()
       
   611   return GetX(dense) > 1400 and StoppedGear(dense)
       
   612 end
       
   613 
       
   614 function DoRefuse()
       
   615   choice = choiceRefuse
       
   616 end
       
   617 
       
   618 function CheckAccept()
       
   619   return GetX(dense) < 1300 and StoppedGear(dense)
       
   620 end
       
   621 
       
   622 function DoAccept()
       
   623   choice = choiceAccept
       
   624 end
       
   625 
       
   626 function CheckConfront()
       
   627   return cyborgAttacked and StoppedGear(dense)
       
   628 end
       
   629 
       
   630 function DoConfront()
       
   631   choice = choiceAttack
       
   632 end
       
   633 
       
   634 function CheckChoice()
       
   635   return choice ~= 0
       
   636 end
       
   637 
       
   638 function DoChoice()
       
   639   RemoveEventFunc(CheckConfront)
       
   640   RemoveEventFunc(CheckAccept)
       
   641   RemoveEventFunc(CheckRefuse)
       
   642   ChoiceTaken()
       
   643 end
       
   644 
       
   645 function CheckNeedGirder()
       
   646   return GetX(dense) > 1640 and StoppedGear(dense)
       
   647 end
       
   648 
       
   649 function DoNeedGirder()
       
   650   ShowMission("The Shadow Falls", "Under Construction", "To place a girder, select it, use [Left] and [Right] to select angle and length, place with [Left Click]", 1, 6000)
       
   651 end
       
   652 
       
   653 function CheckNeedWeapons()
       
   654   return GetX(dense) > 2522 and StoppedGear(dense)
       
   655 end
       
   656 
       
   657 function DoNeedWeapons()
       
   658   grenadeCrate = SpawnAmmoCrate(2550, 600, amGrenade)
       
   659   shotgunCrate = SpawnAmmoCrate(2550, 550, amShotgun)
       
   660   AddCaption("A little gift from the cyborgs")
       
   661 end
       
   662 
       
   663 function CheckTookWeapons()
       
   664   return shotgunTaken and grenadeTaken
       
   665 end
       
   666 
       
   667 function DoTookWeapons()
       
   668   ShowMission("The Shadow Falls", "The guardian", "Protect yourselves!|Grenade hint: set the timer with [1-5], aim with [Up]/[Down] and hold [Space] to set power", 1, 8000)
       
   669   AddAmmo(dense, amSkip, 100)
       
   670   AddAmmo(dense, amSwitch, 100)
       
   671   stage = duoStage
       
   672   RemoveEventFunc(CheckNeedGirder)
       
   673   RemoveEventFunc(CheckNeedWeapons)
       
   674   RemoveEventFunc(CheckRestartReturnAccepted)
       
   675   AddEvent(CheckStronglingsDead, {}, DoStronglingsDead, {}, 0)
       
   676   AddAmmo(cannibals[6], amGrenade, 7)
       
   677   AddAmmo(cannibals[6], amShotgun, 7)
       
   678   SetGearMessage(leaks, 0)
       
   679   SetGearMessage(dense, 0)
       
   680   TurnTimeLeft = TurnTime
       
   681 end
       
   682 
       
   683 function DoStronglingsDead()
       
   684   if denseDead == true then
       
   685     AddAnim(acceptedDiedFinalAnim)
       
   686     SaveCampaignVar("M2DenseDead", "1")
       
   687   else
       
   688     AddAnim(acceptedSurvivedFinalAnim)
       
   689     SaveCampaignVar("M2DenseDead", "0")
       
   690   end
       
   691   SaveCampaignVar("M2RamonDead", "0")
       
   692   SaveCampaignVar("M2SpikyDead", "0")
       
   693   AddFunction({func = KillCyborg, args = {}})
       
   694   SaveCampaignVar("Progress", "2")
       
   695   SaveCampaignVar("M2Choice", "" .. choice)
       
   696 end
       
   697 
       
   698 function DoStronglingsDeadRefused()
       
   699   if denseDead == true then
       
   700     SaveCampaignVar("M2DenseDead", "1")
       
   701   else
       
   702     SaveCampaignVar("M2DenseDead", "0")
       
   703   end
       
   704   if ramonDead == true then
       
   705     SaveCampaignVar("M2RamonDead", "1")
       
   706   else
       
   707     SaveCampaignVar("M2RamonDead", "0")
       
   708   end
       
   709   if spikyDead == true then
       
   710     SaveCampaignVar("M2SpikyDead", "1")
       
   711   else
       
   712     SaveCampaignVar("M2SpikyDead", "0")
       
   713   end
       
   714   AddAnim(refusedFinalAnim)
       
   715   AddFunction({func = KillCyborg, args = {}})
       
   716   SaveCampaignVar("Progress", "2")
       
   717   SaveCampaignVar("M2Choice", "" .. choice)
       
   718 end
       
   719 
       
   720 function DoStronglingsDeadAttacked()
       
   721   SaveCampaignVar("M2DenseDead", "1")
       
   722   SaveCampaignVar("M2RamonDead", "0")
       
   723   SaveCampaignVar("M2SpikyDead", "0")
       
   724   AddAnim(attackedFinalAnim)
       
   725   AddFunction({func = KillCyborg, args = {}})
       
   726   SaveCampaignVar("Progress", "2")
       
   727   SaveCampaignVar("M2Choice", "" .. choice)
       
   728 end
       
   729 
       
   730 function CheckStronglingsDead()
       
   731   if leaksDead == true then
       
   732     return false
       
   733   end
       
   734   for i = 6, 9 do
       
   735     if cannibalDead[i] == false then
       
   736       return false
       
   737     end
       
   738   end
       
   739   return true
       
   740 end
       
   741 
       
   742 function CheckLeaksDead()
       
   743   return leaksDead
       
   744 end
       
   745 
       
   746 function DoDead()
       
   747   AddCaption("...and so the cyborgs took over the world...")
       
   748   stage = loseStage
       
   749   if ramonHidden then
       
   750     RestoreHog(ramon)
       
   751   end
       
   752   if spikyHidden then
       
   753     RestoreHog(spiky)
       
   754   end
       
   755   SetHealth(dense, 0)
       
   756   SetHealth(leaks, 0)
       
   757   SetHealth(ramon, 0)
       
   758   SetHealth(spiky, 0)
       
   759   TurnTimeLeft = 0
       
   760 end
       
   761 
       
   762 function CheckDenseDead()
       
   763   return denseDead and choice ~= choiceAttack 
       
   764 end
       
   765 
       
   766 function CheckRestartReturnAccepted()
       
   767   return retryReturn
       
   768 end
       
   769 
       
   770 -----------------------------Main Functions----------------------------
       
   771 
       
   772 function onGameInit()
       
   773 	Seed = 334 
       
   774   TemplateFilter = 3
       
   775 	GameFlags = gfSolidLand + gfDisableWind
       
   776 	TurnTime = 50000 
       
   777 	CaseFreq = 0
       
   778 	MinesNum = 0
       
   779 	MinesTime = 3000
       
   780 	Explosives = 0
       
   781 	Delay = 10 
       
   782 	MapGen = 0
       
   783 	Theme = "Nature"
       
   784   SuddenDeathTurns = 3000
       
   785 
       
   786   AddHogs()
       
   787   PlaceHogs()
       
   788   VisiblizeHogs()
       
   789   
       
   790   AnimInit()
       
   791   AnimationSetup()
       
   792 end
       
   793 
       
   794 function onGameStart()
       
   795   HideHogs()
       
   796   AddAmmo(leaks, amSwitch, 100)
       
   797   AddEvent(CheckLeaksDead, {}, DoDead, {}, 0)
       
   798   AddEvent(CheckDenseDead, {}, DoDead, {}, 0)
       
   799   AddAnim(startDialogue)
       
   800   AddFunction({func = AfterStartDialogue, args = {}})
       
   801   AddEvent(CheckBrainiacDead, {}, DoBrainiacDead, {}, 0)
       
   802   ShowMission("The Shadow Falls", "The First Encounter", "Survive!|Hint: Cinematics can be skipped with the [Precise] key.", 1, 0)
       
   803 end
       
   804 
       
   805 function onGameTick()
       
   806   AnimUnWait()
       
   807   if ShowAnimation() == false then
       
   808     return
       
   809   end
       
   810   ExecuteAfterAnimations()
       
   811   CheckEvents()
       
   812 end
       
   813 
       
   814 function onGearDelete(gear)
       
   815   if gear == cannibals[1] then
       
   816     brainiacDead = true
       
   817   elseif gear == grenadeCrate then
       
   818     grenadeTaken = true
       
   819   elseif gear == shotgunCrate then
       
   820     shotgunTaken = true
       
   821   elseif gear == dense then
       
   822     denseDead = true
       
   823   elseif gear == leaks then
       
   824     leaksDead = true
       
   825   elseif gear == ramon then
       
   826     ramonDead = true
       
   827   elseif gear == spiky then
       
   828     spikyDead = true
       
   829   else
       
   830     for i = 2, 9 do
       
   831       if gear == cannibals[i] then
       
   832         cannibalDead[i] = true
       
   833       end
       
   834     end
       
   835   end
       
   836 end
       
   837 
       
   838 function onGearAdd(gear)
       
   839 end
       
   840 
       
   841 function onAmmoStoreInit()
       
   842   SetAmmo(amDEagle, 9, 0, 0, 0)
       
   843   SetAmmo(amSniperRifle, 9, 0, 0, 0)
       
   844   SetAmmo(amFirePunch, 9, 0, 0, 0)
       
   845   SetAmmo(amWhip, 9, 0, 0, 0)
       
   846   SetAmmo(amBaseballBat, 9, 0, 0, 0)
       
   847   SetAmmo(amHammer, 9, 0, 0, 0)
       
   848   SetAmmo(amLandGun, 9, 0, 0, 0)
       
   849   SetAmmo(amSnowball, 9, 0, 0, 0)
       
   850   SetAmmo(amGirder, 0, 0, 0, 2)
       
   851   SetAmmo(amParachute, 0, 0, 0, 2)
       
   852   SetAmmo(amGrenade, 0, 0, 0, 8)
       
   853   SetAmmo(amShotgun, 0, 0, 0, 8)
       
   854   SetAmmo(amSwitch, 0, 0, 0, 8)
       
   855   SetAmmo(amRope, 0, 0, 0, 6)
       
   856 end
       
   857 
       
   858 function onNewTurn()
       
   859   if AnimInProgress() then
       
   860     TurnTimeLeft = -1
       
   861 --  elseif stage == interSpyStage and GetHogTeamName(CurrentHedgehog) ~= "Natives" then
       
   862 --    TurnTimeLeft = 0
       
   863 --    SetState(CurrentHedgehog, gstInvisible)
       
   864   elseif stage == cyborgStage then
       
   865     if CurrentHedgehog ~= dense then
       
   866       TurnTimeLeft = 0
       
   867     else
       
   868       TurnTimeLeft = -1
       
   869     end
       
   870   elseif stage == acceptedReturnStage then
       
   871     SwitchHog(dense)
       
   872     FollowGear(dense)
       
   873     TurnTimeLeft = -1
       
   874   end
       
   875 end
       
   876 
       
   877 function onGearDamage(gear, damage)
       
   878   if gear == cyborg and stage == cyborgStage then
       
   879     cyborgAttacked = true
       
   880   end
       
   881 end
       
   882 
       
   883 function onPrecise()
       
   884   if GameTime > 2500 then
       
   885     SetAnimSkip(true)
       
   886   end
       
   887   if stage == acceptedReturnStage then
       
   888     retryReturn = true
       
   889   end
       
   890 end
       
   891