Guest User

Bluebear

a guest
Nov 1st, 2015
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.87 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. -- OTServ event handling functions start
  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. function greetCallback(cid)
  14. if getPlayerSex(cid) == 1 then
  15. npcHandler:setMessage(MESSAGE_GREET, "Welcome on board, Sir ".. getPlayerName(cid) ..".")
  16. return true
  17. else
  18. npcHandler:setMessage(MESSAGE_GREET, "Welcome on board, Madam ".. getPlayerName(cid) ..".")
  19. return true
  20. end
  21. end
  22.  
  23. npcHandler:setCallback(CALLBACK_GREET, greetCallback)
  24.  
  25. local shopModule = ShopModule:new()
  26. npcHandler:addModule(shopModule)
  27.  
  28. keywordHandler:addKeyword({'name'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "My name is Captain Bluebear from the Royal Tibia Line."})
  29. keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I am the captain of this sailing-ship."})
  30. keywordHandler:addKeyword({'captain'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I am the captain of this sailing-ship."})
  31. keywordHandler:addKeyword({'ship'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "The Royal Tibia Line connects all seaside towns of Tibia."})
  32. keywordHandler:addKeyword({'line'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "The Royal Tibia Line connects all seaside towns of Tibia."})
  33. keywordHandler:addKeyword({'company'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "The Royal Tibia Line connects all seaside towns of Tibia."})
  34. keywordHandler:addKeyword({'route'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "The Royal Tibia Line connects all seaside towns of Tibia."})
  35. keywordHandler:addKeyword({'tibia'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "The Royal Tibia Line connects all seaside towns of Tibia."})
  36. keywordHandler:addKeyword({'good'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "We can transport everything you want."})
  37. keywordHandler:addKeyword({'passenger'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "We would like to welcome you on board."})
  38. keywordHandler:addKeyword({'trip'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Where do you want to go? To Carlin, Ab'Dendriel, Venore, Port Hope or Edron?"})
  39. keywordHandler:addKeyword({'passage'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Where do you want to go? To Carlin, Ab'Dendriel, Venore, Port Hope or Edron?"})
  40. keywordHandler:addKeyword({'town'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Where do you want to go? To Carlin, Ab'Dendriel, Venore, Port Hope or Edron?"})
  41. keywordHandler:addKeyword({'destination'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Where do you want to go? To Carlin, Ab'Dendriel, Venore, Port Hope or Edron?"})
  42. keywordHandler:addKeyword({'sail'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Where do you want to go? To Carlin, Ab'Dendriel, Venore, Port Hope or Edron?"})
  43. keywordHandler:addKeyword({'go'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Where do you want to go? To Carlin, Ab'Dendriel, Venore, Port Hope or Edron?"})
  44. keywordHandler:addKeyword({'ice'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I'm sorry, but we don't serve the routes to the Ice Islands."})
  45. keywordHandler:addKeyword({'senja'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I'm sorry, but we don't serve the routes to the Ice Islands."})
  46. keywordHandler:addKeyword({'folda'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I'm sorry, but we don't serve the routes to the Ice Islands."})
  47. keywordHandler:addKeyword({'vega'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I'm sorry, but we don't serve the routes to the Ice Islands."})
  48. keywordHandler:addKeyword({'darashia'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I'm not sailing there. This route is afflicted by a ghostship! However I've heard that Captain Fearless from Venore sails there."})
  49. keywordHandler:addKeyword({'darama'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I'm not sailing there. This route is afflicted by a ghostship! However I've heard that Captain Fearless from Venore sails there."})
  50. keywordHandler:addKeyword({'ghost'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Many people who sailed to Darashia never returned because they were attacked by a ghostship! I'll never sail there!"})
  51. keywordHandler:addKeyword({'thais'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "This is Thais. Where do you want to go?"})
  52.  
  53. function creatureSayCallback(cid, type, msg)
  54. if(npcHandler.focus ~= cid) then
  55. return false
  56. end
  57.  
  58. local carlin = {x=32387,y=31821,z=6, stackpos=0}
  59. local abdendriel = {x=32733,y=31668,z=6, stackpos=0}
  60. local edron = {x=33175,y=31764,z=6, stackpos=0}
  61. local venore = {x=32954,y=32023,z=6, stackpos=0}
  62. local porthope = {x=32530,y=32784,z=6, stackpos=0}
  63.  
  64. -- Carlin
  65. if msgcontains(msg, 'carlin') then
  66. if isPlayerVip(cid) == TRUE then
  67. npcHandler:say('Do you seek a passage to Carlin for free?')
  68. talk_state = 1
  69. town_boat = carlin
  70. else
  71. npcHandler:say('Do you seek a passage to Carlin for 110 gold?')
  72. talk_state = 1
  73. price = 110
  74. town_boat = carlin
  75.  
  76. -- Ab'Dendriel
  77. elseif msgcontains(msg, 'ab\'dendriel') then
  78. if isPlayerVip(cid) == TRUE then
  79. npcHandler:say('Do you seek a passage to Ab\'Dendriel for free?')
  80. talk_state = 1
  81. town_boat = abdendriel
  82. else
  83. npcHandler:say('Do you seek a passage to Ab\'Dendriel for 130 gold?')
  84. talk_state = 1
  85. price = 130
  86. town_boat = abdendriel
  87. end
  88.  
  89. -- Edron
  90. elseif msgcontains(msg, 'edron') then
  91. if isPlayerVip(cid) == TRUE then
  92. npcHandler:say('Do you seek a passage to Edron for free?')
  93. talk_state = 1
  94. town_boat = edron
  95. else
  96. npcHandler:say('Do you seek a passage to Edron for 160 gold?')
  97. talk_state = 1
  98. price = 160
  99. town_boat = edron
  100. end
  101.  
  102. -- Venore
  103. elseif msgcontains(msg, 'venore') then
  104. if isPlayerVip(cid) == TRUE then
  105. npcHandler:say('Do you seek a passage to Venore for free?')
  106. talk_state = 1
  107. town_boat = venore
  108. else
  109. npcHandler:say('Do you seek a passage to Venore for 170 gold?')
  110. talk_state = 1
  111. price = 170
  112. town_boat = venore
  113. end
  114.  
  115. -- Port Hope
  116. elseif msgcontains(msg, 'port hope') then
  117. if isPlayerVip(cid) == TRUE then
  118. npcHandler:say('Do you seek a passage to Port Hope for free?')
  119. talk_state = 1
  120. town_boat = porthope
  121. else
  122. npcHandler:say('Do you seek a passage to Port Hope for 160 gold?')
  123. talk_state = 1
  124. price = 160
  125. town_boat = porthope
  126. end
  127.  
  128. -- Confirm Yes or No
  129. elseif msgcontains(msg, 'yes') and talk_state == 1 then
  130. if isPremium(cid) == TRUE then
  131. if getTilePzInfo(getPlayerPosition(cid)) == 1 then
  132. if getPlayerMoney(cid) >= price or isPlayerVip(cid) == TRUE then
  133. if isPlayerVip(cid) == TRUE then
  134. selfSay('Set the sails!')
  135. doTeleportThing(cid, town_boat)
  136. doSendMagicEffect(getCreaturePosition(cid), 10)
  137. talk_state = 0
  138. else
  139. selfSay('Set the sails!')
  140. doPlayerRemoveMoney(cid, price)
  141. doTeleportThing(cid, town_boat)
  142. doSendMagicEffect(getCreaturePosition(cid), 10)
  143. talk_state = 0
  144. end
  145. else
  146. npcHandler:say('You don\'t have enough money.')
  147. talk_state = 0
  148. end
  149. else
  150. npcHandler:say('First get rid of those blood stains! You are not going to ruin my vehicle!')
  151. talk_state = 0
  152. end
  153. else
  154. npcHandler:say('I\'m sorry, but you need a premium account in order to travel onboard our ships.')
  155. talk_state = 0
  156. end
  157. elseif msgcontains(msg, 'no') and talk_state == 1 then
  158. npcHandler:say('We would like to serve you some time.')
  159. talk_state = 0
  160. end
  161.  
  162. return TRUE
  163. end
  164.  
  165. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
  166. npcHandler:addModule(FocusModule:new())
Add Comment
Please, Sign In to add comment