Guest User

Untitled

a guest
Oct 27th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 18.77 KB | None | 0 0
  1. local keywordHandler = KeywordHandler:new()
  2. local npcHandler = NpcHandler:new(keywordHandler)
  3. NpcSystem.parseParameters(npcHandler)
  4.  
  5. local Topic
  6.  
  7. function onCreatureAppear(cid)              npcHandler:onCreatureAppear(cid) end
  8. function onCreatureDisappear(cid)           npcHandler:onCreatureDisappear(cid) end
  9. function onCreatureSay(cid, type, msg)  npcHandler:onCreatureSay(cid, type, msg) end
  10. function onThink()                      npcHandler:onThink() end
  11.  
  12. local CacheMap = {}
  13.  
  14. local QuestValue = function(k)
  15.     if CacheMap[k] then
  16.         return CacheMap[k]
  17.     end
  18.     CacheMap[k] = getPlayerStorageValue(npcHandler.focus, k)
  19.     return CacheMap[k]
  20. end
  21.  
  22. local SetQuestValue = function(k, v)
  23.     setPlayerStorageValue(npcHandler.focus, k, v)
  24.     CacheMap[k] = v
  25. end
  26.  
  27. function greetCallback(cid)
  28.     Topic = nil
  29.     return true
  30. end
  31.  
  32. function creatureSayCallback(cid, type, msg)
  33.     if npcHandler.focus ~= cid then
  34.         return false
  35.     end
  36.  
  37.     local n
  38.  
  39.     if Topic == 23 then
  40.         if msgcontains(msg, 'yes') then
  41.             local s = QuestValue(249)
  42.             if s == 2 then
  43.                 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.")
  44.                 SetQuestValue(250,2)
  45.                 doPlayerAddItem(cid, 2665, 1)
  46.             elseif s == 3 then
  47.                 npcHandler:say("From now on it shall be known that you are a grand postman. You are now a privileged member 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.")
  48.                 SetQuestValue(250,3)
  49.             elseif s == 4 then
  50.                 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.")
  51.                 SetQuestValue(250,4)
  52.                 doPlayerAddItem(cid, 2078, 1)
  53.             elseif s == 5 then
  54.                 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.")
  55.                 SetQuestValue(250,5)
  56.             end
  57.         end -- no else
  58.     elseif msgcontains(msg, 'special') and msgcontains(msg, 'operations') then
  59.         if QuestValue(250) < 4 then
  60.             npcHandler:say("Sorry but I won't talk about this matter with someone of your rank.")
  61.         else
  62.             npcHandler:say("We have a secret branch, called 'the stamps of the gods'. They secretly supervise our members reliability and have an eye on certain groups of interest that want to gain influence over our guild.")
  63.         end
  64.     elseif msgcontains(msg, 'member') then
  65.         if QuestValue(227) == -1 then
  66.             npcHandler:say("We have high standards for our members. To rise in our guild is a difficult but rewarding task. Why do you ask? Are you interested in joining?")
  67.             n = 1
  68.         else
  69.             npcHandler:say("You are already a member, " .. getCreatureName(cid) .. ".")
  70.         end
  71.     elseif msgcontains(msg, "mission") then
  72.         if QuestValue(248) == 1 and QuestValue(250) < QuestValue(249) then
  73.             npcHandler:say("Your eagerness is a virtue, young one, but first lets talk about advancement.")
  74.         elseif QuestValue(246) == 1 and QuestValue(244) == -1 then
  75.             npcHandler:say("So are you ready for another Mission?")
  76.             n = 20
  77.         elseif QuestValue(243) == -1 and QuestValue(242) == 1 then
  78.             npcHandler:say("You are not done with your current mission. Search for the whereabout of Postofficer Waldo. Please report back when you are ready.")
  79.         elseif QuestValue(234) > 0 and QuestValue(234) < 7 then
  80.             npcHandler:say("You are not done with your current mission. We still need the measurements of several postofficers. Please report back when you are ready.")
  81.         elseif QuestValue(233) > 0 and QuestValue(233) < 10 then
  82.             npcHandler:say("You are not done with your current mission. Make sure Hugo chief is tailoring our new uniforms. Please report back when you are ready.")
  83.         elseif QuestValue(229) > 0 and QuestValue(229) < 3 then
  84.             npcHandler:say("You are not done with your current mission. Find David Brassacres and hand him that bill. Report when you are ready.")
  85.         elseif QuestValue(230) > 1 and QuestValue(230) < 20 then
  86.             npcHandler:say("Do you bring a bone for our officers' safety fund?")
  87.             n = 12
  88.         elseif QuestValue(230) > 1 and QuestValue(230) == 20 then
  89.             npcHandler:say("Do you bring a bone for our officers' safety fund?")
  90.             n = 22
  91.         elseif QuestValue(227) == -1 then
  92.             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?")
  93.             n = 1
  94.         elseif QuestValue(248) == 1 then
  95.             npcHandler:say("You have mastered all our current missions. There's nothing left to be done ... for now.")
  96.         elseif QuestValue(245) == 1 then
  97.             npcHandler:say("You are not done with your current mission. Deliver that letter to king Markwin. Please report back when you are ready.")
  98.         elseif QuestValue(245) == 2 then
  99.             npcHandler:say("You have delivered that letter? You are a true postofficer. All over the land bards shall praise your name. There are no missions for you left right now.")
  100.             SetQuestValue(248,1)
  101.             SetQuestValue(249,5)
  102.         elseif QuestValue(244) == 1 then
  103.             npcHandler:say("You are not done with your current mission. Deliver those letters to Santa. Please report back when you are ready.")
  104.         elseif QuestValue(244) == 2 then
  105.             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?")
  106.             n = 21
  107.         elseif QuestValue(243) == 1 then
  108.             npcHandler:say("So Waldo is dead? This is grave news indeed. Did you recover his posthorn?")
  109.             n = 19
  110.         elseif QuestValue(234) == 7 then
  111.             npcHandler:say("Once more you have impressed me! Are you willing to do another job?")
  112.             n = 17
  113.         elseif QuestValue(233) == 10 then
  114.             npcHandler:say("Excellent! Another job well done! Would you accept another mission?")
  115.             SetQuestValue(249,3)
  116.             n = 16
  117.         elseif QuestValue(231) == 1 then
  118.             npcHandler:say("You are not done with your current mission. Deliver that present to Fibula. Please report back when you are ready.")
  119.         elseif QuestValue(231) == 2 then
  120.             npcHandler:say("Splendid, I knew we could trust you. I would like to ask for your help in another matter. Are you interested?")
  121.             n = 14
  122.         elseif QuestValue(230) == 1 then
  123.             npcHandler:say("Do you bring ONE bone for our officers' safety fund or ALL bones at once?")
  124.             n = 24
  125.         elseif QuestValue(230) > 20 then
  126.             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?")
  127.             n = 13
  128.         elseif QuestValue(229) == 3 then
  129.             npcHandler:say("You truly got him? Quite impressive. You are a very prommising candidate! I think I have another mission for you. Are you interested?")
  130.             n = 11
  131.         elseif QuestValue(228) == 1 then
  132.             npcHandler:say("You are not done with your current mission. The mailbox is still not fixed. Report if you are ready.")
  133.         elseif QuestValue(228) == 2 then
  134.             npcHandler:say("Excellent, you got it fixed! This will teach this mailbox a lesson indeed! Are you interested in another assignment?")
  135.             n = 9
  136.         elseif QuestValue(227) < 5 then
  137.             npcHandler:say("You are not done with your current mission. Make sure all the passages are secure. Report if you are ready.")
  138.         elseif QuestValue(227) == 5 then
  139.             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?")
  140.             n = 8
  141.         end
  142.     elseif msgcontains(msg, 'advancement') then
  143.         if QuestValue(250) < QuestValue(249) then
  144.             npcHandler:say("You are worthy indeed. Do you want to advance in our guild?")
  145.             n = 23
  146.         else
  147.             npcHandler:say("Sorry, but you are not yet ready for advancement.")
  148.         end
  149.     elseif msgcontains(msg, 'dress') and msgcontains(msg, 'pattern') and QuestValue(233) == 8 then
  150.         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.")
  151.         SetQuestValue(233,9)
  152.     elseif ((msgcontains(msg, 'dress') and msgcontains(msg, 'pattern')) or msgcontains(msg, 'uniform')) and QuestValue(233) == 6 then
  153.         npcHandler:say("The queen has sent me the samples we needed. The next part is tricky. We need the uniforms 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?")
  154.         n = 15
  155.     elseif msgcontains(msg, 'dress') and msgcontains(msg, 'pattern') and QuestValue(233) == 2 then
  156.         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.")
  157.         SetQuestValue(233,3)
  158.     elseif msgcontains(msg, 'dress') and msgcontains(msg, 'pattern') and QuestValue(233) == 4 then
  159.         npcHandler:say("The mail with Talphion's instructions just arrived. I remember we asked Queen Eloise of Carlin for the perfect colours. Go there, ask her about the UNIFORMS and report back here.")
  160.         SetQuestValue(233,5)
  161.     elseif Topic == 21 and msgcontains(msg, 'yes') then
  162.         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.")
  163.         SetQuestValue(245,1)
  164.         doPlayerAddItem(cid, 2333, 1)
  165.     elseif Topic == 19 then
  166.         if msgcontains(msg, 'yes') then
  167.             if doPlayerRemoveItem(cid, 2332, 1) == TRUE then
  168.                 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?")
  169.                 SetQuestValue(246,1)
  170.                 SetQuestValue(249,4)
  171.                 n = 20
  172.             else
  173.                 npcHandler:say("Hm, no, you don't have it. Too bad, go and look for it.")
  174.             end
  175.         else
  176.             npcHandler:say("Too bad, go and look for it.")
  177.         end
  178.     elseif Topic == 20 and msgcontains(msg, 'yes') then
  179.         if QuestValue(250) < QuestValue(249) then
  180.             npcHandler:say("Your eagerness is a virtue, young one, but first lets talk about advancement.")
  181.         else
  182.             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 the bag on his mailbox and report back here.")
  183.             SetQuestValue(244,1)
  184.         end
  185.     elseif Topic == 17 and msgcontains(msg, 'yes') then
  186.         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?")
  187.         n = 18
  188.     elseif Topic == 18 then
  189.         if msgcontains(msg, 'yes') then
  190.             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.")
  191.             SetQuestValue(242,1)
  192.         else
  193.             npcHandler:say("Too bad, perhaps you will try some other time then.")
  194.         end
  195.     elseif Topic == 16 and msgcontains(msg, 'yes') then
  196.         if QuestValue(250) < QuestValue(249) then
  197.             npcHandler:say("Your eagerness is a virtue, young one, but first let's talk about advancement.")
  198.         else
  199.             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.")
  200.             SetQuestValue(234,1)
  201.         end
  202.     elseif Topic == 15 then
  203.         if msgcontains(msg, 'yes') then
  204.             npcHandler:say("Good. Go there and find out what taste he dislikes most: moldy cheese, a piece of fur or a bananaskin. 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.")
  205.             SetQuestValue(233,7)
  206.             SetQuestValue(251,math.random(3))
  207.         else
  208.             npcHandler:say("Too bad, perhaps you can try doing it some other time then.")
  209.         end
  210.     elseif Topic == 14 and msgcontains(msg, 'yes') then
  211.         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 a contract for new uniforms.")
  212.         SetQuestValue(233,1)
  213.     elseif Topic == 13 and msgcontains(msg, 'yes') then
  214.         if QuestValue(250) < QuestValue(249) then
  215.             npcHandler:say("Your eagerness is a virtue, young one, but first lets talk about advancement.")
  216.         else
  217.             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.")
  218.             SetQuestValue(231,1)
  219.         end
  220.     elseif Topic == 12 then
  221.         if msgcontains(msg, 'yes') and doPlayerRemoveItem(cid, 2230, 1) == TRUE then
  222.             SetQuestValue(230,QuestValue(230)+1)
  223.             npcHandler:say("Excellent! You have collected " .. QuestValue(230)-1 .. " bones. Just report about your mission again if you find  more.")
  224.         else
  225.             npcHandler:say("You have no suitable bone with you. Too bad, but you surely will find some more.")
  226.         end
  227.     elseif Topic == 22 then
  228.         if msgcontains(msg, 'yes') and doPlayerRemoveItem(cid, 2230, 1) == TRUE then
  229.             SetQuestValue(230,QuestValue(230)+1)
  230.             npcHandler:say("You have collected all the " .. QuestValue(230)-1 .. " bones needed. Excellent! Now let's talk about further missions if you are interested.")
  231.             SetQuestValue(249,2)
  232.         else
  233.             npcHandler:say("You have no suitable bone with you. Too bad, but you surely will find some more.")
  234.         end
  235.     elseif Topic == 24 and msgcontains(msg, 'one') and doPlayerRemoveItem(cid, 2230, 1) == TRUE then
  236.         SetQuestValue(230,QuestValue(230)+1)
  237.         npcHandler:say("Excellent! You have collected " .. QuestValue(230)-1 .. " bones. Just report about your mission again if you find more.")
  238.     elseif Topic == 24 and msgcontains(msg, 'all') then -- don't combine!
  239.         npcHandler:say("Are you sure you have collected all the 20 bones needed?")
  240.         n = 25
  241.     elseif Topic == 25 then
  242.         if msgcontains(msg, 'yes') and doPlayerRemoveItem(cid, 2230, 20) == TRUE then
  243.             SetQuestValue(230,21)
  244.             npcHandler:say("You have collected all the 20 bones needed. Excellent! Now let's talk about further missions if you are interested.")
  245.             SetQuestValue(249,2)
  246.         else
  247.             npcHandler:say("You have not enough bones with you. Too bad, but you surely will find some more.")
  248.         end
  249.     elseif Topic == 11 and msgcontains(msg, 'yes') then
  250.         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.")
  251.         SetQuestValue(230,1)
  252.     elseif Topic == 9 and msgcontains(msg, 'yes') then
  253.         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?")
  254.         SetQuestValue(250,1)
  255.         SetQuestValue(249,1)
  256.         n = 10
  257.     elseif Topic == 10 and msgcontains(msg, 'yes') then
  258.         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.")
  259.         doPlayerAddItem(cid, 2329, 1)
  260.         SetQuestValue(229,1)
  261.     elseif isInArray({9,10,11,13,14,16,17,20,21}, Topic) == TRUE then
  262.         npcHandler:say("Too bad, perhaps another time then.")
  263.     elseif Topic == 8 and msgcontains(msg, 'yes') then
  264.         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 the isle Folda. Get a crowbar and fix the mailbox. Report about your mission when you have done so.")
  265.         SetQuestValue(228,1)
  266.     elseif Topic == 1 and msgcontains(msg, 'yes') then
  267.         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?")
  268.         n = 2
  269.     elseif Topic == 2 and msgcontains(msg, 'yes') then
  270.         npcHandler:say("Excellent! Your first task will be quite simple. But you should better write my instructions down anyways. You can read and write?")
  271.         n = 3
  272.     elseif Topic == 3 then
  273.         if msgcontains(msg, 'yes') then
  274.             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?")
  275.             n = 4
  276.         else
  277.             npcHandler:say("I am sorry, but being illiterate disqualifies you from joining.")
  278.         end
  279.     elseif Topic == 4 and msgcontains(msg, 'yes') then
  280.         npcHandler:say("Excellent! Once you have done that you will travel with Uzon to Edron. You will find him in the Femor Hills. Understood?")
  281.         n = 5
  282.     elseif Topic == 5 and msgcontains(msg, 'yes') then
  283.         npcHandler:say("Fine, fine! Next, travel with Captain Seahorse to the city of Venore. Understood?")
  284.         n = 6
  285.     elseif Topic == 6 and msgcontains(msg, 'yes') then
  286.         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?")
  287.         n = 7
  288.     elseif Topic == 7 and msgcontains(msg, 'yes') then
  289.         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.")
  290.         SetQuestValue(227,1)
  291.     elseif isInArray({1,2,4,5,6,7,8}, Topic) == TRUE then
  292.         npcHandler:say("I thought so. The mail service is not for just anyone.")
  293.     elseif msgcontains(msg, 'name') then
  294.         npcHandler:say("My name is Kevin. Kevin Postner, that is.")
  295.     elseif msgcontains(msg, 'job') then
  296.         npcHandler:say("I am the head of the Tibian Postmaster's Guild.")
  297.     elseif msgcontains(msg, 'guild') or msgcontains(msg, 'postmaster') then
  298.         npcHandler:say("We are a powerful organisation that is vital part of Tibian society. It's a honour and a privilege to be a member.")
  299.     elseif msgcontains(msg, 'academy') then
  300.         npcHandler:say("Ah, yes! One day I will found a postofficers academy. Perhaps with the help of our most able members. But rhats a task for another day.")
  301.     elseif msgcontains(msg, 'wally') then
  302.         npcHandler:say("Wally is my right hand, so to say. He is the head to our guilds office branch.")
  303.     elseif msgcontains(msg, 'branch') then
  304.         npcHandler:say("Well, thers the depot branch, the office brance, the delivery branch and some officers for special operations.")
  305.     end
  306.     Topic = n
  307.     CacheMap = {}
  308.     return true
  309. end
  310.  
  311. npcHandler:setMessage(MESSAGE_GREET, 'Greetings |PLAYERNAME|, what brings you here?')
  312. npcHandler:setMessage(MESSAGE_FAREWELL, 'Good bye.')
  313. npcHandler:setMessage(MESSAGE_WALKAWAY, 'How rude!')
  314. npcHandler:setMessage(MESSAGE_PLACEDINQUEUE, 'Please wait a moment.')
  315.  
  316. npcHandler:setCallback(CALLBACK_GREET, greetCallback)
  317. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
  318.  
  319. npcHandler:addModule(FocusModule:new())
Add Comment
Please, Sign In to add comment