local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
function doCreatureSayWithDelay(cid,text,type,delay,e,pcid)
if delay<=0 then
doCreatureSay(cid,text,type, false,pcid)
else
local func=function(pars)
doCreatureSay(pars.cid,pars.text,pars.type, false,pars.pcid)
pars.e.done=TRUE
end
e.done=FALSE
e.event=addEvent(func,delay,{cid=cid, text=text, type=type, e=e,pcid=pcid})
end
end
function doNPCTalkALot(msgs,interval,pcid)
local e={}
local ret={}
if interval==nil then interval=10000 end --10 seconds is default time between messages
for aux=1,table.getn(msgs) do
e[aux]={}
doCreatureSayWithDelay(getNpcCid(),msgs[aux],TALKTYPE_PRIVATE_NP,(aux-1)*interval,e[aux],pcid)
table.insert(ret,e[aux])
end
return(ret)
end
local Topic = {}
local storage = 90000
-- Storages:
-- 1 = Joining Inquisition
-- 2 = Start Mission 1
-- 3 = Finish Mission 1
-- 4 = Start Mission 2
-- 5 = Finish Mission 2
-- 6 = Start Mission 3
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] = 0
return true
end
function creatureSayCallback(cid, type, msg)
if not npcHandler:isFocused(cid) then
return false
elseif msgcontains(msg, 'ruthless seven') then
npcHandler:say('They\'re one of the mightiest weapons that our enemies have at disposal. They\'re the leaders of some of the most powerful forces of demonkind.', cid)
Topic[cid] = 0
elseif (msgcontains(msg, 'inquisition') or msgcontains(msg, 'join') or msgcontains(msg, 'mission')) and getPlayerStorageValue(cid, storage) == -1 then
npcHandler:say('Do you want to join the inquisition?', cid)
Topic[cid] = 1
elseif Topic[cid] == 1 then
if msgcontains(msg, 'yes') then
npcHandler:say('So be it. Now you are a member of the inquisition. You might ask me for a {mission} to raise in my esteem.', cid)
setPlayerStorageValue(cid, storage, 1)
else
npcHandler:say('Very suspicious!', cid)
end
Topic[cid] = 0
elseif msgcontains(msg, 'mission') then
local v = getPlayerStorageValue(cid, storage)
if v == 1 then -- Start Mission 1 - The interrogation
doNPCTalkALot({"Let's see if you are worthy. Take an inquisitor's field guide from the box in the back room. ...", "Follow the instructions in the guide to talk to the Thaian guards that protect the walls and gates of the city and test their loyalty. Then report to me about your mission."}, 5000, cid)
npcHandler:say("Let's see if you are worthy. Take an inquisitor's field guide from the box in the back room. ...", cid)
setPlayerStorageValue(cid, storage, 2)
Topic[cid] = 0
elseif v == 2 then
npcHandler:say("Your current mission is to investigate the reliability of certain guards. Are you done with that mission?", cid)
Topic[cid] = 2
elseif v == 3 then -- Start Mission 2 - The Eclipse
doNPCTalkALot({"Listen, we have information about a heretic coven that hides in a mountain called the Big Old One. The witches reach this cursed place on flying brooms and think they are safe there. ...", "I've arranged a flying carpet that will bring you to their hideout. Travel to Femor Hills and tell the carpet pilot the code word '{eclipse}'. ...", "He'll bring you to your destination. At their meeting place, you'll find a cauldron in which they cook some forbidden brew. ...", "Use this vial of holy water to destroy the brew. Also steal their grimoire and bring it to me."}, 5000, cid)
setPlayerStorageValue(cid, storage, 4)
doPlayerAddItem(cid, 7494, 1)
Topic[cid] = 0
elseif v == 4 then
npcHandler:say("Your current mission is to destroy this coven. Are you done with that mission?", cid)
Topic[cid] = 3
end
elseif v == 5 then -- Start Mission 3 - Vampire Hunt
doNPCTalkALot({"I think it's time to truly test your abilities. One of our allies has requested assistance. I think you are just the right person to helphim ...", "Storkus is an old and grumpy dwarf who works as a vampire hunter since many, many decades. He's quite successful but even he has his limits. ...", "So occasionally, we send him help. In return he trains and tests our recruits. It's an advantageous agreement for both sides ...", "You'll find him in his cave at the mountain outside of Kazordoon. He'll tell you about your next mission."}, 5000, cid)
setPlayerStorageValue(cid, storage, 6)
Topic[cid] = 0
elseif v == 4 then
npcHandler:say("Your current mission is to investigate the reliability of certain guards. Are you done with that mission?", cid)
Topic[cid] = 4
end
elseif Topic[cid] == 2 then -- Finish mission 1 - The interrogation
if msgcontains(msg, 'yes') then
if getPlayerStorageValue(cid, 90001) == 1 and getPlayerStorageValue(cid, 90002) == 1 and getPlayerStorageValue(cid, 90003) == 1 and getPlayerStorageValue(cid, 90004) == 1 and getPlayerStorageValue(cid, 90005) == 1 then
doNPCTalkALot({"Indeed, this is exactly what my other sources told me. Of course I knew the outcome of this investigation in advance. This was just a test. ...", "Well, now that you've proven yourself as useful, you can ask me for another mission. Let's see if you can handle some field duty, too."}, 5000, cid)
setPlayerStorageValue(cid, storage, 3)
else
npcHandler:say("I don't think so. This failure will be noted down. However, continue your investigations and return to me after you're done.", cid)
end
else
npcHandler:say("This lax behaviour is very suspicious. You better don't return here until you've finished your mission.", cid)
end
Topic[cid] = 0
elseif Topic[cid] == 3 then -- Finish mission 2 - The Eclipse
if msgcontains(msg, 'yes') then
if getPlayerStorageValue(cid, 99221) == 1 and getPlayerStorageValue(cid, 99220) == 1 then
npcHandler:say("Fine, fine. You have proven that you can work efficiently. Still, only further missions will show if you're are truly capable. Ask me for another mission if you're ready.", cid)
setPlayerStorageValue(cid, storage, 5)
else
npcHandler:say("I don't think so. This failure will be noted down. However, continue your mission and return to me when you're done.", cid)
end
else
npcHandler:say("This lax behaviour is very suspicious. You better don't return here until you've finished your mission.", cid)
end
elseif Topic[cid] == 4 then -- Finish mission 3 - Vampire Hunt
if msgcontains(msg, 'yes') then
if getPlayerStorageValue(cid, 92224) == 25 then
npcHandler:say("??", cid)
setPlayerStorageValue(cid, storage, 5)
else
npcHandler:say("I don't think so. This failure will be noted down. However, continue your mission and return to me when you're done.", cid)
end
else
npcHandler:say("This lax behaviour is very suspicious. You better don't return here until you've finished your mission.", cid)
end
elseif msgcontains(msg, 'name') then
npcHandler:say('I\'m Henricus, the Lord Inquisitor.', cid)
Topic[cid] = 0
elseif msgcontains(msg, 'job') then
npcHandler:say('By edict of the churches I\'m the Lord Inquisitor.', cid)
Topic[cid] = 0
elseif msgcontains(msg, 'inquisitor') then
npcHandler:say('The churches of the gods entrusted me with the enormous and responsible task to lead the inquisition. I leave the field work to inquisitors who I recruit from fitting people that cross my way.', cid)
Topic[cid] = 0
elseif msgcontains(msg, 'church') then
npcHandler:say('The churches of the gods united to fight heresy and dark magic. They are the shield of the true believers, while the inquisition is the sword that fights all enemies of virtuousness.', cid)
Topic[cid] = 0
elseif msgcontains(msg, 'gods') then
npcHandler:say('We owe to the gods of good our creation and continuing existence. If it weren\'t for them, we would surely fall prey to the minions of the vile and dark gods.', cid)
Topic[cid] = 0
elseif msgcontains(msg, 'dark') then
npcHandler:say('The dark powers are always present. If a human shows only the slightest weakness, they try to corrupt him and to lure him into their service. ...', cid)
npcHandler:say('We must be constantly aware of evil that comes in many disguises.', cid)
Topic[cid] = 0
elseif msgcontains(msg, 'king') then
npcHandler:say('The Thaian kings are crowned by a representative of the churches. This means they reign in the name of the gods of good and are part of the godly plan for humanity. ...', cid)
npcHandler:say('As nominal head of the church of Banor, the kings aren\'t only worldly but also spiritual authorities. ...', cid)
npcHandler:say('The kings fund the inquisition and sometimes provide manpower in matters of utmost importance. The inquisition, in return, protects the realm from heretics and individuals that aim to undermine the holy reign of the kings.', cid)
Topic[cid] = 0
elseif msgcontains(msg, 'banor') then
npcHandler:say('In the past, the order of Banor was the only order of knighthood in existence. In the course of time, the order concentrated more and more on spiritual matters rather than on worldly ones. ...', cid)
npcHandler:say('Nowadays, the order of Banor sanctions new orders and offers spiritual guidance to the fighters of good.', cid)
Topic[cid] = 0
elseif msgcontains(msg, 'fardos') then
npcHandler:say('The priests of Fardos are often mystics who have secluded themselves from worldly matters. Others provide guidance and healing to people in need in the temples.', cid)
Topic[cid] = 0
elseif msgcontains(msg, 'uman') then
npcHandler:say('The church of Uman oversees the education of the masses as well as the doings of the sorcerer and druid guilds. It decides which lines of research are in accordance with the will of Uman and which are not. ...', cid)
npcHandler:say('Concerned, the inquisition watches the attempts of these guilds to become more and more independent and to make own decisions. ...', cid)
npcHandler:say('Unfortunately, the sorcerer guild has become dangerously influential and so the hands of our priests are tied due to political matters ...', cid)
npcHandler:say('The druids lately claim that they are serving Crunor\'s will and not Uman\'s. Such heresy could only become possible with the independence of Carlin from the Thaian kingdom. ...', cid)
npcHandler:say('The spiritual centre of the druids switched to Carlin where they have much influence and cannot be supervised by the inquisition.', cid)
Topic[cid] = 0
elseif msgcontains(msg, 'crunor') then
npcHandler:say('The church of Crunor works closely together with the druid guild. This makes a cooperation sometimes difficult.', cid)
Topic[cid] = 0
elseif msgcontains(msg, 'zathroth') then
npcHandler:say('We can see his evil influence almost everywhere. Keep your eyes open or the dark one will lead you on the wrong way and destroy you.', cid)
Topic[cid] = 0
elseif msgcontains(msg, 'fafnar') then
npcHandler:say('Fafnar is mostly worshipped by the peasants and farmers in rural areas. ...', cid)
npcHandler:say('The inquisition has a close eye on these activities. Simply people tend to mix local superstitions with the teachings of the gods. This again may lead to heretical subcults.', cid)
Topic[cid] = 0
elseif msgcontains(msg, 'carlin') then
npcHandler:say('Carlin is a city of sin and heresy. After the reunion of Carlin with the kingdom, the inquisition will have much work to purify the city and its inhabitants.', cid)
Topic[cid] = 0
elseif msgcontains(msg, 'demon') then
npcHandler:say('Demons exist in many different shapes and levels of power. In general, they are servants of the dark gods and command great powers of destruction.', cid)
Topic[cid] = 0
elseif msgcontains(msg, 'darashia') then
npcHandler:say('Darashia is a godless town full of mislead fools. One day, it will surely share the fate of its sister town Drefia.', cid)
Topic[cid] = 0
elseif msgcontains(msg, 'drefia') then
npcHandler:say('Drefia used to be a city of sin and heresy, just like Carlin nowadays. One day, the gods decided to destroy this town and to erase all evil there.', cid)
Topic[cid] = 0
elseif msgcontains(msg, 'venore') then
npcHandler:say('Venore is somewhat difficult to handle. The merchants have a close eye on our activities in their city and our authority is limited there. However, we will use all of our influence to prevent a second Carlin.', cid)
Topic[cid] = 0
elseif msgcontains(msg, 'edron') then
npcHandler:say('Edron illustrates perfectly why the inquisition is needed and why we need more funds and manpower. ...', cid)
npcHandler:say('Our agents were on their way to investigate certain occurrences there when some faithless knights fled to some unholy ruins. ...', cid)
npcHandler:say('We were unable to wipe them out and the local order of knighthood was of little help. ...', cid)
npcHandler:say('It\'s almost sure that something dangerous is going on there, so we have to continue our efforts.', cid)
Topic[cid] = 0
elseif msgcontains(msg, 'ankrahmun') then
npcHandler:say('Even though they claim differently, this city is in the firm grip of Zathroth and his evil minions. Their whole twisted religion is a mockery of the teachings of our gods ...', cid)
npcHandler:say('As soon as we have gathered the strength, we should crush this city once and for all.', cid)
Topic[cid] = 0
elseif msgcontains(msg, 'elves') or msgcontains(msg, 'ab\'dendriel') then
npcHandler:say('Those elves are hardly any more civilised than orcs. They can become a threat to mankind at any time.', cid)
Topic[cid] = 0
elseif msgcontains(msg, 'dwarf') or msgcontains(msg, 'kazordoon') then
npcHandler:say('The dwarfs are allied with Thais but follow their own obscure religion. Although dwarfs keep mostly to themselves, we have to observe this alliance closely.', cid)
Topic[cid] = 0
elseif msgcontains(msg, 'druid') then
npcHandler:say('The druids here still follow the old rules. Sadly, the druids of Carlin have left the right path in the last years.', cid)
Topic[cid] = 0
elseif msgcontains(msg, 'sorcerer') then
npcHandler:say('Those who wield great power have to resist great temptations. We have the burden to eliminate all those who give in to the temptations.', cid)
Topic[cid] = 0
elseif msgcontains(msg, 'knight') then
npcHandler:say('Nowadays, most knights seem to have forgotten the noble cause to which all knights were bound in the past. Only a few have remained pious, serve the gods and follow their teachings.', cid)
Topic[cid] = 0
elseif msgcontains(msg, 'paladin') then
npcHandler:say('It\'s a shame that only a few paladins still use their abilities to further the cause of the gods of good. Too many paladins have become selfish and greedy.', cid)
Topic[cid] = 0
end
return true
end
npcHandler:setMessage(MESSAGE_GREET, "Greetings, fellow believer |PLAYERNAME|!")
npcHandler:setMessage(MESSAGE_FAREWELL, "Always be on guard, |PLAYERNAME|!")
npcHandler:setMessage(MESSAGE_WALKAWAY, "This ungraceful haste is most suspicious!")
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())