local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local Topic = {}
function onCreatureAppear(cid) npcHandler
nCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler
nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler
nCreatureSay(cid, type, msg) end
function onThink() npcHandler
nThink() end
function greetCallback(cid)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
Topic[talkUser] = 0
return true
end
function doCreatureSayWithDelay(cid,text,type,delay,e)
if delay<=0 then
doCreatureSay(cid,text,type)
else
local func=function(pars)
doCreatureSay(pars.cid,pars.text,pars.type)
pars.e.done=TRUE
end
e.done=FALSE
e.event=addEvent(func,delay,{cid=cid, text=text, type=type, e=e})
end
end
--returns how many msgs he have said already
function cancelNPCTalk(events)
local ret=1
for aux=1,table.getn(events) do
if events[aux].done==FALSE then
stopEvent(events[aux].event)
else
ret=ret+1
end
end
events=nil
return(ret)
end
function doNPCTalkALot(msgs,interval)
local e={}
local ret={}
if interval==nil then interval=3000 end --3 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])
table.insert(ret,e[aux])
end
return(ret)
end
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local namee = getPlayerName(cid)
if msgcontains(msg, 'name') or msgcontains(msg, 'Name') then
npcHandler:say("My name is Marlene.", cid)
Topic[cid] = nil
elseif msgcontains(msg, 'job') or msgcontains(msg, 'Job') then
npcHandler:say("I'm Bruno's wife. Besides: Have you already heard the latest news about the seamonster, Aneus, or the rumours in this area?", cid)
Topic[cid] = nil
elseif msgcontains(msg, 'bruno') or msgcontains(msg, 'Bruno') then
npcHandler:say("Bruno is a wonderful husband. But he is seldom at home. *looks a little bit sad*", cid)
Topic[cid] = nil
elseif msgcontains(msg, 'Graubart') or msgcontains(msg, 'graubart') then
npcHandler:say("Ah, old Graubart. A very nice person. But he is strange. He always is busy when I want to talk to him. *lost in thoughts*", cid)
Topic[cid] = nil
elseif msgcontains(msg, 'seamonster') or msgcontains(msg, 'Seamonster') then
local msgs={
"Only some days ago I was at the docks late in the night and was looking for my husband's ship when suddenly a known noise appeared near the docks. ...",
"I know this noise very well because it is the noise of a ship sailing very fast. I searched the horizon in hope to see my husbands ship. ...",
"But instead of a ship I saw a huge shape far away. It was like a big snake swimming in the sea. ...",
"I couldn't see it clearly because of the fog but I think I saw two lava-red eyes glowing in the nightly fog. ...",
"I ran into the house and hoped that my husband would arrive safely from fishing. And after one hour he finally arrived. ...",
"I told him about what I saw but he didn't believe me because he never saw anything like that in all the years before. But you believe me right? Go and convince yourself. ...",
"Just go to the docks at exactly midnight and be very quiet. Look at the horizon and maybe you will hear and see it, too!",
}
doNPCTalkALot(msgs,7052)
Topic[cid] = nil
elseif msgcontains(msg, 'aneus') or msgcontains(msg, 'Aneus') then
local msgs={
"A very nice person. He has a great story to tell with big fights and much magic. Just ask him for his story. ...",
"I heard that he came from far, far away. He must have seen soooo many countries, cities, different races. ...",
"He must have collected so much wisdom. *sigh* I wish I could also travel around the world. ...",
"I would try to visit as many cities and meet as many beings as possible. Who knows what strange races I will meet? ...",
"Maybe I can also find a lovely new dress for me. I have been looking for one for months now but never found a good one. Maybe... *keeps on babbling*",
}
doNPCTalkALot(msgs,7052)
Topic[cid] = nil
elseif msgcontains(msg, 'rumours') or msgcontains(msg, 'Rumours') then
local msgs={
"Well, I heard about evil beings living in a dungeon below us. So once I tried to find them and went down the hole far to the southwest. ...",
"I'm pretty curious, you know. *smiles* So I took the coat of invisibility from my husband and went down there. At first I only found some spiders, snakes, and wolves. ...",
"But after some time I found a ladder to a deeper level of the dungeon but I didn't dare to go down there because I heard many voices. ...",
"The voices were very strange and I ran back to my house because they were very loud and very angry. I hope they will never get the idea to attack the surface beings. ...",
"I heard they are almighty and have incredible powers! I already packed our stuff for an emergency escape. You never know. Maybe they plan to conquer the whole world. ...",
"I bet that they look very ugly. Most mighty monsters look very ugly. Hmm, you seem to be very strong. Maybe you can go deeper and explore the area. But be careful, please. ...",
"I heard that they can kill humans with only one hit! And that they have magic abilities twenty times stronger than the mightiest sorcerer in our world.",
}
doNPCTalkALot(msgs,7052)
Topic[cid] = nil
elseif msgcontains(msg, 'thank you') or msgcontains(msg, 'Thank You') then
npcHandler:say("My pleasure, I always enjoy sharing interesting stories..", cid)
Topic[cid] = nil
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())