share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/family.lua
changeset 7484 f3a7c4e75815
parent 7472 cd747aefcba1
child 7493 f261d6bf76b3
equal deleted inserted replaced
7481:50e09add9ffc 7484:f3a7c4e75815
    68 nativePos2 = {196, 1499}
    68 nativePos2 = {196, 1499}
    69 
    69 
    70 cyborgNames = {loc("Unit 0x0007"), loc("Hogminator"), loc("Carol"), 
    70 cyborgNames = {loc("Unit 0x0007"), loc("Hogminator"), loc("Carol"), 
    71                loc("Blender"), loc("Elderbot"), loc("Fiery Water")}
    71                loc("Blender"), loc("Elderbot"), loc("Fiery Water")}
    72 cyborgsDif = {2, 2, 2, 2, 2, 1}
    72 cyborgsDif = {2, 2, 2, 2, 2, 1}
    73 cyborgsHealth = {90, 90, 90, 80, 80, 20}
    73 cyborgsHealth = {45, 45, 45, 40, 40, 20}
    74 cyborgPos = {945, 1216}
    74 cyborgPos = {945, 1216}
    75 cyborgsNum = 6
    75 cyborgsNum = 6
    76 cyborgsPos = {{2243, 1043}, {3588, 1227}, {2781, 1388},
    76 cyborgsPos = {{2243, 1043}, {3588, 1227}, {2781, 1388},
    77               {3749, 1040}, {2475, 1338}, {3853, 881}}
    77               {3749, 1040}, {2475, 1338}, {3853, 881}}
    78 cyborgsDir = {"Left", "Left", "Left", "Left", "Left", "Right"}
    78 cyborgsDir = {"Left", "Left", "Left", "Left", "Left", "Right"}
   174   table.insert(midAnim, {func = AnimTeleportGear, args = {natives[1], unpack(nativeMidPos)}})
   174   table.insert(midAnim, {func = AnimTeleportGear, args = {natives[1], unpack(nativeMidPos)}})
   175   table.insert(midAnim, {func = AnimSay, args = {cyborg, loc("Here, let me help you save her!"), SAY_SAY, 5000}})
   175   table.insert(midAnim, {func = AnimSay, args = {cyborg, loc("Here, let me help you save her!"), SAY_SAY, 5000}})
   176   table.insert(midAnim, {func = AnimSay, args = {natives[1], loc("Thanks!"), SAY_SAY, 2000}})
   176   table.insert(midAnim, {func = AnimSay, args = {natives[1], loc("Thanks!"), SAY_SAY, 2000}})
   177   table.insert(midAnim, {func = AnimTeleportGear, args = {natives[1], unpack(nativeMidPos2)}})
   177   table.insert(midAnim, {func = AnimTeleportGear, args = {natives[1], unpack(nativeMidPos2)}})
   178   table.insert(midAnim, {func = AnimSay, args = {natives[1], loc("Why can't he just let her go?!"), SAY_THINK, 5000}})
   178   table.insert(midAnim, {func = AnimSay, args = {natives[1], loc("Why can't he just let her go?!"), SAY_THINK, 5000}})
   179   AddSkipFunction(midAnim, SkipStartAnim, {})
   179   AddSkipFunction(midAnim, SkipMidAnim, {})
   180 end
   180 end
   181 
   181 
   182 --------------------------Anim skip functions--------------------------
   182 --------------------------Anim skip functions--------------------------
   183 function AfterMidAnim()
   183 function AfterMidAnim()
   184   HideHedge(cyborg)
   184   HideHedge(cyborg)
   187   AddNewEvent(CheckPrincessFreed, {}, DoPrincessFreed, {}, 0)
   187   AddNewEvent(CheckPrincessFreed, {}, DoPrincessFreed, {}, 0)
   188   TurnTimeLeft = 0
   188   TurnTimeLeft = 0
   189   ShowMission(loc("Family Reunion"), loc("Salvation"), loc("Get your teammates out of their natural prison and save the princess!|Hint: Drilling holes should solve everything."), 1, 7000)
   189   ShowMission(loc("Family Reunion"), loc("Salvation"), loc("Get your teammates out of their natural prison and save the princess!|Hint: Drilling holes should solve everything."), 1, 7000)
   190 end
   190 end
   191   
   191   
       
   192 function SkipMidAnim()
       
   193   AnimTeleportGear(natives[1], unpack(nativeMidPos2))
       
   194   SkipStartAnim()
       
   195 end
       
   196 
   192 function SetupPlace3()
   197 function SetupPlace3()
   193   SpawnUtilityCrate(2086, 1887, amRope, 1)
   198   SpawnUtilityCrate(2086, 1887, amRope, 1)
   194   SpawnUtilityCrate(2147, 728, amBlowTorch, 2)
   199   SpawnUtilityCrate(2147, 728, amBlowTorch, 2)
   195   SpawnUtilityCrate(2778, 1372, amPickHammer, 2)
   200   SpawnUtilityCrate(2778, 1372, amPickHammer, 2)
   196   SpawnUtilityCrate(2579, 1886, amPickHammer, 2)
   201   SpawnUtilityCrate(2579, 1886, amPickHammer, 2)
   235   for i = 1, cyborgsNum do
   240   for i = 1, cyborgsNum do
   236     AddNewEvent(CheckGearDead, {cyborgs[i]}, DoCyborgDead, {i}, 0)
   241     AddNewEvent(CheckGearDead, {cyborgs[i]}, DoCyborgDead, {i}, 0)
   237   end
   242   end
   238   AddNewEvent(CheckOutOfCluster, {}, DoOutOfCluster, {}, 1)
   243   AddNewEvent(CheckOutOfCluster, {}, DoOutOfCluster, {}, 1)
   239   AddNewEvent(CheckOutOfGrenade, {}, DoOutOfGrenade, {}, 1)
   244   AddNewEvent(CheckOutOfGrenade, {}, DoOutOfGrenade, {}, 1)
       
   245 --  AddNewEvent(CheckNeedToHide, {}, DoNeedToHide, {}, 1)
   240   TurnTimeLeft = TurnTime
   246   TurnTimeLeft = TurnTime
   241   ShowMission(loc("Family Reunion"), loc("Hostage Situation"), loc("Save the princess! All your hogs must survive!|Hint: Kill the cyborgs first! Use the ammo very carefully!|Hint: You might want to spare a girder for cover!"), 1, 7000)
   247   ShowMission(loc("Family Reunion"), loc("Hostage Situation"), loc("Save the princess! All your hogs must survive!|Hint: Kill the cyborgs first! Use the ammo very carefully!|Hint: You might want to spare a girder for cover!"), 1, 7000)
   242 end
   248 end
   243 
   249 
   244 function SetupPlace2()
   250 function SetupPlace2()
   250 	PlaceGirder(674, 1170, 5)
   256 	PlaceGirder(674, 1170, 5)
   251 	PlaceGirder(710, 1310, 7)
   257 	PlaceGirder(710, 1310, 7)
   252 	PlaceGirder(648, 1427, 5)
   258 	PlaceGirder(648, 1427, 5)
   253   PlaceGirder(2110, 980, 0)
   259   PlaceGirder(2110, 980, 0)
   254 
   260 
   255 	SpawnAmmoCrate(814, 407, amBazooka, 8)
   261 	SpawnAmmoCrate(814, 407, amBazooka, 4)
   256 	clusterCrate = SpawnAmmoCrate(862, 494, amClusterBomb, 8)
   262 	clusterCrate = SpawnAmmoCrate(862, 494, amClusterBomb, 4)
   257 	SpawnAmmoCrate(855, 486, amBee, 5)
   263 	SpawnAmmoCrate(855, 486, amBee, 3)
   258 	grenadeCrate1 = SpawnAmmoCrate(849, 459, amGrenade, 8)
   264 	grenadeCrate1 = SpawnAmmoCrate(849, 459, amGrenade, 4)
   259 	SpawnAmmoCrate(2077, 847, amWatermelon, 3)
   265 	SpawnAmmoCrate(2077, 847, amWatermelon, 3)
   260 	grenadeCrate2 = SpawnAmmoCrate(2122, 847, amGrenade, 8)
   266 	grenadeCrate2 = SpawnAmmoCrate(2122, 847, amGrenade, 3)
   261 
   267 
   262 	SpawnUtilityCrate(747, 1577, amPickHammer, 1)
   268 	SpawnUtilityCrate(747, 1577, amPickHammer, 1)
   263 	SpawnUtilityCrate(496, 1757, amGirder, 2)
   269 	SpawnUtilityCrate(496, 1757, amGirder, 2)
   264   SpawnUtilityCrate(1809, 1880, amGirder, 1)
   270   SpawnUtilityCrate(1809, 1880, amGirder, 1)
   265 	SpawnUtilityCrate(530, 1747, amPortalGun, 1)
   271 	SpawnUtilityCrate(530, 1747, amPortalGun, 1)
   282   return cyborgsLeft == 0
   288   return cyborgsLeft == 0
   283 end
   289 end
   284 
   290 
   285 function DoCyborgsDead()
   291 function DoCyborgsDead()
   286   SetGearMessage(CurrentHedgehog, 0)
   292   SetGearMessage(CurrentHedgehog, 0)
       
   293   RestoreHedge(princess)
       
   294 --  RemoveEventFunc(CheckNeedToHide)
   287   AddAnim(midAnim)
   295   AddAnim(midAnim)
   288   AddFunction({func = AfterMidAnim, args = {}})
   296   AddFunction({func = AfterMidAnim, args = {}})
   289 end
   297 end
   290 
   298 
   291 function DoCyborgDead(index)
   299 function DoCyborgDead(index)
   320 function CheckGearDead(gear)
   328 function CheckGearDead(gear)
   321   return gearDead[gear]
   329   return gearDead[gear]
   322 end
   330 end
   323 
   331 
   324 function EndMission()
   332 function EndMission()
       
   333   RemoveEventFunc(CheckPrincessFreed)
   325   AddCaption("So the princess was never heard of again...")
   334   AddCaption("So the princess was never heard of again...")
   326   ParseCommand("teamgone " .. loc("Natives"))
   335   ParseCommand("teamgone " .. loc("Natives"))
   327   ParseCommand("teamgone " .. loc("011101001"))
   336   ParseCommand("teamgone " .. loc("011101001"))
   328   TurnTimeLeft = 0
   337   TurnTimeLeft = 0
   329 end
   338 end
   335 function CheckOutOfGrenade()
   344 function CheckOutOfGrenade()
   336   return CheckGearDead(grenadeCrate1) and CheckGearDead(grenadeCrate2) and GetAmmoCount(natives[1], amGrenade) == 0
   345   return CheckGearDead(grenadeCrate1) and CheckGearDead(grenadeCrate2) and GetAmmoCount(natives[1], amGrenade) == 0
   337 end
   346 end
   338 
   347 
   339 function DoOutOfCluster()
   348 function DoOutOfCluster()
   340   clusterCrate = SpawnAmmoCrate(GetX(natives[1]) - 50, GetY(natives[1]) - 50, amClusterBomb)
   349   clusterCrate = SpawnAmmoCrate(GetX(natives[1]) - 50, GetY(natives[1]) - 50, amClusterBomb, 3)
   341 end
   350 end
   342 
   351 
   343 function DoOutOfGrenade()
   352 function DoOutOfGrenade()
   344   grenadeCrate2 = SpawnAmmoCrate(GetX(natives[1]) - 50, GetY(natives[1]) - 50, amGrenade)
   353   grenadeCrate2 = SpawnAmmoCrate(GetX(natives[1]) - 50, GetY(natives[1]) - 50, amGrenade, 3)
   345 end
   354 end
   346 
   355 
   347 function CheckNeedToHide()
   356 function CheckNeedToHide()
   348   if gearDead[princess] == true then
   357   if gearDead[princess] == true then
   349     return false
   358     return false
   384   end
   393   end
   385   HideHedge(cyborg)
   394   HideHedge(cyborg)
   386 end
   395 end
   387 
   396 
   388 function SetupEvents()
   397 function SetupEvents()
   389   AddNewEvent(CheckNeedToHide, {}, DoNeedToHide, {}, 1)
       
   390 end
   398 end
   391 
   399 
   392 function SetupAmmo()
   400 function SetupAmmo()
   393   AddAmmo(cyborgs[1], amBazooka, 100)
   401   AddAmmo(cyborgs[1], amBazooka, 100)
   394   AddAmmo(cyborgs[1], amGrenade, 100)
   402   AddAmmo(cyborgs[1], amGrenade, 100)
   516   if AnimInProgress() then
   524   if AnimInProgress() then
   517     TurnTimeLeft = -1
   525     TurnTimeLeft = -1
   518     return
   526     return
   519   end
   527   end
   520   if GetHogTeamName(CurrentHedgehog) == loc("011101001") then
   528   if GetHogTeamName(CurrentHedgehog) == loc("011101001") then
       
   529     if CheckCyborgsDead() ~= true then
       
   530       for i = 1, 3 do
       
   531         if gearDead[natives[i]] ~= true then
       
   532           HideHedge(natives[i])
       
   533         end
       
   534       end
       
   535     end
   521     TurnTimeLeft = 0
   536     TurnTimeLeft = 0
   522   else
   537   else
   523     AnimWait(princess, 10)
   538     for i = 1, 3 do
   524     AddFunction({func = RestoreHedge, args = {princess}})
   539       if gearDead[natives[i]] ~= true then
       
   540         RestoreHedge(natives[i])
       
   541       end
       
   542     end
   525   end
   543   end
   526 end
   544 end
   527 
   545 
   528 function onGearDamage(gear, damage)
   546 function onGearDamage(gear, damage)
   529 end
   547 end
   531 function onPrecise()
   549 function onPrecise()
   532   if GameTime > 2500 and AnimInProgress() then
   550   if GameTime > 2500 and AnimInProgress() then
   533     SetAnimSkip(true)
   551     SetAnimSkip(true)
   534     return
   552     return
   535   end
   553   end
   536 end
   554 --  HideHedge(princess)
       
   555 --  for i = 1, 5 do
       
   556 --    DeleteGear(cyborgs[i])
       
   557 --  end
       
   558 --  AddAmmo(natives[1], amTeleport, 100)
       
   559 end