9
3

HelpingSarmaSingebellows.lua 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. --[[
  2. Script Name : Quests/EnchantedLands/HelpingSarmaSingebellows.lua
  3. Script Purpose : Handles the quest "Helping Sarma Singebellows"
  4. Script Author : Cynnar
  5. Script Date : 2015.03.21
  6. Script Notes : Reward coin goes up each time quest is repeated
  7. Zone : Enchanted Lands
  8. Quest Giver : Sarma Singebellows
  9. Preceded by : <preceded-quest-name(lua file)>
  10. Followed by : <followed-by-quest-name(lua file)>
  11. --]]
  12. local kill8 = 8
  13. local kill9 = 9
  14. local kill10 = 10
  15. local kill11 = 11
  16. local kill12 = 12
  17. function Init(Quest)
  18. SetQuestFeatherColor(Quest, 3)
  19. SetQuestRepeatable(Quest)
  20. end
  21. function Accepted(Quest, QuestGiver, Player)
  22. if GetTempVariable(Player, "HelpingSarmaSingebellows") == "true" then
  23. PlayFlavor(NPC, "voiceover/english/sarma_singebellows/enchanted/sarma_singebellows002.mp3", "", "", 2943069626, 2445316031, Spawn)
  24. AddConversationOption(conversation, "I shall return when they are destroyed.")
  25. StartConversation(conversation, NPC, Spawn, "Excellent! You worked hard to kill all of those goblins, but we need to make sure they don't regain their foothold.")
  26. else
  27. PlayFlavor(NPC, "voiceover/english/sarma_singebellows/enchanted/sarma_singebellows002.mp3", "", "", 2943069626, 2445316031, Spawn)
  28. AddConversationOption(conversation, "As you wish.")
  29. StartConversation(conversation, NPC, Spawn, "Excellent! Goblins are tainting the water and withering the trees at a watermill by a nearby lake. I want you to destroy as many of them as you can!")
  30. end
  31. SetTempVariable(Player, "HelpingSarmaSingebellows", nil)
  32. if GetQuestFlags(Quest) == 0 then
  33. local quantity = math.random(8, 12)
  34. local flags = 0
  35. if quantity == 8 then
  36. flags = flags + kill8
  37. elseif quantity == 9 then
  38. flags = flags + kill9
  39. elseif quantity == 10 then
  40. flags = flags + kill10
  41. elseif quantity == 11 then
  42. flags = flags + kill11
  43. elseif quantity == 12 then
  44. flags = flags + kill12
  45. end
  46. SetQuestFlags(Quest, flags)
  47. SetStep(Quest, Player, quantity)
  48. else -- need the else for /reload quest
  49. CheckBitMask(Quest, Player, GetQuestFlags(Quest))
  50. end
  51. end
  52. function hasflag(flags, flag)
  53. return flags % (2*flag) >= flag
  54. end
  55. function CheckBitMask(Quest, Player, Flags)
  56. local quantity = 0
  57. if hasflag(Flags, kill8) then
  58. quantity = 8
  59. elseif hasflag(Flags, kill9) then
  60. quantity = 9
  61. elseif hasflag(Flags, kill10) then
  62. quantity = 10
  63. elseif hasflag(Flags, kill11) then
  64. quantity = 11
  65. elseif hasflag(Flags, kill12) then
  66. quantity = 12
  67. end
  68. SetStep(Quest, Player, quantity)
  69. end
  70. function SetStep(Quest, Player, quantity)
  71. if quantity == 8 then
  72. AddQuestStepKill(Quest, 1, "Hunt some goblins in the Enchanted Lands", quantity, 100, "I need to kill as many goblins as I am able to prevent them from tainting this land further. I need to slay more goblins!", 159, 390028, 390018, 390002, 390006, 390151, 390154, 390003, 390029)
  73. elseif quantity == 9 then
  74. AddQuestStepKill(Quest, 1, "Hunt some goblins in the Enchanted Lands", quantity, 100, "I need to kill as many goblins as I am able to prevent them from tainting this land further. I need to slay more goblins!", 159, 390028, 390018, 390002, 390006, 390151, 390154, 390003, 390029)
  75. elseif quantity == 10 then
  76. AddQuestStepKill(Quest, 1, "Hunt some goblins in the Enchanted Lands", quantity, 100, "I need to kill as many goblins as I am able to prevent them from tainting this land further. I need to slay more goblins!", 159, 390028, 390018, 390002, 390006, 390151, 390154, 390003, 390029)
  77. elseif quantity == 11 then
  78. AddQuestStepKill(Quest, 1, "Hunt some goblins in the Enchanted Lands", quantity, 100, "I need to kill as many goblins as I am able to prevent them from tainting this land further. I need to slay more goblins!", 159, 390028, 390018, 390002, 390006, 390151, 390154, 390003, 390029)
  79. elseif quantity == 12 then
  80. AddQuestStepKill(Quest, 1, "Hunt some goblins in the Enchanted Lands", quantity, 100, "I need to kill as many goblins as I am able to prevent them from tainting this land further. I need to slay more goblins!", 159, 390028, 390018, 390002, 390006, 390151, 390154, 390003, 390029)
  81. end
  82. AddQuestStepCompleteAction(Quest, 1, "Step1Complete")
  83. end
  84. function Step1Complete(Quest, QuestGiver, Player)
  85. UpdateQuestStepDescription(Quest, 1, "I have killed quite a few goblins, I should report back to Sarma Singebellows now.")
  86. AddQuestStepChat(Quest, 2, "I need to speak to Sarma Singebellows in the Enchanted Lands.", 1, "I need to kill as many goblins as I am able to prevent them from tainting this land further. I need to slay more goblins!", 0, 390181)
  87. AddQuestStepCompleteAction(Quest, 2, "QuestReward")
  88. end
  89. function Deleted(Quest, QuestGiver, Player)
  90. end
  91. function Declined(Quest, QuestGiver, Player)
  92. SetTempVariable(Player, "HelpingSarmaSingebellows", nil)
  93. end
  94. function QuestReward(Quest, QuestGiver, Player)
  95. GiveQuestReward(Quest, Player)
  96. SetCompleteFlag(Quest)
  97. end
  98. function Reload(Quest, QuestGiver, Player, Step)
  99. if Step == 0 then
  100. CheckBitMask(Quest, Player, GetQuestFlags(Quest))
  101. elseif Step == 1 then
  102. Step1Complete(Quest, QuestGiver, Player)
  103. elseif Step == 2 then
  104. QuestReward(Quest, QuestGiver, Player)
  105. end
  106. end