local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
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 creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if msgcontains(msg, 'task') or msgcontains(msg, 'quest') then
-- Task #1 start
if(getPlayerStorageValue(cid, 3500) == -1) then
selfSay('My friend is missing. Recently he said that he was going to kill a few trolls. Can you find him?', cid)
talkState[talkUser] = 1
-- Task #1 completed
elseif(getPlayerStorageValue(cid, 3500) == 1) then
if(getPlayerStorageValue(cid, 3501) == 2) then
selfSay('My friend is dead? It\'s terrible! Here you are, this is your reward. But don\'t worry, I have more {task}s for you.', cid)
setPlayerStorageValue(cid, 3501, 3)
setPlayerStorageValue(cid, 3500, 2)
doPlayerAddItem(cid, 2152, 5)
doPlayerAddExp(cid, 250)
doSendAnimatedText(getCreaturePosition(cid), "250", TEXTCOLOR_WHITE)
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_FIREWORK_BLUE)
else
selfSay('Please try to save my friend.', cid)
end
-- Task #2 start
elseif(getPlayerStorageValue(cid, 3500) == 2) then
selfSay('A very important document was stolen during the last raid on the city by orcs. Can you get it back?', cid)
talkState[talkUser] = 2
-- Task #2 completed
elseif(getPlayerStorageValue(cid, 3500) == 3) then
if(getPlayerStorageValue(cid, 3502) == 2) then
if(doPlayerRemoveItem(cid, 7702, 1) == true) then
selfSay('You found this document? Great! Here you are, this is your reward. But don\'t worry, I have one more {taks} for you.', cid)
setPlayerStorageValue(cid, 3502, 3)
setPlayerStorageValue(cid, 3500, 4)
doPlayerAddItem(cid, 2152, 10)
doPlayerAddExp(cid, 500)
doSendAnimatedText(getCreaturePosition(cid), "500", TEXTCOLOR_WHITE)
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_FIREWORK_BLUE)
else
selfSay('Please try to find this document.', cid)
end
else
selfSay('Please try to find this document.', cid)
end
-- Task #3 start
elseif(getPlayerStorageValue(cid, 3500) == 4) then
selfSay('I hate witches and I love cookies. Can you kill 15 of them and get for me 10 cookies?', cid)
talkState[talkUser] = 3
-- Task #3 completed
elseif(getPlayerStorageValue(cid, 3500) == 5) then
if(getPlayerStorageValue(cid, 3503) == 16) then
if(doPlayerRemoveItem(cid, 2687, 10) == true) then
selfSay('Oh... you killed witches? And... yes, cookies for me! Thank you! Here you are, this is your reward.', cid)
setPlayerStorageValue(cid, 3503, 17)
setPlayerStorageValue(cid, 3500, 6)
doPlayerAddItem(cid, 2152, 15)
doPlayerAddItem(cid, 2167, 1)
doPlayerAddExp(cid, 750)
doSendAnimatedText(getCreaturePosition(cid), "750", TEXTCOLOR_WHITE)
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_FIREWORK_BLUE)
else
selfSay('Okay... you killed witches but where are my cookies?', cid)
end
else
selfSay('Go and kill these witches. Don\'t forget about cookies for me!', cid)
end
-- All task completed
elseif(getPlayerStorageValue(cid, 3500) == 6) then
selfSay('Yes, I remember you. Thank you for all the help. Right now, I don\'t need more help.', cid)
end
elseif talkState[talkUser] == 1 then
if msgcontains(msg, 'yes') then
selfSay('Thank you! Please, this potion you probably want to fight with trolls. Sorry, I can\'t give you more.', cid)
doPlayerAddItem(cid, 7618, 1)
setPlayerStorageValue(cid, 3500, 1)
setPlayerStorageValue(cid, 3501, 1)
talkState[talkUser] = {}
else
selfSay('Then not.', cid)
talkState[talkUser] = {}
end
elseif talkState[talkUser] == 2 then
if msgcontains(msg, 'yes') then
selfSay('Thank you! Please, this potion you probably want to fight with orcs. Sorry, I can\'t give you more.', cid)
doPlayerAddItem(cid, 7618, 1)
setPlayerStorageValue(cid, 3500, 3)
setPlayerStorageValue(cid, 3502, 1)
talkState[talkUser] = {}
else
selfSay('Then not.', cid)
talkState[talkUser] = {}
end
elseif talkState[talkUser] == 3 then
if msgcontains(msg, 'yes') then
selfSay('Thank you! Please, this potion you probably want to fight with witches. Sorry, I can\'t give you more.', cid)
doPlayerAddItem(cid, 7618, 1)
setPlayerStorageValue(cid, 3500, 5)
setPlayerStorageValue(cid, 3503, 1)
talkState[talkUser] = {}
else
selfSay('Then not.', cid)
talkState[talkUser] = {}
end
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())