Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local keywordHandler = KeywordHandler:new()
- local npcHandler = NpcHandler:new(keywordHandler)
- NpcSystem.parseParameters(npcHandler)
- function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
- function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
- function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
- function onThink() npcHandler:onThink() end
- local Topic = {}
- local story = {}
- local function cancelStory(cid)
- if not(story[cid]) then return true end
- for _, eventId in pairs(story[cid]) do
- stopEvent(eventId)
- end
- story[cid] = {}
- end
- function creatureFarewell(cid)
- if not(isPlayer(cid)) then
- return true
- end
- cancelStory(cid)
- return true
- end
- npcHandler:setCallback(CALLBACK_FAREWELL, creatureFarewell)
- npcHandler:setCallback(CALLBACK_CREATURE_DISAPPEAR, creatureFarewell)
- function creatureSayCallback(cid, type, msg)
- if(not npcHandler:isFocused(cid)) then
- return false
- end
- local player = Player(cid)
- local t = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
- local delayTime = 5*1000
- if isInArray({"quest", "mission", "sumail"}, msg:lower()) and player:getStorageValue(STORAGEVALUE_DJINNQUEST) < 0 and Topic[t] == nil then
- npcHandler:say("I can help you build trust with Sumail, but you will need to help me first. Are you interested?", cid)
- Topic[t] = 1
- elseif msgcontains(msg, "trade") then
- npcHandler:say("{Sumail} is the one that do the trading.", cid)
- Topic[t] = nil
- elseif msgcontains(msg, "yes") and Topic[t] == 1 and player:getStorageValue(STORAGEVALUE_DJINNQUEST) < 0 then
- npcHandler:say("Our families don't like each other, but me and Sumail are really close, you know? I'm thinking about cooking him a special meal, I need you to steal a special cook book from the elves.", cid)
- player:setStorageValue(STORAGEVALUE_DJINNQUEST, 1)
- player:setStorageValue(6025, 1) -- magic door
- Topic[t] = nil
- elseif isInArray({"meal", "book", "mission", "cookbook"}, msg:lower()) and player:getStorageValue(STORAGEVALUE_DJINNQUEST) == 1 then
- if player:removeItem(2347, 1) then
- npcHandler:say("Ohh, thanks! That's exactly what I was needing. I will tell Sumail you the one that got the recipe. Would you {help} me more?", cid)
- player:setStorageValue(STORAGEVALUE_DJINNQUEST, 2)
- player:addExperience(10 * 1000, true)
- player:setStorageValue(6025, 0) -- magic door
- Topic[t] = 1
- else
- npcHandler:say("Please, I need this special meal to pleasure Sumail.", cid)
- Topic[t] = nil
- end
- elseif ((msgcontains(msg, "yes") and Topic[t] == 1) or msgcontains(msg, "help")) and player:getStorageValue(STORAGEVALUE_DJINNQUEST) == 2 then
- npcHandler:say("Ok, I will be honest with you, what I will ask you now has nothing to do with Sumail, but I really need help with it. I haven't been able to travel with my magic capert lately because it need some {repair}.", cid)
- Topic[t] = nil
- elseif msgcontains(msg, "repair") and player:getStorageValue(STORAGEVALUE_DJINNQUEST) == 2 then
- npcHandler:say("It has some holes, I need a blue fabric to fix it. I heard whispers about a person in Stonegate that deal with blue tapestry, I need just one.", cid)
- player:setStorageValue(STORAGEVALUE_DJINNQUEST, 3)
- Topic[t] = nil
- elseif isInArray({"blue", "tapestry", "mission", "blue tapestry", "fabric"}, msg:lower()) and player:getStorageValue(STORAGEVALUE_DJINNQUEST) == 3 then
- if player:removeItem(1872, 1) then
- npcHandler:say("It can't be better! My magic carpet will be gorgeous now. Should we get back to the Sumail {issue}?", cid)
- player:setStorageValue(STORAGEVALUE_DJINNQUEST, 4)
- player:addExperience(10 * 1000, true)
- Topic[t] = 1
- else
- npcHandler:say("I heard whispers about a person in Stonegate that deal with blue tapestry, I need just one.", cid)
- Topic[t] = nil
- end
- elseif ((msgcontains(msg, "yes") and Topic[t] == 1) or msgcontains(msg, "issue")) and player:getStorageValue(STORAGEVALUE_DJINNQUEST) == 4 then
- cancelStory(cid)
- story[cid] = selfStory({"I want to give Sumail a really special present, that he won't ever forget. He was set free from his magical lamp by the famous hero Alistar Lionheart.",
- "Alistar Lionheart is a really great person, I think he will concede me this favor, as he also appreciate the services Sumail did for him in the past.",
- "I need you to find him, and ask him for Sumail magic {lamp}. He went in a mission in the orc cave to the west."}, cid, delayTime)
- player:setStorageValue(STORAGEVALUE_DJINNQUEST, 5)
- player:setStorageValue(6026, 1) -- magic door
- Topic[t] = nil
- elseif isInArray({"lamp", "alistar", "mission", "dead"}, msg:lower()) and player:getStorageValue(STORAGEVALUE_DJINNQUEST) == 5 then
- npcHandler:say("Please find Alistar Lionheart and ask him for Sumail {lamp}.", cid)
- Topic[t] = nil
- elseif isInArray({"lamp", "alistar", "mission", "dead"}, msg:lower()) and player:getStorageValue(STORAGEVALUE_DJINNQUEST) == 6 then
- cancelStory(cid)
- story[cid] = selfStory({"Nooo! I can't believe, he was soo strong. Please do never mention this to Sumail, he will be hearthbroken by this notice, I will chose the best moment to tell him.",
- "But we shouldn't give up, you still up to help me find a {present}, right?"}, cid, delayTime)
- player:setStorageValue(STORAGEVALUE_DJINNQUEST, 7)
- player:setStorageValue(6026, 0) -- magic door
- Topic[t] = 1
- elseif ((msgcontains(msg, "yes") and Topic[t] == 1) or msgcontains(msg, "present")) and player:getStorageValue(STORAGEVALUE_DJINNQUEST) == 7 then
- npcHandler:say("Great. In the bloodborne library, there is a bookshelf with a special book. Sumail is a real bookworm, and would love this rare volume. Try to find it in the Monastery of Angels.", cid)
- player:setStorageValue(STORAGEVALUE_DJINNQUEST, 8)
- player:setStorageValue(6027, 1) -- magic door
- Topic[t] = nil
- elseif isInArray({"book", "special", "mission", "rare", "special book", "present", "rare volume", "volume"}, msg:lower()) and player:getStorageValue(STORAGEVALUE_DJINNQUEST) == 8 then
- if player:removeItem(8983, 1) then
- npcHandler:say("You are awesome, |PLAYERNAME|. I can't believe you really got it. Sumail will be so happy with me, ... I mean, with us! I will tell him everything, I'm sure it will soften his heart, talk to him about {trust}.", cid)
- player:setStorageValue(STORAGEVALUE_DJINNQUEST, 9)
- player:setStorageValue(6027, 0) -- magic door
- player:addExperience(10 * 1000, true)
- Topic[t] = 1
- else
- npcHandler:say("Please bring me the rare book from bloodborne library.", cid)
- Topic[t] = nil
- end
- elseif msgcontains(msg, "mission") and player:getStorageValue(STORAGEVALUE_DJINNQUEST) >= 9 then
- npcHandler:say("I have no more missions for you, my friend.", cid)
- Topic[t] = nil
- end
- return true
- end
- --[[
- -- Travel
- local function addTravelKeyword(keyword, cost, destination)
- local travelKeyword = keywordHandler:addKeyword({keyword}, StdModule.say, {npcHandler = npcHandler, text = 'Do you seek a passage to ' .. keyword:titleCase() .. ' for |TRAVELCOST|?', cost = cost, discount = 'postman'})
- travelKeyword:addChildKeyword({'yes'}, StdModule.travel, {npcHandler = npcHandler, premium = true, cost = cost, discount = 'postman', destination = destination})
- travelKeyword:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, text = 'We would like to serve you some time.', reset = true})
- end
- addTravelKeyword('stonegate', 140, Position(494, 488, 6))
- ]]--
- -- Basic
- keywordHandler:addKeyword({'sail'}, StdModule.say, {npcHandler = npcHandler, text = 'The winds are dangerous today, sorry.'})
- keywordHandler:addAliasKeyword({'passage'})
- keywordHandler:addAliasKeyword({'city'})
- keywordHandler:addAliasKeyword({'cities'})
- keywordHandler:addAliasKeyword({'travel'})
- keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, text = 'I am a licensed carpetpilot'})
- keywordHandler:addKeyword({'name'}, StdModule.say, {npcHandler = npcHandler, text = 'I\'m Saahil Arora.'})
- npcHandler:setMessage(MESSAGE_GREET, 'Be greeted, human |PLAYERNAME|. How can a humble djinn be of service?')
- npcHandler:setMessage(MESSAGE_FAREWELL, 'Finally.')
- npcHandler:setMessage(MESSAGE_WALKAWAY, 'Finally.')
- npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
- npcHandler:addModule(FocusModule:new())
Add Comment
Please, Sign In to add comment