share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/first_blood.lua
changeset 7448 d0521a3a4358
parent 7425 3495e70c6d14
child 7512 cc3f036121fe
equal deleted inserted replaced
7443:a7f861f1c3b8 7448:d0521a3a4358
    90   SetInputMask(0xFFFFFFFF)
    90   SetInputMask(0xFFFFFFFF)
    91 end
    91 end
    92 
    92 
    93 function SkipOnShroom()
    93 function SkipOnShroom()
    94   Skipanim(onShroomAnim)
    94   Skipanim(onShroomAnim)
    95   SetGearPosition(elderh, 2700, 1278)
    95   AnimSetGearPosition(elderh, 2700, 1278)
    96 end
    96 end
    97 
    97 
    98 function AnimationSetup()
    98 function AnimationSetup()
    99   AddSkipFunction(damageAnim, SkipDamageAnim, {damageAnim})
    99   AddSkipFunction(damageAnim, SkipDamageAnim, {damageAnim})
   100   table.insert(damageAnim, {func = AnimWait, args = {youngh, 500}, skipFunc = Skipanim, skipArgs = damageAnim})
   100   table.insert(damageAnim, {func = AnimWait, args = {youngh, 500}, skipFunc = Skipanim, skipArgs = damageAnim})
   320   return GetX(youngh) >= 2461 and StoppedGear(youngh)
   320   return GetX(youngh) >= 2461 and StoppedGear(youngh)
   321 end
   321 end
   322 
   322 
   323 function DoOnShroom()
   323 function DoOnShroom()
   324   ropeCrate1 = SpawnUtilityCrate(2751, 1194, amRope)
   324   ropeCrate1 = SpawnUtilityCrate(2751, 1194, amRope)
       
   325   SetGearMessage(CurrentHedgehog, 0)
   325   AddAnim(onShroomAnim)
   326   AddAnim(onShroomAnim)
   326   AddEvent(CheckOnFlower, {}, DoOnFlower, {}, 0)
   327   AddEvent(CheckOnFlower, {}, DoOnFlower, {}, 0)
   327 end
   328 end
   328 
   329 
   329 function CheckOnFlower()
   330 function CheckOnFlower()
   331 end
   332 end
   332 
   333 
   333 function DoOnFlower()
   334 function DoOnFlower()
   334   AddAmmo(youngh, amRope, 100)
   335   AddAmmo(youngh, amRope, 100)
   335   paraCrate = SpawnUtilityCrate(3245, 1758, amParachute)
   336   paraCrate = SpawnUtilityCrate(3245, 1758, amParachute)
       
   337   SetGearMessage(CurrentHedgehog, 0)
   336   AddAnim(onFlowerAnim)
   338   AddAnim(onFlowerAnim)
   337   AddEvent(CheckTookParaCrate, {}, DoTookParaCrate, {}, 0)
   339   AddEvent(CheckTookParaCrate, {}, DoTookParaCrate, {}, 0)
   338 end
   340 end
   339 
   341 
   340 function CheckTookParaCrate()
   342 function CheckTookParaCrate()
   341   return paraTaken and StoppedGear(youngh)
   343   return paraTaken and StoppedGear(youngh)
   342 end
   344 end
   343 
   345 
   344 function DoTookParaCrate()
   346 function DoTookParaCrate()
   345   AddAmmo(youngh, amParachute, 100)
   347   AddAmmo(youngh, amParachute, 100)
       
   348   SetGearMessage(CurrentHedgehog, 0)
   346   AddAnim(tookParaAnim)
   349   AddAnim(tookParaAnim)
   347   AddEvent(CheckOnMoleHead, {}, DoOnMoleHead, {}, 0)
   350   AddEvent(CheckOnMoleHead, {}, DoOnMoleHead, {}, 0)
   348   AddEvent(CheckPastMoleHead, {}, DoPastMoleHead, {}, 0)
   351   AddEvent(CheckPastMoleHead, {}, DoPastMoleHead, {}, 0)
   349 end
   352 end
   350 
   353 
   361 
   364 
   362 function DoPastMoleHead()
   365 function DoPastMoleHead()
   363   RemoveEventFunc(CheckOnMoleHead)
   366   RemoveEventFunc(CheckOnMoleHead)
   364   ropeCrate2 = SpawnUtilityCrate(2782, 1720, amRope)
   367   ropeCrate2 = SpawnUtilityCrate(2782, 1720, amRope)
   365   AddAmmo(youngh, amRope, 0)
   368   AddAmmo(youngh, amRope, 0)
       
   369   SetGearMessage(CurrentHedgehog, 0)
   366   AddAnim(pastMoleHeadAnim)
   370   AddAnim(pastMoleHeadAnim)
   367   AddEvent(CheckTookRope2, {}, DoTookRope2, {}, 0)
   371   AddEvent(CheckTookRope2, {}, DoTookRope2, {}, 0)
   368 end
   372 end
   369 
   373 
   370 function DoOnMoleHead()
   374 function DoOnMoleHead()
   371   RemoveEventFunc(CheckPastMoleHead)
   375   RemoveEventFunc(CheckPastMoleHead)
   372   ropeCrate2 = SpawnUtilityCrate(2782, 1720, amRope)
   376   ropeCrate2 = SpawnUtilityCrate(2782, 1720, amRope)
   373   AddAmmo(youngh, amRope, 0)
   377   AddAmmo(youngh, amRope, 0)
       
   378   SetGearMessage(CurrentHedgehog, 0)
   374   AddAnim(onMoleHeadAnim)
   379   AddAnim(onMoleHeadAnim)
   375   AddEvent(CheckTookRope2, {}, DoTookRope2, {}, 0)
   380   AddEvent(CheckTookRope2, {}, DoTookRope2, {}, 0)
   376 end
   381 end
   377 
   382 
   378 function CheckTookRope2()
   383 function CheckTookRope2()
   379   return rope2Taken and StoppedGear(youngh)
   384   return rope2Taken and StoppedGear(youngh)
   380 end
   385 end
   381 
   386 
   382 function DoTookRope2()
   387 function DoTookRope2()
   383   AddAmmo(youngh, amRope, 100)
   388   AddAmmo(youngh, amRope, 100)
       
   389   SetGearMessage(CurrentHedgehog, 0)
   384   AddAnim(tookRope2Anim)
   390   AddAnim(tookRope2Anim)
   385   punchCrate = SpawnAmmoCrate(2460, 1321, amFirePunch)
   391   punchCrate = SpawnAmmoCrate(2460, 1321, amFirePunch)
   386   AddEvent(CheckTookPunch, {}, DoTookPunch, {})
   392   AddEvent(CheckTookPunch, {}, DoTookPunch, {})
   387 end
   393 end
   388 
   394 
   391 end
   397 end
   392 
   398 
   393 function DoTookPunch()
   399 function DoTookPunch()
   394   AddAmmo(youngh, amFirePunch, 100)
   400   AddAmmo(youngh, amFirePunch, 100)
   395   AddAmmo(youngh, amRope, 0)
   401   AddAmmo(youngh, amRope, 0)
       
   402   SetGearMessage(CurrentHedgehog, 0)
   396   AddAnim(tookPunchAnim)
   403   AddAnim(tookPunchAnim)
   397   targets[1] = AddGear(1594, 1185, gtTarget, 0, 0, 0, 0)
   404   targets[1] = AddGear(1594, 1185, gtTarget, 0, 0, 0, 0)
   398   targets[2] = AddGear(2188, 1314, gtTarget, 0, 0, 0, 0)
   405   targets[2] = AddGear(2188, 1314, gtTarget, 0, 0, 0, 0)
   399   targets[3] = AddGear(1961, 1318, gtTarget, 0, 0, 0, 0)
   406   targets[3] = AddGear(1961, 1318, gtTarget, 0, 0, 0, 0)
   400   targets[4] = AddGear(1961, 1200, gtTarget, 0, 0, 0, 0)
   407   targets[4] = AddGear(1961, 1200, gtTarget, 0, 0, 0, 0)
   405 function CheckTargDestroyed()
   412 function CheckTargDestroyed()
   406   return targetsDestroyed == 5 and StoppedGear(youngh)
   413   return targetsDestroyed == 5 and StoppedGear(youngh)
   407 end
   414 end
   408 
   415 
   409 function DoTargDestroyed()
   416 function DoTargDestroyed()
       
   417   SetGearMessage(CurrentHedgehog, 0)
   410   AddAnim(challengeAnim)
   418   AddAnim(challengeAnim)
   411   targetsDestroyed = 0
   419   targetsDestroyed = 0
   412   AddFunction({func = SetChoice, args = {}})
   420   AddFunction({func = SetChoice, args = {}})
   413   ropeCrate3 = SpawnAmmoCrate(2000, 1200, amRope)
   421   ropeCrate3 = SpawnAmmoCrate(2000, 1200, amRope)
   414   AddEvent(CheckTookRope3, {}, AddAmmo, {youngh, amRope, 100}, 0)
   422   AddEvent(CheckTookRope3, {}, AddAmmo, {youngh, amRope, 100}, 0)
   441   return cratesCollected == crateNum[difficulty] and StoppedGear(youngh)
   449   return cratesCollected == crateNum[difficulty] and StoppedGear(youngh)
   442 end
   450 end
   443 
   451 
   444 function DoChallengeWon()
   452 function DoChallengeWon()
   445   desertCrate = SpawnAmmoCrate(1240, 1212, amDEagle)
   453   desertCrate = SpawnAmmoCrate(1240, 1212, amDEagle)
       
   454   SetGearMessage(CurrentHedgehog, 0)
   446   AddAnim(challengeCompletedAnim)
   455   AddAnim(challengeCompletedAnim)
   447   AddEvent(CheckDesertColled, {}, DoDesertColled, {}, 0)
   456   AddEvent(CheckDesertColled, {}, DoDesertColled, {}, 0)
   448 end
   457 end
   449 
   458 
   450 function CheckTookRope3()
   459 function CheckTookRope3()
   467   return challengeFailed and StoppedGear(youngh)
   476   return challengeFailed and StoppedGear(youngh)
   468 end
   477 end
   469 
   478 
   470 function DoChallengeFailed()
   479 function DoChallengeFailed()
   471   challengeFailed = false
   480   challengeFailed = false
       
   481   SetGearMessage(CurrentHedgehog, 0)
   472   AddAnim(challengeFailedAnim)
   482   AddAnim(challengeFailedAnim)
   473   chalTries = chalTries + 1
   483   chalTries = chalTries + 1
   474   difficulty = 0
   484   difficulty = 0
   475   AddFunction({func = SetChoice, args = {}})
   485   AddFunction({func = SetChoice, args = {}})
   476 end
   486 end
   496   targsWave = targsWave + 1
   506   targsWave = targsWave + 1
   497   if targsWave > 3 then
   507   if targsWave > 3 then
   498     RemoveEventFunc(CheckTargetsKilled)
   508     RemoveEventFunc(CheckTargetsKilled)
   499     SetState(cannibal, gstVisible)
   509     SetState(cannibal, gstVisible)
   500     cannibalVisible = true
   510     cannibalVisible = true
       
   511     SetGearMessage(CurrentHedgehog, 0)
   501     AddAnim(beforeKillAnim)
   512     AddAnim(beforeKillAnim)
   502     AddEvent(CheckCloseToCannibal, {}, DoCloseToCannibal, {}, 0)
   513     AddEvent(CheckCloseToCannibal, {}, DoCloseToCannibal, {}, 0)
   503     AddEvent(CheckCannibalKilled, {}, DoCannibalKilled, {}, 0)
   514     AddEvent(CheckCannibalKilled, {}, DoCannibalKilled, {}, 0)
   504   else
   515   else
   505     PutTargets(targsWave)
   516     PutTargets(targsWave)
   512   end
   523   end
   513   return math.abs(GetX(cannibal) - GetX(youngh)) <= 400 and StoppedGear(youngh)
   524   return math.abs(GetX(cannibal) - GetX(youngh)) <= 400 and StoppedGear(youngh)
   514 end
   525 end
   515 
   526 
   516 function DoCloseToCannibal()
   527 function DoCloseToCannibal()
       
   528   SetGearMessage(CurrentHedgehog, 0)
   517   AddAnim(closeCannim)
   529   AddAnim(closeCannim)
   518   AddFunction({func = SpawnAmmoCrate, args = {targetPosX[1][1], targetPosY[1][1], amWhip}})
   530   AddFunction({func = SpawnAmmoCrate, args = {targetPosX[1][1], targetPosY[1][1], amWhip}})
   519   AddFunction({func = SpawnAmmoCrate, args = {targetPosX[1][2], targetPosY[1][2], amBaseballBat}})
   531   AddFunction({func = SpawnAmmoCrate, args = {targetPosX[1][2], targetPosY[1][2], amBaseballBat}})
   520   AddFunction({func = SpawnAmmoCrate, args = {targetPosX[1][3], targetPosY[1][3], amHammer}})
   532   AddFunction({func = SpawnAmmoCrate, args = {targetPosX[1][3], targetPosY[1][3], amHammer}})
   521 end
   533 end
   597 
   609 
   598 	AddTeam(loc("Natives"), 29439, "Bone", "Island", "HillBilly", "cm_birdy")
   610 	AddTeam(loc("Natives"), 29439, "Bone", "Island", "HillBilly", "cm_birdy")
   599 	youngh = AddHog(loc("Leaks A Lot"), 0, 100, "Rambo")
   611 	youngh = AddHog(loc("Leaks A Lot"), 0, 100, "Rambo")
   600   elderh = AddHog(loc("Righteous Beard"), 0, 99, "IndianChief")
   612   elderh = AddHog(loc("Righteous Beard"), 0, 99, "IndianChief")
   601   princess = AddHog(loc("Fell From Heaven"), 0, 300, "tiara")
   613   princess = AddHog(loc("Fell From Heaven"), 0, 300, "tiara")
   602   SetGearPosition(princess, 1911, 1361)
   614   AnimSetGearPosition(princess, 1911, 1361)
   603   HogTurnLeft(princess, true)
   615   HogTurnLeft(princess, true)
   604   SetGearPosition(elderh, 2667, 1208)
   616   AnimSetGearPosition(elderh, 2667, 1208)
   605   HogTurnLeft(elderh, true)
   617   HogTurnLeft(elderh, true)
   606   SetGearPosition(youngh, 1862, 1362)
   618   AnimSetGearPosition(youngh, 1862, 1362)
   607   HogTurnLeft(youngh, false)
   619   HogTurnLeft(youngh, false)
   608 
   620 
   609   AddTeam(loc("Cannibals"), 14483456, "Skull", "Island", "Pirate","cm_vampire")
   621   AddTeam(loc("Cannibals"), 14483456, "Skull", "Island", "Pirate","cm_vampire")
   610   cannibal = AddHog(loc("Brainiac"), 0, 5, "Zombi")
   622   cannibal = AddHog(loc("Brainiac"), 0, 5, "Zombi")
   611   SetGearPosition(cannibal, 525, 1256)
   623   AnimSetGearPosition(cannibal, 525, 1256)
   612   HogTurnLeft(cannibal, false)
   624   HogTurnLeft(cannibal, false)
   613   
   625   
   614   AnimInit()
   626   AnimInit()
   615   AnimationSetup()
   627   AnimationSetup()
   616 end
   628 end