Advertisement
Guest User

Untitled

a guest
Nov 12th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.99 KB | None | 0 0
  1. dofile(getDataDir() .. 'npc/scripts/lib/greeting.lua')
  2.  
  3. local keywordHandler = KeywordHandler:new()
  4. local npcHandler = NpcHandler:new(keywordHandler)
  5. NpcSystem.parseParameters(npcHandler)
  6.  
  7. -- OTServ event handling functions
  8. function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
  9. function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
  10. function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
  11. function onThink() npcHandler:onThink() end
  12.  
  13. local shopModule = ShopModule:new()
  14. npcHandler:addModule(shopModule)
  15.  
  16. -- interesting option for a module here
  17. -- get more creative as they get drunk?
  18. shopModule:addBuyableItem({'beer'}, 2006, 10, 3)
  19. shopModule:addBuyableItem({'wine'}, 2689, 10, 15)
  20.  
  21. keywordHandler:addKeyword({'ship'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "My ship is on the desert. It doesn\'t look well but still can sail. Of course if you know how to steer it."})
  22.  
  23. function creatureSayCallback(cid, type, msg)
  24. if(npcHandler.focus ~= cid) then
  25. return false
  26. end
  27.  
  28. cname = creatureGetName(cid)
  29.  
  30. if talk_state == 0 then
  31. if msgcontains(msg, 'yes') then -- wanna go to mainland
  32. level = getPlayerLevel(cname)
  33.  
  34. if level >= mainlevel then
  35. npcHandler:say('Great! Do you want to be a knight, a paladin, a sorcerer or a druid?')
  36. talk_state = 1
  37. else
  38. npcHandler:say('Sorry, you need level ' .. mainlevel .. ' to go to the mainland.')
  39. talk_state = 0
  40. end
  41. else
  42. npcHandler:say('Come back when you are ready then.')
  43. talk_state = 0
  44. end
  45.  
  46. elseif talk_state == 1 then -- telling vocation
  47. talk_state = 2
  48.  
  49. if msgcontains(msg, 'sorcerer') then
  50. npcHandler:say('A mighty sorcerer! Are you sure?')
  51. vocation = 1
  52. elseif msgcontains(msg, 'druid') then
  53. npcHandler:say('A mysterious druid! Are you sure?')
  54. vocation = 2
  55. elseif msgcontains(msg, 'paladin') then
  56. npcHandler:say('A nimble paladin! Are you sure?')
  57. vocation = 3
  58. elseif msgcontains(msg, 'knight') then
  59. npcHandler:say('A valorous knight! Are you sure?')
  60. vocation = 4
  61. else
  62. npcHandler:say('Sorry, there is no such vocation.')
  63. vocation = 0
  64. talk_state = 1
  65. end
  66.  
  67. elseif talk_state == 2 then -- confirming vocation
  68. if msgcontains(msg, 'yes') then
  69. npcHandler:say('Great! I can send you to The City. Where do you want to go?')
  70. talk_state = 3
  71. else
  72. npcHandler:say('What vocation do you want then?')
  73. talk_state = 1
  74. end
  75.  
  76. elseif talk_state == 3 then -- telling city name
  77. if msgcontains(msg, 'city') then
  78. npcHandler:say('Good luck, young adventurer!')
  79. setPlayerVocation(cid,vocation)
  80. setPlayerMasterPos(cid,160,54,7)
  81. npcHandler:say('/send ' .. cname .. ', 160 54 7')
  82.  
  83. talk_state = 0
  84. focus = 0
  85. talk_start = 0
  86. else
  87. npcHandler:say('Sorry, there is no such city.')
  88. talk_state = 3
  89. end
  90. end
  91. end
  92.  
  93. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
  94. npcHandler:addModule(FocusModule:new())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement