Guest User

Untitled

a guest
Apr 8th, 2015
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.69 KB | None | 0 0
  1. local keywordHandler = KeywordHandler:new()
  2. local npcHandler = NpcHandler:new(keywordHandler)
  3. NpcSystem.parseParameters(npcHandler)
  4.  
  5. local Topic, vocation, town, destination = {}, {}, {}, {}
  6. local TOWN_ISLANDOFDESTINY = 16
  7. local islandOfDestinyEnabled = false
  8.  
  9. function onCreatureAppear(cid)       npcHandler:onCreatureAppear(cid)       end
  10. function onCreatureDisappear(cid)     npcHandler:onCreatureDisappear(cid)       end
  11. function onCreatureSay(cid, type, msg)     npcHandler:onCreatureSay(cid, type, msg)     end
  12. function onThink()         npcHandler:onThink()           end
  13.  
  14. function greetCallback(cid)
  15. if(getPlayerLevel(cid) < 8) then
  16. npcHandler:say("CHILD! COME BACK WHEN YOU HAVE GROWN UP!", cid)
  17. return false
  18. elseif(getPlayerLevel(cid) > 9) then
  19. npcHandler:say(getCreatureName(cid) .. ", I CAN'T LET YOU LEAVE - YOU ARE TOO STRONG ALREADY! YOU CAN ONLY LEAVE WITH LEVEL 9 OR LOWER.", cid)
  20. return false
  21. else
  22. local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
  23. Topic[talkUser], vocation[talkUser], town[talkUser], destination[talkUser] = 0, 0, 0, 0
  24. return true
  25. end
  26. end
  27.  
  28. function creatureSayCallback(cid, type, msg)
  29. local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
  30. if(not npcHandler:isFocused(cid)) then
  31. return false
  32. elseif msgcontains(msg, "yes") and Topic[talkUser] == 0 then
  33. npcHandler:say(islandOfDestinyEnabled and "I WILL BRING YOU TO THE ISLAND OF DESTINY AND YOU WILL BE UNABLE TO RETURN HERE! ARE YOU SURE?" or "IN WHICH TOWN DO YOU WANT TO LIVE: {CARLIN}, {AB'DENDRIEL}, {KAZORDOON}" .. (isPremium(cid) == TRUE and ", {THAIS}, {VENORE}, {DARASHIA}, {ANKRAHMUN}, {EDRON} OR {PORT HOPE}?" or " OR {THAIS}?"), cid)
  34. Topic[talkUser] = islandOfDestinyEnabled and 4 or 1
  35. elseif Topic[talkUser] == 0 then
  36. npcHandler:unGreet(cid)
  37. elseif msgcontains(msg, "carlin") and Topic[talkUser] == 1 then
  38. npcHandler:say("IN CARLIN! AND WHAT PROFESSION HAVE YOU CHOSEN: {KNIGHT}, {PALADIN}, {SORCERER}, OR {DRUID}?", cid)
  39. Topic[talkUser] = 2
  40. town[talkUser] = 2
  41. destination[talkUser] = {x=32360, y=31782, z=7}
  42. elseif msgcontains(msg, "ab'dendriel") and Topic[talkUser] == 1 then
  43. npcHandler:say("IN AB'DENDRIEL! AND WHAT PROFESSION HAVE YOU CHOSEN: {KNIGHT}, {PALADIN}, {SORCERER}, OR {DRUID}?", cid)
  44. Topic[talkUser] = 2
  45. town[talkUser] = 3
  46. destination[talkUser] = {x=32732, y=31634, z=7}
  47. elseif msgcontains(msg, "kazordoon") and Topic[talkUser] == 1 then
  48. npcHandler:say("IN KAZORDOON! AND WHAT PROFESSION HAVE YOU CHOSEN: {KNIGHT}, {PALADIN}, {SORCERER}, OR {DRUID}?", cid)
  49. Topic[talkUser] = 2
  50. town[talkUser] = 4
  51. destination[talkUser] = {x=32649, y=31925, z=11}
  52. elseif msgcontains(msg, "thais") and Topic[talkUser] == 1 then
  53. npcHandler:say("IN THAIS! AND WHAT PROFESSION HAVE YOU CHOSEN: {KNIGHT}, {PALADIN}, {SORCERER}, OR {DRUID}?", cid)
  54. Topic[talkUser] = 2
  55. town[talkUser] = 5
  56. destination[talkUser] = {x=32369, y=32241, z=7}
  57. elseif msgcontains(msg, "venore") and Topic[talkUser] == 1 then
  58. npcHandler:say("IN VENORE! AND WHAT PROFESSION HAVE YOU CHOSEN: {KNIGHT}, {PALADIN}, {SORCERER}, OR {DRUID}?", cid)
  59. Topic[talkUser] = 2
  60. town[talkUser] = 6
  61. destination[talkUser] = {x=32957, y=32076, z=7}
  62. elseif msgcontains(msg, "darashia") and Topic[talkUser] == 1 then
  63. if isPremium(cid) == TRUE then
  64. npcHandler:say("IN DARASHIA! AND WHAT PROFESSION HAVE YOU CHOSEN: {KNIGHT}, {PALADIN}, {SORCERER}, OR {DRUID}?", cid)
  65. Topic[talkUser] = 2
  66. town[talkUser] = 7
  67. destination[talkUser] = {x=33213, y=32454, z=1}
  68. else
  69. npcHandler:say("YOU NEED A PREMIUM ACCOUNT IN ORDER TO GO THERE!", cid)
  70. Topic[talkUser] = 1
  71. end
  72. elseif msgcontains(msg, "ankrahmun") and Topic[talkUser] == 1 then
  73. if isPremium(cid) == TRUE then
  74. npcHandler:say("IN ANKRAHMUN! AND WHAT PROFESSION HAVE YOU CHOSEN: {KNIGHT}, {PALADIN}, {SORCERER}, OR {DRUID}?", cid)
  75. Topic[talkUser] = 2
  76. town[talkUser] = 8
  77. destination[talkUser] = {x=33194, y=32853, z=8}
  78. else
  79. npcHandler:say("YOU NEED A PREMIUM ACCOUNT IN ORDER TO GO THERE!", cid)
  80. Topic[talkUser] = 1
  81. end
  82. elseif msgcontains(msg, "edron") and Topic[talkUser] == 1 then
  83. if isPremium(cid) == TRUE then
  84. npcHandler:say("IN EDRON! AND WHAT PROFESSION HAVE YOU CHOSEN: {KNIGHT}, {PALADIN}, {SORCERER}, OR {DRUID}?", cid)
  85. Topic[talkUser] = 2
  86. town[talkUser] = 9
  87. destination[talkUser] = {x=33217, y=31814, z=8}
  88. else
  89. npcHandler:say("YOU NEED A PREMIUM ACCOUNT IN ORDER TO GO THERE!", cid)
  90. Topic[talkUser] = 1
  91. end
  92. elseif msgcontains(msg, "port") and msgcontains(msg, "hope") and Topic[talkUser] == 1 then
  93. if isPremium(cid) == TRUE then
  94. npcHandler:say("IN PORT HOPE! AND WHAT PROFESSION HAVE YOU CHOSEN: {KNIGHT}, {PALADIN}, {SORCERER}, OR {DRUID}?", cid)
  95. Topic[talkUser] = 2
  96. town[talkUser] = 10
  97. destination[talkUser] = {x=32595, y=32744, z=6}
  98. else
  99. npcHandler:say("YOU NEED A PREMIUM ACCOUNT IN ORDER TO GO THERE!", cid)
  100. Topic[talkUser] = 1
  101. end
  102. elseif Topic[talkUser] == 1 then
  103. npcHandler:say("{CARLIN}, {AB'DENDRIEL}, {KAZORDOON}" .. (isPremium(cid) == TRUE and ", {THAIS}, {VENORE}, {DARASHIA}, {ANKRAHMUN}, {EDRON} OR {PORT HOPE}?" or " OR {THAIS}?"), cid)
  104. Topic[talkUser] = 1
  105. elseif msgcontains(msg, "sorcerer") and Topic[talkUser] == 2 then
  106. npcHandler:say("A SORCERER! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!", cid)
  107. Topic[talkUser] = 3
  108. vocation[talkUser] = 1
  109. elseif msgcontains(msg, "druid") and Topic[talkUser] == 2 then
  110. npcHandler:say("A DRUID! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!", cid)
  111. Topic[talkUser] = 3
  112. vocation[talkUser] = 2
  113. elseif msgcontains(msg, "paladin") and Topic[talkUser] == 2 then
  114. npcHandler:say("A PALADIN! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!", cid)
  115. Topic[talkUser] = 3
  116. vocation[talkUser] = 3
  117. elseif msgcontains(msg, "knight") and Topic[talkUser] == 2 then
  118. npcHandler:say("A KNIGHT! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!", cid)
  119. Topic[talkUser] = 3
  120. vocation[talkUser] = 4
  121. elseif Topic[talkUser] == 2 then
  122. npcHandler:say("{KNIGHT}, {PALADIN}, {SORCERER}, OR {DRUID}?", cid)
  123. Topic[talkUser] = 2
  124. elseif msgcontains(msg, "yes") and Topic[talkUser] == 3 then
  125. npcHandler:say("SO BE IT!", cid)
  126. Topic[talkUser] = 0
  127. doPlayerSetVocation(cid, vocation[talkUser])
  128. doPlayerSetTown(cid, town[talkUser])
  129. npcHandler:releaseFocus(cid)
  130. doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
  131. doTeleportThing(cid, destination[talkUser])
  132. doSendMagicEffect(destination[talkUser], CONST_ME_TELEPORT)
  133. elseif Topic[talkUser] == 3 then
  134. npcHandler:unGreet(cid)
  135. elseif Topic[talkUser] == 4 then
  136. if msgcontains(msg, "yes") then
  137. npcHandler:say("SO BE IT!", cid)
  138. Topic[talkUser] = 0
  139. doPlayerSetTown(cid, TOWN_ISLANDOFDESTINY)
  140. npcHandler:releaseFocus(cid)
  141. doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
  142. doTeleportThing(cid, {x=32091,y=32027,z=7})
  143. doSendMagicEffect({x=32091,y=32027,z=7}, CONST_ME_TELEPORT)
  144. doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Welcome to the Island of Destiny. Walk north to find trainers who will help you find a suitable vocation.")
  145. doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "The surface of this island is a protection zone. You can't attack or regain health here. If you need healing, talk to Yandur.")
  146. doAddMapMark(cid, {x=32099,y=31996,z=7}, MAPMARK_EXCLAMATION, "Island of Destiny - Training Centre")
  147. doAddMapMark(cid, {x=32098,y=31986,z=7}, MAPMARK_GREENNORTH, "Ship to Mainland")
  148. else
  149. npcHandler:unGreet(cid)
  150. end
  151. end
  152. return TRUE
  153. end
  154.  
  155. npcHandler:setMessage(MESSAGE_GREET, "|PLAYERNAME|, ARE YOU PREPARED TO FACE YOUR DESTINY?")
  156. npcHandler:setMessage(MESSAGE_WALKAWAY, "COME BACK WHEN YOU ARE PREPARED TO FACE YOUR DESTINY!")
  157. npcHandler:setMessage(MESSAGE_FAREWELL, "COME BACK WHEN YOU ARE PREPARED TO FACE YOUR DESTINY!")
  158.  
  159. npcHandler:setCallback(CALLBACK_GREET, greetCallback)
  160. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
  161. npcHandler:addModule(FocusModule:new())
Add Comment
Please, Sign In to add comment