local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local Topic = {}
local count = {}
local destiny = {"Hmmm, let me look at you. You got that intelligent sparkle in your eyes and you'd love to handle great power - that must be a future sorcerer!","Hmmm, let me look at you. You have an aura of great wisdom and may have healing hands as well as a sense for the powers of nature - I think you're a natural born druid!","Hmmm, let me look at you. Such a lean and swift fighter you are - I can imagine you really well with a bow - I think you'd make a tremendous paladin!","Hmmm, let me look at you. Strong and sturdy, with a determined look in your eyes - no doubt the knight profession would be suited for you!"}
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
function greetCallback(cid)
Topic[cid] = 1
count[cid] = 0
return true
end
function thinkCallback(cid)
local rand = math.random(250)
if rand == 1 then
npcHandler:say("Get some training in the academy!")
elseif rand == 2 then
npcHandler:say("Feeling lost? Ask me for help!")
elseif rand == 3 then
npcHandler:say("Newcomers - visit me! I'll answer your questions!")
end
return true
end
function creatureSayCallback(cid, type, msg)
if not npcHandler:isFocused(cid) then
return false
elseif msgcontains(msg, "how") and msgcontains(msg, "are") and msgcontains(msg, "you") then
npcHandler:say("Well, the {king} doesn't send troops anymore, the {academy} is dreadfully low on money, and the end of the world is pretty nigh. Apart from that I'm reasonably fine, I suppose.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "fuck") then
npcHandler:say("For this remark I will wash your mouth with soap, young " .. (getPlayerSex(cid) == 0 and "lady!" or "man!"), cid)
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_YELLOW_RINGS)
Topic[cid] = 0
elseif (msgcontains(msg, "yes") or msgcontains(msg, "student")) and Topic[cid] == 1 then
npcHandler:say("Brilliant! We need fine adventurers like you! If you are ready to learn, just ask me for a {lesson}. You can always ask for the differently coloured words - such as {this} one - to continue the lesson.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "al") and msgcontains(msg, "dee") then
npcHandler:say("Al Dee has a general {equipment} store in the north-western part of the village. He sells useful stuff such as {ropes}.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "island") and msgcontains(msg, "destiny") then
npcHandler:say("This is an island with {vocation} teachers. You can learn all about the different vocations there once you are level 8.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "hint") then
if getPlayerStorageValue(cid, 6079) == -1 then
setPlayerStorageValue(cid, 6079, 1)
end
local str = getPlayerStorageValue(cid, 6079)
npcHandler:say(hints[str], cid)
setPlayerStorageValue(cid, 6079, str == 28 and 0 or str + 1)
Topic[cid] = 0
elseif msgcontains(msg, "mission") or msgcontains(msg, "quest") then
npcHandler:say(getPlayerLevel(cid) < 4 and "You are pretty inexperienced. I think killing rats is a suitable challenge for you. For each fresh {dead rat} I will give you two shiny coins of gold." or "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 to me.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "destiny") then
if getPlayerStorageValue(cid, 6080) <= 0 then
npcHandler:say("Shall I try and take a guess at your destiny?", cid)
Topic[cid] = 5
else
local destiny = {[1] = "Well, like I told you before, I really think you got that spirit of a sorcerer in you. But of course it's completely up to you!", [2] = "Well, like I told you before, I really think you got that spirit of a druid in you. But of course it's completely up to you!", [3] = "Well, like I told you before, I really think you got that spirit of a paladin in you. But of course it's completely up to you!", [4] = "Well, like I told you before, I really think you got that spirit of a knight in you. But of course it's completely up to you!"}
npcHandler:say(destiny[getPlayerStorageValue(cid,6080)], cid)
end
elseif msgcontains(msg, "dead") and msgcontains(msg, "rat") then
if getCount(msg) ~= -1 and 1 < getCount(msg) then
count[cid] = getCount(msg)
npcHandler:say("Have you brought " .. count[cid] .. " dead rats to me to pick up your reward?", cid)
else
count[cid] = 1
npcHandler:say("Have you brought a dead rat to me to pick up your reward?", cid)
end
Topic[cid] = 2
elseif msgcontains(msg, "yes") and Topic[cid] == 5 then
local rand = math.random(4)
npcHandler:say(destiny[rand], cid)
setPlayerStorageValue(cid, 6080, rand)
Topic[cid] = 0
elseif Topic[cid] == 2 and msgcontains(msg, "yes") then
if getPlayerItemCount(cid, 2813) >= count[cid] then
npcHandler:say("Thank you! Here is your reward.", cid)
doPlayerRemoveItem(cid, 2813, count[cid])
doPlayerAddMoney(cid, count[cid] * 2)
else
npcHandler:say(count[cid] > 1 and "HEY! You do not have so many!" or "HEY! You don't have one! Stop playing tricks on fooling me or I will give you some extra work!", cid)
end
Topic[cid] = 0
elseif Topic[cid] == 2 then
npcHandler:say("Go and find some rats to kill!", cid)
Topic[cid] = 0
elseif msgcontains(msg, "job") then
npcHandler:say("I'm the master of this fine {academy}, giving {lessons} to my students.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "time") then
npcHandler:say("It's "..getTibianTime()..", so you are late. Hurry!", cid)
Topic[cid] = 0
elseif msgcontains(msg, "name") then
npcHandler:say("My name is Seymour, but for you I am 'Sir' Seymour.", cid)
elseif msgcontains(msg, "sir") then
npcHandler:say("At least you know how to address a man of my importance.", cid)
Topic[cid] = 0
elseif Topic[cid] == 1 then
npcHandler:say("Only nonsense on your mind, eh?", cid)
Topic[cid] = 0
elseif msgcontains(msg, "information") then
npcHandler:say("Well, I could give you valuable {lessons} or some general {hints} about the game, or a small {quest} if you're interested.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "lesson") then
npcHandler:say("Oh, which lesson did you want to attend again? Was it {Rookgaard}, {fighting}, {equipment}, {citizens}, the {academy} or the {oracle}?", cid)
Topic[cid] = 0
elseif msgcontains(msg, "this") then
npcHandler:say("Yes, you got it. Ask me for a {lesson} anytime.?", cid)
Topic[cid] = 0
elseif msgcontains(msg, "rookgaard") then
npcHandler:say("Rookgaard is the name of this {village} as well as of the whole {island}. It belongs to the kingdom of {Thais}, in our world which is called {Tibia}.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "village") then
npcHandler:say("The most important places in this village are the {temple}, the different {shops}, the {academy} and the {bridges}.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "island") then
npcHandler:say("The island is separated into a {premium} side and a non-premium side. On both sides you will find {dungeons}, but the premium side tends to be a little less crowded with other players.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "thais") then
npcHandler:say("The city of Thais is reigned by King Tibianus. Of course, there are many other cities but you will learn about them later.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "tibia") then
npcHandler:say("The world of Tibia is very large with tons of places to explore. Vast deserts, Caribbean islands, deep jungles, green meadows and jagged mountains await you!", cid)
Topic[cid] = 0
elseif msgcontains(msg, "temple") then
npcHandler:say("The temple is the place to go when you are very low on {health} or poisoned. Ask {Cipfried} for a heal - he usually notices emergencies by himself.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "shop") then
npcHandler:say("We have a {weapon} and an {armor} shop south of the academy. {Equipment} such as {ropes} are sold to the north-west. {Potions} can be bought to the south. And then there are the {farms}.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "bridge") then
npcHandler:say("There is a bridge to the north and one to the west which lead outside the village. You should only leave once you are well {equipped} and at least level 2.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "farm") then
npcHandler:say("The farms are west of here. You can buy and sell {food} there which you need to regain {health}.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "dungeon") then
npcHandler:say("You should not descend into dungeons without proper {equipment}. Once you are all prepared, ask the bridge {guards} for suitable {monsters}.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "main") then
npcHandler:say("You can leave for mainland once you are level 8. To do so talk to the {oracle}.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "fight") then
npcHandler:say("You have to fight {monsters} to train your {skills} and {level}. If you lose {health}, eat {food} to regain it or use a {potion}.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "skill") then
npcHandler:say("The more you fight with a weapon, the better will be your skill handling this weapon. Don't worry about that right now though, this will become important once you have a {vocation}.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "level") then
npcHandler:say("Once you gained enough experience for a level, you will advance. This means - among other things - more {health} points, a faster walking speed and more strength to carry things.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "equip") then
npcHandler:say("Don't go hunting without proper equipment. You need at least a suitable {weapon}, {armor}, {shield}, {rope} and {shovel}. A {torch} is also good as well as {legs}, a {helmet} and {shoes}.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "premium") then
npcHandler:say("Paying for your Tibia account will turn it into a premium account. This means access to more areas and functions of the game as well as other neat features.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "potion") then
npcHandler:say("Use a small health potion in case of emergencies to fill up around 75 health points. You can buy them at {Lily}'s shop. She also has {antidote} potions.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "antidote") then
npcHandler:say("Some monsters poison you. To heal poison, use an antidote potion on yourself. Buy them at {Lily}'s store.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "food") then
npcHandler:say("Many monsters, such as rabbits or deer, are excellent food providers. You can also buy food from {Willie} or {Billy}, the farmers.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "weapon") then
npcHandler:say("The starter weapon, a club, won't get you far. You should earn some {money} and buy a better weapon such as a sabre from {Obi}'s or {Lee'Delle}'s shop. Simply ask for a {trade}.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "armor") then
npcHandler:say("The starter armor, a coat, does not protect you well. First of all, earn some money and try to get a sturdy leather armor from {Dixi}'s or {Lee'Delle}'s shop. Simply ask for a {trade}.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "shield") then
npcHandler:say("I fear you have to buy your first shield by yourself. A wooden shield from {Dixi} or {Lee'Delle} is a good choice.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "rope") then
npcHandler:say("You definitely need a rope to progress in dungeons, else you might end up stuck. Buy one from {Al Dee} or {Lee'Delle}.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "shovel") then
npcHandler:say("A shovel is needed to dig some {dungeon} entrances open. 'Use' it on a loose stone pile to make a hole large enough to enter.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "torch") then
npcHandler:say("A torch will provide you with light in dark {dungeons}. 'Use' it to light it. You can buy them from {Al Dee} or {Lee'Delle}.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "legs") then
npcHandler:say("Leather legs might be a good basic protection. You can buy them from {Dixi} or {Lee'Delle}. Or, once you are strong enough, hunt {trolls}. They sometimes carry them in their {loot}.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "helmet") then
npcHandler:say("A sturdy leather helmet is a good choice for a beginner. You can either buy it from {Dixi} and {Lee'Delle}, or, once you are strong enough, {loot} them from {trolls}.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "shoe") then
npcHandler:say("Leather boots are basic shoes which will protect you well. You can either buy them from {Dixi} and {Lee'Delle}, or, once you are strong enough, {loot} them from {trolls}.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "trade") then
npcHandler:say("I personally don't have anything to trade, but you can ask {merchants} for a trade. That will open a window where you can see their offers and the things they buy from you.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "citizen") then
npcHandler:say("Most of the citizens here are {merchants}. You can give me the name of any non-player character and I will tell you something about him or her.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "merchant") then
npcHandler:say("Merchants buy and sell goods. Just ask them for a {trade} to see what they offer or buy from you.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "king") then
npcHandler:say("Hail to King Tibianus! Long live our king! Not that he cares for an old veteran who is stuck on this godforsaken island...", cid)
Topic[cid] = 0
elseif msgcontains(msg, "guard") then
npcHandler:say("The guards {Dallheim} and {Zerbrus} protect our village from {monsters} trying to enter. They also mark useful {dungeon} locations on your map.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "monster") then
npcHandler:say("Good monsters to start hunting are {rats}. They live in the {sewers} below the village.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "rat") then
npcHandler:say("To attack a rat, simply click on it in your battle list. Make sure that you have proper {equipment}, though! Also, I give you 2 gold coins for each {dead rat}.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "sewer") then
npcHandler:say("One entrance to the sewers is south of this {academy}. Look for a sewer grate, then use it to climb down.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "troll") then
npcHandler:say("Trolls are quite nasty monsters which you shouldn't face before level 3 or 4 depending on your {equipment}. Ask the bridge {guards} for their locations!", cid)
Topic[cid] = 0
elseif msgcontains(msg, "money") then
npcHandler:say("Make money by killing {monsters} and picking up their {loot}. You can sell many of the things they carry.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "loot") then
npcHandler:say("Once a monster is dead, you can select 'Open' on the {corpse} to check what's inside. Sometimes they carry {money} or other items which you can sell to {merchants}.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "corpse") then
npcHandler:say("You can even sell some corpses! For example, you can sell fresh dead rats to {Tom} the tanner or me. He also buys other dead creatures, just ask him for a {trade}.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "obi") then
npcHandler:say("Obi sells and buys {weapons}. You can find his shop south of the academy.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "dixi") then
npcHandler:say("Dixi sells and buys {armors}, {shields}, {helmets} and {legs}. You can find her shop south of the academy, just go up the stairs in {Obi}'s shop.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "dallheim") then
npcHandler:say("He's the guard on the north {bridge} and a great fighter. He can show you {monster} locations. Just ask him about monsters!", cid)
Topic[cid] = 0
elseif msgcontains(msg, "zerbrus") then
npcHandler:say("He's the guard on the west {bridge} and a great fighter. He can show you {monster} locations. Just ask him about monsters!!", cid)
Topic[cid] = 0
elseif msgcontains(msg, "amber") then
npcHandler:say("A traveller from the {main} continent. I wonder what brought her here. No one comes here of his own free will.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "norma") then
npcHandler:say("Norma has recently opened a bar here meaning she sells drinks and snacks. Nothing of importance to you, young student.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "willie") then
npcHandler:say("Willie is a fine farmer, although he is short-tempered. He sells and buys {food}.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "billy") then
npcHandler:say("Billy is {Willie}'s cousin, but he has his farm on the {premium} side of the village.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "lily") then
npcHandler:say("In the southern part of town, Lily sells {potions} which might come in handy once you are deep in a dungeon and need {health}.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "lee'delle") then
npcHandler:say("Lee'Delle's shop is in the western part of town, on the {premium} side. She sells everything cheaper.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "hyacinth") then
npcHandler:say("A mysterious druid who lives somewhere in the wilderness. He sells small health {potions} just like {Lily}.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "tom") then
npcHandler:say("Tom the tanner buys fresh {corpses}, minotaur leather and paws. Always good to make some {money} if you can carry the corpses there fast enough.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "loui") then
npcHandler:say("Oh, let's not talk about Loui.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "santiago") then
npcHandler:say("A fine and helpful man. Without him, many new adventurers would be quite clueless.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "zirella") then
npcHandler:say("This is Tom the tanner's mother. Other than that, I don't think she is of importance.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "paulie") then
npcHandler:say("Yes, Paulie is very important. He is the local {bank} clerk.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "academy") then
npcHandler:say("The academy is the building you are standing in. We have a {library}, a {training} centre, a {bank} and the room of the {oracle}.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "train") then
npcHandler:say("When you have the time, please visit our training centre downstairs. 'Look' at the blackboards to read some important advice. Oh, you need a {key} for that!", cid)
Topic[cid] = 0
elseif msgcontains(msg, "library") then
npcHandler:say("There are many books in the bookcases around you, unless some naughty kids stole them again. Read them for more and detailed information.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "bank") then
npcHandler:say("In a bank you can deposit your earned gold coins safely. Just go downstairs to {Paulie} and ask him to {deposit} your money.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "deposit") then
npcHandler:say("Yes, depositing your money will keep it safe, so it is a good idea to store it in the bank. Of course, you can always withdraw it again.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "key") then
npcHandler:say("Do you want to buy the Key to Adventure for 5 gold coins?", cid)
Topic[cid] = 4
elseif Topic[cid] == 4 then
if msgcontains(msg, "yes") then
if doPlayerRemoveMoney(cid, 5) == TRUE then
npcHandler:say("Here you are.", cid)
doItemSetAttribute(doPlayerAddItem(cid, 2088, 1), 'aid', 4600)
else
npcHandler:say("You don't have enough money.", cid)
end
elseif msgcontains(msg, "no") then
npcHandler:say("As you wish.", cid)
else
npcHandler:say("Only nonsense on your mind, eh?", cid)
end
Topic[cid] = 0
elseif msgcontains(msg, "oracle") then
npcHandler:say("The oracle is a mysterious being just upstairs. It will bring you to the {Island of Destiny} to choose your {vocation} once you are level 8.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "vocation") then
npcHandler:say("There are four vocations: {knights}, {paladins}, {sorcerers} and {druids}. You can choose your vocation once you are level 8 and have talked to the {oracle}.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "knight") then
npcHandler:say("Knights are strong melee fighters. You will learn all about them once you are level 8 and reached the Island of {Destiny}.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "paladin") then
npcHandler:say("Paladins are swift distance fighters. You will learn all about them once you are level 8 and reached the Island of {Destiny}.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "druid") then
npcHandler:say("Druids are nature magic users and great healers. You will learn all about them once you are level 8 and reached the Island of {Destiny}.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "sorcerer") then
npcHandler:say("Sorcerers are talented elemental magicians. You will learn all about them once you are level 8 and reached the Island of {Destiny}.", cid)
Topic[cid] = 0
elseif msgcontains(msg, "box") then
npcHandler:say("Do you have a suitable present box for me?", cid)
Topic[cid] = 3
elseif Topic[cid] == 3 then
if msgcontains(msg, "yes") then
if doPlayerRemoveItem(cid, 1990, 1) == TRUE then
npcHandler:say("THANK YOU! Here is a helmet that will serve you well.", cid)
doPlayerAddItem(cid, 2480, 1)
else
npcHandler:say("HEY! You don't have one! Stop playing tricks on me or I'll give you some extra work!", cid)
end
else
npcHandler:say("HEY! You don't have one! Stop playing tricks on me or I will give some extra work!", cid)
end
Topic[cid] = 0
end
return true
end
npcHandler:setMessage(MESSAGE_GREET, "Hello, |PLAYERNAME|. Welcome to the Academy of Rookgaard. May I sign you up as a {student}?")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Good bye! And remember: No running up and down in the academy!")
npcHandler:setMessage(MESSAGE_FAREWELL, "Good bye, |PLAYERNAME|! And remember: No running up and down in the academy!")
npcHandler:setCallback(CALLBACK_ONTHINK, thinkCallback)
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())