Guest User

Untitled

a guest
Dec 1st, 2016
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 8.80 KB | None | 0 0
  1. local keywordHandler = KeywordHandler:new()
  2. local npcHandler = NpcHandler:new(keywordHandler)
  3. NpcSystem.parseParameters(npcHandler)
  4. local talkState = {}
  5. local Topic = {}
  6. local vocation = {}
  7. local town = {}
  8. local destination = {}
  9. local TOWN_ISLANDOFDESTINY = 6
  10. local islandOfDestinyEnabled = false
  11.  
  12. local config = {
  13.     vocations = {
  14.         ["sorcerer"] = {
  15.             text = "A SORCERER! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!",
  16.             vocationId = 1,
  17.             -- wand of vortex
  18.             {{2190, 1}},
  19.             -- health potion and mana potion
  20.             {{7618, 2}, {7620, 2}}
  21.         },
  22.  
  23.         ["druid"] = {
  24.             text = "A DRUID! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!",
  25.             vocationId = 2,
  26.             -- snakebite rod
  27.             {{2182, 1}},
  28.             -- health potion and mana potion
  29.             {{7618, 2}, {7620, 2}}
  30.         },
  31.  
  32.         ["paladin"] = {
  33.             text = "A PALADIN! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!",
  34.             vocationId = 3,
  35.             --equipment dwrven shield, 5 spear, ranger's cloak, ranger legs scarf, legion helmet
  36.             {{2525, 1}, {2389, 5}, {2660, 1}, {8923, 1}, {2643, 1}, {2661, 1}, {2480, 1}},
  37.             --container rope, shovel, health potion, bow, 50 arrow
  38.             {{2120, 1}, {2554, 1}, {7618, 1}, {18559, 1}, {2456, 1}, {2544, 50}}
  39.         },
  40.  
  41.         ["knight"] = {
  42.             text = "A KNIGHT! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!",
  43.             vocationId = 4,
  44.             --equipment dwarven shield, steel axe, brass armor, brass helmet, brass legs scarf
  45.             {{2525, 1}, {8601, 1}, {2465, 1}, {2460, 1}, {2478, 1}, {2643, 1}, {2661, 1}},
  46.             --container jagged sword, daramian mace, rope, shovel, health potion
  47.             {{8602, 1}, {2439, 1}, {2120, 1}, {18559, 1}, {2554, 1}, {7618, 1}}
  48.         }
  49.     }
  50. }
  51.  
  52. function onCreatureAppear(cid)              npcHandler:onCreatureAppear(cid)            end
  53. function onCreatureDisappear(cid)           npcHandler:onCreatureDisappear(cid)         end
  54. function onCreatureSay(cid, type, msg)      npcHandler:onCreatureSay(cid, type, msg)    end
  55. function onThink()                          npcHandler:onThink()                        end
  56. function onPlayerEndTrade(cid)              npcHandler:onPlayerEndTrade(cid)            end
  57. function onPlayerCloseChannel(cid)          npcHandler:onPlayerCloseChannel(cid)        end
  58.  
  59.  
  60. --///////////////////////////START SCRIPT(oracle))///////////////////////////--
  61. function greetCallback(cid)
  62.  
  63.     if(getPlayerLevel(cid) < 8) then
  64.         npcHandler:say("CHILD! COME BACK WHEN YOU HAVE GROWN UP!", cid)
  65.         return false
  66.     elseif(getPlayerLevel(cid) >= 9) then
  67.         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)
  68.         return false
  69.     else
  70.         local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
  71.         Topic[talkUser], vocation[talkUser], town[talkUser], destination[talkUser] = 0, 0, 0, 0
  72.         return true
  73.     end
  74. end
  75.  
  76. function creatureSayCallback(cid, type, msg)
  77.  
  78.     local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
  79.     if(not npcHandler:isFocused(cid)) then
  80.         return false
  81.      
  82.     elseif msgcontains(msg, "yes") and Topic[talkUser] == 0 then
  83.         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}, {VENORE} OR {THAIS}?", cid)
  84.         Topic[talkUser] = islandOfDestinyEnabled and 4 or 1
  85.  
  86.     elseif Topic[talkUser] == 0 then
  87.         npcHandler:unGreet(cid)
  88.      
  89.     elseif msgcontains(msg, "carlin") and Topic[talkUser] == 1 then
  90.         npcHandler:say("IN CARLIN! AND WHAT PROFESSION HAVE YOU CHOSEN: {KNIGHT}, {PALADIN}, {SORCERER}, OR {DRUID}?", cid)
  91.         Topic[talkUser] = 2
  92.         town[talkUser] = 4
  93.         destination[talkUser] = {x=32360, y=31782, z=7}
  94.      
  95.     elseif msgcontains(msg, "ab'dendriel") and Topic[talkUser] == 1 then
  96.         npcHandler:say("IN AB'DENDRIEL! AND WHAT PROFESSION HAVE YOU CHOSEN: {KNIGHT}, {PALADIN}, {SORCERER}, OR {DRUID}?", cid)
  97.         Topic[talkUser] = 2
  98.         town[talkUser] = 5
  99.         destination[talkUser] = {x=32732, y=31634, z=7}
  100.      
  101.     elseif msgcontains(msg, "kazordoon") and Topic[talkUser] == 1 then
  102.         npcHandler:say("IN KAZORDOON! AND WHAT PROFESSION HAVE YOU CHOSEN: {KNIGHT}, {PALADIN}, {SORCERER}, OR {DRUID}?", cid)
  103.         Topic[talkUser] = 2
  104.         town[talkUser] = 3
  105.         destination[talkUser] = {x=32649, y=31925, z=11}
  106.      
  107.     elseif msgcontains(msg, "thais") and Topic[talkUser] == 1 then
  108.         npcHandler:say("IN THAIS! AND WHAT PROFESSION HAVE YOU CHOSEN: {KNIGHT}, {PALADIN}, {SORCERER}, OR {DRUID}?", cid)
  109.         Topic[talkUser] = 2
  110.         town[talkUser] = 2
  111.         destination[talkUser] = {x=32369, y=32241, z=7}
  112.      
  113.     elseif msgcontains(msg, "venore") and Topic[talkUser] == 1 then
  114.         npcHandler:say("IN VENORE! AND WHAT PROFESSION HAVE YOU CHOSEN: {KNIGHT}, {PALADIN}, {SORCERER}, OR {DRUID}?", cid)
  115.         Topic[talkUser] = 2
  116.         town[talkUser] = 1
  117.         destination[talkUser] = {x=32957, y=32076, z=7}
  118.      
  119.     elseif Topic[talkUser] == 1 then
  120.         npcHandler:say("{CARLIN}, {AB'DENDRIEL}, {KAZORDOON}, {VENORE} OR {THAIS}?", cid)
  121.         Topic[talkUser] = 1
  122.      
  123.      
  124.     elseif msgcontains(msg, "sorcerer") and Topic[talkUser] == 2 then
  125.         npcHandler:say("A SORCERER! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!", cid)
  126.         Topic[talkUser] = 3
  127.         vocation[talkUser] = 1
  128.      
  129.     elseif msgcontains(msg, "druid") and Topic[talkUser] == 2 then
  130.         npcHandler:say("A DRUID! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!", cid)
  131.         Topic[talkUser] = 3
  132.         vocation[talkUser] = 2
  133.      
  134.     elseif msgcontains(msg, "paladin") and Topic[talkUser] == 2 then
  135.         npcHandler:say("A PALADIN! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!", cid)
  136.         Topic[talkUser] = 3
  137.         vocation[talkUser] = 3
  138.      
  139.     elseif msgcontains(msg, "knight") and Topic[talkUser] == 2 then
  140.         npcHandler:say("A KNIGHT! ARE YOU SURE? THIS DECISION IS IRREVERSIBLE!", cid)
  141.         Topic[talkUser] = 3
  142.         vocation[talkUser] = 4
  143.      
  144.     elseif Topic[talkUser] == 2 then
  145.         npcHandler:say("{KNIGHT}, {PALADIN}, {SORCERER}, OR {DRUID}?", cid)
  146.         Topic[talkUser] = 2
  147.      
  148.     elseif msgcontains(msg, "yes") and Topic[talkUser] == 3 then
  149.         npcHandler:say("SO BE IT!", cid)
  150.         Topic[talkUser] = 0
  151.         doPlayerSetVocation(cid, vocation[talkUser])
  152.         doPlayerSetTown(cid, town[talkUser])
  153.         npcHandler:releaseFocus(cid)
  154.         doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
  155.         doTeleportThing(cid, destination[talkUser])
  156.         doSendMagicEffect(destination[talkUser], CONST_ME_TELEPORT)
  157.         local targetVocation = config.vocations[Vocation(vocation[talkUser]):getName():lower()]
  158.             for i = 1, #targetVocation[1] do
  159.                 player:addItem(targetVocation[1][i][1], targetVocation[1][i][2])
  160.             end
  161.             local backpack = player:addItem(1987)
  162.             for i = 1, #targetVocation[2] do
  163.                 backpack:addItem(targetVocation[2][i][1], targetVocation[2][i][2])
  164.             end
  165.      
  166.     elseif Topic[talkUser] == 3 then
  167.         npcHandler:unGreet(cid)
  168.      
  169.     elseif Topic[talkUser] == 4 then
  170.         if msgcontains(msg, "yes") then
  171.             npcHandler:say("SO BE IT!", cid)
  172.             Topic[talkUser] = 0
  173.             doPlayerSetTown(cid, TOWN_ISLANDOFDESTINY)
  174.             npcHandler:releaseFocus(cid)
  175.             doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
  176.             doTeleportThing(cid, {x=32091,y=32027,z=7})
  177.             doSendMagicEffect({x=32091,y=32027,z=7}, CONST_ME_TELEPORT)
  178.             doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Welcome to the Island of Destiny. Walk north to find trainers who will help you find a suitable vocation.")
  179.             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.")
  180.             doAddMapMark(cid, {x=32099,y=31996,z=7}, MAPMARK_EXCLAMATION, "Island of Destiny - Training Centre")
  181.             doAddMapMark(cid, {x=32098,y=31986,z=7}, MAPMARK_GREENNORTH, "Ship to Mainland")
  182.         else
  183.             npcHandler:unGreet(cid)
  184.         end
  185.     end
  186.     return true
  187. end
  188.  
  189. --///////////////////////////END SCRIPT(oracle)///////////////////////////--
  190.  
  191. npcHandler:setCallback(CALLBACK_GREET, greetCallback)
  192. npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
  193. npcHandler:addModule(FocusModule:new())
Advertisement
Add Comment
Please, Sign In to add comment