Ir para conteúdo

Cip Rookgaard Npc's


tibiaa4e

Posts Recomendados

terá q ter esse sistema aki

 

jiddo system

 

 

creditos:Jiddo (NPC System, Oracle)

Me and Ispiro (NPCs)

Augusto Alvetoria and Deamon_OTS (ItemforItem function)

 

B]Al Dee[/b]

-- Al Dee

local internalCustomerQueue = {}
local keywordHandler = KeywordHandler:new({root = {}})
local npcHandler = ShopNpcHandler:new({})
local customerQueue = CustomerQueue:new({customers = internalCustomerQueue, handler = npcHandler})
npcHandler:init(customerQueue, keywordHandler)
npcHandler.walkDistance = 1


-- OTServ event handling functions start
function onThingMove(creature, thing, oldpos, oldstackpos)     npcHandler:onThingMove(creature, thing, oldpos, oldstackpos) end
function onCreatureAppear(creature)                             npcHandler:onCreatureAppear(creature) end
function onCreatureDisappear(id)                                 npcHandler:onCreatureDisappear(id) end
function onCreatureTurn(creature)                                 npcHandler:onCreatureTurn(creature) end
function onCreatureSay(cid, type, msg)                         npcHandler:onCreatureSay(cid, type, msg) end
function onCreatureChangeOutfit(creature)                         npcHandler:onCreatureChangeOutfit(creature) end
function onThink()                                             npcHandler:onThink() end
-- OTServ event handling functions end

-- Keyword handling functions start
function tradeItem(cid, message, keywords, parameters)     return npcHandler:defaultTradeHandler(cid, message, keywords, parameters) end
function confirmAction(cid, message, keywords, parameters) return npcHandler:defaultConfirmHandler(cid, message, keywords, parameters) end
function sayMessage(cid, message, keywords, parameters)     return npcHandler:defaultMessageHandler(cid, message, keywords, parameters) end

function greet(cid, message, keywords, parameters)     
   if npcHandler.focus == cid then
       selfSay('I am already talking to you.')
       npcHandler.talkStart = os.clock()
   elseif npcHandler.focus > 0 or not(npcHandler.queue:isEmpty()) then
       selfSay('I\'ll be with you in a moment, ' .. creatureGetName(cid) .. '.')
       if(not npcHandler.queue:isInQueue(cid)) then
           npcHandler.queue:pushBack(cid)
       end
   elseif(npcHandler.focus == 0) and (npcHandler.queue:isEmpty()) then
       selfSay('Hello hello, ' .. creatureGetName(cid) .. '!  Please come in, look, and buy!')
       npcHandler.focus = cid
       npcHandler.talkStart = os.clock()
   end
   
   return true
end

function farewell(cid, message, keywords, parameters)      
   if(cid == npcHandler.focus) then
       selfSay('Bye, bye')
       npcHandler:resetNpc()
       npcHandler.queue:greetNext()
       return true
   end
   return false
end

-- Keyword handling functions end

function itemForItem(cid, message, keywords, parameters)
if(getPlayerItemCount(cid, parameters.itemtrade) >= parameters.counti) then
doPlayerRemoveItem(cid, parameters.itemtrade, parameters.counti)
doPlayerAddItem(cid, parameters.itemtrade2, parameters.counti2)
selfSay('Splendid! Here take your pickaxe.')
else
selfSay('Sorry I\'m looking for a SMALL axe.')
end
end

-- Sell Item Keywords
keywordHandler:addKeyword({'sell', 'spear'},     tradeItem, {itemid = 2389, cost = 1, stackable = true})
keywordHandler:addKeyword({'sell', 'rapier'},     tradeItem, {itemid = 2384, cost = 1})
keywordHandler:addKeyword({'sell', 'sabre'},     tradeItem, {itemid = 2385, cost = 1})
keywordHandler:addKeyword({'sell', 'dagger'},     tradeItem, {itemid = 2379, cost = 1})
keywordHandler:addKeyword({'sell', 'sickle'},     tradeItem, {itemid = 2405, cost = 1})
keywordHandler:addKeyword({'sell', 'hand axe'},     tradeItem, {itemid = 2380, cost = 1})
keywordHandler:addKeyword({'sell', 'axe'},     tradeItem, {itemid = 2386, cost = 1})
keywordHandler:addKeyword({'sell', 'short sword'},     tradeItem, {itemid = 2406, cost = 1})
keywordHandler:addKeyword({'sell', 'jacket'},     tradeItem, {itemid = 2650, cost = 1})
keywordHandler:addKeyword({'sell', 'coat'},     tradeItem, {itemid = 2651, cost = 1})
keywordHandler:addKeyword({'sell', 'doublet'},     tradeItem, {itemid = 2485, cost = 1})
keywordHandler:addKeyword({'sell', 'leather armor'},     tradeItem, {itemid = 2467, cost = 1})
keywordHandler:addKeyword({'sell', 'leather legs'},     tradeItem, {itemid = 2649, cost = 1})
keywordHandler:addKeyword({'sell', 'leather helmet'},     tradeItem, {itemid = 2461, cost = 1})
keywordHandler:addKeyword({'sell', 'studded helmet'},     tradeItem, {itemid = 2482, cost = 1})
keywordHandler:addKeyword({'sell', 'chain helmet'},     tradeItem, {itemid = 2458, cost = 1})
keywordHandler:addKeyword({'sell', 'wooden shield'},     tradeItem, {itemid = 2512, cost = 1})
keywordHandler:addKeyword({'sell', 'studded shield'},     tradeItem, {itemid = 2526, cost = 1})

-- Buy Item Keywords

keywordHandler:addKeyword({'pick'},   sayMessage, {text = 'Picks are hard to come by. I trade them only for high quality small axes.', onlyfocus = true})
keywordHandler:addKeyword({'small', 'axe'}, itemForItem, {itemtrade = 2441, counti = 1, itemtrade2 = 2553, counti2 = 1})

keywordHandler:addKeyword({'rope'},     tradeItem, {itemid = 2120, cost = 50})
keywordHandler:addKeyword({'shovel'},     tradeItem, {itemid = 2554, cost = 10})
keywordHandler:addKeyword({'backpack'},     tradeItem, {itemid = 1988, cost = 10})
keywordHandler:addKeyword({'torch'},     tradeItem, {itemid = 2050, cost = 2})
keywordHandler:addKeyword({'machete'},     tradeItem, {itemid = 2420, cost = 30})
keywordHandler:addKeyword({'scythe'},     tradeItem, {itemid = 2550, cost = 12})
keywordHandler:addKeyword({'rod'},     tradeItem, {itemid = 2580, cost = 150})
keywordHandler:addKeyword({'worm'},     tradeItem, {itemid = 3976, cost = 5, charges = 6, realname = "6-pack of worms", stackable = true})

keywordHandler:addKeyword({'spear'},     tradeItem, {itemid = 2389, cost = 10, stackable = true})
keywordHandler:addKeyword({'rapier'},     tradeItem, {itemid = 2384, cost = 15})
keywordHandler:addKeyword({'sabre'},     tradeItem, {itemid = 2385, cost = 25})
keywordHandler:addKeyword({'dagger'},     tradeItem, {itemid = 2379, cost = 5})
keywordHandler:addKeyword({'sickle'},     tradeItem, {itemid = 2405, cost = 8})
keywordHandler:addKeyword({'hand', 'axe'},     tradeItem, {itemid = 2380, cost = 8})

keywordHandler:addKeyword({'short sword'},     tradeItem, {itemid = 2406, cost = 30})
keywordHandler:addKeyword({'jacket'},     tradeItem, {itemid = 2650, cost = 10})
keywordHandler:addKeyword({'coat'},     tradeItem, {itemid = 2651, cost = 8})
keywordHandler:addKeyword({'doublet'},     tradeItem, {itemid = 2485, cost = 16})
keywordHandler:addKeyword({'leather armor'},     tradeItem, {itemid = 2467, cost = 25})
keywordHandler:addKeyword({'leather legs'},     tradeItem, {itemid = 2649, cost = 10})
keywordHandler:addKeyword({'leather helmet'},     tradeItem, {itemid = 2461, cost = 12})
keywordHandler:addKeyword({'studded helmet'},     tradeItem, {itemid = 2482, cost = 63})
keywordHandler:addKeyword({'chain helmet'},     tradeItem, {itemid = 2458, cost = 52})
keywordHandler:addKeyword({'wooden shield'},     tradeItem, {itemid = 2512, cost = 15})
keywordHandler:addKeyword({'studded shield'},     tradeItem, {itemid = 2526, cost = 50})

keywordHandler:addKeyword({'yes'}, confirmAction, nil)
keywordHandler:addKeyword({'no'}, confirmAction, nil)

keywordHandler:addKeyword({'offer'},     sayMessage, {text = 'I sell weapons, shields, armor, helmets, and equipment. For what do you want to ask?', onlyfocus = true})
keywordHandler:addKeyword({'wares'},     sayMessage, {text = 'I sell weapons, shields, armor, helmets, and equipment. For what do you want to ask?', onlyfocus = true})
keywordHandler:addKeyword({'sell'},     sayMessage, {text = 'I sell much. Just read the blackboards for my awesome wares or just ask me.', onlyfocus = true})
keywordHandler:addKeyword({'job'},     sayMessage, {text = 'I am a merchant. What can I do for you?', onlyfocus = true})
keywordHandler:addKeyword({'weapon'},     sayMessage, {text = 'I sell spears, rapiers, sabres, daggers, hand axes, axes, and short swords. Just tell me what you want to buy.', onlyfocus = true})
keywordHandler:addKeyword({'armor'},    sayMessage, {text = 'I sell jackets, coats, doublets, leather armor, and leather legs. Just tell me what you want to buy.', onlyfocus = true})
keywordHandler:addKeyword({'helmet'},   sayMessage, {text = 'I sell leather helmets, studded helmets, and chain helmets. Just tell me what you want to buy.', onlyfocus = true})
keywordHandler:addKeyword({'shield'},   sayMessage, {text = 'I sell wooden shields and studded shields. Just tell me what you want to buy.', onlyfocus = true})
keywordHandler:addKeyword({'equipment'},   sayMessage, {text = 'I sell torches, shovels, picks, backpacks, sickles, scythes, ropes, worms and fishing rods. Just tell me what you want to buy.', onlyfocus = true})
keywordHandler:addKeyword({'name'},   sayMessage, {text = 'My name is Al Dee, but you can call me Al. Do you want to buy something?', onlyfocus = true})
keywordHandler:addKeyword({'monster'},   sayMessage, {text = 'If you want to challenge the monsters, you need some weapons and armor I sell. You need them definitely!', onlyfocus = true})
keywordHandler:addKeyword({'dungeon'},   sayMessage, {text = 'If you want to explore the dungeons, you have to equip yourself with the vital stuff I am selling. It\'s vital in the deepest sense of the word.', onlyfocus = true})
keywordHandler:addKeyword({'sewer'},   sayMessage, {text = 'Oh, our sewer system is very primitive; so primitive it\'s overrun by rats. But the stuff I sell is safe from them. Do you want to buy some of it?', onlyfocus = true})
keywordHandler:addKeyword({'king'},   sayMessage, {text = 'The king encouraged salesmen to travel here, but only I dared to take the risk, and a risk it was!', onlyfocus = true})
keywordHandler:addKeyword({'dallheim'},     sayMessage, {text = 'Some call him a hero.', onlyfocus = true})
keywordHandler:addKeyword({'bug'},     sayMessage, {text = 'Bugs plague this isle, but my wares are bugfree, totally bugfree.', onlyfocus = true})
keywordHandler:addKeyword({'stuff'},     sayMessage, {text = 'I sell equipment of all kinds, all kind available on this isle. Just ask me about my wares if you are interested.', onlyfocus = true})
keywordHandler:addKeyword({'tibia'},     sayMessage, {text = 'One day I will return to the continent as a rich, a very rich man!', onlyfocus = true})

keywordHandler:addKeyword({'hi'}, greet, nil)
keywordHandler:addKeyword({'hello'}, greet, nil)
keywordHandler:addKeyword({'hey'}, greet, nil)
keywordHandler:addKeyword({'bye'}, farewell, nil)
keywordHandler:addKeyword({'farewell'}, farewell, nil)
-- Keyword structure generation end

 

Billy

-- Billy

local internalCustomerQueue = {}
local keywordHandler = KeywordHandler:new({root = {}})
local npcHandler = ShopNpcHandler:new({})
local customerQueue = CustomerQueue:new({customers = internalCustomerQueue, handler = npcHandler})
npcHandler:init(customerQueue, keywordHandler)
npcHandler.walkDistance = 1


-- OTServ event handling functions start
function onThingMove(creature, thing, oldpos, oldstackpos)     npcHandler:onThingMove(creature, thing, oldpos, oldstackpos) end
function onCreatureAppear(creature)                             npcHandler:onCreatureAppear(creature) end
function onCreatureDisappear(id)                                 npcHandler:onCreatureDisappear(id) end
function onCreatureTurn(creature)                                 npcHandler:onCreatureTurn(creature) end
function onCreatureSay(cid, type, msg)                         npcHandler:onCreatureSay(cid, type, msg) end
function onCreatureChangeOutfit(creature)                         npcHandler:onCreatureChangeOutfit(creature) end
function onThink()                                             npcHandler:onThink() end
-- OTServ event handling functions end

-- Keyword handling functions start
function tradeItem(cid, message, keywords, parameters)     return npcHandler:defaultTradeHandler(cid, message, keywords, parameters) end
function confirmAction(cid, message, keywords, parameters) return npcHandler:defaultConfirmHandler(cid, message, keywords, parameters) end
function sayMessage(cid, message, keywords, parameters)     return npcHandler:defaultMessageHandler(cid, message, keywords, parameters) end

function greet(cid, message, keywords, parameters)     
   if npcHandler.focus == cid then
       selfSay('I am already talking to you.')
       npcHandler.talkStart = os.clock()
   elseif npcHandler.focus > 0 or not(npcHandler.queue:isEmpty()) then
       selfSay('Can\'t you see i am talking? Wait!')
       if(not npcHandler.queue:isInQueue(cid)) then
           npcHandler.queue:pushBack(cid)
       end
   elseif(npcHandler.focus == 0) and (npcHandler.queue:isEmpty()) then
       selfSay('Howdy ' .. creatureGetName(cid) .. '.')
       npcHandler.focus = cid
       npcHandler.talkStart = os.clock()
   end
   
   return true
end

function farewell(cid, message, keywords, parameters)      
   if(cid == npcHandler.focus) then
       selfSay('Bye.')
       npcHandler:resetNpc()
       npcHandler.queue:greetNext()
       return true
   end
   return false
end

-- Keyword handling functions end

-- Sell Item Keywords
keywordHandler:addKeyword({'sell', 'bread'},     tradeItem, {itemid = 2689, cost = 1, stackable = true})
keywordHandler:addKeyword({'sell', 'cheese'},     tradeItem, {itemid = 2696, cost = 1})
keywordHandler:addKeyword({'sell', 'meat'},     tradeItem, {itemid = 2666, cost = 1, stackable = true})
keywordHandler:addKeyword({'sell', 'ham'},     tradeItem, {itemid = 2671, cost = 1, stackable = true})
keywordHandler:addKeyword({'sell', 'salmon'},     tradeItem, {itemid = 2668, cost = 1, stackable = true})
keywordHandler:addKeyword({'sell', 'fish'},     sayMessage, {text = '"Go away with this stinking $#%^"', onlyfocus = true})
keywordHandler:addKeyword({'sell', 'cherry'},     tradeItem, {itemid = 2679, cost = 1, stackable = true})

keywordHandler:addKeyword({'sell', 'rat'},     tradeItem, {itemid = 2813, cost = 2})

-- Buy Item Keywords
keywordHandler:addKeyword({'bread'},     tradeItem, {itemid = 2689, cost = 3, stackable = true})
keywordHandler:addKeyword({'cheese'},     tradeItem, {itemid = 2696, cost = 5})
keywordHandler:addKeyword({'meat'},     tradeItem, {itemid = 2666, cost = 5, stackable = true})
keywordHandler:addKeyword({'ham'},     tradeItem, {itemid = 2671, cost = 8, stackable = true})

keywordHandler:addKeyword({'yes'}, confirmAction, nil)
keywordHandler:addKeyword({'no'}, confirmAction, nil)

keywordHandler:addKeyword({'offer'},     sayMessage, {text = 'I can offer you bread, cheese, ham, or meat.', onlyfocus = true})
keywordHandler:addKeyword({'wares'},     sayMessage, {text = 'I can offer you bread, cheese, ham, or meat.', onlyfocus = true})
keywordHandler:addKeyword({'sell'},     sayMessage, {text = 'I sell various kinds of food.', onlyfocus = true})
keywordHandler:addKeyword({'job'},     sayMessage, {text = 'I am farmer and a cook.', onlyfocus = true})
keywordHandler:addKeyword({'cook'},     sayMessage, {text = 'I am the best cook around. You can sell me most types of food.', onlyfocus = true})
keywordHandler:addKeyword({'tibia'},    sayMessage, {text = 'There is so much to be explored! Better hurry to get to the continent!', onlyfocus = true})
keywordHandler:addKeyword({'cipfried'},   sayMessage, {text = 'He never leaves this temple and only has time to care about those new arivals.', onlyfocus = true})
keywordHandler:addKeyword({'amber'},   sayMessage, {text = 'Shes pretty indeed! I wonder if she likes bearded men.', onlyfocus = true})
keywordHandler:addKeyword({'god'},   sayMessage, {text = 'I am the god of cooking, indeed!', onlyfocus = true})
keywordHandler:addKeyword({'buy'},        sayMessage, {text = 'I buy food of most kind. Since I am a great cook I need much of it.', onlyfocus = true})
keywordHandler:addKeyword({'willie'},        sayMessage, {text = 'Don\'t listen to that old wannabe, I\'m the best cook around.', onlyfocus = true})
keywordHandler:addKeyword({'name'},        sayMessage, {text = 'Billy.', onlyfocus = true})
keywordHandler:addKeyword({'time'},        sayMessage, {text = 'I came here to have some peace and leisure so leave me alone with \'time\'.', onlyfocus = true})
keywordHandler:addKeyword({'help'},        sayMessage, {text = 'Can\'t help you, sorry. I\'m a cook, not a priest.', onlyfocus = true})
keywordHandler:addKeyword({'monster'},        sayMessage, {text = 'Don\'t be afraid, in the town you should be safe."', onlyfocus = true})
keywordHandler:addKeyword({'dungeon'},        sayMessage, {text = 'You\'ll find a lot of dungeons if you look around.', onlyfocus = true})
keywordHandler:addKeyword({'sewer'},        sayMessage, {text = 'The local sewers are infested by rats, fresh rats give a good stew, you can sell them to me.', onlyfocus = true})
keywordHandler:addKeyword({'king'},        sayMessage, {text = 'The king and his tax collectors are far away. You\'ll meet them soon enough."', onlyfocus = true})
keywordHandler:addKeyword({'obi'},        sayMessage, {text = 'I like him, we usualy have a drink or two once a week and share storys about Willie."', onlyfocus = true})
keywordHandler:addKeyword({'seymour'},        sayMessage, {text = 'I don\'t like his headmaster behaviour. Then again, he IS a headmaster after all.', onlyfocus = true})
keywordHandler:addKeyword({'dallheim'},        sayMessage, {text = 'One of the kings best men, here to protect us.', onlyfocus = true})
keywordHandler:addKeyword({'weapon'},        sayMessage, {text = 'Ask one of the shopkeepers. They make a fortune here with all those wannabe heroes.', onlyfocus = true})
keywordHandler:addKeyword({'spell'},        sayMessage, {text = 'I can spell but know no spell.', onlyfocus = true})
keywordHandler:addKeyword({'magic'},        sayMessage, {text = 'I can spell but know no spell.', onlyfocus = true})

keywordHandler:addKeyword({'hi'}, greet, nil)
keywordHandler:addKeyword({'hello'}, greet, nil)
keywordHandler:addKeyword({'hey'}, greet, nil)
keywordHandler:addKeyword({'bye'}, farewell, nil)
keywordHandler:addKeyword({'farewell'}, farewell, nil)
-- Keyword structure generation end

 

Amber

-- Amber

local internalCustomerQueue = {}
local keywordHandler = KeywordHandler:new({root = {}})
local npcHandler = ShopNpcHandler:new({})
local customerQueue = CustomerQueue:new({customers = internalCustomerQueue, handler = npcHandler})
npcHandler:init(customerQueue, keywordHandler)
npcHandler.walkDistance = 1


-- OTServ event handling functions start
function onThingMove(creature, thing, oldpos, oldstackpos)     npcHandler:onThingMove(creature, thing, oldpos, oldstackpos) end
function onCreatureAppear(creature)                             npcHandler:onCreatureAppear(creature) end
function onCreatureDisappear(id)                                 npcHandler:onCreatureDisappear(id) end
function onCreatureTurn(creature)                                 npcHandler:onCreatureTurn(creature) end
function onCreatureSay(cid, type, msg)                         npcHandler:onCreatureSay(cid, type, msg) end
function onCreatureChangeOutfit(creature)                         npcHandler:onCreatureChangeOutfit(creature) end
function onThink()                                             npcHandler:onThink() end
-- OTServ event handling functions end

-- Keyword handling functions start
function tradeItem(cid, message, keywords, parameters)     return npcHandler:defaultTradeHandler(cid, message, keywords, parameters) end
function confirmAction(cid, message, keywords, parameters) return npcHandler:defaultConfirmHandler(cid, message, keywords, parameters) end
function sayMessage(cid, message, keywords, parameters)     return npcHandler:defaultMessageHandler(cid, message, keywords, parameters) end

function greet(cid, message, keywords, parameters)     
   if npcHandler.focus == cid then
       selfSay('I am already talking to you.')
       npcHandler.talkStart = os.clock()
   elseif npcHandler.focus > 0 or not(npcHandler.queue:isEmpty()) then
       selfSay('Sorry, I\'m already talking to someone.')
       if(not npcHandler.queue:isInQueue(cid)) then
           npcHandler.queue:pushBack(cid)
       end
   elseif(npcHandler.focus == 0) and (npcHandler.queue:isEmpty()) then
       selfSay('Oh hello, nice to see you ' .. creatureGetName(cid) .. '.')
       npcHandler.focus = cid
       npcHandler.talkStart = os.clock()
   end
   
   return true
end

function farewell(cid, message, keywords, parameters)      
   if(cid == npcHandler.focus) then
       selfSay('See you later.')
       npcHandler:resetNpc()
       npcHandler.queue:greetNext()
       return true
   end
   return false
end

-- Keyword handling functions end

function itemForItem(cid, message, keywords, parameters)
if(getPlayerItemCount(cid, parameters.itemtrade) >= parameters.counti) then
doPlayerRemoveItem(cid, parameters.itemtrade, parameters.counti)
doPlayerAddItem(cid, parameters.itemtrade2, parameters.counti2)
selfSay('Excellent. Here, take this short sword, that might serve you well.')
else
selfSay('Hm, you don\'t have it.')
end
end

keywordHandler:addKeyword({'explore'},     sayMessage, {text = 'I have been almost everywhere in Tibia.', onlyfocus = true})
keywordHandler:addKeyword({'wares'},     sayMessage, {text = 'I fought fierce monsters, climbed the highest mountains, and crossed the sea on a raft.', onlyfocus = true})
keywordHandler:addKeyword({'sea'},     sayMessage, {text = 'My trip over the sea was horrible. The weather was bad, the waves high and my raft quite simple.', onlyfocus = true})
keywordHandler:addKeyword({'raft'},     sayMessage, {text = 'I left my raft at the south eastern shore. I forgot my private notebook on it. If you could return it to me I would be very grateful."', onlyfocus = true})
keywordHandler:addKeyword({'job'},     sayMessage, {text = 'I explore and seek adventure.', onlyfocus = true})
keywordHandler:addKeyword({'weapon'},     sayMessage, {text = 'The best weapons on this isle are just toothpicks, compared with the weapons warriors of the mainland wield.', onlyfocus = true})
keywordHandler:addKeyword({'tibia'},    sayMessage, {text = 'I try to explore each spot of Tibia, and one day I will succeed.', onlyfocus = true})
keywordHandler:addKeyword({'helmet'},   sayMessage, {text = 'Oh, I fought orcs, cyclopses, minotaurs, and even green dragons.', onlyfocus = true})
keywordHandler:addKeyword({'adventure'},     sayMessage, {text = 'I fought fierce monsters, climbed the highest mountains, and crossed the sea on a raft.', onlyfocus = true})
keywordHandler:addKeyword({'sea'},     sayMessage, {text = 'My trip over the sea was horrible. The weather was bad, the waves high and my raft quite simple.', onlyfocus = true})
keywordHandler:addKeyword({'time'},     sayMessage, {text = 'Sorry, I lost my watch in a storm.', onlyfocus = true})
keywordHandler:addKeyword({'help'},     sayMessage, {text = 'I can\'t help you much beyond information.', onlyfocus = true})
keywordHandler:addKeyword({'information'},     sayMessage, {text = 'Just ask and I\'ll try to answer.', onlyfocus = true})
keywordHandler:addKeyword({'dungeon'},     sayMessage, {text = 'I have not had the time to explore the dungeons of this isle, but I have seen two big caves in the east, and there is a ruined tower in the northwest.', onlyfocus = true})
keywordHandler:addKeyword({'sewer'},     sayMessage, {text = 'I like sewers. I made my very first battle experience in the Thais sewers. The small sewersystem of Rookgaard has some nasty rats to fight.', onlyfocus = true})
keywordHandler:addKeyword({'assistant'},     sayMessage, {text = 'I have a job of great responsibility. Mostly I keep annoying persons away from my boss.', onlyfocus = true})
keywordHandler:addKeyword({'monster'},     sayMessage, {text = 'Oh, I fought orcs, cyclopses, minotaurs, and even green dragons.', onlyfocus = true})
keywordHandler:addKeyword({'dragon'},     sayMessage, {text = 'Horrible monsters they are.', onlyfocus = true})
keywordHandler:addKeyword({'minotaur'},     sayMessage, {text = 'Horrible monsters they are.', onlyfocus = true})
keywordHandler:addKeyword({'cyclopse'},     sayMessage, {text = 'Horrible monsters they are.', onlyfocus = true})
keywordHandler:addKeyword({'seymour'},     sayMessage, {text = 'I think this poor guy was a bad choice as the head of the academy.', onlyfocus = true})
keywordHandler:addKeyword({'academy'},     sayMessage, {text = 'A fine institution, but it needs definitely more funds from the king.', onlyfocus = true})
keywordHandler:addKeyword({'king'},     sayMessage, {text = 'King Tibianus is the ruler of Thais.', onlyfocus = true})
keywordHandler:addKeyword({'thais'},     sayMessage, {text = 'A fine city, but the king has some problems enforcing the law.', onlyfocus = true})
keywordHandler:addKeyword({'cipfried'},     sayMessage, {text = 'A gentle person. You should visit him, if you have problems.', onlyfocus = true})
keywordHandler:addKeyword({'dallheim'},     sayMessage, {text = 'An extraordinary warrior. He\'s the first and last line of defense of Rookgaard.', onlyfocus = true})
keywordHandler:addKeyword({'hyacinth'},     sayMessage, {text = 'Hyacinth is a great healer. He lives somewhere hidden on this isle.', onlyfocus = true})
keywordHandler:addKeyword({'willie'},     sayMessage, {text = 'He\'s funny in his own, gruffy way.', onlyfocus = true})
keywordHandler:addKeyword({'obi'},     sayMessage, {text = 'He\'s a funny little man.', onlyfocus = true})
keywordHandler:addKeyword({'magic'},     sayMessage, {text = 'You can learn spells only in the guildhalls of the mainland.', onlyfocus = true})
keywordHandler:addKeyword({'castle'},     sayMessage, {text = 'If you travel to Thais, you really should visit the marvelous castle.', onlyfocus = true})

-- Notebook Quest
keywordHandler:addKeyword({'notebook'}, itemForItem, {itemtrade = 2325, counti = 1, itemtrade2 = 2406, counti2 = 1})

keywordHandler:addKeyword({'hi'}, greet, nil)
keywordHandler:addKeyword({'hello'}, greet, nil)
keywordHandler:addKeyword({'hey'}, greet, nil)
keywordHandler:addKeyword({'bye'}, farewell, nil)
keywordHandler:addKeyword({'farewell'}, farewell, nil)
-- Keyword structure generation end

 

Seymour

Note: You WILL need tradeItemForItem function, check here. It should be the last script.

 

-- Seymour

local internalCustomerQueue = {}
local keywordHandler = KeywordHandler:new({root = {}})
local npcHandler = ShopNpcHandler:new({})
local customerQueue = CustomerQueue:new({customers = internalCustomerQueue, handler = npcHandler})
npcHandler:init(customerQueue, keywordHandler)
npcHandler.walkDistance = 0

-- OTServ event handling functions start
function tradeItemForItem(cid, message, keywords, parameters)         
   if npcHandler.focus ~= cid then
       return false
   end
npcHandler.talkState = TALKSTATE_TRADE_ITEM
npcHandler.itemid1 = parameters.itemid1
npcHandler.itemid2 = parameters.itemid2
selfSay('Do you have a suitable present box for me?')
return true
end

function onThingMove(creature, thing, oldpos, oldstackpos)     npcHandler:onThingMove(creature, thing, oldpos, oldstackpos) end
function onCreatureAppear(creature)                             npcHandler:onCreatureAppear(creature) end
function onCreatureDisappear(id)                                 npcHandler:onCreatureDisappear(id) end
function onCreatureTurn(creature)                                 npcHandler:onCreatureTurn(creature) end
function onCreatureSay(cid, type, msg)                         npcHandler:onCreatureSay(cid, type, msg) end
function onCreatureChangeOutfit(creature)                         npcHandler:onCreatureChangeOutfit(creature) end
function onThink()                                             
   
   if (os.clock() - npcHandler.talkStart) > 40 then
       if npcHandler.focus > 0 then
           selfSay('Good bye! And remember: No running up and down in the academy!')
       end
       
       npcHandler:resetNpc()
       
       npcHandler.queue:greetNext()
   end
   
   local dist = getDistanceToCreature(npcHandler.focus)
   if dist > 4 then
       selfSay('Good bye! And remember: No running up and down in the academy!')
       npcHandler:resetNpc()
       npcHandler.queue:greetNext()
   end
   
   
   
   if npcHandler.focus == 0 then
 if(npcHandler.spawnPos == nil) then
 	local sx, sy, sz = selfGetPosition()
 	npcHandler.spawnPos = {x = sx, y = sy, z = sz}
 end
 	npcHandler.lastMove = walk(npcHandler.lastMove, npcHandler.spawnPos, npcHandler.walkDistance)
else
 npcHandler.lastPos = turnToCreature(npcHandler.focus, npcHandler.lastPos)
end
   
end

-- OTServ event handling functions end

-- Keyword handling functions start
function tradeItem(cid, message, keywords, parameters)     
   if npcHandler.focus ~= cid then
       return false
   end
   
   local tempcount = getCount(message)
   if(tempcount > 500) then
       tempcount = 500
   end
   
   if(parameters.realname ~= nil) then
       itemname = parameters.realname
   end
   
   local tradeKeyword = 'buy'

   if(parameters.realname == 'dead rat') then
       npcHandler.talkState = TALKSTATE_SELL_ITEM
   else
       npcHandler.talkState = TALKSTATE_BUY_ITEM
   end
   if(npcHandler.talkState == TALKSTATE_SELL_ITEM) then--"Have you brought a dead rat to me to pick up your reward?"
 if(tempcount ~= 1) then
 	selfSay('Have you broght ' .. tempcount .. ' ' .. itemname .. 's to me to pick up your reward?')
 else
 	selfSay('Have you broght a ' .. itemname .. ' to me to pick up your reward?')
 end
else --"Do you want to buy the Key to Adventure for 5 gold coins?"
 selfSay('Do you want to ' .. tradeKeyword .. ' the ' .. itemname .. ' for ' .. parameters.cost .. ' gold coins?')
 tempcount = 1
end	
   npcHandler:setActiveItem(parameters.itemid, tempcount, parameters.charges, tempcount*parameters.cost, (parameters.stackable ~= nil and parameters.stackable == true))
   return true
end

function confirmAction(cid, message, keywords, parameters) 
   if npcHandler.focus ~= cid then
       return false
   end
   if(keywords[1] == 'yes') then
       if(npcHandler.talkState == TALKSTATE_SELL_ITEM) then
           npcHandler.talkState = TALKSTATE_NONE
           local ret = doPlayerSellItem(npcHandler.focus, npcHandler.itemid, npcHandler.stackable, npcHandler.count, npcHandler.cost)
           if(ret == LUA_NO_ERROR) then
               selfSay('Thank you! Here is your reward.')
           else
   if(parameters.itemid2 ~= nil) then
   	local ret = doPlayerSellItem(npcHandler.focus, npcHandler.itemid2, npcHandler.stackable, npcHandler.count, npcHandler.cost)
   	if(ret == LUA_NO_ERROR) then
     selfSay('Thank you! Here is your reward.')
   	end	
   else
   	if(npcHandler.count == 1) then
     selfSay('HEY! You don\'t have one! Stop playing tricks on fooling me or I will give you some extra work!')
   	else
     selfSay('HEY! You do not have so many!')
   	end	
   end	
           end
       elseif(npcHandler.talkState == TALKSTATE_BUY_ITEM) then
           npcHandler.talkState = TALKSTATE_NONE
           local key = 0
           if(doPlayerRemoveMoney(cid, npcHandler.cost) == 1) then
   key = doPlayerAddItem(cid,npcHandler.itemid,npcHandler.count)
   doSetItemActionId(key,4600)
               selfSay('Here you are.')
           else
               selfSay('You don\'t have enough money.')
           end
       elseif(npcHandler.talkState == TALKSTATE_TRADE_ITEM) then
           npcHandler.talkState = TALKSTATE_NONE
 	if(doPlayerTakeItem(npcHandler.focus, npcHandler.itemid1, false, 1) == LUA_NO_ERROR) then
   local ret = 0
   ret = doPlayerGiveItem(npcHandler.focus, npcHandler.itemid2, false, 1)
   if(ret == LUA_NO_ERROR) then
   	selfSay('THANK YOU! Here is a helmet that will serve you well.')
   end	
 	else
   selfSay('HEY! You don\'t have one! Stop playing tricks on me or I will give some extra work!.')
 	end	
 end
   elseif(keywords[1] == 'no') then
       if(npcHandler.talkState == TALKSTATE_SELL_ITEM) then
           selfSay('Go and find some rats to kill!')
           npcHandler.talkState = TALKSTATE_NONE
       elseif(npcHandler.talkState == TALKSTATE_BUY_ITEM) then
           selfSay('As you wish.')
           npcHandler.talkState = TALKSTATE_NONE
       elseif(npcHandler.talkState == TALKSTATE_TRADE_ITEM) then
           selfSay('HEY! You don\'t have one! Stop playing tricks on me or I will give some extra work!')
           npcHandler.talkState = TALKSTATE_NONE  	
       end
   end
   
   return true
end

function sayMessage(cid, message, keywords, parameters)     return npcHandler:defaultMessageHandler(cid, message, keywords, parameters) end
function greet(cid, message, keywords, parameters)        

   if npcHandler.focus > 0 or not(npcHandler.queue:isEmpty()) then
if npcHandler.focus ~= cid then
       selfSay('Please, ' .. creatureGetName(cid) .. '. Wait for your turn!.')
       if(not npcHandler.queue:isInQueue(cid)) then
           npcHandler.queue:pushBack(cid)
       end
else
 npcHandler.talkStart = os.clock()
end	
   elseif(npcHandler.focus == 0) and (npcHandler.queue:isEmpty()) then
       selfSay('Hello, ' .. creatureGetName(cid) .. '. What do you need?')
       npcHandler.focus = cid
       npcHandler.talkStart = os.clock()
   end
   
   return true
end

function farewell(cid, message, keywords, parameters)      
   if(cid == npcHandler.focus) then
       selfSay('Good bye! And remember: No running up and down in the academy!')
       npcHandler:resetNpc()
       npcHandler.queue:greetNext()
       return true
   end
   return false
end

-- Keyword handling functions end
-- Keyword structure generation start
keywordHandler:addKeyword({'key'},     tradeItem, {itemid = 2088, cost = 5, realname = "Key to Adventure"})
keywordHandler:addKeyword({'rat'},     tradeItem, {itemid = 2813, itemid2 = 2814, cost = 2, realname = "dead rat"})
--keywordHandler:addKeyword({'magic sulpher'},    	tradeItemForItem, {itemid1 = 2392, count1 = 3, stackable1 = false, itemid2 = 5904, count2 = 1, cost = 0, prize = 0, stackable2 = true, itemname1 = "fire swords"})
keywordHandler:addKeyword({'box'},     tradeItemForItem, {itemid1 = 1990, itemid2 = 2480})
--Do you have a suitable present box for me?
keywordHandler:addKeyword({'yes'}, confirmAction, nil)
keywordHandler:addKeyword({'no'}, confirmAction, nil)


keywordHandler:addKeyword({'mission'},     sayMessage, {text = 'Well I would like to send our king a little present, but I do not have a suitable box. If you find a nice box, please bring it tome.', onlyfocus = true})
keywordHandler:addKeyword({'quest'},     sayMessage, {text = 'Well I would like to send our king a little present, but I do not have a suitable box. If you find a nice box, please bring it tome.', onlyfocus = true})
keywordHandler:addKeyword({'job'},     sayMessage, {text = 'I am the master of this fine academy.', onlyfocus = true})
keywordHandler:addKeyword({'tibia'},        sayMessage, {text = 'Oh, how I miss the crowded streets of Thais. I know one day I will get promoted and get a job at the castle... I must get outof here! The faster the better! It is people like you who are driving me mad.', onlyfocus = true})
keywordHandler:addKeyword({'seymour'},        sayMessage, {text = 'My name is Seymour, but to you I am \'Sir\' Seymour.', onlyfocus = true})
keywordHandler:addKeyword({'name'},     sayMessage, {text = 'My name is Seymour, but to you I am \'Sir\' Seymour.', onlyfocus = true})
keywordHandler:addKeyword({'cipfried'},        sayMessage, {text = 'A humble monk with healing powers, and a pupil of the great Quentin himself.', onlyfocus = true})
keywordHandler:addKeyword({'al', 'dee'},        sayMessage, {text = 'He is a shop owner in the northwestern part of the village.', onlyfocus = true})
keywordHandler:addKeyword({'amber'},        sayMessage, {text = 'A traveller from the main land. I wonder what brought her here, since no one comes here of his own free will.', onlyfocus = true})
keywordHandler:addKeyword({'dallheim'},        sayMessage, {text = 'Oh good Dallheim! What a fighter he is! Without him we would be doomed.', onlyfocus = true})
keywordHandler:addKeyword({'hyacinth'},        sayMessage, {text = 'A mysterious druid who lives somewhere in the wilderness. He sells precious life fluids.', onlyfocus = true})
keywordHandler:addKeyword({'obi'},        sayMessage, {text = 'A cousin of Thais\' smith Sam. He has a shop here where you can buy most stuff an adventurer needs.', onlyfocus = true})
keywordHandler:addKeyword({'willie'},        sayMessage, {text = 'Willie is a fine farmer, although he has short temper.', onlyfocus = true})
keywordHandler:addKeyword({'the oracle'},        sayMessage, {text = 'You will find the oracle upstairs. Talk to the oracle as soon as you have made level 8. Choose a vocation and a new hometown, and you will be sent off to the continent.', onlyfocus = true})

keywordHandler:addKeyword({'hi'}, greet, nil)
keywordHandler:addKeyword({'hello'}, greet, nil)
keywordHandler:addKeyword({'bye'}, farewell, nil)
-- Keyword structure generation end

 

continua

Link para o comentário
Compartilhar em outros sites

Cipfried

-- Cipfried

local internalCustomerQueue = {}
local keywordHandler = KeywordHandler:new({root = {}})
local npcHandler = ShopNpcHandler:new({})
local customerQueue = CustomerQueue:new({customers = internalCustomerQueue, handler = npcHandler})
npcHandler:init(customerQueue, keywordHandler)


-- OTServ event handling functions start
function onThingMove(creature, thing, oldpos, oldstackpos)     npcHandler:onThingMove(creature, thing, oldpos, oldstackpos) end
function onCreatureAppear(creature)                             npcHandler:onCreatureAppear(creature) end
function onCreatureDisappear(id)                                 npcHandler:onCreatureDisappear(id) end
function onCreatureTurn(creature)                                 npcHandler:onCreatureTurn(creature) end
function onCreatureSay(cid, type, msg)                         npcHandler:onCreatureSay(cid, type, msg) end
function onCreatureChangeOutfit(creature)                         npcHandler:onCreatureChangeOutfit(creature) end
function onThink()                                             
   
   if (os.clock() - npcHandler.talkStart) > 40 then
       if npcHandler.focus > 0 then
           selfSay('Well, bye then.')
       end
       
       npcHandler:resetNpc()
       
       npcHandler.queue:greetNext()
   end
   
   local dist = getDistanceToCreature(npcHandler.focus)
   if dist > 3 then
       selfSay('Well, bye then.')
       npcHandler:resetNpc()
       npcHandler.queue:greetNext()
   end
   
   
   
   if npcHandler.focus == 0 then
 if(npcHandler.spawnPos == nil) then
 	local sx, sy, sz = selfGetPosition()
 	npcHandler.spawnPos = {x = sx, y = sy, z = sz}
 end
 	npcHandler.lastMove = walk(npcHandler.lastMove, npcHandler.spawnPos, npcHandler.walkDistance)
else
 npcHandler.lastPos = turnToCreature(npcHandler.focus, npcHandler.lastPos)
end
   
end
-- OTServ event handling functions end

-- Keyword handling functions start
function healPlayer(cid, message, keywords, parameters)
if(getPlayerHealth(cid) < parameters.maxheal) then
 position = getPlayerPosition(npcHandler.focus)
 doSendMagicEffect(position, 12)
 local healHP = parameters.maxheal - getPlayerHealth(cid)
 doPlayerAddHealth(npcHandler.focus,healHP)
 selfSay('You are looking really bad. Let me heal your wounds.')
else
 selfSay('You aren\'t looking really bad, ' .. creatureGetName(cid) .. '. I only help in cases of real emergencies. Raise your health simply by eating food.')
end	
return true
end

function healPlayerNoMsg(cid, maxheal)
if(getPlayerHealth(cid) < maxheal) then
 position = getPlayerPosition(npcHandler.focus)
 doSendMagicEffect(position, 12)
 local healHP = maxheal - getPlayerHealth(cid)
 doPlayerAddHealth(npcHandler.focus,healHP)
 selfSay('Hello, ' .. creatureGetName(cid) .. '! You are looking really bad. Let me heal your wounds.')
end	
return true
end

function tradeItem(cid, message, keywords, parameters)     return npcHandler:defaultTradeHandler(cid, message, keywords, parameters) end
function confirmAction(cid, message, keywords, parameters) return npcHandler:defaultConfirmHandler(cid, message, keywords, parameters) end
function sayMessage(cid, message, keywords, parameters)     return npcHandler:defaultMessageHandler(cid, message, keywords, parameters) end
function greet(cid, message, keywords, parameters)       
   if (npcHandler.focus > 0 or not(npcHandler.queue:isEmpty()) and npcHandler.focus ~= cid) then
       selfSay('Please, ' .. creatureGetName(cid) .. '. Wait for your turn!.')
       if(not npcHandler.queue:isInQueue(cid)) then
           npcHandler.queue:pushBack(cid)
       end
   elseif(npcHandler.focus == 0) and (npcHandler.queue:isEmpty()) then
       npcHandler.focus = cid
       npcHandler.talkStart = os.clock()
 if(getPlayerHealth(cid) >= 65) then
 	selfSay('Hello, ' .. creatureGetName(cid) .. '! I will heal you if you are injured. Feel free to ask me for help.')
 else
 	healPlayerNoMsg(npcHandler.focus, 65)
 end  
   end
   
   return true
end

function farewell(cid, message, keywords, parameters)         return npcHandler:defaultFarewellHandler(cid, message, keywords, parameters) end

keywordHandler:addKeyword({'heal'},     healPlayer, {maxheal = 65})
keywordHandler:addKeyword({'help'},     healPlayer, {maxheal = 65})

keywordHandler:addKeyword({'yes'}, confirmAction, nil)
keywordHandler:addKeyword({'no'}, confirmAction, nil)


keywordHandler:addKeyword({'monk'},     sayMessage, {text = 'I sacrifice my life to serve the good gods of Tibia.', onlyfocus = true})
keywordHandler:addKeyword({'rookgaard'},     sayMessage, {text = 'The gods have chosen this isle as the point of arrival for the newborn souls.', onlyfocus = true})
keywordHandler:addKeyword({'god'},     sayMessage, {text = 'They created Tibia and all life on it. Visit our library and learn about them.', onlyfocus = true})
keywordHandler:addKeyword({'job'},     sayMessage, {text = 'I am just a humble monk. Ask me if you need help or healing.', onlyfocus = true})
keywordHandler:addKeyword({'life'},     sayMessage, {text = 'The gods decorated Tibia with various forms of life. Plants, the citizens, and even the monsters.', onlyfocus = true})
keywordHandler:addKeyword({'plant'},    sayMessage, {text = 'Just walk around. You will see grass, trees, and bushes.', onlyfocus = true})
keywordHandler:addKeyword({'citizen'},   sayMessage, {text = 'Only few people live here. Walk around and talk to them.', onlyfocus = true})
keywordHandler:addKeyword({'obi'},   sayMessage, {text = 'He is a local shop owner.', onlyfocus = true})
keywordHandler:addKeyword({'al dee'},   sayMessage, {text = 'He is a local shop owner.', onlyfocus = true})
keywordHandler:addKeyword({'name'},   sayMessage, {text = 'My name is Cipfried.', onlyfocus = true})
keywordHandler:addKeyword({'seymour'},   sayMessage, {text = 'Seymour is a loyal follower of the king and responsible for the academy.', onlyfocus = true})
keywordHandler:addKeyword({'academy'},   sayMessage, {text = 'You should visit Seymour in the academy and ask him about a mission.', onlyfocus = true})
keywordHandler:addKeyword({'willie'},   sayMessage, {text = 'He is a fine farmer. The farm is located to the left of the temple.', onlyfocus = true})
keywordHandler:addKeyword({'monster'},   sayMessage, {text = 'They are a constant threat. Learn to fight by hunting rabbits, deers and sheeps. Then try to fight rats, bugs and perhaps spiders.', onlyfocus = true})
keywordHandler:addKeyword({'help'},     sayMessage, {text = 'First you should try to get some gold and buy better equipment.', onlyfocus = true})
keywordHandler:addKeyword({'quest'},     sayMessage, {text = 'First you should try to get some gold and buy better equipment.', onlyfocus = true})
keywordHandler:addKeyword({'gold'},     sayMessage, {text = 'You have to slay monsters and take their gold. Or sell food at Willie\'s farm.', onlyfocus = true})
keywordHandler:addKeyword({'tibia'},     sayMessage, {text = 'That\'s where we are. The world of Tibia.', onlyfocus = true})
keywordHandler:addKeyword({'rat'},     sayMessage, {text = 'In the north of this temple you find a sewer grate. Use it to enter the sewers if you feel prepared. Don\'t forget a torch; you\'ll need it.', onlyfocus = true})
keywordHandler:addKeyword({'sewer'},     sayMessage, {text = 'In the north of this temple you find a sewer grate. Use it to enter the sewers if you feel prepared. Don\'t forget a torch; you\'ll need it.', onlyfocus = true})
keywordHandler:addKeyword({'equipment'},     sayMessage, {text = 'First you need some armor and perhaps a better weapon or a shield. A real adventurer needs a rope, a shovel, and a fishing pole, too.', onlyfocus = true})
keywordHandler:addKeyword({'food'},     sayMessage, {text = 'If you want to heal your wounds you should eat something. Willie sells excellent meals. But if you are very weak, come to me and ask me to heal you.', onlyfocus = true})

keywordHandler:addKeyword({'hi'}, greet, nil)
keywordHandler:addKeyword({'hello'}, greet, nil)
keywordHandler:addKeyword({'hey'}, greet, nil)
keywordHandler:addKeyword({'bye'}, farewell, nil)
keywordHandler:addKeyword({'farewell'}, farewell, nil)
-- Keyword structure generation end

 

Oracle

-- Oracle

local internalCustomerQueue = {}
local keywordHandler = KeywordHandler:new({root = {}})
local npcHandler = ShopNpcHandler:new({})
local customerQueue = CustomerQueue:new({customers = internalCustomerQueue, handler = npcHandler})
npcHandler:init(customerQueue, keywordHandler)
npcHandler.walkDistance = 0
local voc = 0

-- OTServ event handling functions start
function onThingMove(creature, thing, oldpos, oldstackpos)     npcHandler:onThingMove(creature, thing, oldpos, oldstackpos) end
function onCreatureAppear(creature)                             npcHandler:onCreatureAppear(creature) end
function onCreatureDisappear(id)                                 npcHandler:onCreatureDisappear(id) end
function onCreatureTurn(creature)                                 npcHandler:onCreatureTurn(creature) end
function onCreatureSay(cid, type, msg)                         npcHandler:onCreatureSay(cid, type, msg) end
function onCreatureChangeOutfit(creature)                         npcHandler:onCreatureChangeOutfit(creature) end
function onThink()                                             npcHandler:onThink() end
-- OTServ event handling functions end

-- Keyword handling functions start
function sayMessage(cid, message, keywords, parameters)     return npcHandler:defaultMessageHandler(cid, message, keywords, parameters) end

function greet(cid, message, keywords, parameters)
   -- We do not want to use the default "Welcome to my shop" thingie for this npc, so we'll just make this ourselves!
   if npcHandler.focus == cid then
       selfSay('I am already talking to you.')
       npcHandler.talkStart = os.clock()
   elseif npcHandler.focus > 0 or not(npcHandler.queue:isEmpty()) then
       selfSay('Please, ' .. creatureGetName(cid) .. '. Wait for your turn!.')
       if(not npcHandler.queue:isInQueue(cid)) then
           npcHandler.queue:pushBack(cid)
       end
   elseif(npcHandler.focus == 0) and (npcHandler.queue:isEmpty()) then
       selfSay(creatureGetName(cid) .. '! Are you prepared you face your destiny?')
       npcHandler.focus = cid
       voc = 0
       npcHandler.talkStart = os.clock()
   end
   
   return true
end

function farewell(cid, message, keywords, parameters)         return npcHandler:defaultFarewellHandler(cid, message, keywords, parameters) end
-- Keyword handling functions end


function confirmAction(cid, message, keywords, parameters)
   if(cid ~= npcHandler.focus) then
       return false
   end
   
   if(keywords[1] == 'yes') then
       
       if(getPlayerLevel(cid) < 8) then
           selfSay('You are not yet worthy. Come back when you are ready!')
           npcHandler:resetNpc()
           voc = 0
           return true
       end
       
       if(voc == 0) then
           selfSay('Allright then. What vocation do you wish to become? A sorcerer, druid, paladin or knight?')
       else
           doPlayerSetVocation(npcHandler.focus,voc)
           local pos = { x=939, y=263, z=7 }
           doPlayerSetMasterPos(npcHandler.focus,pos)
           doTeleportThing(npcHandler.focus,pos)
           voc = 0
       end
       
   elseif(keywords[1] == 'no') then
       
       if(voc == 0) then
           selfSay('Then come back when you are ready!')
           npcHandler.focus = 0
             voc = 0
             if not(queue[1] == nil) then
                 greetNextCostumer(queue)
             end
       else
           selfSay('Allright then. What vocation do you wish to become? A sorcerer, druid, paladin or knight?')
           voc = 0
       end
       
   end
   
   return true
end

function selectVocation(cid, message, keywords, parameters)
   if(cid ~= npcHandler.focus) then
       return false
   end
   
   selfSay('Are you sure that you wish to become a ' .. keywords[1] .. '? This decition is irreversible!')
   voc = parameters.voc
   
   return true
   
end


keywordHandler:addKeyword({'sorcerer'}, selectVocation, {voc = 1})
keywordHandler:addKeyword({'druid'}, selectVocation, {voc = 2})
keywordHandler:addKeyword({'paladin'}, selectVocation, {voc = 3})
keywordHandler:addKeyword({'knight'}, selectVocation, {voc = 4})

-- Confirm sell/buy keywords
keywordHandler:addKeyword({'yes'}, confirmAction)
keywordHandler:addKeyword({'no'}, confirmAction)

keywordHandler:addKeyword({'hi'}, greet, nil)
keywordHandler:addKeyword({'hello'}, greet, nil)
keywordHandler:addKeyword({'hey'}, greet, nil)
keywordHandler:addKeyword({'bye'}, farewell, nil)
keywordHandler:addKeyword({'farewell'}, farewell, nil)

 

Blind Orc

-- Blind Orc

local internalCustomerQueue = {}
local keywordHandler = KeywordHandler:new({root = {}})
local npcHandler = ShopNpcHandler:new({})
local customerQueue = CustomerQueue:new({customers = internalCustomerQueue, handler = npcHandler})
npcHandler:init(customerQueue, keywordHandler)
npcHandler.walkDistance = 1


-- OTServ event handling functions start
function onThingMove(creature, thing, oldpos, oldstackpos)     npcHandler:onThingMove(creature, thing, oldpos, oldstackpos) end
function onCreatureAppear(creature)                             npcHandler:onCreatureAppear(creature) end
function onCreatureDisappear(id)                                 npcHandler:onCreatureDisappear(id) end
function onCreatureTurn(creature)                                 npcHandler:onCreatureTurn(creature) end
function onCreatureSay(cid, type, msg)                         npcHandler:onCreatureSay(cid, type, msg) end
function onCreatureChangeOutfit(creature)                         npcHandler:onCreatureChangeOutfit(creature) end
-- OTServ event handling functions end

-- Keyword handling functions start

function onThink()                                             
   
   if (os.clock() - npcHandler.talkStart) > 40 then
       if npcHandler.focus > 0 then
           selfSay('Futchi')
       end
       
       npcHandler:resetNpc()
       
       npcHandler.queue:greetNext()
   end
   
   local dist = getDistanceToCreature(npcHandler.focus)
   if dist > 3 then
       selfSay('Futchi')
       npcHandler:resetNpc()
       npcHandler.queue:greetNext()
   end
   
   
   
   if npcHandler.focus == 0 then
 if(npcHandler.spawnPos == nil) then
 	local sx, sy, sz = selfGetPosition()
 	npcHandler.spawnPos = {x = sx, y = sy, z = sz}
 end
 	npcHandler.lastMove = walk(npcHandler.lastMove, npcHandler.spawnPos, npcHandler.walkDistance)
else
 npcHandler.lastPos = turnToCreature(npcHandler.focus, npcHandler.lastPos)
end
   
end

-- OTServ event handling functions end

-- Keyword handling functions start
function tradeItem(cid, message, keywords, parameters)     
   if npcHandler.focus ~= cid then
       return false
   end
   
   local tempcount = getCount(message)
   if(tempcount > 500) then
       tempcount = 500
   end
   
   
   local itemname = keywords[1]
   if(keywords[1] == 'sell') then
       itemname = keywords[2]
   end
   
   if(parameters.realname ~= nil) then
       itemname = parameters.realname
   end
   
   local tradeKeyword = 'goshak'
   if(keywords[1] == 'sell') then
       tradeKeyword = 'goshak'
   end
if(tempcount == 1) then
 selfSay('Maruk goshak ta?')
else
 selfSay('Maruk goshak ta?')
   end
   if(keywords[1] == 'sell') then
       npcHandler.talkState = TALKSTATE_SELL_ITEM
   else
       npcHandler.talkState = TALKSTATE_BUY_ITEM
   end
   
   npcHandler:setActiveItem(parameters.itemid, tempcount, parameters.charges, tempcount*parameters.cost, (parameters.stackable ~= nil and parameters.stackable == true))
   return true
end

function confirmAction(cid, message, keywords, parameters) 
   if npcHandler.focus ~= cid then
       return false
   end
   if(keywords[1] == 'mok') then
       if(npcHandler.talkState == TALKSTATE_SELL_ITEM) then
           npcHandler.talkState = TALKSTATE_NONE
           local ret = doPlayerSellItem(npcHandler.focus, npcHandler.itemid, npcHandler.stackable, npcHandler.count, npcHandler.cost)
           if(ret == LUA_NO_ERROR) then
               selfSay('Maruk rambo zambo!')
           else
               selfSay('Buta maruk klamuk!')
           end
       elseif(npcHandler.talkState == TALKSTATE_BUY_ITEM) then
           npcHandler.talkState = TALKSTATE_NONE
           local ret = 0
           if(npcHandler.charges == nil or npcHandler.charges <= 1) then
               ret = doPlayerBuyItem(npcHandler.focus, npcHandler.itemid, npcHandler.stackable, npcHandler.count, npcHandler.cost)
           else
               ret = doPlayerBuyRune(npcHandler.focus, npcHandler.itemid, npcHandler.count, npcHandler.charges, npcHandler.cost)
           end
           if(ret == LUA_NO_ERROR) then
               selfSay('Maruk rambo zambo!')
           else
               selfSay('Buta maruk klamuk!')
           end
       elseif(npcHandler.talkState == TALKSTATE_TRADE_ITEM) then
           npcHandler.talkState = TALKSTATE_NONE
 	
 	if (getPlayerItemCount(cid, npcHandler.itemid1) >= npcHandler.count1) then
   if(npcHandler.cost ~= nil and npcHandler.cost > 0) then
   	if(doPlayerRemoveMoney(cid, npcHandler.cost) ~= 1) then
     selfSay('Buta maruk klamuk!')
     return true
   	end	
   end
 	else
   selfSay('You do not have '.. npcHandler.count1 ..' ' .. npcHandler.itemname1 .. '.')
   return true
 	end  
 	if(npcHandler.prize > 0) then
   doPlayerAddMoney(cid, parameters.prize)
 	end	
           local ret = 0
 	if(doPlayerTakeItem(cid, npcHandler.itemid1, npcHandler.stackable1, npcHandler.count1) == LUA_NO_ERROR) then
   ret = doPlayerGiveItem(npcHandler.focus, npcHandler.itemid2, npcHandler.stackable2, npcHandler.count2)
   if(ret == LUA_NO_ERROR) then
   	selfSay('Here you go.')
   end	
 	end	
 end
   elseif(keywords[1] == 'burp') then
       if(npcHandler.talkState == TALKSTATE_SELL_ITEM) then
           selfSay('Buta maruk klamuk!')
           npcHandler.talkState = TALKSTATE_NONE
       elseif(npcHandler.talkState == TALKSTATE_BUY_ITEM) then
           selfSay('Buta maruk klamuk!')
           npcHandler.talkState = TALKSTATE_NONE
       elseif(npcHandler.talkState == TALKSTATE_TRADE_ITEM) then
           selfSay('Buta maruk klamuk!')
           npcHandler.talkState = TALKSTATE_NONE  	
       end
   end
   
   return true
end


function sayMessage(cid, message, keywords, parameters)     return npcHandler:defaultMessageHandler(cid, message, keywords, parameters) end

function greet(cid, message, keywords, parameters)     
   if npcHandler.focus == cid then
       selfSay('Charach!')
       npcHandler.talkStart = os.clock()
   elseif npcHandler.focus > 0 or not(npcHandler.queue:isEmpty()) then
       selfSay('Ikem napak aluk.')
       if(not npcHandler.queue:isInQueue(cid)) then
           npcHandler.queue:pushBack(cid)
       end
   elseif(npcHandler.focus == 0) and (npcHandler.queue:isEmpty()) then
       selfSay('Ikem Charach maruk.')
       npcHandler.focus = cid
       npcHandler.talkStart = os.clock()
   end
   
   return true
end

function farewell(cid, message, keywords, parameters)      
   if(cid == npcHandler.focus) then
       selfSay('Futchi.')
       npcHandler:resetNpc()
       npcHandler.queue:greetNext()
       return true
   end
   return false
end

-- Keyword handling functions end


-- Buy Item Keywords

keywordHandler:addKeyword({'charcha'},     tradeItem, {itemid = 2385, cost = 25})
keywordHandler:addKeyword({'burka', 'bata'},     tradeItem, {itemid = 2376, cost = 80})
keywordHandler:addKeyword({'burka'},     tradeItem, {itemid = 2406, cost = 30})
keywordHandler:addKeyword({'hakhak'},     tradeItem, {itemid = 2388, cost = 85})

keywordHandler:addKeyword({'tulak', 'bora'},     tradeItem, {itemid = 2484, cost = 90})
keywordHandler:addKeyword({'aka', 'bora'},     tradeItem, {itemid = 2467, cost = 25})
keywordHandler:addKeyword({'grofa'},     tradeItem, {itemid = 2482, cost = 60})

keywordHandler:addKeyword({'donga'},     tradeItem, {itemid = 2511, cost = 65})

keywordHandler:addKeyword({'batuk'},     tradeItem, {itemid = 2571, cost = 400})
keywordHandler:addKeyword({'pixo'},     tradeItem, {itemid = 2544, cost = 30, charges = 10, stackable = true})

keywordHandler:addKeyword({'mok'}, confirmAction, nil)
keywordHandler:addKeyword({'burp'}, confirmAction, nil)

keywordHandler:addKeyword({'ikem', 'goshak'},     sayMessage, {text = 'Ikem pashak porak, bata, dora. Ba goshak maruk?', onlyfocus = true})
keywordHandler:addKeyword({'porak'},     sayMessage, {text = 'Ikem pashak charcha, burka, burka bata, hakhak. Ba goshak maruk?', onlyfocus = true})
keywordHandler:addKeyword({'bata'},     sayMessage, {text = 'Ikem pashak aka bora, tulak bora, grofa. Ba goshak maruk?', onlyfocus = true})
keywordHandler:addKeyword({'dora'},     sayMessage, {text = 'Ikem pashak donga. Ba goshak maruk?', onlyfocus = true})

keywordHandler:addKeyword({'charach'}, greet, nil)
keywordHandler:addKeyword({'futchi'}, farewell, nil)
-- Keyword structure generation end

 

Obi (Similar to Al Dee)

-- Obi

local internalCustomerQueue = {}
local keywordHandler = KeywordHandler:new({root = {}})
local npcHandler = ShopNpcHandler:new({})
local customerQueue = CustomerQueue:new({customers = internalCustomerQueue, handler = npcHandler})
npcHandler:init(customerQueue, keywordHandler)
npcHandler.walkDistance = 1


-- OTServ event handling functions start
function onThingMove(creature, thing, oldpos, oldstackpos)     npcHandler:onThingMove(creature, thing, oldpos, oldstackpos) end
function onCreatureAppear(creature)                             npcHandler:onCreatureAppear(creature) end
function onCreatureDisappear(id)                                 npcHandler:onCreatureDisappear(id) end
function onCreatureTurn(creature)                                 npcHandler:onCreatureTurn(creature) end
function onCreatureSay(cid, type, msg)                         npcHandler:onCreatureSay(cid, type, msg) end
function onCreatureChangeOutfit(creature)                         npcHandler:onCreatureChangeOutfit(creature) end
function onThink()                                             npcHandler:onThink() end
-- OTServ event handling functions end

-- Keyword handling functions start
function tradeItem(cid, message, keywords, parameters)     return npcHandler:defaultTradeHandler(cid, message, keywords, parameters) end
function confirmAction(cid, message, keywords, parameters) return npcHandler:defaultConfirmHandler(cid, message, keywords, parameters) end
function sayMessage(cid, message, keywords, parameters)     return npcHandler:defaultMessageHandler(cid, message, keywords, parameters) end

function greet(cid, message, keywords, parameters)     
   if npcHandler.focus == cid then
       selfSay('I am already talking to you.')
       npcHandler.talkStart = os.clock()
   elseif npcHandler.focus > 0 or not(npcHandler.queue:isEmpty()) then
       selfSay('Please stand in line ' .. creatureGetName(cid) .. '. I\'ll be with you in a moment.')
       if(not npcHandler.queue:isInQueue(cid)) then
           npcHandler.queue:pushBack(cid)
       end
   elseif(npcHandler.focus == 0) and (npcHandler.queue:isEmpty()) then
       selfSay('Hello hello, ' .. creatureGetName(cid) .. '!  Please come in, look, and buy!')
       npcHandler.focus = cid
       npcHandler.talkStart = os.clock()
   end
   
   return true
end

function farewell(cid, message, keywords, parameters)      
   if(cid == npcHandler.focus) then
       selfSay('Bye, bye.')
       npcHandler:resetNpc()
       npcHandler.queue:greetNext()
       return true
   end
   return false
end

-- Keyword handling functions end


-- Sell Item Keywords
keywordHandler:addKeyword({'sell', 'spear'},     tradeItem, {itemid = 2389, cost = 1, stackable = true})
keywordHandler:addKeyword({'sell', 'rapier'},     tradeItem, {itemid = 2384, cost = 1})
keywordHandler:addKeyword({'sell', 'sabre'},     tradeItem, {itemid = 2385, cost = 1})
keywordHandler:addKeyword({'sell', 'dagger'},     tradeItem, {itemid = 2379, cost = 1})
keywordHandler:addKeyword({'sell', 'sickle'},     tradeItem, {itemid = 2405, cost = 1})
keywordHandler:addKeyword({'sell', 'hand axe'},     tradeItem, {itemid = 2380, cost = 1})
keywordHandler:addKeyword({'sell', 'axe'},     tradeItem, {itemid = 2386, cost = 1})
keywordHandler:addKeyword({'sell', 'short sword'},     tradeItem, {itemid = 2406, cost = 1})
keywordHandler:addKeyword({'sell', 'jacket'},     tradeItem, {itemid = 2650, cost = 1})
keywordHandler:addKeyword({'sell', 'coat'},     tradeItem, {itemid = 2651, cost = 1})
keywordHandler:addKeyword({'sell', 'doublet'},     tradeItem, {itemid = 2485, cost = 1})
keywordHandler:addKeyword({'sell', 'leather armor'},     tradeItem, {itemid = 2467, cost = 1})
keywordHandler:addKeyword({'sell', 'leather legs'},     tradeItem, {itemid = 2649, cost = 1})
keywordHandler:addKeyword({'sell', 'leather helmet'},     tradeItem, {itemid = 2461, cost = 1})
keywordHandler:addKeyword({'sell', 'studded helmet'},     tradeItem, {itemid = 2482, cost = 1})
keywordHandler:addKeyword({'sell', 'chain helmet'},     tradeItem, {itemid = 2458, cost = 1})
keywordHandler:addKeyword({'sell', 'wooden shield'},     tradeItem, {itemid = 2512, cost = 1})
keywordHandler:addKeyword({'sell', 'studded shield'},     tradeItem, {itemid = 2526, cost = 1})

-- Buy Item Keywords

keywordHandler:addKeyword({'rope'},     tradeItem, {itemid = 2120, cost = 50})
keywordHandler:addKeyword({'shovel'},     tradeItem, {itemid = 2554, cost = 10})
keywordHandler:addKeyword({'backpack'},     tradeItem, {itemid = 1988, cost = 10})
keywordHandler:addKeyword({'torch'},     tradeItem, {itemid = 2050, cost = 2})
keywordHandler:addKeyword({'machete'},     tradeItem, {itemid = 2420, cost = 30})
keywordHandler:addKeyword({'scythe'},     tradeItem, {itemid = 2550, cost = 12})
keywordHandler:addKeyword({'rod'},     tradeItem, {itemid = 2580, cost = 150})
keywordHandler:addKeyword({'worm'},     tradeItem, {itemid = 3976, cost = 5, charges = 6, realname = "6-pack of worms", stackable = true})
keywordHandler:addKeyword({'spear'},     tradeItem, {itemid = 2389, cost = 10, stackable = true})
keywordHandler:addKeyword({'rapier'},     tradeItem, {itemid = 2384, cost = 15})
keywordHandler:addKeyword({'sabre'},     tradeItem, {itemid = 2385, cost = 25})
keywordHandler:addKeyword({'dagger'},     tradeItem, {itemid = 2379, cost = 5})
keywordHandler:addKeyword({'sickle'},     tradeItem, {itemid = 2405, cost = 8})
keywordHandler:addKeyword({'hand axe'},     tradeItem, {itemid = 2380, cost = 8})

keywordHandler:addKeyword({'short sword'},     tradeItem, {itemid = 2406, cost = 30})
keywordHandler:addKeyword({'jacket'},     tradeItem, {itemid = 2650, cost = 10})
keywordHandler:addKeyword({'coat'},     tradeItem, {itemid = 2651, cost = 8})
keywordHandler:addKeyword({'doublet'},     tradeItem, {itemid = 2485, cost = 16})
keywordHandler:addKeyword({'leather armor'},     tradeItem, {itemid = 2467, cost = 25})
keywordHandler:addKeyword({'leather legs'},     tradeItem, {itemid = 2649, cost = 10})
keywordHandler:addKeyword({'leather helmet'},     tradeItem, {itemid = 2461, cost = 12})
keywordHandler:addKeyword({'studded helmet'},     tradeItem, {itemid = 2482, cost = 63})
keywordHandler:addKeyword({'chain helmet'},     tradeItem, {itemid = 2458, cost = 52})
keywordHandler:addKeyword({'wooden shield'},     tradeItem, {itemid = 2512, cost = 15})
keywordHandler:addKeyword({'studded shield'},     tradeItem, {itemid = 2526, cost = 50})

keywordHandler:addKeyword({'yes'}, confirmAction, nil)
keywordHandler:addKeyword({'no'}, confirmAction, nil)

keywordHandler:addKeyword({'offer'},     sayMessage, {text = 'I sell weapons, shields, armor, helmets, and equipment. For what do you want to ask?', onlyfocus = true})
keywordHandler:addKeyword({'wares'},     sayMessage, {text = 'I sell weapons, shields, armor, helmets, and equipment. For what do you want to ask?', onlyfocus = true})
keywordHandler:addKeyword({'sell'},     sayMessage, {text = 'I sell much. Just read the blackboards for my awesome wares or just ask me.', onlyfocus = true})
keywordHandler:addKeyword({'job'},     sayMessage, {text = 'I am a merchant. What can I do for you?', onlyfocus = true})
keywordHandler:addKeyword({'weapon'},     sayMessage, {text = 'I sell spears, rapiers, sabres, daggers, hand axes, axes, and short swords. Just tell me what you want to buy.', onlyfocus = true})
keywordHandler:addKeyword({'armor'},    sayMessage, {text = 'I sell jackets, coats, doublets, leather armor, and leather legs. Just tell me what you want to buy.', onlyfocus = true})
keywordHandler:addKeyword({'helmet'},   sayMessage, {text = 'I sell leather helmets, studded helmets, and chain helmets. Just tell me what you want to buy.', onlyfocus = true})
keywordHandler:addKeyword({'shield'},   sayMessage, {text = 'I sell wooden shields and studded shields. Just tell me what you want to buy.', onlyfocus = true})
keywordHandler:addKeyword({'equipment'},   sayMessage, {text = 'I sell torches, shovels, picks, backpacks, sickles, scythes, ropes, worms and fishing rods. Just tell me what you want to buy.', onlyfocus = true})
keywordHandler:addKeyword({'name'},   sayMessage, {text = 'My name is Al Dee, but you can call me Al. Do you want to buy something?', onlyfocus = true})
keywordHandler:addKeyword({'monster'},   sayMessage, {text = 'If you want to challenge the monsters, you need some weapons and armor I sell. You need them definitely!', onlyfocus = true})
keywordHandler:addKeyword({'dungeon'},   sayMessage, {text = 'If you want to explore the dungeons, you have to equip yourself with the vital stuff I am selling. It\'s vital in the deepest sense of the word.', onlyfocus = true})
keywordHandler:addKeyword({'sewer'},   sayMessage, {text = 'Oh, our sewer system is very primitive; so primitive it\'s overrun by rats. But the stuff I sell is safe from them. Do you want to buy some of it?', onlyfocus = true})
keywordHandler:addKeyword({'king'},   sayMessage, {text = 'The king encouraged salesmen to travel here, but only I dared to take the risk, and a risk it was!', onlyfocus = true})
keywordHandler:addKeyword({'dallheim'},     sayMessage, {text = 'What a hero, what a hero.', onlyfocus = true})
keywordHandler:addKeyword({'bug'},     sayMessage, {text = 'Bugs plague this isle, but my wares are bugfree, totally bugfree.', onlyfocus = true})
keywordHandler:addKeyword({'stuff'},     sayMessage, {text = 'I sell equipment of all kinds, all kind available on this isle. Just ask me about my wares if you are interested.', onlyfocus = true})
keywordHandler:addKeyword({'tibia'},     sayMessage, {text = 'One day I will return to the continent as a rich, a very rich man!', onlyfocus = true})
keywordHandler:addKeyword({'seymour'},     sayMessage, {text = 'He is the head of the local academy. I encouraged him to sponsor you guy, but no one listens to Obi, no one listens to me, as usual.', onlyfocus = true})
keywordHandler:addKeyword({'hyacinth'},     sayMessage, {text = 'I don\'t like him, I dislike him deeply. He is so greedy that he doesn\'t want to share his profit from life fluids.', onlyfocus = true})
keywordHandler:addKeyword({'amber'},     sayMessage, {text = 'She is beautiful, very, very beautiful. I hope I can impress her in some way.', onlyfocus = true})
keywordHandler:addKeyword({'willie'},     sayMessage, {text = 'This guy does not understand that he should entrust me with the foodbusiness, too. He really should do that and have more time for his farm.', onlyfocus = true})
keywordHandler:addKeyword({'sam'},     sayMessage, {text = 'My good old cousin Sam. Oh, how I miss him, how I miss him.', onlyfocus = true})
keywordHandler:addKeyword({'thais'},     sayMessage, {text = 'Oh, Thais, I\'ll be back, I\'ll be back one day.', onlyfocus = true})

keywordHandler:addKeyword({'pick'},     sayMessage, {text = 'I am sorry, we are out of pick axes. I heard that old greedy Al Dee has some but he will charge a fortune.', onlyfocus = true})

keywordHandler:addKeyword({'hi'}, greet, nil)
keywordHandler:addKeyword({'hello'}, greet, nil)
keywordHandler:addKeyword({'hey'}, greet, nil)
keywordHandler:addKeyword({'bye'}, farewell, nil)
keywordHandler:addKeyword({'farewell'}, farewell, nil)
-- Keyword structure generation end

 

Dallheim

-- Dallheim

local internalCustomerQueue = {}
local keywordHandler = KeywordHandler:new({root = {}})
local npcHandler = ShopNpcHandler:new({})
local customerQueue = CustomerQueue:new({customers = internalCustomerQueue, handler = npcHandler})
npcHandler:init(customerQueue, keywordHandler)


-- OTServ event handling functions start
function onThingMove(creature, thing, oldpos, oldstackpos)     npcHandler:onThingMove(creature, thing, oldpos, oldstackpos) end
function onCreatureAppear(creature)                             npcHandler:onCreatureAppear(creature) end
function onCreatureDisappear(id)                                 npcHandler:onCreatureDisappear(id) end
function onCreatureTurn(creature)                                 npcHandler:onCreatureTurn(creature) end
function onCreatureSay(cid, type, msg)                         npcHandler:onCreatureSay(cid, type, msg) end
function onCreatureChangeOutfit(creature)                         npcHandler:onCreatureChangeOutfit(creature) end
function onThink()                                             
   
   if (os.clock() - npcHandler.talkStart) > 40 then
       if npcHandler.focus > 0 then
           selfSay('Well, bye then.')
       end
       
       npcHandler:resetNpc()
       
       npcHandler.queue:greetNext()
   end
   
   local dist = getDistanceToCreature(npcHandler.focus)
   if dist > 3 then
       selfSay('Well, bye then.')
       npcHandler:resetNpc()
       npcHandler.queue:greetNext()
   end
   
   
   
   if npcHandler.focus == 0 then
 if(npcHandler.spawnPos == nil) then
 	local sx, sy, sz = selfGetPosition()
 	npcHandler.spawnPos = {x = sx, y = sy, z = sz}
 end
 	npcHandler.lastMove = walk(npcHandler.lastMove, npcHandler.spawnPos, npcHandler.walkDistance)
else
 npcHandler.lastPos = turnToCreature(npcHandler.focus, npcHandler.lastPos)
end
   
end
-- OTServ event handling functions end

-- Keyword handling functions start
function healPlayer(cid, message, keywords, parameters)
if(getPlayerHealth(cid) < parameters.maxheal) then
 position = getPlayerPosition(npcHandler.focus)
 doSendMagicEffect(position, 12)
 local healHP = parameters.maxheal - getPlayerHealth(cid)
 doPlayerAddHealth(npcHandler.focus,healHP)
 selfSay('You are looking really bad. Let me heal your wounds.')
else
 selfSay('You aren\'t looking really bad, ' .. creatureGetName(cid) .. '.')
end	
return true
end

function healPlayerNoMsg(cid, maxheal)
if(getPlayerHealth(cid) < maxheal) then
 position = getPlayerPosition(npcHandler.focus)
 doSendMagicEffect(position, 12)
 local healHP = maxheal - getPlayerHealth(cid)
 doPlayerAddHealth(npcHandler.focus,healHP)
 selfSay('Hello, ' .. creatureGetName(cid) .. '! You are looking really bad. Let me heal your wounds.')
end	
return true
end

function tradeItem(cid, message, keywords, parameters)     return npcHandler:defaultTradeHandler(cid, message, keywords, parameters) end
function confirmAction(cid, message, keywords, parameters) return npcHandler:defaultConfirmHandler(cid, message, keywords, parameters) end
function sayMessage(cid, message, keywords, parameters)     return npcHandler:defaultMessageHandler(cid, message, keywords, parameters) end

function greet(cid, message, keywords, parameters)       
   if (npcHandler.focus > 0 or not(npcHandler.queue:isEmpty()) and npcHandler.focus ~= cid) then
       selfSay('Not now.')
       if(not npcHandler.queue:isInQueue(cid)) then
           npcHandler.queue:pushBack(cid)
       end
   elseif(npcHandler.focus == 0) and (npcHandler.queue:isEmpty()) then
       npcHandler.focus = cid
       npcHandler.talkStart = os.clock()
 if(getPlayerHealth(cid) >= 65) then
 	selfSay('<nods silently>')
 else
 	healPlayerNoMsg(npcHandler.focus, 65)
 end  
   end
   
   return true
end

function farewell(cid, message, keywords, parameters)      
   if(cid == npcHandler.focus) then
       selfSay('Bye.')
       npcHandler:resetNpc()
       npcHandler.queue:greetNext()
       return true
   end
   return false
end

keywordHandler:addKeyword({'heal'},     healPlayer, {maxheal = 65})

keywordHandler:addKeyword({'yes'}, confirmAction, nil)
keywordHandler:addKeyword({'no'}, confirmAction, nil)

keywordHandler:addKeyword({'tibia'},     sayMessage, {text = 'A nice place for a hero, but nothing for whelps.', onlyfocus = true})
keywordHandler:addKeyword({'sell'},     sayMessage, {text = 'I sell nothing.', onlyfocus = true})
keywordHandler:addKeyword({'help'},     sayMessage, {text = 'I have to stay here, sorry, but I can heal you if you are wounded.', onlyfocus = true})
keywordHandler:addKeyword({'monster'},     sayMessage, {text = 'I will crush all monsters who dare to attack our base.', onlyfocus = true})
keywordHandler:addKeyword({'job'},     sayMessage, {text = 'I am the bridgeguard. I defend Rookgaard against the beasts from the wilderness and the dungeons!', onlyfocus = true})
keywordHandler:addKeyword({'dungeon'},     sayMessage, {text = 'Dungeons are dangerous, be prepared.', onlyfocus = true})
keywordHandler:addKeyword({'wilderness'},    sayMessage, {text = 'There are wolves, bears, snakes, deers, and spiders. You can find some dungeon entrances there, too.', onlyfocus = true})
keywordHandler:addKeyword({'sewer'},   sayMessage, {text = 'In the sewers there are some rats, fine targets for young heroes.', onlyfocus = true})
keywordHandler:addKeyword({'banor'},   sayMessage, {text = 'The great one! Read books to learn about him.', onlyfocus = true})
keywordHandler:addKeyword({'god'},   sayMessage, {text = 'I am a follower of Banor.', onlyfocus = true})
keywordHandler:addKeyword({'name'},   sayMessage, {text = 'Dallheim.', onlyfocus = true})
keywordHandler:addKeyword({'seymour'},   sayMessage, {text = 'Leave me alone with this wimp.', onlyfocus = true})
keywordHandler:addKeyword({'amber'},   sayMessage, {text = 'I don\'t trust her.', onlyfocus = true})
keywordHandler:addKeyword({'willie'},   sayMessage, {text = 'A fine cook and farmer he is.', onlyfocus = true})
keywordHandler:addKeyword({'magic'},   sayMessage, {text = 'Not interested in such party tricks.', onlyfocus = true})
keywordHandler:addKeyword({'hyacinth'},     sayMessage, {text = 'Strange Fellow, hides somewhere in the mountains of the isle.', onlyfocus = true})
keywordHandler:addKeyword({'weapon'},     sayMessage, {text = 'With my spikesword I slice even a cyclops in pieces."', onlyfocus = true})

keywordHandler:addKeyword({'hi'}, greet, nil)
keywordHandler:addKeyword({'hello'}, greet, nil)
keywordHandler:addKeyword({'hey'}, greet, nil)
keywordHandler:addKeyword({'bye'}, farewell, nil)
keywordHandler:addKeyword({'farewell'}, farewell, nil)
-- Keyword structure generation end

 

 

...

Link para o comentário
Compartilhar em outros sites

Tom the Tanner

-- Tom

local internalCustomerQueue = {}
local keywordHandler = KeywordHandler:new({root = {}})
local npcHandler = ShopNpcHandler:new({})
local customerQueue = CustomerQueue:new({customers = internalCustomerQueue, handler = npcHandler})
npcHandler:init(customerQueue, keywordHandler)
npcHandler.walkDistance = 0

-- OTServ event handling functions start
function onThingMove(creature, thing, oldpos, oldstackpos)     npcHandler:onThingMove(creature, thing, oldpos, oldstackpos) end
function onCreatureAppear(creature)                             npcHandler:onCreatureAppear(creature) end
function onCreatureDisappear(id)                                 npcHandler:onCreatureDisappear(id) end
function onCreatureTurn(creature)                                 npcHandler:onCreatureTurn(creature) end
function onCreatureSay(cid, type, msg)                         npcHandler:onCreatureSay(cid, type, msg) end
function onCreatureChangeOutfit(creature)                         npcHandler:onCreatureChangeOutfit(creature) end
function onThink()                                             
   
   if (os.clock() - npcHandler.talkStart) > 40 then
       if npcHandler.focus > 0 then
           selfSay('Doh?')
       end
       
       npcHandler:resetNpc()
       
       npcHandler.queue:greetNext()
   end
   
   local dist = getDistanceToCreature(npcHandler.focus)
   if dist > 3 then
       selfSay('Doh?')
       npcHandler:resetNpc()
       npcHandler.queue:greetNext()
   end
   
   
   
   if npcHandler.focus == 0 then
 if(npcHandler.spawnPos == nil) then
 	local sx, sy, sz = selfGetPosition()
 	npcHandler.spawnPos = {x = sx, y = sy, z = sz}
 end
 	npcHandler.lastMove = walk(npcHandler.lastMove, npcHandler.spawnPos, npcHandler.walkDistance)
else
 npcHandler.lastPos = turnToCreature(npcHandler.focus, npcHandler.lastPos)
end
   
end

-- OTServ event handling functions end

-- Keyword handling functions start
function tradeItem(cid, message, keywords, parameters)     
   if npcHandler.focus ~= cid then
       return false
   end
   
   local tempcount = getCount(message)
   if(tempcount > 500) then
       tempcount = 500
   end
   
   
   local itemname = keywords[1]
   if(keywords[1] == 'buy') then
       itemname = keywords[2]
   end
   
   if(parameters.realname ~= nil) then
       itemname = parameters.realname
   end
   
   local tradeKeyword = 'sell'
   if(keywords[1] == 'buy') then
       tradeKeyword = 'buy'
   end
if(tempcount == 1) then
 selfSay('I\'ll give you ' .. parameters.cost*tempcount .. ' gold for a ' .. itemname .. '. Do you accept? ')
else
 selfSay('I\'ll give you ' .. parameters.cost*tempcount .. ' gold for ' .. tempcount .. ' ' .. itemname .. 's. Do you accept? ')
   end
   if(keywords[1] == 'buy') then
       npcHandler.talkState = TALKSTATE_BUY_ITEM
   else
       npcHandler.talkState = TALKSTATE_SELL_ITEM
   end
   
   npcHandler:setActiveItem(parameters.itemid, tempcount, parameters.charges, tempcount*parameters.cost, (parameters.stackable ~= nil and parameters.stackable == true))
   return true
end

function confirmAction(cid, message, keywords, parameters) 
   if npcHandler.focus ~= cid then
       return false
   end
   if(keywords[1] == 'yes') then
       if(npcHandler.talkState == TALKSTATE_SELL_ITEM) then
           npcHandler.talkState = TALKSTATE_NONE
           local ret = doPlayerSellItem(npcHandler.focus, npcHandler.itemid, npcHandler.stackable, npcHandler.count, npcHandler.cost)
           if(ret == LUA_NO_ERROR) then
               selfSay('Ok. Corpse for me, gold for you.')
           else
               selfSay('Sorry, you do not have one.')
           end
       elseif(npcHandler.talkState == TALKSTATE_BUY_ITEM) then
           npcHandler.talkState = TALKSTATE_NONE
           local ret = 0
           if(npcHandler.charges == nil or npcHandler.charges <= 1) then
               ret = doPlayerBuyItem(npcHandler.focus, npcHandler.itemid, npcHandler.stackable, npcHandler.count, npcHandler.cost)
           else
               ret = doPlayerBuyRune(npcHandler.focus, npcHandler.itemid, npcHandler.count, npcHandler.charges, npcHandler.cost)
           end
           if(ret == LUA_NO_ERROR) then
               selfSay('Thank you. Here it is.')
           else
               selfSay('Sorry, you do not have enough gold.')
           end
       elseif(npcHandler.talkState == TALKSTATE_TRADE_ITEM) then
           npcHandler.talkState = TALKSTATE_NONE
 	
 	if (getPlayerItemCount(cid, npcHandler.itemid1) >= npcHandler.count1) then
   if(npcHandler.cost ~= nil and npcHandler.cost > 0) then
   	if(doPlayerRemoveMoney(cid, npcHandler.cost) ~= 1) then
     selfSay('You don\'t have enough money.')
     return true
   	end	
   end
 	else
   selfSay('You do not have '.. npcHandler.count1 ..' ' .. npcHandler.itemname1 .. '.')
   return true
 	end  
 	if(npcHandler.prize > 0) then
   doPlayerAddMoney(cid, parameters.prize)
 	end	
           local ret = 0
 	if(doPlayerTakeItem(cid, npcHandler.itemid1, npcHandler.stackable1, npcHandler.count1) == LUA_NO_ERROR) then
   ret = doPlayerGiveItem(npcHandler.focus, npcHandler.itemid2, npcHandler.stackable2, npcHandler.count2)
   if(ret == LUA_NO_ERROR) then
   	selfSay('Here you go.')
   end	
 	end	
 end
   elseif(keywords[1] == 'no') then
       if(npcHandler.talkState == TALKSTATE_SELL_ITEM) then
           selfSay('Maybe another time.')
           npcHandler.talkState = TALKSTATE_NONE
       elseif(npcHandler.talkState == TALKSTATE_BUY_ITEM) then
           selfSay('Maybe you will buy it another time.')
           npcHandler.talkState = TALKSTATE_NONE
       elseif(npcHandler.talkState == TALKSTATE_TRADE_ITEM) then
           selfSay('You don\'t even have a simple item?')
           npcHandler.talkState = TALKSTATE_NONE  	
       end
   end
   
   return true
end

function sayMessage(cid, message, keywords, parameters)     return npcHandler:defaultMessageHandler(cid, message, keywords, parameters) end
function greet(cid, message, keywords, parameters)        

   if npcHandler.focus > 0 or not(npcHandler.queue:isEmpty()) then
if npcHandler.focus ~= cid then
       selfSay('Please wait, ' .. creatureGetName(cid) .. '. I\'ll call you in a minute.')
       if(not npcHandler.queue:isInQueue(cid)) then
           npcHandler.queue:pushBack(cid)
       end
else
 npcHandler.talkStart = os.clock()
end	
   elseif(npcHandler.focus == 0) and (npcHandler.queue:isEmpty()) then
       selfSay('I\'m Tom the Tanner. How can I help you ' .. creatureGetName(cid) .. '?')
       npcHandler.focus = cid
       npcHandler.talkStart = os.clock()
   end
   
   return true
end

function farewell(cid, message, keywords, parameters)      
   if(cid == npcHandler.focus) then
       selfSay('Good hunting, ' .. creatureGetName(cid) .. '.')
       npcHandler:resetNpc()
       npcHandler.queue:greetNext()
       return true
   end
   return false
end

-- Keyword handling functions end

-- Rats
keywordHandler:addKeyword({'rat'},     tradeItem, {itemid = 2813, cost = 2, realname = 'dead rat'})

-- Rabbits
keywordHandler:addKeyword({'rabbit'},     tradeItem, {itemid = 3119, cost = 2, realname = 'dead rabbit'})

-- Wolf
keywordHandler:addKeyword({'wolf'},     tradeItem, {itemid = 3086, cost = 5, realname = 'dead wolf'})

keywordHandler:addKeyword({'yes'}, confirmAction, nil)
keywordHandler:addKeyword({'no'}, confirmAction, nil)

keywordHandler:addKeyword({'offer'},     sayMessage, {text = 'I\'m buying fresh corpses of rats, rabbits and wolves. What do you want to sell?', onlyfocus = true})
keywordHandler:addKeyword({'job'},     sayMessage, {text = 'I\'m the local tanner. I buy fresh animal corpses, tan them, and convert them into fine leather clothes. I\'m only selling to major customers. But I\'m buying fresh corpses of rats, rabbits and wolves from you.', onlyfocus = true})
keywordHandler:addKeyword({'time'},     sayMessage, {text = 'Sorry, I haven\'t been outside for a while, so I don\'t know.', onlyfocus = true})
keywordHandler:addKeyword({'sell'},        sayMessage, {text = 'I\'m only selling to major customers. But I\'m buying fresh corpses of rats, rabbits and wolves from you.', onlyfocus = true})
keywordHandler:addKeyword({'major'},     sayMessage, {text = 'Yes. Obi, Norma and good old Al. Go ask them for leather clothes.', onlyfocus = true})
keywordHandler:addKeyword({'customer'},     sayMessage, {text = 'Yes. Obi, Norma and good old Al. Go ask them for leather clothes.', onlyfocus = true})
keywordHandler:addKeyword({'name'},     sayMessage, {text = 'My name is Tom the tanner.', onlyfocus = true})
keywordHandler:addKeyword({'help'},     sayMessage, {text = 'Help? I will give you a few gold coins if you have some dead animals for me.', onlyfocus = true})
keywordHandler:addKeyword({'wares'},     sayMessage, {text = 'I\'m buying fresh corpses of rats, rabbits and wolves. What do you want to sell?', onlyfocus = true})
keywordHandler:addKeyword({'corpse'},     sayMessage, {text = 'I\'m buying fresh corpses of rats, rabbits and wolves. What do you want to sell?', onlyfocus = true})
keywordHandler:addKeyword({'animal'},     sayMessage, {text = 'I\'m buying fresh corpses of rats, rabbits and wolves. What do you want to sell?', onlyfocus = true})

keywordHandler:addKeyword({'hi'}, greet, nil)
keywordHandler:addKeyword({'hello'}, greet, nil)
keywordHandler:addKeyword({'bye'}, farewell, nil)
-- Keyword structure generation end

 

Hyacinth

Note: She will take full vials off you as well as empty so up to you whether to include this however I did include a warning message. (Here you are. There is a deposit of 5 gold on the vial, but be sure to only sell empty vials.) Until we figure a fix this is how it will stay.

local internalCustomerQueue = {}
local keywordHandler = KeywordHandler:new({root = {}})
local npcHandler = ShopNpcHandler:new({})
local customerQueue = CustomerQueue:new({customers = internalCustomerQueue, handler = npcHandler})
npcHandler:init(customerQueue, keywordHandler)
npcHandler.walkDistance = 0

-- OTServ event handling functions start
function onThingMove(creature, thing, oldpos, oldstackpos)     npcHandler:onThingMove(creature, thing, oldpos, oldstackpos) end
function onCreatureAppear(creature)                             npcHandler:onCreatureAppear(creature) end
function onCreatureDisappear(id)                                 npcHandler:onCreatureDisappear(id) end
function onCreatureTurn(creature)                                 npcHandler:onCreatureTurn(creature) end
function onCreatureSay(cid, type, msg)                         npcHandler:onCreatureSay(cid, type, msg) end
function onCreatureChangeOutfit(creature)                         npcHandler:onCreatureChangeOutfit(creature) end
function onThink()                                             
   
   if (os.clock() - npcHandler.talkStart) > 40 then
       if npcHandler.focus > 0 then
           selfSay('May Crunor bless you.')
       end
       
       npcHandler:resetNpc()
       
       npcHandler.queue:greetNext()
   end
   
   local dist = getDistanceToCreature(npcHandler.focus)
   if dist > 3 then
       selfSay('May Crunor bless you.')
       npcHandler:resetNpc()
       npcHandler.queue:greetNext()
   end
   
   
   
   if npcHandler.focus == 0 then
 if(npcHandler.spawnPos == nil) then
 	local sx, sy, sz = selfGetPosition()
 	npcHandler.spawnPos = {x = sx, y = sy, z = sz}
 end
 	npcHandler.lastMove = walk(npcHandler.lastMove, npcHandler.spawnPos, npcHandler.walkDistance)
else
 npcHandler.lastPos = turnToCreature(npcHandler.focus, npcHandler.lastPos)
end
   
end

-- OTServ event handling functions end

-- Keyword handling functions start
function tradeItem(cid, message, keywords, parameters)     
   if npcHandler.focus ~= cid then
       return false
   end
   
   local tempcount = getCount(message)
   if(tempcount > 500) then
       tempcount = 500
   end
   
   
   local itemname = keywords[1]
   if(keywords[1] == 'sell') then
       itemname = keywords[2]
   end
   
   if(parameters.realname ~= nil) then
       itemname = parameters.realname
   end
   
   local tradeKeyword = 'buy'
   if(keywords[1] == 'sell') then
       tradeKeyword = 'sell'
   end
if(tempcount == 1) then
 selfSay('Do you want to ' .. tradeKeyword .. ' a ' .. itemname .. ' for ' .. parameters.cost*tempcount .. ' gold?')
else
 selfSay('Do you want to ' .. tradeKeyword .. ' ' .. tempcount .. ' ' .. itemname .. 's for ' .. parameters.cost*tempcount .. ' gold?')
   end
   if(keywords[1] == 'sell') then
       npcHandler.talkState = TALKSTATE_SELL_ITEM
   else
       npcHandler.talkState = TALKSTATE_BUY_ITEM
   end
   
   npcHandler:setActiveItem(parameters.itemid, tempcount, parameters.charges, tempcount*parameters.cost, (parameters.stackable ~= nil and parameters.stackable == true))
   return true
end

function confirmAction(cid, message, keywords, parameters) 
   if npcHandler.focus ~= cid then
       return false
   end
   if(keywords[1] == 'yes') then
       if(npcHandler.talkState == TALKSTATE_SELL_ITEM) then
           npcHandler.talkState = TALKSTATE_NONE
           local ret = doPlayerSellItem(npcHandler.focus, npcHandler.itemid, npcHandler.stackable, npcHandler.count, npcHandler.cost)
           if(ret == LUA_NO_ERROR) then
               selfSay('Here you are.')
           else
               selfSay('You don\'t have any empty vials.')
           end
       elseif(npcHandler.talkState == TALKSTATE_BUY_ITEM) then
           npcHandler.talkState = TALKSTATE_NONE
           local ret = 0
           if(npcHandler.charges == nil or npcHandler.charges <= 1) then
               ret = doPlayerBuyItem(npcHandler.focus, npcHandler.itemid, npcHandler.stackable, npcHandler.count, npcHandler.cost)
           else
               ret = doPlayerBuyRune(npcHandler.focus, npcHandler.itemid, npcHandler.count, npcHandler.charges, npcHandler.cost)
           end
           if(ret == LUA_NO_ERROR) then
               selfSay('Here you are. There is a deposit of 5 gold on the vial, but be sure to only sell empty vials.')
           else
               selfSay('Come back, when you have enough money.')
           end
       elseif(npcHandler.talkState == TALKSTATE_TRADE_ITEM) then
           npcHandler.talkState = TALKSTATE_NONE
 	
 	if (getPlayerItemCount(cid, npcHandler.itemid1) >= npcHandler.count1) then
   if(npcHandler.cost ~= nil and npcHandler.cost > 0) then
   	if(doPlayerRemoveMoney(cid, npcHandler.cost) ~= 1) then
     selfSay('Come back, when you have enough money.')
     return true
   	end	
   end
 	else
   selfSay('You don\'t have any empty vials.')
   return true
 	end  
 	if(npcHandler.prize > 0) then
   doPlayerAddMoney(cid, parameters.prize)
 	end	
           local ret = 0
 	if(doPlayerTakeItem(cid, npcHandler.itemid1, npcHandler.stackable1, npcHandler.count1) == LUA_NO_ERROR) then
   ret = doPlayerGiveItem(npcHandler.focus, npcHandler.itemid2, npcHandler.stackable2, npcHandler.count2)
   if(ret == LUA_NO_ERROR) then
   	selfSay('Here you are.')
   end	
 	end	
 end
   elseif(keywords[1] == 'no') then
       if(npcHandler.talkState == TALKSTATE_SELL_ITEM) then
           selfSay('Hmm, but please keep Tibia litter free.')
           npcHandler.talkState = TALKSTATE_NONE
       elseif(npcHandler.talkState == TALKSTATE_BUY_ITEM) then
           selfSay('Hmm but next time.')
           npcHandler.talkState = TALKSTATE_NONE
       elseif(npcHandler.talkState == TALKSTATE_TRADE_ITEM) then
           selfSay('You don\'t even have a simple item?')
           npcHandler.talkState = TALKSTATE_NONE  	
       end
   end
   
   return true
end

function sayMessage(cid, message, keywords, parameters)     return npcHandler:defaultMessageHandler(cid, message, keywords, parameters) end
function greet(cid, message, keywords, parameters)        

   if npcHandler.focus > 0 or not(npcHandler.queue:isEmpty()) then
if npcHandler.focus ~= cid then
       selfSay('Wait, ' .. creatureGetName(cid) .. '')
       if(not npcHandler.queue:isInQueue(cid)) then
           npcHandler.queue:pushBack(cid)
       end
else
 npcHandler.talkStart = os.clock()
end	
   elseif(npcHandler.focus == 0) and (npcHandler.queue:isEmpty()) then
       selfSay('Greetings, traveller ' .. creatureGetName(cid) .. '.')
       npcHandler.focus = cid
       npcHandler.talkStart = os.clock()
   end
   
   return true
end

function farewell(cid, message, keywords, parameters)      
   if(cid == npcHandler.focus) then
       selfSay('May Crunor bless you.')
       npcHandler:resetNpc()
       npcHandler.queue:greetNext()
       return true
   end
   return false
end

-- Keyword handling functions end

-- Keyword structure generation start

-- Vial - will sell life fluids also so it's up to you whether to include this code. I have included a warning in "function confirmAction".
keywordHandler:addKeyword({'sell', 'vial'},     tradeItem, {itemid = 2006, cost = 5, charges = 0, realname = "empty vial"})
-- Lifefluid
keywordHandler:addKeyword({'life fluid'},     tradeItem, {itemid = 2006, cost = 60, charges = 10})


keywordHandler:addKeyword({'yes'}, confirmAction, nil)
keywordHandler:addKeyword({'no'}, confirmAction, nil)

keywordHandler:addKeyword({'job'},     sayMessage, {text = 'I am a druid and healer, a follower of Crunor.', onlyfocus = true})
keywordHandler:addKeyword({'sell'},        sayMessage, {text = 'I just sell some revitalizing life fluids.', onlyfocus = true})
keywordHandler:addKeyword({'name'},     sayMessage, {text = 'I am Hyacinth.', onlyfocus = true})

keywordHandler:addKeyword({'dallheim'},     sayMessage, {text = 'A man of the sword.', onlyfocus = true})
keywordHandler:addKeyword({'amber'},     sayMessage, {text = 'I never talked to her long.', onlyfocus = true})
keywordHandler:addKeyword({'cipfried'},     sayMessage, {text = 'His healing powers equal even mine.', onlyfocus = true})
keywordHandler:addKeyword({'seymour'},     sayMessage, {text = 'I am Hyacinth.', onlyfocus = true})
keywordHandler:addKeyword({'obi'},     sayMessage, {text = 'A greedy and annoying person as most people are.', onlyfocus = true})
keywordHandler:addKeyword({'tibia'},     sayMessage, {text = 'It is shaped by the will of the gods, so we don\'t have to question it.', onlyfocus = true})
keywordHandler:addKeyword({'time'},     sayMessage, {text = 'Time does not matter to me.', onlyfocus = true})
keywordHandler:addKeyword({'king'},     sayMessage, {text = 'I don\'t care about kings, queens, and the like.', onlyfocus = true})
keywordHandler:addKeyword({'magic'},     sayMessage, {text = 'I am one of the few magic users on this isle. But I sense a follower of the dark path of magic hiding somewhere in the depths of the dungeons.', onlyfocus = true})
keywordHandler:addKeyword({'help'},     sayMessage, {text = 'I can only sell life fluids, ask Cipfried for further help.', onlyfocus = true})
keywordHandler:addKeyword({'weapon'},     sayMessage, {text = 'I don\'t care much about weapons.', onlyfocus = true})
keywordHandler:addKeyword({'spell'},     sayMessage, {text = 'I can\'t teach you magic. On the mainland you will learn your spells soon enough.', onlyfocus = true})
keywordHandler:addKeyword({'sewer'},     sayMessage, {text = 'I rarely visit the town.', onlyfocus = true})
keywordHandler:addKeyword({'god'},     sayMessage, {text = 'As far as I know there is a library in the village. Teach yourself about the gods.', onlyfocus = true})
keywordHandler:addKeyword({'dungeon'},     sayMessage, {text = 'The dungeons are dangerous for unexperienced adventurers.', onlyfocus = true})
keywordHandler:addKeyword({'monster'},     sayMessage, {text = 'Most of the so called monsters of this isle are just creatures of the gods. On the mainland there are some beasts that truly are monstrous.', onlyfocus = true})

keywordHandler:addKeyword({'hi'}, greet, nil)
keywordHandler:addKeyword({'hello'}, greet, nil)
keywordHandler:addKeyword({'bye'}, farewell, nil)
-- Keyword structure generation end

 

comentem

 

todos os npcs 100% rl :D

 

flws :hi:

Link para o comentário
Compartilhar em outros sites

  • 1 month later...
  • 1 month later...
  • 1 month later...

Simplesmente perfeitos

Ficaram muito bons

Precisa do tradeToItem algo assim né?

Dia desses posta isso, mudando de assunto

Ficaram bem úteis, agora eu sei melhor como falar com os npc também

Mas usa [ codebox] por favor

Ficou horríivel de ler

Link para o comentário
Compartilhar em outros sites

  • 1 month later...
  • 3 months later...
  • 4 weeks later...
×
×
  • Criar Novo...