local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
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 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
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, "arkarra") or msgcontains(msg, "Arkarra") then
local msgs={
"The stampor in the back? She's my friend, but she came to me out of her own free will. I must admit I've never managed to tame any other stampor. ...",
"I heard that there's some sort of voodoo magic which would allow you to summon a stampor, but I'm not a voodoo expert, so I wouldn't know.",
}
doNPCTalkALot(msgs,7052)
Topic[cid] = 0
end
return TRUE
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())