Advertisement
holmbergfan

Untitled

Nov 28th, 2022
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.31 KB | None | 0 0
  1. dofile(getDataDir() .. 'global/greeting.lua')
  2.  
  3. local keywordHandler = KeywordHandler:new()
  4. local npcHandler = NpcHandler:new(keywordHandler)
  5. NpcSystem.parseParameters(npcHandler)
  6.  
  7.  
  8.  
  9. -- OTServ event handling functions start
  10. function onCreatureAppear(cid)              npcHandler:onCreatureAppear(cid) end
  11. function onCreatureDisappear(cid)           npcHandler:onCreatureDisappear(cid) end
  12. function onCreatureSay(cid, type, msg)  npcHandler:onCreatureSay(cid, type, msg) end
  13. function onThink()                      npcHandler:onThink() end
  14.  
  15. local shopModule = ShopModule:new()
  16. npcHandler:addModule(shopModule)
  17.  
  18. shopModule:addSellableItem({'rune'},                    Cfblankrune, 10)
  19.  
  20.  
  21. keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Job? JOB? Hey man - I am in prison! But you know - once upon a time - I was a powerful mage! A mage ... come to think of it .., what is that - a mage?"})
  22. keywordHandler:addKeyword({'name'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "My name is - uhm - hang on? I knew it yesterday, didn't I? Doesn't matter!"})
  23. keywordHandler:addKeyword({'time'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Better save time than comitting a crime. I am a poet and I know it!"})
  24. keywordHandler:addKeyword({'sorcerer'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I am the mightiest sorcerer from here to there! Yeah!"})
  25. keywordHandler:addKeyword({'power'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Power. Hmmm. Once while we were crossing the mountains together a man named Aureus said to me that parcels are equal to power. Any idea what that meant?"})
  26. keywordHandler:addKeyword({'books'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I have many books in my home. But only powerful people can read them. I bet you will only see three dots after the headline! Hehehe! Hahaha! Excellent!"})
  27. keywordHandler:addKeyword({'mad mage'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Hey! That's me! You got it! Thanks mate - now I remember my name!"})
  28. keywordHandler:addKeyword({'riddle'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Great riddle, isn´t it? If you can tell me the correct answer, I will give you something. Hehehe!"})
  29. keywordHandler:addKeyword({'something'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "No! I won´t tell you. Shame coz it would be useful for you - hehehe."})
  30. keywordHandler:addKeyword({'escape'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "How could I escape? They only give me rotten food here. I can´t regain my powers because I have no mana!"})
  31. keywordHandler:addKeyword({'key'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Sure I have the key! Hehehe! Perhaps I will give it to you. IF you can solve my riddle."})
  32. keywordHandler:addKeyword({'mino'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "They are trying to capture me! Or hang on! Haven't they already captured me? Hmmm - I will have to think about this."})
  33. keywordHandler:addKeyword({'markwin'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "He is the worst of them all! He is the king of the minos! May he burn in hell!"})
  34. keywordHandler:addKeyword({'labyrinth'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "It´s easy to find your way through it! Just follow the pools of mud. Hehe - useful hint, isn´t it?"})
  35. keywordHandler:addKeyword({'way'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "It´s easy to find your way through it! Just follow the pools of mud. Hehe - useful hint, isn´t it?"})
  36. keywordHandler:addKeyword({'palkar'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "He is the leader of the outcasts. I hope he will never conquer the city of Mintwallin. That would be the end of me!"})
  37. keywordHandler:addKeyword({'karl'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Tataah!"})
  38. keywordHandler:addKeyword({'demon'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "The only monster I cannot conjure. But soon I will be powerful enough!"})
  39. keywordHandler:addKeyword({'monster'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Yeah! There are many monsters guarding my home. Only the bravest hero will be able to slay them!"})
  40. keywordHandler:addKeyword({'conjure'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Yeah! There are many monsters guarding my home. Only the bravest hero will be able to slay them!"})
  41. keywordHandler:addKeyword({'home'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Yeah! There are many monsters guarding my home. Only the bravest hero will be able to slay them!"})
  42.  
  43.  
  44. function creatureSayCallback(cid, type, msg) msg = string.lower(msg)
  45.     if(npcHandler.focus ~= cid) then
  46.         return false
  47.     end
  48. if msgcontains(msg, 'apple') or msgcontains(msg, 'Apple') then
  49.     NPCSay("Apples! Real apples! Man I love them! Can I have one? Oh please say yes!", 1)
  50.     aprisoner_talk_state = 1
  51.            
  52. elseif aprisoner_talk_state == 1 and msgcontains(msg, 'yes') or aprisoner_talk_state == 1 and msgcontains(msg, 'Yes') then
  53.     if doPlayerRemoveItem(cid, Cfapple, 1) == TRUE then
  54.     NPCSay("Mnjam. Excellent! Thanks, man!", 1)
  55.     else
  56.     NPCSay("Do you want to trick me? You don´t have one lousy apple!", 1)
  57.     end
  58.     aprisoner_talk_state = 0
  59. elseif aprisoner_talk_state == 1 and msgcontains(msg, '') then
  60.     NPCSay("Ooooooooooo.<sniff>", 1)
  61.     aprisoner_talk_state = 0
  62.  
  63. elseif msgcontains(msg, 'number') or msgcontains(msg, 'Number') or msgcontains(msg, 'math') or msgcontains(msg, '+') or msgcontains(msg, 'plus') then
  64.     if getPlayerStorageValue(cid, 8086) <= 0 then
  65.     NPCSay("My surreal numbers are based on astonishing facts. Are you interested in learning the secret of mathemagics?", 1)
  66.     aprisoner_talk_state = 7   
  67.     elseif getPlayerStorageValue(cid, 8086) >= 1 then
  68.     NPCSay("You already know the secrets of mathemagics! Now go and use them to learn.", 1)
  69.     end
  70.  
  71. elseif aprisoner_talk_state == 7 and msgcontains(msg, 'yes') or aprisoner_talk_state == 7 and msgcontains(msg, 'Yes') then
  72.     NPCSay("But first tell me your favourite colour please!", 1)
  73.     aprisoner_talk_state = 8
  74.  
  75. elseif aprisoner_talk_state == 8 and msgcontains(msg, '') then
  76.     NPCSay("Very interesting. So are you ready to proceed in you lesson in mathemagics?", 1)
  77.     aprisoner_talk_state = 9
  78.    
  79. elseif aprisoner_talk_state == 9 and msgcontains(msg, 'yes') or aprisoner_talk_state == 9 and msgcontains(msg, 'Yes') then
  80. THEMATH = math.random(1,4)
  81.     if THEMATH == 1 then
  82.     NPCSay("So know that everthing is based on the simple fact that 1 + 1 = 49!", 1)
  83.     elseif THEMATH == 2 then
  84.     NPCSay("So know that everthing is based on the simple fact that 1 + 1 = 94!", 1)
  85.     elseif THEMATH == 3 then
  86.     NPCSay("So know that everthing is based on the simple fact that 1 + 1 = 13!", 1)
  87.     elseif THEMATH == 4 then
  88.     NPCSay("So know that everthing is based on the simple fact that 1 + 1 = 1!", 1)
  89.     end
  90.     aprisoner_talk_state = 0
  91.     setPlayerStorageValue(cid, 8086, 1)
  92.  
  93. elseif aprisoner_talk_state == 8 and msgcontains(msg, '') then
  94.     NPCSay("I think you are not in touch with yourself, come back if you have tuned in on your own feelings.", 1)
  95.     aprisoner_talk_state = 0   
  96.  
  97. elseif msgcontains(msg, 'dp') or msgcontains(msg, 'pd') then
  98.     NPCSay("Hurray! For that I will give you my key for - hmm - let´s say ... some apples. Interested?", 1)
  99.     aprisoner_talk_state = 3
  100.  
  101. elseif aprisoner_talk_state == 3 and msgcontains(msg, 'yes') or aprisoner_talk_state == 3 and msgcontains(msg, 'Yes') then
  102.     if doPlayerRemoveItem(cid, Cfapple, 7) == TRUE then
  103.     NPCSay("Mnjam - excellent apples. Now - about that key. You are sure want it?", 1)
  104.     aprisoner_talk_state = 4
  105.     else
  106.     NPCSay("Get some more apples first!", 1)
  107.     aprisoner_talk_state = 0
  108.     end
  109. elseif aprisoner_talk_state == 3 and msgcontains(msg, '') then
  110.     NPCSay("Then go away!",1)
  111.     aprisoner_talk_state = 0
  112.     npcHandler:releaseFocus()
  113.     npcHandler:resetNpc()
  114.    
  115. elseif aprisoner_talk_state == 4 and msgcontains(msg, 'yes') or aprisoner_talk_state == 4 and msgcontains(msg, 'Yes') then
  116.     NPCSay("Really, really?", 1)
  117.     aprisoner_talk_state = 5
  118. elseif aprisoner_talk_state == 4 and msgcontains(msg, '') then
  119.     NPCSay("Then go away!", 1)
  120.     aprisoner_talk_state = 0
  121.     npcHandler:releaseFocus()
  122.     npcHandler:resetNpc()
  123.  
  124. elseif aprisoner_talk_state == 5 and msgcontains(msg, 'yes') or aprisoner_talk_state == 5 and msgcontains(msg, 'Yes') then
  125.     NPCSay("Really, really, really, really?", 1)
  126.     aprisoner_talk_state = 6
  127. elseif aprisoner_talk_state == 5 and msgcontains(msg, '') then
  128.     NPCSay("Then go away!", 1)
  129.     aprisoner_talk_state = 0
  130.     npcHandler:releaseFocus()
  131.     npcHandler:resetNpc()  
  132.    
  133. elseif aprisoner_talk_state == 6 and msgcontains(msg, 'yes') or aprisoner_talk_state == 6 and msgcontains(msg, 'Yes') then
  134.     NPCSay("Then take it and get happy - or die, hehe.", 1)
  135.     KEY = doPlayerAddItemStack(cid, Cfsilverkey, 1)
  136.     doSetItemActionId(KEY, 2036)
  137.     doSetItemSpecialDescription(KEY, "(Key: 3666)")
  138.     aprisoner_talk_state = 0
  139. elseif aprisoner_talk_state == 6 and msgcontains(msg, '') then
  140.     NPCSay("Then go away!", 1)
  141.     aprisoner_talk_state = 0
  142.    
  143. end    
  144.     return 1
  145. end
  146.  
  147.  
  148. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
  149. npcHandler:addModule(FocusModule:new())
  150.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement