local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local Topic = {}
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 thinkCallback(cid)
local rand = math.random(300)
if rand == 1 then
npcHandler:say("Are you injured? Come and get a free healing at my little hut.")
elseif rand == 2 then
npcHandler:say("If you like to choose a druid's way of life, talk to me.")
elseif rand == 3 then
npcHandler:say("Follow your instincts and let nature guide you.")
elseif rand == 4 then
npcHandler:say("Sometimes it's not the loudest voice which has the most valuable information to give.")
end
return true
end
function creatureSayCallback(cid, type, msg)
if not npcHandler:isFocused(cid) then
if msgcontains(msg, "hello") or msgcontains(msg, "hi") then
local voc = getPlayerVocation(cid)
if voc == 0 then
npcHandler:say("Welcome to my humble hut, "..getCreatureName(cid).."! Are you interested in learning something about the druid vocation?", cid)
Topic[cid] = 1
elseif isDruid(cid) then
npcHandler:say("Be greeted again, fellow druid "..getCreatureName(cid).."! If you require {information}, I will assist you.", cid)
else
npcHandler:say("Have a good day, "..getCreatureName(cid).."! Although you chose to be a ".. (isSorcerer(cid) and "sorcerer" or isPaladin(cid) and "paladin" or isKnight(cid) and "knight")..", you are still always welcome here. I can also {heal} you if you're injured.", cid)
Topic[cid] = 0
end
npcHandler:addFocus(cid)
else
return false
end
elseif msgcontains(msg, "bye") or msgcontains(msg, "farewell") then
npcHandler:say("Farewell "..getCreatureName(cid)..", may you always have friends in your company.", cid)
Topic[cid] = nil
npcHandler:releaseFocus(cid)
elseif Topic[cid] == 1 then
if msgcontains(msg, "yes") then
npcHandler:say("I'm happy to hear that, dear "..getCreatureName(cid)..". I'll gladly give you some {information} or help you to become a {druid} right away. What would you prefer?", cid)
elseif msgcontains(msg, "no") then
npcHandler:say("That's sad, but maybe you just lack some {information} about our beautiful vocation?", cid)
else
npcHandler:say("I'm not quite sure if I understand you, but maybe you'd like some {information} about druids in general?", cid)
end
Topic[cid] = 2
elseif Topic[cid] == 2 then
if msgcontains(msg, "yes") or msgcontains(msg, "info") then
npcHandler:say("Depending on how much time you have, I can either give you the {short} or the {detailed} version. Choose whatever suits you most!", cid)
Topic[cid] = 3
else
npcHandler:say("No, no, you are given the choice between receiving {information} or becoming a {druid} if you've already made up your mind.", cid)
Topic[cid] = 2
end
elseif Topic[cid] == 3 then
if msgcontains(msg, "short") then
npcHandler:say("In short: Druids are focused on ice, earth and healing magic. We use runes, spells and rods to hunt our enemies and usually try to avoid body contact. Easy, right?", cid)
Topic[cid] = 4
elseif msgcontains(msg, "detail") then
npcHandler:say("That's wonderful. As a druid, your spirit is close to nature and its powers. Your aim is also to protect your friends with powerful healing magic. Can you follow me so far?", cid)
Topic[cid] = 8
else
npcHandler:say("That's not an option, my impatient young student. Would you like to listen to the {short} version or to the {detailed} version of my druid lecture?", cid)
Topic[cid] = 3
end
elseif Topic[cid] == 4 then
npcHandler:say("Well, anyway "..getCreatureName(cid)..", after having learnt a few basic things about druids, do you think that vocation would be fine for you?", cid)
Topic[cid] = 5
elseif Topic[cid] == 5 then
if msgcontains(msg, "yes") then
npcHandler:say("That's good to hear, "..getCreatureName(cid)..". Since this is such an important decision, I have to ask you, though, whether you have gotten all the information that you need?", cid)
Topic[cid] = 6
elseif msgcontains(msg, "no") then
npcHandler:say("Well, the other vocations have their own advantages and disadvantages. Maybe you will find something more suitable for you by talking to {Hykrion}, {Estrella} and {Narai}. Come and talk to me anytime!", cid)
Topic[cid] = 0
else
npcHandler:say("<ahem> This is the point of the conversation where you answer with {'yes'} or {'no'}.", cid)
Topic[cid] = 5
end
elseif Topic[cid] == 6 then
if msgcontains(msg, "yes") then
npcHandler:say("Be aware that this decision is final, "..getCreatureName(cid).."! Step in front of me and announce it proudly: DO YOU WANT TO BE A DRUID?", cid)
Topic[cid] = 7
elseif msgcontains(msg, "no") then
npcHandler:say("Well, the other vocations have their own advantages and disadvantages. Maybe you will find something more suitable for you by talking to {Hykrion}, {Estrella} and {Narai}. Come and talk to me anytime!", cid)
Topic[cid] = 0
else
npcHandler:say("That's an important question which you should answer with {'yes'} or {'no'}.", cid)
Topic[cid] = 6
end
elseif Topic[cid] == 7 then
if msgcontains(msg, "yes") then
npcHandler:say("SO BE IT! Let the energy of nature fill you, druid "..getCreatureName(cid).."! Learn the words of your first spell: 'UTEVO LUX'! This spell will provide light to you in dark locations and hours. ...", cid)
npcHandler:say("You may cast it by saying the magic words 'UTEVO LUX' while you have 20 mana or more. Also, you have earned the right to enter the cellar of this house. What your will find inside the chests there is yours to take. ...", cid)
npcHandler:say("Equip yourself well and gather some experience in the caves below. You may stay there for a while, but you should leave for the main continent soon. ...", cid)
npcHandler:say("The captain on the ship to the north will bring you to a city of your choice when you are prepared. Farewell, young druid, and don't hesitate to ask me if you have any questions.", cid)
else
npcHandler:say("Well, maybe you need some more time. Just make sure you choose the right vocation for you, no matter if it's the druid profession or something else. Talk to the other vocation masters, too, and take care!", cid)
end
Topic[cid] = nil
npcHandler:releaseFocus(cid)
elseif Topic[cid] == 8 then
if msgcontains(msg, "yes") then
npcHandler:say("Good. Don't assume that druids are weak and can't defend themselves. Our magic is as strong as that of sorcerers, just in a different way. Do you understand that so far?", cid)
Topic[cid] = 9
else
npcHandler:say("Well, in short, druids use nature spells and healing magic. Can you follow me so far?", cid)
Topic[cid] = 8
end
elseif Topic[cid] == 9 then
if msgcontains(msg, "yes") then
npcHandler:say("Good. Whereas sorcerers call forth hellfire and death itself, druids ask nature for assistance to conjure powerful ice storms and rock showers. Can you follow me so far?", cid)
Topic[cid] = 10
else
npcHandler:say("To say it in easy words: Druids and sorcerers have similar powers, but different types of spells. Do you understand that so far?", cid)
Topic[cid] = 9
end
elseif Topic[cid] == 10 then
if msgcontains(msg, "yes") then
npcHandler:say("Good. Like all mages, we do not have that much health and should be careful when fighting strong monsters, but we can easily keep our distance and deal great damage anyway. Do you understand?", cid)
Topic[cid] = 11
else
npcHandler:say("I said, the difference between sorcerer and druid spells is the focus. Sorcerers use black magic and druids white magic, so to speak. Can you follow me so far?", cid)
Topic[cid] = 10
end
elseif Topic[cid] == 11 then
if msgcontains(msg, "yes") then
npcHandler:say("Good. Last but not least, we can create runes storing magic power and enchant gems at elemental shrines to be used in weapons. Do you understand that so far?", cid)
Topic[cid] = 12
else
npcHandler:say("To put this differently: Don't get hit by monsters. Rather shoot spells on them from a distance as druids don't have a lot of hit points. Do you understand?", cid)
Topic[cid] = 11
end
elseif Topic[cid] == 12 then
if msgcontains(msg, "yes") then
npcHandler:say("Once a druid reaches character level 20, he or she can receive a vocation promotion and become an elder druid. Did you listen to everything I told you?", cid)
Topic[cid] = 13
else
npcHandler:say("Well, I just said that druids can create runes and enchant gems which are used in weapons. Do you understand that so far?", cid)
Topic[cid] = 12
end
elseif Topic[cid] == 13 then
if msgcontains(msg, "yes") then
npcHandler:say("So, dear "..getCreatureName(cid)..", let's test your newly gained knowledge! Let me ask you: How is a promoted druid called? {Master Druid}, {Elder Druid} or {Royal Druid}?", cid)
Topic[cid] = 14
else
npcHandler:say("Again, at level 20 a druid can be promoted to an elder druid. Did understand everything I told you?", cid)
Topic[cid] = 13
end
elseif Topic[cid] == 14 then
if msgcontains(msg, "master") then
npcHandler:say("I'm sorry "..getCreatureName(cid)..", but the sorcerers are the ones which gain a 'Master' title. We druids will become 'Elder'. Another question for you: Name one of the elements which we mastered - is it {ice}, {holy} or {fire}?", cid)
Topic[cid] = 15
else
npcHandler:say("This isn't an answer to my question, "..getCreatureName(cid)..". Please think again: how is a promoted druid called? {Master Druid}, {Elder Druid} or {Royal Druid}?", cid)
Topic[cid] = 14
end
elseif Topic[cid] == 15 then
if msgcontains(msg, "ice") then
npcHandler:say("Very good "..getCreatureName(cid)..", you remembered that detail about the ice storms. Next question: Where are magically enchanted gems used? In {weapons}, as {decoration} or as {food}?", cid)
Topic[cid] = 16
else
npcHandler:say("What element is this supposed to be? I know only {earth}, {fire}, {ice}, {energy}, {death} and {holy}.", cid)
Topic[cid] = 15
end
elseif Topic[cid] == 16 then
if msgcontains(msg, "weapon") then
npcHandler:say("Right, enchanted gems add elemental damage to weapons. I have one last question for you, "..getCreatureName(cid)..". What do you think a druid will spend most of his money on - buying {runes} or buying {weapons}?", cid)
Topic[cid] = 17
else
npcHandler:say("That wasn't among the allowed answers. The question was whether magical gems are used for {weapons}, as {decoration} or as {food}?", cid)
Topic[cid] = 16
end
elseif Topic[cid] == 17 then
if msgcontains(msg, "rune") then
npcHandler:say("Right, although we need of course some basic equipment, most of our money is spent on buying new runes and mana potions. That was easy, don't you think?", cid)
Topic[cid] = 4
else
npcHandler:say("Please try giving a clear answer - what does a druid spend a lot of money on, rather on {runes} or on {weapons}?", cid)
Topic[cid] = 17
end
end
return true
end
npcHandler:setMessage(MESSAGE_WALKAWAY, "Leaving without a friendly word... what a pity.")
npcHandler:setCallback(CALLBACK_ONTHINK, thinkCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)