Advertisement
Guest User

Untitled

a guest
Feb 13th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.53 KB | None | 0 0
  1. local keywordHandler = KeywordHandler:new()
  2. local npcHandler = NpcHandler:new(keywordHandler)
  3. NpcSystem.parseParameters(npcHandler)
  4.  
  5. function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
  6. function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
  7. function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
  8. function onThink() npcHandler:onThink() end
  9.  
  10. local function creatureSayCallback(cid, type, msg)
  11. if not npcHandler:isFocused(cid) then
  12. return false
  13. end
  14.  
  15. local player = Player(cid)
  16. if player:getStorageValue(Storage.InServiceofYalahar.Questline) < 1 then
  17. player:setStorageValue(Storage.InServiceofYalahar.Questline, 3)
  18. end
  19.  
  20. if msgcontains(msg, "job") and not player:getStorageValue(Storage.InServiceofYalahar.Questline) == 54 then
  21. npcHandler:say("I'm an Augur of the city of Yalahar. My special duty consists of coordinating the efforts to keep the city and its services running.", cid)
  22. elseif msgcontains(msg, "job") then
  23. if player:getStorageValue(Storage.InServiceofYalahar.Questline) == 54 then
  24. npcHandler:say("Did you bring me the vampiric crest?", cid)
  25. npcHandler.topic[cid] = 6
  26. end
  27. elseif msgcontains(msg, "mission") then
  28. if player:getStorageValue(Storage.InServiceofYalahar.Questline) == 3 then
  29. npcHandler:say({
  30. "You probably heard that we have numerous problems in different quarters of our city. Our forces are limited, so we really could need some help from outsiders. ...",
  31. "Would you like to assist us in re-establishing order in our city?"
  32. }, cid)
  33. npcHandler.topic[cid] = 1
  34. elseif player:getStorageValue(Storage.InServiceofYalahar.Questline) == 4 then
  35. player:setStorageValue(Storage.InServiceofYalahar.Mission01, 1) -- StorageValue for Questlog "Mission 01: Something Rotten"
  36. player:setStorageValue(Storage.InServiceofYalahar.Questline, 5)
  37. npcHandler:say({
  38. "I hope your first mission will not scare you off. Even though, we cut off our sewer system from other parts of the city to prevent the worst, it still has deteriorated in the last decades. ...",
  39. "Certain parts of the controls are rusty and the drains are stuffed with garbage. Get yourself a crowbar, loosen the controls and clean the pipes from the garbage. ...",
  40. "We were able to locate the 4 worst spots in the sewers. I will mark them for you on your map so you have no trouble finding them. Report to me when you have finished your {mission}. ..."
  41. }, cid)
  42. player:addMapMark(Position(32823, 31161, 8), 4, "Sewer Problem 1")
  43. player:addMapMark(Position(32795, 31152, 8), 4, "Sewer Problem 2")
  44. player:addMapMark(Position(32842, 31250, 8), 4, "Sewer Problem 3")
  45. player:addMapMark(Position(32796, 31192, 8), 4, "Sewer Problem 4")
  46. npcHandler.topic[cid] = 0
  47. elseif player:getStorageValue(Storage.InServiceofYalahar.Questline) == 5 then
  48. npcHandler:say("So are you done with your work?", cid)
  49. npcHandler.topic[cid] = 2
  50. elseif player:getStorageValue(Storage.InServiceofYalahar.Questline) == 6 then
  51. npcHandler:say({
  52. "We are still present at each quarter's city wall, even though we can do little to stop the chaos from spreading. Still, our garrisons are necessary to maintain some sort of order in the city. ...",
  53. "My superiors ask for a first hand report about the current situation in the single city quarters. I need someone to travel to our garrisons to get the reports from the guards. Are you willing to do that?"
  54. }, cid)
  55. npcHandler.topic[cid] = 3
  56. elseif player:getStorageValue(Storage.InServiceofYalahar.Questline) >= 7 and player:getStorageValue(Storage.InServiceofYalahar.Questline) <= 14 then
  57. npcHandler:say("Did you get all the reports my superiors asked for? ", cid)
  58. npcHandler.topic[cid] = 4
  59. elseif player:getStorageValue(Storage.InServiceofYalahar.Questline) == 15 then
  60. npcHandler:say({
  61. "I did my best to impress my superiors with your accomplishments and it seems that it worked quite well. They want you for their own missions now. ...",
  62. "Missions that are more important than the ones you've fulfilled for me. However, before you leave, there are still some things I need to tell you. ...",
  63. "Listen, I can't explain you everything in detail right now and here. You never know who might be eavesdropping. ...",
  64. "I left some notes in the small room there. Get them and read them. Talk to me again when you've read the notes."
  65. }, cid)
  66. player:setStorageValue(Storage.InServiceofYalahar.Mission03, 1) -- StorageValue for Questlog "Mission 03: Death to the Deathbringer"
  67. player:setStorageValue(Storage.InServiceofYalahar.Questline, 16)
  68. player:setStorageValue(Storage.InServiceofYalahar.NotesPalimuth, 0)
  69. npcHandler.topic[cid] = 0
  70. elseif player:getStorageValue(Storage.InServiceofYalahar.NotesPalimuth) == 1 and player:getStorageValue(Storage.InServiceofYalahar.Questline) == 16 then
  71. npcHandler:say({
  72. "Now you know as much as we do about the things happening in Yalahar. It's up to you what you do with this information. ...",
  73. "Now leave and talk to my superior Azerus in the city centre to get your next mission. I urge you, though, to talk to me whenever he sends you on a new mission. ...",
  74. "I think it is important that you hear my opinion about them. Now hurry. I suppose Azerus is already waiting."
  75. }, cid)
  76. player:setStorageValue(Storage.InServiceofYalahar.Mission03, 2) -- StorageValue for Questlog "Mission 03: Death to the Deathbringer"
  77. player:setStorageValue(Storage.InServiceofYalahar.Questline, 17)
  78. player:setStorageValue(Storage.InServiceofYalahar.DoorToAzerus, 1)
  79. npcHandler.topic[cid] = 0
  80. elseif player:getStorageValue(Storage.InServiceofYalahar.Questline) == 20 then
  81. npcHandler:say({
  82. "This quarter has been sealed off years ago. To send someone there poses a high risk to spread the plague. I assume these research notes you've mentioned must be very important. ...",
  83. "After all those years it is more than strange that someone shows interest in these notes now. Considering what has happened to the alchemists, it is rather unlikely that they contain harmless information. ...",
  84. "I fear these notes will be used to turn the plague into some kind of weapon. Someone with this plague at his disposal could subdue the whole city by blackmailing. ...",
  85. "I beg you to destroy these notes. Just put them into some burning oven to get rid of them and report that you did not find the notes."
  86. }, cid)
  87. player:setStorageValue(Storage.InServiceofYalahar.Questline, 21)
  88. player:setStorageValue(Storage.InServiceofYalahar.DoorToBog, 1)
  89. player:setStorageValue(Storage.InServiceofYalahar.Mission03, 5) -- StorageValue for Questlog "Mission 03: Death to the Deathbringer"
  90. npcHandler.topic[cid] = 0
  91. elseif player:getStorageValue(Storage.InServiceofYalahar.Questline) == 23 then
  92. npcHandler:say({
  93. "Mr. West is a little paranoid. That's the reason for his immense private army of bodyguards. He could surely be helpful, especially as he rules over the former trade quarter. ...",
  94. "If you were able to reach him without killing his henchmen, you could probably convince him that you mean no harm to him. ...",
  95. "That would certainly cement our relationship without any needless bloodshed. Perhaps you could use the way through the sewers to avoid his men. ...",
  96. "Mr. West is not a bad man. We should be able to work out some plans to reconstruct the city's safety as soon as he overcomes his paranoia towards us."
  97. }, cid)
  98. player:setStorageValue(Storage.InServiceofYalahar.Questline, 24)
  99. player:setStorageValue(Storage.InServiceofYalahar.Mission04, 2) -- StorageValue for Questlog "Mission 04: Good to be Kingpin"
  100. npcHandler.topic[cid] = 0
  101. elseif player:getStorageValue(Storage.InServiceofYalahar.Questline) == 25 and player:getStorageValue(Storage.InServiceofYalahar.MrWestStatus) == 1 then
  102. npcHandler:say({
  103. "You did quite well in gaining a new friend who will work together with us. ...",
  104. "I'm sure he'll still try to gain some profit but that's still better than his former one-man rule during which he dictated his own laws."
  105. }, cid)
  106. player:setStorageValue(Storage.InServiceofYalahar.GoodSide, player:getStorageValue(Storage.InServiceofYalahar.GoodSide) >= 0 and player:getStorageValue(Storage.InServiceofYalahar.GoodSide) + 1 or 0)
  107. player:setStorageValue(Storage.InServiceofYalahar.Questline, 26)
  108. player:setStorageValue(Storage.InServiceofYalahar.Mission04, 5) -- StorageValue for Questlog "Mission 04: Good to be Kingpin"
  109. npcHandler.topic[cid] = 0
  110. elseif player:getStorageValue(Storage.InServiceofYalahar.Questline) == 28 then
  111. npcHandler:say({
  112. "Warbeasts? Is this true? People are already starving. ...",
  113. "How can we afford to feed an army of hungry beasts? They will not only strengthen the power of the Yalahari over the citizens, they also mean starvation and deathfor the poor. ...",
  114. "Instead of breeding warbeasts, this druid should breed cattle to feed our people. Please I beg you, convince him to do that!"
  115. }, cid)
  116. player:setStorageValue(Storage.InServiceofYalahar.Questline, 29)
  117. player:setStorageValue(Storage.InServiceofYalahar.TamerinStatus, 0)
  118. player:setStorageValue(Storage.InServiceofYalahar.Mission05, 2) -- StorageValue for Questlog "Mission 05: Food or Fight"
  119. npcHandler.topic[cid] = 0
  120. elseif player:getStorageValue(Storage.InServiceofYalahar.Questline) == 32 and player:getStorageValue(Storage.InServiceofYalahar.TamerinStatus) == 1 then
  121. npcHandler:say("These are great news indeed. The people of Yalahar will be grateful. The Yalahari probably not, so take care of yourself. ", cid)
  122. player:setStorageValue(Storage.InServiceofYalahar.GoodSide, player:getStorageValue(Storage.InServiceofYalahar.GoodSide) >= 0 and player:getStorageValue(Storage.InServiceofYalahar.GoodSide) + 1 or 0) -- Side Storage
  123. player:setStorageValue(Storage.InServiceofYalahar.Questline, 33)
  124. player:setStorageValue(Storage.InServiceofYalahar.Mission05, 8) -- StorageValue for Questlog "Mission 05: Food or Fight"
  125. npcHandler.topic[cid] = 0
  126. elseif player:getStorageValue(Storage.InServiceofYalahar.Questline) == 35 then
  127. npcHandler:say({
  128. "What a sick idea to misuse tortured souls to power some device! Though, this charm might be useful to free these poor souls. ...",
  129. "Please capture the souls as you have been instructed and then bring the charm to me. I will see to it that the souls are freed to go to the afterlife in peace."
  130. }, cid)
  131. player:setStorageValue(Storage.InServiceofYalahar.Questline, 36)
  132. player:setStorageValue(Storage.InServiceofYalahar.Mission06, 2) -- StorageValue for Questlog "Mission 06: Frightening Fuel"
  133. npcHandler.topic[cid] = 0
  134. elseif player:getStorageValue(Storage.InServiceofYalahar.Questline) == 37 then
  135. if player:removeItem(9742, 1) then
  136. npcHandler:say({
  137. "I thank you also in the name of these poor lost souls. I will send the charm to a priest who is able to release them. ...",
  138. "Tell the Yalahari that the charm was destroyed by the energy it contained."
  139. }, cid)
  140. player:setStorageValue(Storage.InServiceofYalahar.Questline, 38)
  141. player:setStorageValue(Storage.InServiceofYalahar.Mission06, 4) -- StorageValue for Questlog "Mission 06: Frightening Fuel"
  142. player:setStorageValue(Storage.InServiceofYalahar.QuaraState, 1)
  143. player:setStorageValue(Storage.InServiceofYalahar.GoodSide, player:getStorageValue(Storage.InServiceofYalahar.GoodSide) >= 0 and player:getStorageValue(Storage.InServiceofYalahar.GoodSide) + 1 or 0) -- Side Storage
  144. npcHandler.topic[cid] = 0
  145. end
  146. elseif player:getStorageValue(Storage.InServiceofYalahar.Questline) == 40 then
  147. npcHandler:say({
  148. "The quara are indeed a threat. Yet, they are numerous and reproduce quickly. Slaying some of them will only enrage them even more. ...",
  149. "The quara have been there for many generations. They have never threatened anyone who stayed out of their watery realm. ...",
  150. "It would be much more useful to find out what the quara are so upset about. Better avoid slaying their leaders as this will only further the animosities."
  151. }, cid)
  152. player:setStorageValue(Storage.InServiceofYalahar.Questline, 41)
  153. player:setStorageValue(Storage.InServiceofYalahar.DoorToQuara, 1)
  154. player:setStorageValue(Storage.InServiceofYalahar.Mission07, 2) -- StorageValue for Questlog "Mission 07: A Fishy Mission"
  155. npcHandler.topic[cid] = 0
  156. elseif player:getStorageValue(Storage.InServiceofYalahar.Questline) == 42 and player:getStorageValue(Storage.InServiceofYalahar.QuaraState) == 1 then
  157. npcHandler:say("Oh no! So that's the reason for the quara attacks! I will do my best to close these sewage pipes. We will have to use other drains. ", cid)
  158. player:setStorageValue(Storage.InServiceofYalahar.Questline, 43)
  159. player:setStorageValue(Storage.InServiceofYalahar.Mission07, 5) -- StorageValue for Questlog "Mission 07: A Fishy Mission"
  160. player:setStorageValue(Storage.InServiceofYalahar.GoodSide, player:getStorageValue(Storage.InServiceofYalahar.GoodSide) >= 0 and player:getStorageValue(Storage.InServiceofYalahar.GoodSide) + 1 or 0) -- Side Storage
  161. npcHandler.topic[cid] = 0
  162. elseif player:getStorageValue(Storage.InServiceofYalahar.Questline) == 44 then
  163. npcHandler:say({
  164. "The constant unrest in the city is to a great extent caused by the lack of food. Weapons will only serve to suppress the poor. ...",
  165. "The factory you were sent to was once used for the production of food. Somewhere in the factory you might find an old pattern crystal for the production of food. ...",
  166. "If you use it on the controls instead of the weapon pattern, you will ensure that our people are supplied with the desperately needed food. ..."
  167. }, cid)
  168. player:setStorageValue(Storage.InServiceofYalahar.Questline, 45)
  169. player:setStorageValue(Storage.InServiceofYalahar.DoorToMatrix, 1)
  170. player:setStorageValue(Storage.InServiceofYalahar.Mission08, 2) -- StorageValue for Questlog "Mission 08: Dangerous Machinations"
  171. npcHandler.topic[cid] = 0
  172. elseif player:getStorageValue(Storage.InServiceofYalahar.Questline) == 48 then
  173. npcHandler:say({
  174. "Listen, I know you have worked for Azerus and his friends, but it is not too late to change your mind! I beg you to rethink your loyalties. ...",
  175. "The fate of the whole city might depend on your decision! Think about your options carefully."
  176. }, cid)
  177. player:setStorageValue(Storage.InServiceofYalahar.Questline, 49)
  178. npcHandler.topic[cid] = 0
  179. elseif player:getStorageValue(Storage.InServiceofYalahar.Questline) == 49 or player:getStorageValue(Storage.InServiceofYalahar.Questline) == 48 then
  180. npcHandler:say("So do you want to side with me? ", cid)
  181. npcHandler.topic[cid] = 5
  182. elseif player:getStorageValue(Storage.InServiceofYalahar.Questline) == 50 and player:getStorageValue(Storage.InServiceofYalahar.SideDecision) == 1 then
  183. npcHandler:say({
  184. "I cannot tell you how we acquired this information, but we have heard that a circle of Yalahari is planning some kind of ritual. ...",
  185. "They plan to create a portal for some powerful demons and to unleash them in the city to 'purge' it once and for all. ...",
  186. "I doubt those poor fools will be able to control such entities. I can't figure out how they came up with such an insane idea, but they have to be stopped. ...",
  187. "The entrance to their inner sanctum has been opened for you. Please hurry and stop them before it's too late. Be prepared for a HARD battle! Better gather some friends to assist you."
  188. }, cid)
  189. player:setStorageValue(Storage.InServiceofYalahar.Questline, 51)
  190. player:setStorageValue(Storage.InServiceofYalahar.DoorToLastFight, 1)
  191. player:setStorageValue(Storage.InServiceofYalahar.Mission10, 2) -- StorageValue for Questlog "Mission 10: The Final Battle"
  192. npcHandler.topic[cid] = 0
  193. elseif player:getStorageValue(Storage.InServiceofYalahar.Questline) == 52 then
  194. npcHandler:say({
  195. "So the Yalahari that opposed us are dead or fled from the city. This should bring us more stability and perhaps a true chance to rebuild the city. ...",
  196. "Still, I wonder from where they gained some of the Yalahari secrets. Did they find some source of knowledge? ...",
  197. "And if so, is this source still around so that we can use it for the benefit of our city? What really troubles me is that none of those false Yalahari had the personality of agreat leader. ...",
  198. "Quite the opposite, they were opportunistic and not exactly bold. Perhaps they were led by some greater power which stayed behind the scenes. ...",
  199. "I'm afraid we have not seen the last chapter of Yalahar's drama. But anyhow, I wish to thank you for putting your life at stake for our cause. ...",
  200. "I allow you to enter the Yalaharian treasure room. I'm sure that you can put what you find inside to better use than them. Choose one chest, but think before takingone! ...",
  201. "Also, take this Yalaharian outfit. Depending on which side you chose previously, you can also acquire one specific addon. Thank you again for your help."
  202. }, cid)
  203. player:setStorageValue(Storage.InServiceofYalahar.Questline, 53)
  204. player:setStorageValue(Storage.InServiceofYalahar.DoorToReward, 1)
  205. player:setStorageValue(Storage.InServiceofYalahar.Mission10, 4) -- StorageValue for Questlog "Mission 10: The Final Battle"
  206. player:addOutfit(324, 0)
  207. player:addOutfit(325, 0)
  208. player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
  209. npcHandler.topic[cid] = 0
  210. end
  211. elseif msgcontains(msg, "yes") then
  212. if npcHandler.topic[cid] == 1 then
  213. player:setStorageValue(Storage.InServiceofYalahar.Questline, 4)
  214. npcHandler:say({
  215. "I'm pleased to hear that. Rarely we meet outsiders that care about our problems. Most people come here looking for wealth and luxury. ...",
  216. "However, I have to tell you that our ranking system is quite rigid. So, I'm not allowed to entrust you with important missions as long as you haven't proven yourself as reliable. ...",
  217. "If you are willing to work for the city of Yalahar, you can ask me for a {mission} any time, be it night or day."
  218. }, cid)
  219. npcHandler.topic[cid] = 0
  220. elseif npcHandler.topic[cid] == 2 then
  221. if player:getStorageValue(Storage.InServiceofYalahar.SewerPipe01) == 1 and player:getStorageValue(Storage.InServiceofYalahar.SewerPipe02) == 1 and player:getStorageValue(Storage.InServiceofYalahar.SewerPipe03) == 1 and player:getStorageValue(Storage.InServiceofYalahar.SewerPipe04) == 1 then
  222. player:setStorageValue(Storage.InServiceofYalahar.Questline, 6)
  223. player:setStorageValue(Storage.InServiceofYalahar.Mission01, 6) -- StorageValue for Questlog "Mission 01: Something Rotten"
  224. npcHandler:say("Thank you very much. You have no idea how hard it was to find someone volunteering for that job. If you feel ready for further {missions}, just tell me.", cid)
  225. npcHandler.topic[cid] = 0
  226. end
  227. elseif npcHandler.topic[cid] == 3 then
  228. player:setStorageValue(Storage.InServiceofYalahar.Mission02, 1) -- StorageValue for Questlog "Mission 02: Watching the Watchmen"
  229. player:setStorageValue(Storage.InServiceofYalahar.Questline, 7)
  230. npcHandler:say({
  231. "You'll find our seven guards at the gates of each quarter. Just ask them for their report and they will tell you all you need to know.",
  232. "I must warn you, the quarters are in a horrible state. I strongly advise you to stay on the main roads whenever possible while you get those reports. ..."
  233. }, cid)
  234. npcHandler.topic[cid] = 0
  235. elseif npcHandler.topic[cid] == 4 then
  236. if player:getStorageValue(Storage.InServiceofYalahar.Questline) == 14 then
  237. player:setStorageValue(Storage.InServiceofYalahar.Mission02, 8) -- StorageValue for Questlog "Mission 02: Watching the Watchmen"
  238. player:setStorageValue(Storage.InServiceofYalahar.Questline, 15)
  239. npcHandler:say("Excellent! My superiors will be pleased to get these reports. I will for sure emphasise your efforts in this mission. Please come back soon to see if there are any more {missions} available for you. ", cid)
  240. npcHandler.topic[cid] = 0
  241. else
  242. npcHandler:say("Come back when you do.", cid)
  243. npcHandler.topic[cid] = 0
  244. end
  245. elseif npcHandler.topic[cid] == 5 then
  246. player:setStorageValue(Storage.InServiceofYalahar.Questline, 50)
  247. player:setStorageValue(Storage.InServiceofYalahar.Mission09, 2) -- StorageValue for Questlog "Mission 09: Decision"
  248. player:setStorageValue(Storage.InServiceofYalahar.Mission10, 1) -- StorageValue for Questlog "Mission 10: The Final Battle"
  249. player:setStorageValue(Storage.InServiceofYalahar.SideDecision, 1)
  250. npcHandler:say("I knew that you were smart enough to make the right decision! Your next mission will be a special one! ", cid)
  251. npcHandler.topic[cid] = 0
  252. elseif npcHandler.topic[cid] == 6 then
  253. if player:getItemCount(9956) > 0 and player:getStorageValue(Storage.InServiceofYalahar.Questline) == 54 then
  254. player:setStorageValue(Storage.InServiceofYalahar.Questline, 55)
  255. npcHandler:say("Great! Here, take this yalaharian addon in a return.", cid)
  256. player:addOutfitAddon(325, player:getStorageValue(Storage.InServiceofYalahar.SideDecision) == 1 and 1 or 2)
  257. player:addOutfitAddon(324, player:getStorageValue(Storage.InServiceofYalahar.SideDecision) == 1 and 1 or 2)
  258. player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
  259. npcHandler.topic[cid] = 0
  260. else
  261. npcHandler:say("Come back when you do.", cid)
  262. npcHandler.topic[cid] = 0
  263. end
  264. end
  265. end
  266. return true
  267. end
  268.  
  269. npcHandler:setMessage(MESSAGE_GREET, "Greetings.")
  270. npcHandler:setMessage(MESSAGE_FAREWELL, "Good bye, |PLAYERNAME|.")
  271. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
  272. npcHandler:addModule(FocusModule:new())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement