local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
local voices = {
{ text = 'Are you looking for the best tools? Come to my shop!' },
{ text = 'Feeling lost? You can always ask me about general hints!' },
{ text = 'Tools and general equipment at Al Dee\'s!' },
{ text = 'Don\'t head for adventure without a rope and torches! Buy your supplies here!' }
}
-- Greets --
npcHandler:setMessage(MESSAGE_WALKAWAY, 'Those kids today are more and more rud...')
npcHandler:setMessage(MESSAGE_FAREWELL, 'Have a nice day |PLAYERNAME|!')
npcHandler:setMessage(MESSAGE_SENDTRADE, 'Take a look in the trade window to your left.')
npcHandler:setMessage(MESSAGE_GREET, 'Welcome |PLAYERNAME|. If You have tools, or need one just ask me to {Trade}. We will make a good deal!')
-- Basic Keywords --
keywordHandler:addKeyword({'hint'}, StdModule.rookgaardHints, {npcHandler = npcHandler})
keywordHandler:addKeyword({'sell'}, StdModule.say, {npcHandler = npcHandler, text = 'Just ask me for a {trade} to see what I buy from you.'})
keywordHandler:addKeyword({'stuff'}, StdModule.say, {npcHandler = npcHandler, text = 'Just ask me for a {trade} to see my offers.'})
keywordHandler:addKeyword({'help'}, StdModule.say, {npcHandler = npcHandler, text = 'If you need general {equipment}, just ask me for a {trade}. I can also provide you with some general {hints} about the game.'})
keywordHandler:addKeyword({'equip'}, StdModule.say, {npcHandler = npcHandler, text = 'As an adventurer, you should always have at least a {backpack}, a {rope}, a {shovel}, a {weapon}, an {armor} and a {shield}.'})
keywordHandler:addKeyword({'how', 'are', 'you'}, StdModule.say, {npcHandler = npcHandler, text = 'I\'m feeling good. I\'m so glad to have you here as my customer.'})
keywordHandler:addKeyword({'job'}, StdModule.say, {npcHandler = npcHandler, text = 'I\'m a merchant. Just ask me for a {trade} to see my offers.'})
keywordHandler:addKeyword({'name'}, StdModule.say, {npcHandler = npcHandler, text = 'My name is Al Dee, but you can call me Al. Can I interest you in a {trade}?'})
keywordHandler:addKeyword({'time'}, StdModule.say, {npcHandler = npcHandler, text = 'It\'s about |TIME|. I\'m so sorry, I have no watches to sell. Do you want to buy something else?'})
keywordHandler:addKeyword({'monster'}, StdModule.say, {npcHandler = npcHandler, text = 'If you want to challenge monsters in the {dungeons}, you need some {weapons} and {armor} from the local {merchants}.'})
keywordHandler:addKeyword({'dungeon'}, StdModule.say, {npcHandler = npcHandler, text = 'If you want to explore the dungeons such as the {sewers}, you have to {equip} yourself with the vital stuff I am selling. It\'s {vital} in the deepest sense of the word.'})
keywordHandler:addKeyword({'sewer'}, StdModule.say, {npcHandler = npcHandler, text = 'Oh, our sewer system is very primitive - it\'s so primitive that it\'s overrun by {rats}. But the stuff I sell is safe from them. Just ask me for a {trade} to see it!'})
keywordHandler:addKeyword({'king'}, StdModule.say, {npcHandler = npcHandler, text = 'The king encouraged salesmen to travel here, but only I dared to take the risk, and a risk it was!'})
keywordHandler:addKeyword({'bug'}, StdModule.say, {npcHandler = npcHandler, text = 'Bugs plague this isle, but my wares are bug-free, totally bug-free.'})
keywordHandler:addKeyword({'tibia'}, StdModule.say, {npcHandler = npcHandler, text = 'One day I will return to the continent as a rich, a very rich man!'})
keywordHandler:addKeyword({'thais'}, StdModule.say, {npcHandler = npcHandler, text = 'Thais is a crowded town.'})
keywordHandler:addKeyword({'mainland'}, StdModule.say, {npcHandler = npcHandler, text = 'Have you ever wondered what that \'main\' is people are talking about? Well, once you\'ve reached level 8, you should talk to the {oracle}. You can choose a {profession} afterwards and explore much more of Tibia.'})
keywordHandler:addKeyword({'weapon'}, StdModule.say, {npcHandler = npcHandler, text = 'Oh, I\'m sorry, but I don\'t deal with weapons. That\'s {Obi\'s} or {Lee\'Delle\'s} business. I could offer you a {pick} in exchange for a {small axe} if you should happen to own one.'})
keywordHandler:addKeyword({'armor'}, StdModule.say, {npcHandler = npcHandler, text = 'Armor and shields can be bought at {Dixi\'s} or at {Lee\'Delle\'s}. Dixi runs that shop near {Obi\'s}.'})
keywordHandler:addKeyword({'shield'}, StdModule.say, {npcHandler = npcHandler, text = 'Armor and shields can be bought at {Dixi\'s} or at {Lee\'Delle\'s}. Dixi runs that shop near {Obi\'s}.'})
keywordHandler:addKeyword({'cooki'}, StdModule.say, {npcHandler = npcHandler, text = 'I you want to find someone who may want to buy your cookies, you should meet Lily.'})
keywordHandler:addKeyword({'blueberr'}, StdModule.say, {npcHandler = npcHandler, text = 'Blueberries grow on bushes. They\'re quite common in Tibia. Just pick them from a bush if you need a snack!'})
keywordHandler:addKeyword({'potion'}, StdModule.say, {npcHandler = npcHandler, text = 'Sorry, I don\'t sell potions. You should visit {Lily} for that.'})
keywordHandler:addKeyword({'food'}, StdModule.say, {npcHandler = npcHandler, text = 'Hmm, the best address to look for food might be {Willie} or {Billy}. {Norma} also has some snacks for sale.'})
keywordHandler:addKeyword({'bank'}, StdModule.say, {npcHandler = npcHandler, text = 'A bank is quite useful. You can deposit your money safely there. This way you don\'t have to carry it around with you all the time. You could also invest your money in my {wares}!'})
keywordHandler:addKeyword({'academy'}, StdModule.say, {npcHandler = npcHandler, text = 'The big building in the centre of Rookgaard. They have a library, a training centre, a {bank} and the room of the {oracle}. {Seymour} is the teacher there.'})
keywordHandler:addKeyword({'temple'}, StdModule.say, {npcHandler = npcHandler, text = 'The monk {Cipfried} takes care of our temple. He can heal you if you\'re badly injured or poisoned.'})
keywordHandler:addKeyword({'premium'}, StdModule.say, {npcHandler = npcHandler, text = 'As a premium adventurer you have many advantages. You really should check them out!'})
keywordHandler:addKeyword({'citizen'}, StdModule.say, {npcHandler = npcHandler, text = 'If you tell me the name of a citizen, I\'ll tell you what I know about him or her.'})
keywordHandler:addKeyword({'merchant'}, StdModule.say, {npcHandler = npcHandler, text = 'To view the offers of a merchant, simply talk to him or her and ask for a {trade}. They will gladly show you their offers and also the things they buy from you.'})
keywordHandler:addKeyword({'profession'}, StdModule.say, {npcHandler = npcHandler, text = 'You will learn everything you need to know about professions once you\'ve reached the {Island of Destiny}.'})
keywordHandler:addKeyword({'destiny'}, StdModule.say, {npcHandler = npcHandler, text = 'The Island of Destiny can be reached via the {oracle} once you are level 8. This trip will help you choose your {profession}!'})
keywordHandler:addKeyword({'torch'}, StdModule.say, {npcHandler = npcHandler, text = 'No thank you. I can already overstock the market with torches.'})
keywordHandler:addKeyword({'fishing'}, StdModule.say, {npcHandler = npcHandler, text = 'I sell fishing rods and worms if you want to fish. Simply ask me for a {trade}.'})
keywordHandler:addKeyword({'shovel'}, StdModule.say, {npcHandler = npcHandler, text = 'Yes, I am selling that. Simply ask me for a {trade} to view all my offers.'})
-- Names
keywordHandler:addKeyword({'cipfried'}, StdModule.say, {npcHandler = npcHandler, text = 'He is just an old monk. However, he can heal you if you are badly injured or poisoned.'})
keywordHandler:addKeyword({'zirella'}, StdModule.say, {npcHandler = npcHandler, text = 'Poor old woman, her son {Tom} never visits her.'})
keywordHandler:addKeyword({'santiago'}, StdModule.say, {npcHandler = npcHandler, text = 'He dedicated his life to welcome newcomers to this island.'})
keywordHandler:addKeyword({'loui'}, StdModule.say, {npcHandler = npcHandler, text = 'No idea who that is.'})
keywordHandler:addKeyword({'al', 'dee'}, StdModule.say, {npcHandler = npcHandler, text = 'Yep, that\'s me. Smart of you to notice that!'})
keywordHandler:addKeyword({'paulie'}, StdModule.say, {npcHandler = npcHandler, text = 'He\'s the local {bank} clerk.'})
keywordHandler:addKeyword({'hyacinth'}, StdModule.say, {npcHandler = npcHandler, text = 'He mostly stays by himself. He\'s a hermit outside of town - good luck finding him.'})
keywordHandler:addKeyword({'dixi'}, StdModule.say, {npcHandler = npcHandler, text = 'She\'s {Obi\'s} granddaughter and deals with {armors} and {shields}. Her shop is south west of town, close to the {temple}.'})
keywordHandler:addKeyword({'obi'}, StdModule.say, {npcHandler = npcHandler, text = 'He sells {weapons}. His shop is south west of town, close to the {temple}.'})
keywordHandler:addKeyword({'lee\'delle'}, StdModule.say, {npcHandler = npcHandler, text = 'If you are a {premium} adventurer, you should check out {Lee\'Delle\'s} shop. She lives in the western part of town, just across the bridge.'})
keywordHandler:addKeyword({'tom'}, StdModule.say, {npcHandler = npcHandler, text = 'He\'s the local tanner. You could try selling fresh corpses or leather to him.'})
keywordHandler:addKeyword({'amber'}, StdModule.say, {npcHandler = npcHandler, text = 'She\'s currently recovering from her travels in the {academy}. It\'s always nice to chat with her!'})
keywordHandler:addKeyword({'oracle'}, StdModule.say, {npcHandler = npcHandler, text = 'You can find the oracle on the top floor of the {academy}, just above {Seymour}. Go there when you are level 8.'})
keywordHandler:addKeyword({'seymour'}, StdModule.say, {npcHandler = npcHandler, text = 'Seymour is a teacher running the {academy}. He has many important {information} about Tibia.'})
keywordHandler:addKeyword({'lily'}, StdModule.say, {npcHandler = npcHandler, text = 'She sells health {potions} and antidote potions. Also, she buys {blueberries} and {cookies} in case you find any.'})
keywordHandler:addKeyword({'willie'}, StdModule.say, {npcHandler = npcHandler, text = 'This is a local farmer. If you need fresh {food} to regain your health, it\'s a good place to go. However, many monsters also carry food such as meat or cheese. Or you could simply pick {blueberries}.'})
keywordHandler:addKeyword({'billy'}, StdModule.say, {npcHandler = npcHandler, text = 'This is a local farmer. If you need fresh {food} to regain your health, it\'s a good place to go. He\'s only trading with {premium} adventurers though.'})
keywordHandler:addKeyword({'norma'}, StdModule.say, {npcHandler = npcHandler, text = 'She used to sell equipment, but I think she has opened a small bar now. Talks about changing her name to \'Mary\' and such, strange girl.'})
keywordHandler:addKeyword({'zerbrus'}, StdModule.say, {npcHandler = npcHandler, text = 'Some call him a hero. He protects the town from {monsters}.'})
-- Backpacks
keywordHandler:addKeyword({'backpack'}, StdModule.say, {npcHandler = npcHandler, text = 'You want me to make {pirate}, {fur}, {minotaur} or {expedition} backpack for you?'})
local piratebp = {5462, 5918, 5927, 6095, 6096}
local function creatureSayCallback(cid, type, msg)
local player = Player(cid)
if npcHandler.topic[cid] == 0 then
if msgcontains(msg, 'pirate') then
npcHandler:say('Do you have all 4 pieces of pirate set and pirate bag?', cid)
npcHandler.topic[cid] = 1
end
elseif npcHandler.topic[cid] == 1 then
if msgcontains(msg, "yes") then
for key, itemid in pairs(piratebp) do
if player:getItemCount(itemid) < 1 then
npcHandler:say('HEY! You don\'t have them!', cid)
npcHandler.topic[cid] = 0
return true
end
end
for key, itemid in pairs(piratebp) do
player:removeItem(itemid, 1)
end
player:addItem(5926, 1)
npcHandler:say('Here You go! I\'ll use your ingredients to make second backpack and sell it to Tom.', cid)
else
npcHandler:say("Okay then.", cid)
end
npcHandler.topic[cid] = 0
end
return true
end
local minotaurbp = {5878, 12428}
local function creatureSayCallback(cid, type, msg)
local player = Player(cid)
if npcHandler.topic[cid] == 0 then
if msgcontains(msg, 'minotaur') then
npcHandler:say('Do you have both 50 minotaur leathers and horns for the minotaur backpack?', cid)
npcHandler.topic[cid] = 1
end
elseif npcHandler.topic[cid] == 1 then
if msgcontains(msg, "yes") then
for key, itemid in pairs(minotaurbp) do
if player:getItemCount(itemid) < 50 then
npcHandler:say('HEY! You don\'t have what I need!', cid)
npcHandler.topic[cid] = 0
return true
end
end
for key, itemid in pairs(minotaurbp) do
player:removeItem(itemid, 50)
end
player:addItem(11244, 1)
npcHandler:say('Have it then horny |PLAYERNAME|', cid)
else
npcHandler:say("Maybe another time", cid)
end
npcHandler.topic[cid] = 0
end
return true
end
local furbp = {5896, 11235, 11212, 11209, 11216}
local function creatureSayCallback(cid, type, msg)
local player = Player(cid)
if npcHandler.topic[cid] == 0 then
if msgcontains(msg, 'fur') then
npcHandler:say('Listen then, I need fur, 10 of each: Bear (could be bear paws), Warwolf, Badger, Winter wolf and Silky fur to sew inside. Do You have them now?', cid)
npcHandler.topic[cid] = 1
end
elseif npcHandler.topic[cid] == 1 then
if msgcontains(msg, "yes") then
for key, itemid in pairs(furbp) do
if player:getItemCount(itemid) < 10 then
npcHandler:say('No, You don\'t', cid)
npcHandler.topic[cid] = 0
return true
end
end
for key, itemid in pairs(furbp) do
player:removeItem(itemid, 10)
end
player:addItem(7342, 1)
npcHandler:say('Excellent! In cold winter you can throw everything out and use it as a tent! ', cid)
else
npcHandler:say("Um, okay..", cid)
end
npcHandler.topic[cid] = 0
end
return true
end
local expeditionbp = {11242, 7731, 5710, 2563, 2580, 11421}
local function creatureSayCallback(cid, type, msg)
local player = Player(cid)
if npcHandler.topic[cid] == 0 then
if msgcontains(msg, 'expedition') then
npcHandler:say('I need some example, if You find bring expedition bag. Ow of course You will need also special light tools: matchete, elvenhair rope, light shovel, dwarven pick, pan and.. fishing rod.. You know better to carry than to ask for.. Ow, You already have them?', cid)
npcHandler.topic[cid] = 1
end
elseif npcHandler.topic[cid] == 1 then
if msgcontains(msg, "yes") then
for key, itemid in pairs(expeditionbp) do
if player:getItemCount(itemid) < 1 then
npcHandler:say('Better start looking for all this tools', cid)
npcHandler.topic[cid] = 0
return true
end
end
do player:removeItem(11242, 1)
end
player:addItem(11241, 1)
npcHandler:say('Sure You do! This backpack is really spacious! I\'m really proud of it, don\'t loose it!', cid)
else
npcHandler:say("Whatever..", cid)
end
npcHandler.topic[cid] = 0
end
return true
end
--Citizen first addon backpack--
function playerBuyAddonNPC(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
return false
end
if (parameters.confirm ~= true) and (parameters.decline ~= true) then
if (getPlayerStorageValue(cid, parameters.storageID) ~= -1) then
npcHandler:say('You already have backpack addon!', cid)
npcHandler:resetNpc()
return true
end
local itemsTable = parameters.items
local items_list = '!!'
local text = '??'
if (parameters.cost > 0) and table.maxn(parameters.items) then
text = items_list .. ' and ' .. parameters.cost .. ' gp'
elseif (parameters.cost > 0) then
text = parameters.cost .. ' gp'
elseif table.maxn(parameters.items) then
text = items_list
end
npcHandler:say('Did you bring me 50 Minotaur leathers and 50 Orc leathers for citizen backpack addon?', cid)
return true
elseif (parameters.confirm == true) then
local addonNode = node:getParent()
local addoninfo = addonNode:getParameters()
local items_number = 0
if table.maxn(addoninfo.items) > 0 then
for i = 1, table.maxn(addoninfo.items) do
local item = addoninfo.items[i]
if (getPlayerItemCount(cid,item[1]) >= item[2]) then
items_number = items_number + 1
end
end
end
if(getPlayerMoney(cid) >= addoninfo.cost) and (items_number == table.maxn(addoninfo.items)) then
doPlayerRemoveMoney(cid, addoninfo.cost)
if table.maxn(addoninfo.items) > 0 then
for i = 1, table.maxn(addoninfo.items) do
local item = addoninfo.items[i]
doPlayerRemoveItem(cid,item[1],item[2])
end
end
doPlayerAddOutfit(cid, addoninfo.outfit_male, addoninfo.addon)
doPlayerAddOutfit(cid, addoninfo.outfit_female, addoninfo.addon)
setPlayerStorageValue(cid,addoninfo.storageID,1)
npcHandler:say('You look better now!.', cid)
else
npcHandler:say('You do not have enough leathers!', cid)
end
npcHandler:resetNpc()
return true
elseif (parameters.decline == true) then
npcHandler:say('Why bothering me then?', cid)
npcHandler:resetNpc()
return true
end
return false
end
local noNode = KeywordNode:new({'no'}, playerBuyAddonNPC, {decline = true})
local yesNode = KeywordNode:new({'yes'}, playerBuyAddonNPC, {confirm = true})
local outfit_node = keywordHandler:addKeyword({'addon'}, playerBuyAddonNPC, {premium = false, cost = 0, items = {{5878,50}, {12435,50}}, outfit_female = 128, outfit_male = 136, addon = 1, storageID = 10041})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)
npcHandler:addModule(FocusModule:new())
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())