Advertisement
Guest User

Untitled

a guest
Aug 31st, 2015
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.75 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. function oracle(cid, message, keywords, parameters, node)
  11. if(not npcHandler:isFocused(cid)) then
  12. return false
  13. end
  14.  
  15. local cityNode = node:getParent():getParent()
  16. local vocNode = node:getParent()
  17.  
  18. local destination = cityNode:getParameters().destination
  19. local town = cityNode:getParameters().town
  20. local vocation = vocNode:getParameters().vocation
  21.  
  22. if(destination ~= nil and vocation ~= nil and town ~= nil) then
  23. if(getPlayerLevel(cid) < parameters.level) then
  24. npcHandler:say('You must first reach level ' .. parameters.level .. '!', cid)
  25. npcHandler:resetNpc()
  26. else
  27. if(getPlayerVocation(cid) > 0) then
  28. npcHandler:say('Sorry, You already have a vocation!')
  29. npcHandler:resetNpc()
  30. else
  31. doPlayerSetVocation(cid, vocation)
  32. doPlayerSetTown(cid, town)
  33. npcHandler:resetNpc()
  34.  
  35. local tmp = getCreaturePosition(cid)
  36. doTeleportThing(cid, destination)
  37. doSendMagicEffect(tmp, CONST_ME_POFF)
  38. doSendMagicEffect(destination, CONST_ME_TELEPORT)
  39. end
  40. end
  41. end
  42.  
  43. return true
  44. end
  45.  
  46. function greetCallback(cid)
  47. if(getPlayerLevel(cid) < 8) then
  48. npcHandler:say('COME BACK WHEN YOU GROW UP, CHILD!')
  49. return false
  50. else
  51. return true
  52. end
  53. end
  54. npcHandler:setCallback(CALLBACK_GREET, greetCallback)
  55. npcHandler:setMessage(MESSAGE_GREET, 'Hello |PLAYERNAME|. Are you prepared to face your destiny?')
  56.  
  57. local yesNode = KeywordNode:new({'yes'}, oracle, {level = 12})
  58. local noNode = KeywordNode:new({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, moveup = 1, text = 'Then what vocation do you want to become?'})
  59.  
  60. local node1 = keywordHandler:addKeyword({'yes'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'What city do you wish to live in? {Rhyves}, {Varak} or {Jorvik}?'})
  61. local node2 = node1:addChildKeyword({'varak'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, town = 1, destination = {x=242, y=429, z=12}, text = 'Varak, eh? So what vocation do you wish to become? {Sorcerer}, {druid}, {paladin} or {knight}?'})
  62. local node3 = node2:addChildKeyword({'sorcerer'}, StdModule.say, {npcHandler = npcHandler, vocation = 1, onlyFocus = true, text = 'So, you wish to be a powerful magician? Are you sure about that? This decision is irreversible!'})
  63. node3:addChildKeywordNode(yesNode)
  64. node3:addChildKeywordNode(noNode)
  65. node3 = node2:addChildKeyword({'druid'}, StdModule.say, {npcHandler = npcHandler, vocation = 2, onlyFocus = true, text = 'Are you sure that a druid is what you wish to become? This decision is irreversible!'})
  66. node3:addChildKeywordNode(yesNode)
  67. node3:addChildKeywordNode(noNode)
  68. node3 = node2:addChildKeyword({'paladin'}, StdModule.say, {npcHandler = npcHandler, vocation = 3, onlyFocus = true, text = 'A ranged marksman. Are you sure? This decision is irreversible!'})
  69. node3:addChildKeywordNode(yesNode)
  70. node3:addChildKeywordNode(noNode)
  71. node3 = node2:addChildKeyword({'knight'}, StdModule.say, {npcHandler = npcHandler, vocation = 4, onlyFocus = true, text = 'A mighty warrior. Is that your final decision? This decision is irreversible!'})
  72. node3:addChildKeywordNode(yesNode)
  73. node3:addChildKeywordNode(noNode)
  74.  
  75. keywordHandler:addKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Then come back when you are ready.'})
  76.  
  77. npcHandler:addModule(FocusModule:new())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement