share/hedgewars/Data/Missions/Campaign/A Classic Fairytale/first_blood.lua
changeset 7245 53f73f4ae203
parent 7243 9ae9178c525e
child 7425 3495e70c6d14
equal deleted inserted replaced
7243:9ae9178c525e 7245:53f73f4ae203
    55 punchTaken = false
    55 punchTaken = false
    56 canKilled = false
    56 canKilled = false
    57 desertTaken = false
    57 desertTaken = false
    58 challengeFailed = false
    58 challengeFailed = false
    59 difficultyChoice = false
    59 difficultyChoice = false
       
    60 princessFace = "Left"
       
    61 elderFace = "Left"
    60 
    62 
    61 goals = {
    63 goals = {
    62   [startDialogue] = {loc("First Blood"), loc("First Steps"), loc("Press [Left] or [Right] to move around, [Enter] to jump"), 1, 4000},
    64   [startDialogue] = {loc("First Blood"), loc("First Steps"), loc("Press [Left] or [Right] to move around, [Enter] to jump"), 1, 4000},
    63   [onShroomAnim] = {loc("First Blood"), loc("A leap in a leap"), loc("Go on top of the flower"), 1, 4000},
    65   [onShroomAnim] = {loc("First Blood"), loc("A leap in a leap"), loc("Go on top of the flower"), 1, 4000},
    64   [onFlowerAnim] = {loc("First Blood"), loc("Hightime"), loc("Collect the crate on the right.|Hint: Select the rope, [Up] or [Down] to aim, [Space] to fire, directional keys to move.|Ropes can be fired again in the air!"), 1, 7000},
    66   [onFlowerAnim] = {loc("First Blood"), loc("Hightime"), loc("Collect the crate on the right.|Hint: Select the rope, [Up] or [Down] to aim, [Space] to fire, directional keys to move.|Ropes can be fired again in the air!"), 1, 7000},
    76 function Skipanim(anim)
    78 function Skipanim(anim)
    77   AnimSwitchHog(youngh)
    79   AnimSwitchHog(youngh)
    78   if goals[anim] ~= nil then
    80   if goals[anim] ~= nil then
    79     ShowMission(unpack(goals[anim]))
    81     ShowMission(unpack(goals[anim]))
    80   end
    82   end
       
    83   if anim == startDialogue then
       
    84     HogTurnLeft(princess, false)
       
    85   end
    81 end
    86 end
    82 
    87 
    83 function SkipDamageAnim(anim)
    88 function SkipDamageAnim(anim)
    84   SwitchHog(youngh)
    89   SwitchHog(youngh)
    85   SetInputMask(0xFFFFFFFF)
    90   SetInputMask(0xFFFFFFFF)
   129   table.insert(onShroomAnim, {func = AnimSay, args = {princess, loc("He moves like an eagle in the sky."), SAY_THINK, 4000}})
   134   table.insert(onShroomAnim, {func = AnimSay, args = {princess, loc("He moves like an eagle in the sky."), SAY_THINK, 4000}})
   130   table.insert(onShroomAnim, {func = AnimSwitchHog, args = {youngh}})
   135   table.insert(onShroomAnim, {func = AnimSwitchHog, args = {youngh}})
   131   table.insert(onShroomAnim, {func = AnimShowMission, args = {youngh, loc("First Blood"), loc("A leap in a leap"), loc("Go on top of the flower"), 1, 4000}}) 
   136   table.insert(onShroomAnim, {func = AnimShowMission, args = {youngh, loc("First Blood"), loc("A leap in a leap"), loc("Go on top of the flower"), 1, 4000}}) 
   132 
   137 
   133   AddSkipFunction(onFlowerAnim, Skipanim, {onFlowerAnim})
   138   AddSkipFunction(onFlowerAnim, Skipanim, {onFlowerAnim})
   134   table.insert(onFlowerAnim, {func = AnimTurn, args = {elderh, "Right"}, skipFunc = Skipanim, skipArgs = onFlowerAnim})
       
   135   table.insert(onFlowerAnim, {func = AnimSay, args = {elderh, loc("See that crate farther on the right?"), SAY_SAY, 4000}})
   139   table.insert(onFlowerAnim, {func = AnimSay, args = {elderh, loc("See that crate farther on the right?"), SAY_SAY, 4000}})
   136   table.insert(onFlowerAnim, {func = AnimSay, args = {elderh, loc("Swing, Leaks A Lot, on the wings of the wind!"), SAY_SAY, 6000}})
   140   table.insert(onFlowerAnim, {func = AnimSay, args = {elderh, loc("Swing, Leaks A Lot, on the wings of the wind!"), SAY_SAY, 6000}})
   137   table.insert(onFlowerAnim, {func = AnimSay, args = {princess, loc("His arms are so strong!"), SAY_THINK, 4000}})
   141   table.insert(onFlowerAnim, {func = AnimSay, args = {princess, loc("His arms are so strong!"), SAY_THINK, 4000}})
   138   table.insert(onFlowerAnim, {func = AnimSwitchHog, args = {youngh}})
   142   table.insert(onFlowerAnim, {func = AnimSwitchHog, args = {youngh}})
   139   table.insert(onFlowerAnim, {func = AnimShowMission, args = {youngh, loc("First Blood"), loc("Hightime"), loc("Collect the crate on the right.|Hint: Select the rope, [Up] or [Down] to aim, [Space] to fire, directional keys to move.|Ropes can be fired again in the air!"), 1, 7000}}) 
   143   table.insert(onFlowerAnim, {func = AnimShowMission, args = {youngh, loc("First Blood"), loc("Hightime"), loc("Collect the crate on the right.|Hint: Select the rope, [Up] or [Down] to aim, [Space] to fire, directional keys to move.|Ropes can be fired again in the air!"), 1, 7000}}) 
   164   table.insert(tookRope2Anim, {func = AnimSay, args = {elderh, loc("You probably know what to do next..."), SAY_SAY, 4000}})
   168   table.insert(tookRope2Anim, {func = AnimSay, args = {elderh, loc("You probably know what to do next..."), SAY_SAY, 4000}})
   165   table.insert(tookRope2Anim, {func = AnimShowMission, args = {youngh, loc("First Blood"), loc("The Rising"), loc("Do the deed"), 1, 4000}}) 
   169   table.insert(tookRope2Anim, {func = AnimShowMission, args = {youngh, loc("First Blood"), loc("The Rising"), loc("Do the deed"), 1, 4000}}) 
   166   table.insert(tookRope2Anim, {func = AnimSwitchHog, args = {youngh}})
   170   table.insert(tookRope2Anim, {func = AnimSwitchHog, args = {youngh}})
   167 
   171 
   168   AddSkipFunction(tookPunchAnim, Skipanim, {tookPunchAnim})
   172   AddSkipFunction(tookPunchAnim, Skipanim, {tookPunchAnim})
   169   table.insert(tookPunchAnim, {func = AnimTurn, args = {elderh, "Left"}, skipFunc = Skipanim, skipArgs = tookPunchAnim})
       
   170   table.insert(tookPunchAnim, {func = AnimSay, args = {elderh, loc("It is time to practice your fighting skills."), SAY_SAY, 4000}})
   173   table.insert(tookPunchAnim, {func = AnimSay, args = {elderh, loc("It is time to practice your fighting skills."), SAY_SAY, 4000}})
   171   table.insert(tookPunchAnim, {func = AnimSay, args = {elderh, loc("Imagine those targets are the wolves that killed your parents! Take your anger out on them!"), SAY_SAY, 5000}})
   174   table.insert(tookPunchAnim, {func = AnimSay, args = {elderh, loc("Imagine those targets are the wolves that killed your parents! Take your anger out on them!"), SAY_SAY, 5000}})
   172   table.insert(tookPunchAnim, {func = AnimShowMission, args = {youngh, loc("First Blood"), loc("The Slaughter"), loc("Destroy the targets!|Hint: Select the Shoryuken and hit [Space]|P.S. You can use it mid-air."), 1, 5000}}) 
   175   table.insert(tookPunchAnim, {func = AnimShowMission, args = {youngh, loc("First Blood"), loc("The Slaughter"), loc("Destroy the targets!|Hint: Select the Shoryuken and hit [Space]|P.S. You can use it mid-air."), 1, 5000}}) 
   173   table.insert(tookPunchAnim, {func = AnimSwitchHog, args = {youngh}})
   176   table.insert(tookPunchAnim, {func = AnimSwitchHog, args = {youngh}})
   174 
   177 
   214   table.insert(cannKilledAnim, {func = AnimSay, args = {elderh, loc("Yes, yeees! You are now ready to enter the real world!"), SAY_SHOUT, 6000}})
   217   table.insert(cannKilledAnim, {func = AnimSay, args = {elderh, loc("Yes, yeees! You are now ready to enter the real world!"), SAY_SHOUT, 6000}})
   215 
   218 
   216   table.insert(cannKilledEarlyAnim, {func = AnimSay, args = {elderh, loc("What?! A cannibal? Here? There is no time to waste! Come, you are prepared."), SAY_SHOUT, 4000}})
   219   table.insert(cannKilledEarlyAnim, {func = AnimSay, args = {elderh, loc("What?! A cannibal? Here? There is no time to waste! Come, you are prepared."), SAY_SHOUT, 4000}})
   217 end
   220 end
   218 -----------------------------Events------------------------------------
   221 -----------------------------Events------------------------------------
       
   222 function CheckNeedToTurn(gear)
       
   223   if gear == princess then
       
   224     if princessKilled ~= true then
       
   225       if (GetX(princess) > GetX(youngh) and princessFace == "Right")
       
   226         or (GetX(princess) < GetX(youngh) and princessFace == "Left") then
       
   227       --if (GetX(princess) > GetX(youngh))
       
   228        -- or (GetX(princess) < GetX(youngh)) then
       
   229         return true
       
   230       end
       
   231     end
       
   232   else
       
   233     if elderKilled ~= true then
       
   234       if (GetX(elderh) > GetX(youngh) and elderFace == "Right")
       
   235         or (GetX(elderh) < GetX(youngh) and elderFace == "Left") then
       
   236         return true
       
   237       end
       
   238     end
       
   239   end
       
   240   return false
       
   241 end
       
   242 
       
   243 function DoNeedToTurn(gear)
       
   244   if gear == princess then
       
   245     if GetX(princess) > GetX(youngh) then
       
   246       HogTurnLeft(princess, true)
       
   247       princessFace = "Left"
       
   248     elseif GetX(princess) < GetX(youngh) then
       
   249       HogTurnLeft(princess, false)
       
   250       princessFace = "Right"
       
   251     end
       
   252   else
       
   253     if GetX(elderh) > GetX(youngh) then
       
   254       HogTurnLeft(elderh, true)
       
   255       elderFace = "Left"
       
   256     elseif GetX(elderh) < GetX(youngh) then
       
   257       HogTurnLeft(elderh, false)
       
   258       elderFace = "Right"
       
   259     end
       
   260   end
       
   261 end
   219 
   262 
   220 function CheckDamage()
   263 function CheckDamage()
   221   return youngdamaged and StoppedGear(youngh) 
   264   return youngdamaged and StoppedGear(youngh) 
   222 end
   265 end
   223 
   266 
   272   ShowMission(loc("First Blood"), loc("Step By Step"), loc("Hint: Double Jump - Press [Backspace] twice"), -amSkip, 0)
   315   ShowMission(loc("First Blood"), loc("Step By Step"), loc("Hint: Double Jump - Press [Backspace] twice"), -amSkip, 0)
   273   AddEvent(CheckOnShroom, {}, DoOnShroom, {}, 0)
   316   AddEvent(CheckOnShroom, {}, DoOnShroom, {}, 0)
   274 end
   317 end
   275 
   318 
   276 function CheckOnShroom()
   319 function CheckOnShroom()
   277   return GetX(youngh) >= 2461
   320   return GetX(youngh) >= 2461 and StoppedGear(youngh)
   278 end
   321 end
   279 
   322 
   280 function DoOnShroom()
   323 function DoOnShroom()
   281   ropeCrate1 = SpawnUtilityCrate(2751, 1194, amRope)
   324   ropeCrate1 = SpawnUtilityCrate(2751, 1194, amRope)
   282   AddAnim(onShroomAnim)
   325   AddAnim(onShroomAnim)
   283   AddEvent(CheckOnFlower, {}, DoOnFlower, {}, 0)
   326   AddEvent(CheckOnFlower, {}, DoOnFlower, {}, 0)
   284 end
   327 end
   285 
   328 
   286 function CheckOnFlower()
   329 function CheckOnFlower()
   287   return rope1Taken
   330   return rope1Taken and StoppedGear(youngh)
   288 end
   331 end
   289 
   332 
   290 function DoOnFlower()
   333 function DoOnFlower()
   291   AddAmmo(youngh, amRope, 100)
   334   AddAmmo(youngh, amRope, 100)
   292   paraCrate = SpawnUtilityCrate(3245, 1758, amParachute)
   335   paraCrate = SpawnUtilityCrate(3245, 1758, amParachute)
   353   AddAnim(tookPunchAnim)
   396   AddAnim(tookPunchAnim)
   354   targets[1] = AddGear(1594, 1185, gtTarget, 0, 0, 0, 0)
   397   targets[1] = AddGear(1594, 1185, gtTarget, 0, 0, 0, 0)
   355   targets[2] = AddGear(2188, 1314, gtTarget, 0, 0, 0, 0)
   398   targets[2] = AddGear(2188, 1314, gtTarget, 0, 0, 0, 0)
   356   targets[3] = AddGear(1961, 1318, gtTarget, 0, 0, 0, 0)
   399   targets[3] = AddGear(1961, 1318, gtTarget, 0, 0, 0, 0)
   357   targets[4] = AddGear(1961, 1200, gtTarget, 0, 0, 0, 0)
   400   targets[4] = AddGear(1961, 1200, gtTarget, 0, 0, 0, 0)
   358   targets[5] = AddGear(1900, 1100, gtTarget, 0, 0, 0, 0)
   401   targets[5] = AddGear(1800, 900, gtTarget, 0, 0, 0, 0)
   359   AddEvent(CheckTargDestroyed, {}, DoTargDestroyed, {}, 0)
   402   AddEvent(CheckTargDestroyed, {}, DoTargDestroyed, {}, 0)
   360 end
   403 end
   361 
   404 
   362 function CheckTargDestroyed()
   405 function CheckTargDestroyed()
   363   return targetsDestroyed == 5 and StoppedGear(youngh)
   406   return targetsDestroyed == 5 and StoppedGear(youngh)
   552 	Theme = "Nature"
   595 	Theme = "Nature"
   553 
   596 
   554 
   597 
   555 	AddTeam(loc("Natives"), 29439, "Bone", "Island", "HillBilly", "cm_birdy")
   598 	AddTeam(loc("Natives"), 29439, "Bone", "Island", "HillBilly", "cm_birdy")
   556 	youngh = AddHog(loc("Leaks A Lot"), 0, 100, "Rambo")
   599 	youngh = AddHog(loc("Leaks A Lot"), 0, 100, "Rambo")
   557   elderh = AddHog(loc("White Raven"), 0, 99, "IndianChief")
   600   elderh = AddHog(loc("Righteous Beard"), 0, 99, "IndianChief")
   558   princess = AddHog(loc("Fell From Heaven"), 0, 300, "tiara")
   601   princess = AddHog(loc("Fell From Heaven"), 0, 300, "tiara")
   559   SetGearPosition(princess, 1911, 1361)
   602   SetGearPosition(princess, 1911, 1361)
   560   HogTurnLeft(princess, true)
   603   HogTurnLeft(princess, true)
   561   SetGearPosition(elderh, 2667, 1208)
   604   SetGearPosition(elderh, 2667, 1208)
   562   HogTurnLeft(elderh, true)
   605   HogTurnLeft(elderh, true)
   577   FollowGear(youngh)
   620   FollowGear(youngh)
   578 	ShowMission(loc("A Classic Fairytale"), loc("First Blood"), loc("Finish your training|Hint: Animations can be skipped with the [Precise] key."), -amSkip, 0)
   621 	ShowMission(loc("A Classic Fairytale"), loc("First Blood"), loc("Finish your training|Hint: Animations can be skipped with the [Precise] key."), -amSkip, 0)
   579   SetState(cannibal, gstInvisible)
   622   SetState(cannibal, gstInvisible)
   580 
   623 
   581   AddAnim(startDialogue)
   624   AddAnim(startDialogue)
       
   625   princessFace = "Right"
       
   626   AddEvent(CheckNeedToTurn, {princess}, DoNeedToTurn, {princess}, 1)
       
   627   AddEvent(CheckNeedToTurn, {elderh}, DoNeedToTurn, {elderh}, 1)
   582   AddEvent(CheckDamage, {}, DoOnDamage, {}, 1)
   628   AddEvent(CheckDamage, {}, DoOnDamage, {}, 1)
   583   AddEvent(CheckDeath, {}, DoDeath, {}, 0)
   629   AddEvent(CheckDeath, {}, DoDeath, {}, 0)
   584   AddEvent(CheckDamagedOthers, {}, DoOnDamagedOthers, {}, 1)
   630   AddEvent(CheckDamagedOthers, {}, DoOnDamagedOthers, {}, 1)
   585   AddEvent(CheckKilledOthers, {}, DoKilledOthers, {}, 0)
   631   AddEvent(CheckKilledOthers, {}, DoKilledOthers, {}, 0)
   586   AddEvent(CheckMovedUntilJump, {}, DoMovedUntilJump, {}, 0)
   632   AddEvent(CheckMovedUntilJump, {}, DoMovedUntilJump, {}, 0)