share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/united.lua
changeset 7241 7fda4d886c5e
parent 7225 e3f2280d9000
child 7243 9ae9178c525e
equal deleted inserted replaced
7239:598fe796dd01 7241:7fda4d886c5e
    37 
    37 
    38 startAnim = {}
    38 startAnim = {}
    39 wave2Anim = {}
    39 wave2Anim = {}
    40 finalAnim = {}
    40 finalAnim = {}
    41 --------------------------Anim skip functions--------------------------
    41 --------------------------Anim skip functions--------------------------
       
    42 function AfterHogDeadAnim()
       
    43   freshDead = nil
       
    44   TurnTimeLeft = TurnTime
       
    45 end
       
    46 
    42 function AfterStartAnim()
    47 function AfterStartAnim()
    43   local goal = loc("Defeat the cannibals!|")
    48   local goal = loc("Defeat the cannibals!|")
    44   local chiefgoal = loc("Try to protect the chief! Unlike your other hogs, he won't return on future missions if he dies.")
    49   local chiefgoal = loc("Try to protect the chief! Unlike your other hogs, he won't return on future missions if he dies.")
    45   TurnTimeLeft = TurnTime
    50   TurnTimeLeft = TurnTime
    46   ShowMission(loc("United We Stand"), loc("Invasion"), goal .. chiefgoal, 1, 6000)
    51   ShowMission(loc("United We Stand"), loc("Invasion"), goal .. chiefgoal, 1, 6000)
    72   end
    77   end
    73   AnimSwitchHog(cannibals[5])
    78   AnimSwitchHog(cannibals[5])
    74 end
    79 end
    75 
    80 
    76 function AfterWave2Anim()
    81 function AfterWave2Anim()
    77   TurnTimeLeft = 0
    82   SetGearMessage(CurrentHegdgehog, 0)
       
    83   SetState(CurrentHedgehog, 0)
       
    84   TurnTimeLeft = TurnTime
    78 end
    85 end
    79 
    86 
    80 function AfterFinalAnim()
    87 function AfterFinalAnim()
    81   if chiefDead == true then
    88   if chiefDead == true then
    82     SaveCampaignVar("M4ChiefDead", "1")
    89     SaveCampaignVar("M4ChiefDead", "1")
    86   SaveCampaignVar("Progress", "4")
    93   SaveCampaignVar("Progress", "4")
    87   ParseCommand("teamgone " .. loc("011101001"))
    94   ParseCommand("teamgone " .. loc("011101001"))
    88   TurnTimeLeft = 0
    95   TurnTimeLeft = 0
    89 end
    96 end
    90 -----------------------------Animations--------------------------------
    97 -----------------------------Animations--------------------------------
    91 
    98 function Wave2Reaction()
    92 function EmitDenseClouds(anim, dir)
    99   local i = 1
       
   100   local gearr = nil
       
   101   while nativesDead[i] == true do
       
   102     i = i + 1
       
   103   end
       
   104   gearr = natives[i]
       
   105   if denseDead ~= true and band(GetState(dense), gstDrowning) == 0 then
       
   106     AnimInsertStepNext({func = AnimSay, args = {dense, loc("I'm so scared!"), SAY_SAY, 3000}})
       
   107     AnimInsertStepNext({func = AnimCustomFunction, args = {dense, EmitDenseClouds, {"left"}}})
       
   108     AnimInsertStepNext({func = AnimTurn, args = {dense, "Left"}})
       
   109   end
       
   110   AnimInsertStepNext({func = AnimSay, args = {gearr, loc("There's more of them? When did they become so hungry?"), SAY_SHOUT, 8000}}) 
       
   111 end
       
   112 
       
   113 function EmitDenseClouds(dir)
    93   local dif
   114   local dif
    94   if dir == "left" then
   115   if dir == "left" then
    95     dif = 10
   116     dif = 10
    96   else
   117   else
    97     dif = -10
   118     dif = -10
   159 
   180 
   160   table.insert(wave2Anim, {func = AnimCustomFunction, args = {leaks, RestoreWave, {2}}, swh = false})
   181   table.insert(wave2Anim, {func = AnimCustomFunction, args = {leaks, RestoreWave, {2}}, swh = false})
   161   for i = 5, 8 do
   182   for i = 5, 8 do
   162     table.insert(wave2Anim, {func = AnimOutOfNowhere, args = {cannibals[i], unpack(cannibalPos[i])}})
   183     table.insert(wave2Anim, {func = AnimOutOfNowhere, args = {cannibals[i], unpack(cannibalPos[i])}})
   163   end
   184   end
       
   185   table.insert(wave2Anim, {func = AnimCustomFunction, args = {leaks, Wave2Reaction, {}}, swh = false})
   164   table.insert(wave2Anim, {func = AnimCustomFunction, args = {leaks, SpawnCrates, {2}}, swh = false})
   186   table.insert(wave2Anim, {func = AnimCustomFunction, args = {leaks, SpawnCrates, {2}}, swh = false})
   165   table.insert(wave2Anim, {func = AnimCustomFunction, args = {leaks, SpawnHealthCrates, {2}}, swh = false})
   187   table.insert(wave2Anim, {func = AnimCustomFunction, args = {leaks, SpawnHealthCrates, {2}}, swh = false})
   166   AddSkipFunction(wave2Anim, SkipWave2Anim, {})
   188   AddSkipFunction(wave2Anim, SkipWave2Anim, {})
       
   189 end
       
   190 
       
   191 function SetupHogDeadAnim(gear)
       
   192   hogDeadAnim = {}
       
   193   if nativesNum == 0 then
       
   194     return
       
   195   end
       
   196   local hogDeadStrings = {"They killed " .. gear .."! You bastards!", 
       
   197                           gear .. "! Why?!", 
       
   198                           "That was just mean!", 
       
   199                           "Oh no, not " .. gear .. "!"}
       
   200   table.insert(hogDeadAnim, {func = AnimSay, args = {CurrentHedgehog, hogDeadStrings[nativesNum], SAY_SHOUT, 4000}})
   167 end
   201 end
   168 
   202 
   169 function SetupFinalAnim()
   203 function SetupFinalAnim()
   170   local found = 0
   204   local found = 0
   171   local hogs = {}
   205   local hogs = {}
   257     cannibals[i] = AddHog(HogNames[i], 3, 70, "Zombi")
   291     cannibals[i] = AddHog(HogNames[i], 3, 70, "Zombi")
   258   end
   292   end
   259 
   293 
   260   AddTeam(loc("Heavy Cannfantry"), 14483456, "Skull", "Island", "Pirate", "cm_vampire")
   294   AddTeam(loc("Heavy Cannfantry"), 14483456, "Skull", "Island", "Pirate", "cm_vampire")
   261   for i = 5, 8 do
   295   for i = 5, 8 do
   262     cannibals[i] = AddHog(HogNames[i], 2, 100, "vampirichog")
   296     cannibals[i] = AddHog(HogNames[i], 2, 70, "vampirichog")
   263   end
   297   end
   264 
   298 
   265   AddTeam(loc("011101001"), 14483456, "ring", "UFO", "Robot", "cm_star")
   299   AddTeam(loc("011101001"), 14483456, "ring", "UFO", "Robot", "cm_star")
   266   cyborg = AddHog(loc("Unit 334a$7%;.*"), 0, 200, "cyborg1")
   300   cyborg = AddHog(loc("Unit 334a$7%;.*"), 0, 200, "cyborg1")
   267 
   301 
   381 function onGearDelete(gear)
   415 function onGearDelete(gear)
   382   if gear == dense then
   416   if gear == dense then
   383     denseDead = true
   417     denseDead = true
   384     nativesNum = nativesNum - 1
   418     nativesNum = nativesNum - 1
   385     nativesDead[2] = true
   419     nativesDead[2] = true
       
   420     freshDead = loc("Dense Cloud")
   386   elseif gear == leaks then
   421   elseif gear == leaks then
   387     leaksDead = true
   422     leaksDead = true
   388     nativesNum = nativesNum - 1
   423     nativesNum = nativesNum - 1
   389     nativesDead[1] = true
   424     nativesDead[1] = true
       
   425     freshDead = loc("Leaks A Lot")
   390   elseif gear == chief then
   426   elseif gear == chief then
   391     chiefDead = true
   427     chiefDead = true
   392     nativesNum = nativesNum - 1
   428     nativesNum = nativesNum - 1
   393     nativesDead[5] = true
   429     nativesDead[5] = true
       
   430     freshDead = loc("Righteous Beard")
   394   elseif gear == water then
   431   elseif gear == water then
   395     waterDead = true
   432     waterDead = true
   396     nativesNum = nativesNum - 1
   433     nativesNum = nativesNum - 1
   397     nativesDead[3] = true
   434     nativesDead[3] = true
       
   435     freshDead = loc("Fiery Water")
   398   elseif gear == buffalo then
   436   elseif gear == buffalo then
   399     buffaloDead = true
   437     buffaloDead = true
   400     nativesNum = nativesNum - 1
   438     nativesNum = nativesNum - 1
   401     nativesDead[4] = true
   439     nativesDead[4] = true
       
   440     freshDead = loc("Raging Buffalo")
   402   else
   441   else
   403     for i = 1, 8 do
   442     for i = 1, 8 do
   404       if gear == cannibals[i] then
   443       if gear == cannibals[i] then
   405         cannibalDead[i] = true
   444         cannibalDead[i] = true
   406       end
   445       end
   411 function onGearAdd(gear)
   450 function onGearAdd(gear)
   412 end
   451 end
   413 
   452 
   414 function onAmmoStoreInit()
   453 function onAmmoStoreInit()
   415   SetAmmo(amDEagle, 9, 0, 0, 0)
   454   SetAmmo(amDEagle, 9, 0, 0, 0)
   416   SetAmmo(amSniperRifle, 9, 0, 0, 0)
   455   SetAmmo(amSniperRifle, 4, 0, 0, 0)
   417   SetAmmo(amFirePunch, 9, 0, 0, 0)
   456   SetAmmo(amFirePunch, 9, 0, 0, 0)
   418   SetAmmo(amWhip, 9, 0, 0, 0)
   457   SetAmmo(amWhip, 9, 0, 0, 0)
   419   SetAmmo(amBaseballBat, 9, 0, 0, 0)
   458   SetAmmo(amBaseballBat, 9, 0, 0, 0)
   420   SetAmmo(amHammer, 9, 0, 0, 0)
   459   SetAmmo(amHammer, 9, 0, 0, 0)
   421   SetAmmo(amLandGun, 9, 0, 0, 0)
   460   SetAmmo(amLandGun, 9, 0, 0, 0)
   422   SetAmmo(amSnowball, 9, 0, 0, 0)
   461   SetAmmo(amSnowball, 8, 0, 0, 0)
   423   SetAmmo(amGirder, 4, 0, 0, 2)
   462   SetAmmo(amGirder, 4, 0, 0, 2)
   424   SetAmmo(amParachute, 4, 0, 0, 2)
   463   SetAmmo(amParachute, 4, 0, 0, 2)
   425   SetAmmo(amSwitch, 8, 0, 0, 2)
   464   SetAmmo(amSwitch, 8, 0, 0, 2)
   426   SetAmmo(amSkip, 9, 0, 0, 0)
   465   SetAmmo(amSkip, 8, 0, 0, 0)
   427   SetAmmo(amRope, 5, 0, 0, 3)
   466   SetAmmo(amRope, 5, 0, 0, 3)
   428   SetAmmo(amBlowTorch, 3, 0, 0, 3)
   467   SetAmmo(amBlowTorch, 3, 0, 0, 3)
   429   SetAmmo(amPickHammer, 0, 0, 0, 3)
   468   SetAmmo(amPickHammer, 0, 0, 0, 3)
   430   SetAmmo(amLowGravity, 0, 0, 0, 2)
   469   SetAmmo(amLowGravity, 0, 0, 0, 2)
   431   SetAmmo(amDynamite, 0, 0, 0, 3)
   470   SetAmmo(amDynamite, 0, 0, 0, 3)
   432   SetAmmo(amBazooka, 0, 0, 0, 4)
   471   SetAmmo(amBazooka, 0, 0, 0, 4)
   433   SetAmmo(amGrenade, 0, 0, 0, 5)
   472   SetAmmo(amGrenade, 0, 0, 0, 5)
   434   SetAmmo(amMine, 0, 0, 0, 2)
   473   SetAmmo(amMine, 0, 0, 0, 2)
   435   SetAmmo(amMolotov, 0, 0, 0, 3)
   474   SetAmmo(amMolotov, 0, 0, 0, 3)
   436   SetAmmo(amFlamethrower, 0, 0, 0, 3)
   475   SetAmmo(amFlamethrower, 0, 0, 0, 3)
       
   476   SetAmmo(amShotgun, 0, 0, 0, 3)
       
   477   SetAmmo(amTeleport, 0, 0, 0, 2)
       
   478   SetAmmo(amFlamethrower, 0, 0, 0, 3)
   437 end
   479 end
   438 
   480 
   439 function onNewTurn()
   481 function onNewTurn()
   440   if AnimInProgress() then
   482   if AnimInProgress() then
   441     TurnTimeLeft = -1
   483     TurnTimeLeft = -1
       
   484     return
       
   485   end
       
   486   if freshDead ~= nil and GetHogTeamName(CurrentHedgehog) == loc("Natives") then
       
   487     SetupHogDeadAnim(freshDead)
       
   488     AddAnim(hogDeadAnim)
       
   489     AddFunction({func = AfterHogDeadAnim, args = {}})
   442   end
   490   end
   443 end
   491 end
   444 
   492 
   445 function onGearDamage(gear, damage)
   493 function onGearDamage(gear, damage)
   446 end
   494 end