Guest User

Untitled

a guest
May 23rd, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 15.22 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 getPlayerBones(cid)
  11. local player = Player(cid)
  12. return player:getItemCount(2230) + player:getItemCount(2231)
  13. end
  14.  
  15. local function doPlayerRemoveBones(cid)
  16. local player = Player(cid)
  17. return player:removeItem(2230, player:getItemCount(2230)) and player:removeItem(2231, player:getItemCount(2231))
  18. end
  19.  
  20. local function creatureSayCallback(cid, type, msg)
  21. if not npcHandler:isFocused(cid) then
  22. return false
  23. end
  24. local player = Player(cid)
  25. if msgcontains(msg, "mission") then
  26. if player:getStorageValue(Storage.postman.Mission01) < 1 then
  27. npcHandler:say("You are not a member of our guild yet! We have high standards for our members. To rise in our guild is a difficult but rewarding task. Are you interested in joining?", cid)
  28. npcHandler.topic[cid] = 1
  29. elseif player:getStorageValue(Storage.postman.Mission01) == 5 then
  30. npcHandler:say("So you have finally made it! I did not think that you would have it in you ... However: are you ready for another assignment?", cid)
  31. npcHandler.topic[cid] = 8
  32. elseif player:getStorageValue(Storage.postman.Mission02) == 2 then
  33. npcHandler:say("Excellent, you got it fixed! This will teach this mailbox a lesson indeed! Are you interested in another assignment?", cid)
  34. npcHandler.topic[cid] = 9
  35. elseif player:getStorageValue(Storage.postman.Mission03) == 2 then
  36. npcHandler:say("You truly got him? Quite impressive. You are a very promising candidate! I think I have another mission for you. Are you interested?", cid)
  37. npcHandler.topic[cid] = 11
  38. elseif player:getStorageValue(Storage.postman.Mission04) == 1 then
  39. npcHandler:say("Do you bring ONE bone for our officers' safety fund or ALL bones at once?", cid)
  40. npcHandler.topic[cid] = 12
  41. elseif player:getStorageValue(Storage.postman.Mission04) == 2 and player:getStorageValue(Storage.postman.Mission05) < 1 then
  42. npcHandler:say("You have made it! We have enough bones for the fund! You remind me of myself when I was young! Interested in another mission?", cid)
  43. npcHandler.topic[cid] = 15
  44. elseif player:getStorageValue(Storage.postman.Mission05) == 3 then
  45. npcHandler:say("Splendid, I knew we could trust you. I would like to ask for your help in another matter. Are you interested?", cid)
  46. npcHandler.topic[cid] = 16
  47. elseif player:getStorageValue(Storage.postman.Mission06) == 12 then
  48. npcHandler:say("Excellent! Another job well done! Would you accept another mission?", cid)
  49. npcHandler.topic[cid] = 19
  50. elseif player:getStorageValue(Storage.postman.Mission07) == 7 then
  51. npcHandler:say("Once more you have impressed me! Are you willing to do another job?", cid)
  52. npcHandler.topic[cid] = 21
  53. elseif player:getStorageValue(Storage.postman.Mission08) == 2 then
  54. npcHandler:say("So Waldo is dead? This is grave news indeed. Did you recover his posthorn?", cid)
  55. npcHandler.topic[cid] = 23
  56. elseif player:getStorageValue(Storage.postman.Rank) == 4 and player:getStorageValue(Storage.postman.Mission09) == 0 then
  57. npcHandler:say("So are you ready for another mission?", cid)
  58. npcHandler.topic[cid] = 25
  59. elseif player:getStorageValue(Storage.postman.Mission09) == 3 then
  60. npcHandler:say("You did it? I hope you did not catch a flu in the cold! However theres another mission for you. Are you interested?", cid)
  61. npcHandler.topic[cid] = 26
  62. elseif player:getStorageValue(Storage.postman.Mission10) == 2 then
  63. npcHandler:say("You have delivered that letter? You are a true postofficer. All over the land bards shallpraise your name. There are no missions for you left right now.", cid)
  64. player:setStorageValue(Storage.postman.Mission10, 3)
  65. npcHandler.topic[cid] = 0
  66. end
  67. elseif msgcontains(msg, "dress pattern") then
  68. if player:getStorageValue(Storage.postman.Mission06) == 2 then
  69. npcHandler:say("Oh yes, where did we get that from ...? Let's see, first ask the great technomancer in Kazordoon for the technical details. Return here afterwards.", cid)
  70. player:setStorageValue(Storage.postman.Mission06, 3)
  71. npcHandler.topic[cid] = 0
  72. elseif player:getStorageValue(Storage.postman.Mission06) == 4 then
  73. npcHandler:say("The mail with Talphion's instructions just arived. I remember we asked Queen Eloise of Carlin for the perfect colours. Go there, ask her about the UNIFORMS and report back here.", cid)
  74. player:setStorageValue(Storage.postman.Mission06, 5)
  75. npcHandler.topic[cid] = 0
  76. elseif player:getStorageValue(Storage.postman.Mission06) == 6 then
  77. npcHandler:say("The queen has sent me the samples we needed. The next part is tricky. We need theuniforms to emanate some odor that dogs hate.The dog with the best 'taste' in that field is Noodles,the dog of King Tibianus. Do you understand so far?", cid)
  78. npcHandler.topic[cid] = 18
  79. elseif player:getStorageValue(Storage.postman.Mission06) == 10 then
  80. npcHandler:say("Fine, fine. I think that should do it. Tell Hugo that we order those uniforms. The completed dress pattern will soon arrive in Venore. Report to me when you have talked to him.", cid)
  81. player:setStorageValue(Storage.postman.Mission06, 11)
  82. npcHandler.topic[cid] = 0
  83. end
  84. elseif msgcontains(msg, "all") then
  85. if npcHandler.topic[cid] == 12 then
  86. npcHandler:say("Do you bring ONE bone for our officers' safety fund or ALL bones at once?", cid)
  87. npcHandler.topic[cid] = 13
  88. end
  89. elseif msgcontains(msg, "advancement") then
  90. if player:getStorageValue(Storage.postman.Mission04) == 2 and player:getStorageValue(Storage.postman.Rank) == 1 then
  91. npcHandler:say("You are worthy indeed. Do you want to advance in our guild?", cid)
  92. npcHandler.topic[cid] = 14
  93. elseif player:getStorageValue(Storage.postman.Mission06) == 13 and player:getStorageValue(Storage.postman.Rank) == 2 then
  94. npcHandler:say("You are worthy indeed. Do you want to advance in our guild?", cid)
  95. npcHandler.topic[cid] = 20
  96. elseif player:getStorageValue(Storage.postman.Mission08) == 3 and player:getStorageValue(Storage.postman.Rank) == 3 then
  97. npcHandler:say("You are worthy indeed. Do you want to advance in our guild?", cid)
  98. npcHandler.topic[cid] = 24
  99. elseif player:getStorageValue(Storage.postman.Mission10) == 3 and player:getStorageValue(Storage.postman.Rank) == 4 then
  100. npcHandler:say("You are worthy indeed. Do you want to advance in our guild?", cid)
  101. npcHandler.topic[cid] = 27
  102. end
  103. elseif msgcontains(msg, "yes") then
  104. if npcHandler.topic[cid] == 1 then
  105. npcHandler:say("Hm, I might consider your proposal, but first you will have to prove your worth by doing some tasks for us. Are you willing to do that?", cid)
  106. npcHandler.topic[cid] = 2
  107. elseif npcHandler.topic[cid] == 2 then
  108. npcHandler:say("Excellent! Your first task will be quite simple. But you should better write my instructions down anyways. You can read and write?", cid)
  109. npcHandler.topic[cid] = 3
  110. elseif npcHandler.topic[cid] == 3 then
  111. npcHandler:say("So listen, you will check certain tours our members have to take to see if there is some trouble. First travel with Captain Bluebear's ship from Thais to Carlin, understood?", cid)
  112. npcHandler.topic[cid] = 4
  113. elseif npcHandler.topic[cid] == 4 then
  114. npcHandler:say("Excellent! Once you have done that you will travel with Uzon to Edron. You will find him in the Femor Hills. Understood?", cid)
  115. npcHandler.topic[cid] = 5
  116. elseif npcHandler.topic[cid] == 5 then
  117. npcHandler:say("Fine, fine! Next, travel with Captain Seahorse to the city of Venore. Understood?", cid)
  118. npcHandler.topic[cid] = 6
  119. elseif npcHandler.topic[cid] == 6 then
  120. npcHandler:say("Good! Finally, find the technomancer Brodrosch and travel with him to the Isle of Cormaya. After this passage report back to me here. Understood?", cid)
  121. npcHandler.topic[cid] = 7
  122. elseif npcHandler.topic[cid] == 7 then
  123. npcHandler:say("Ok, remember: the Tibian mail service puts trust in you! Don't fail and report back soon. Just tell me about your {MISSION}.", cid)
  124. player:setStorageValue(Storage.postman.Mission01, 1)
  125. npcHandler.topic[cid] = 0
  126. elseif npcHandler.topic[cid] == 8 then
  127. npcHandler:say("I am glad to hear that. One of our mailboxes was reported to be jammed. It is located on the so called 'mountain' on theisle Folda. Get a crowbar and fix the mailbox. Report about your mission when you have done so.", cid)
  128. player:setStorageValue(Storage.postman.Mission01, 6)
  129. player:setStorageValue(Storage.postman.Mission02, 1)
  130. npcHandler.topic[cid] = 0
  131. elseif npcHandler.topic[cid] == 9 then
  132. npcHandler:say("For your noble deeds I grant you the title Assistant Postofficer. All Postofficers will charge you less money from now on. After every second mission ask me for an ADVANCEMENT. Your next task will be a bit more challenging. Do you feel ready for it?", cid)
  133. player:setStorageValue(Storage.postman.Rank, 1)
  134. npcHandler.topic[cid] = 10
  135. elseif npcHandler.topic[cid] == 10 then
  136. npcHandler:say("I need you to deliver a bill to the stage magician David Brassacres. He's hiding from his creditors somewhere in Venore. It's likely you will have to trick him somehow to reveal his identity. Report back when you delivered this bill.", cid)
  137. player:setStorageValue(Storage.postman.Mission02, 3)
  138. player:setStorageValue(Storage.postman.Mission03, 1)
  139. npcHandler.topic[cid] = 0
  140. elseif npcHandler.topic[cid] == 11 then
  141. npcHandler:say("Ok, listen: we have some serious trouble with agressive dogs lately. We have accumulated some bones as a sort of pacifier but we need more. Collect 20 bones like the one in my room to the left and report here.", cid)
  142. player:setStorageValue(Storage.postman.Mission03, 3)
  143. player:setStorageValue(Storage.postman.Mission04, 1)
  144. npcHandler.topic[cid] = 0
  145. elseif npcHandler.topic[cid] == 13 then
  146. if getPlayerBones(cid) >= 20 then
  147. doPlayerRemoveBones(cid)
  148. npcHandler:say("You have collected all the 20 bones needed. Excellent! Now let's talk about further missions if you are interested.", cid)
  149. player:setStorageValue(Storage.postman.Mission04, 2)
  150. npcHandler.topic[cid] = 0
  151. end
  152. elseif npcHandler.topic[cid] == 14 then
  153. npcHandler:say("I grant you the title of postman. You are now a full member of our guild. Here have your own officers hat and wear it with pride.", cid)
  154. player:setStorageValue(Storage.postman.Rank, 2)
  155. player:addItem(2665, 1)
  156. npcHandler.topic[cid] = 0
  157. elseif npcHandler.topic[cid] == 15 then
  158. npcHandler:say("Since I am convinced I can trust you, this time you must deliver a valuable present to Dermot on Fibula. Do NOT open it!!! You will find the present behind the door here on the lower right side of this room.", cid)
  159. player:setStorageValue(Storage.postman.Mission05, 1)
  160. npcHandler.topic[cid] = 0
  161. elseif npcHandler.topic[cid] == 16 then
  162. npcHandler:say("Ok. We need a new set of uniforms, and only the best will do for us. Please travel to Venore and negotiate with Hugo Chief acontract for new uniforms.", cid)
  163. player:setStorageValue(Storage.postman.Mission05, 4)
  164. player:setStorageValue(Storage.postman.Mission06, 1)
  165. npcHandler.topic[cid] = 0
  166. elseif npcHandler.topic[cid] == 18 then
  167. npcHandler:say("Good. Go there and find out what taste he dislikes most: mouldy cheese, a piece of fur or abananaskin. Tell him to SNIFF, then the object. Show him the object and ask 'Do you like that?'.DONT let the guards know what you are doing.", cid)
  168. player:setStorageValue(Storage.postman.Mission06, 7)
  169. npcHandler.topic[cid] = 0
  170. elseif npcHandler.topic[cid] == 19 then
  171. npcHandler:say("Good, so listen. Hugo Chief informed me that he needs the measurements of our postofficers. Go and bring me the measurements of Ben, Lokur, Dove, Liane, Chrystal and Olrik.", cid)
  172. player:setStorageValue(Storage.postman.Mission06, 13)
  173. player:setStorageValue(Storage.postman.Mission07, 1)
  174. npcHandler.topic[cid] = 0
  175. elseif npcHandler.topic[cid] == 20 then
  176. npcHandler:say("From now on it shall be known that you are a grand postman. You are now a privilegedmember until the end of days. Most captains around the world have an agreement with our guild to transport our privileged members, like you, for less gold.", cid)
  177. player:setStorageValue(Storage.postman.Rank, 3)
  178. npcHandler.topic[cid] = 0
  179. elseif npcHandler.topic[cid] == 21 then
  180. npcHandler:say("Ok but your next assignment might be dangerous. Our Courier Waldo has been missing for a while. I must assume he is dead. Can you follow me so far?", cid)
  181. npcHandler.topic[cid] = 22
  182. elseif npcHandler.topic[cid] == 22 then
  183. npcHandler:say("Find out about his whereabouts and retrieve him or at least his posthorn. He was looking for a new underground passage that is rumoured to be found underneath the troll-infested Mountain east of Thais.", cid)
  184. player:setStorageValue(Storage.postman.Mission07, 8)
  185. player:setStorageValue(Storage.postman.Mission08, 1)
  186. npcHandler.topic[cid] = 0
  187. elseif npcHandler.topic[cid] == 23 then
  188. npcHandler:say("Thank you. We will honour this. Your next mission will be a very special one. Good thing you are a special person as well. Are you ready?", cid)
  189. player:setStorageValue(Storage.postman.Mission08, 3)
  190. player:setStorageValue(Storage.postman.Mission09, 0)
  191. npcHandler.topic[cid] = 0
  192. elseif npcHandler.topic[cid] == 24 then
  193. npcHandler:say("From now on you are a grand postman for special operations. You are an honoured member of our guild and earned the privilege of your own post horn. Here, take it.", cid)
  194. player:setStorageValue(Storage.postman.Rank, 4)
  195. player:addItem(2078, 1)
  196. npcHandler.topic[cid] = 0
  197. elseif npcHandler.topic[cid] == 25 then
  198. npcHandler:say("So listen well. Behind the lower left door you will find a bag. The letters in the bag are for none other than Santa Claus! Deliver them to his house on the isle of Vega, USE thebag on his mailbox and report back here.", cid)
  199. player:setStorageValue(Storage.postman.Mission09, 1)
  200. npcHandler.topic[cid] = 0
  201. elseif npcHandler.topic[cid] == 26 then
  202. npcHandler:say("Excellent. Here is a letter for you to deliver. Well, to be honest, no one else volunteered. It's a letter from the mother of Markwin, the king of Mintwallin. Deliver that letter to him, but note that you will not be welcome there.", cid)
  203. player:setStorageValue(Storage.postman.Mission09, 4)
  204. player:setStorageValue(Storage.postman.Mission10, 1)
  205. player:addItem(2333, 1)
  206. npcHandler.topic[cid] = 0
  207. elseif npcHandler.topic[cid] == 27 then
  208. npcHandler:say("I grant you the title of archpostman. You are a legend in our guild. As privilege of your newly aquired status you are allowed to make use of certain mailboxes in dangerous areas. Just look out for them and you'll see.", cid)
  209. player:setStorageValue(Storage.postman.Rank, 5)
  210. player:setStorageValue(Storage.postman.Door, 1)
  211. npcHandler.topic[cid] = 0
  212. end
  213. end
  214. return true
  215. end
  216.  
  217. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
  218. npcHandler:addModule(FocusModule:new())
Add Comment
Please, Sign In to add comment