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
local storage = 5001
function creatureSayCallback(cid, type, msg)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if not npcHandler:isFocused(cid) then
if msg == "hi" or msg == "hello" then
if getPlayerStorageValue(cid, storage) == -1 then
selfSay("I created this prison for myself to keep me safe, the creatures are unable to penatrate the magical barriers.", cid)
wait(1000)
selfSay("I have been working on a powerful morphing potion and things went terribly wrong.", cid)
wait(1000)
selfSay("The potion was accidently mixed into the punch at a party my colleagues had, now they are Werewolves.", cid)
wait(1000)
selfSay(" There is a place in a desert town that might hold the solution, in those caves lie a priceless item that I want. Should you bring me this item, you will prove yourself strong enough to visit what I once called home.", cid)
wait(1000)
selfSay("Are you sure you want to take on this task?", cid)
talkState[talkUser] = 1
elseif getPlayerStorageValue(cid, storage) == 1 then
selfSay("Did you find the rune?", cid)
talkState[talkUser] = 1
else
selfSay("Thanks again for finding the rune.", cid)
end
npcHandler:addFocus(cid)
else
return false
end
end
if msgcontains(msg, "yes") and talkState[talkUser] == 1 then
if getPlayerStorageValue(cid, storage) == -1 then
selfSay("Thanks alot, come back when you have it.", cid)
setPlayerStorageValue(cid, storage, 1)
else
if doPlayerRemoveItem(cid, 2348, 1) then
selfSay("This makes Zafmak very happy, you now have access to my home island. You might as well exterminate the island since there is no cure for this batch. Just be carefull, the Werewolves are very territorial and anger easy.", cid)
doPlayerAddItem(cid, 2160, 1)
doPlayerAddExp(cid, 15000)
setPlayerStorageValue(cid, 5009, 2)
setPlayerStorageValue(cid, storage, 2)
else
selfSay("You don't have it.", cid)
end
end
talkState[talkUser] = 0
elseif msgcontains(msg, "no") and talkState[talkUser] == 1 then
selfSay("Ok then.", cid)
talkState[talkUser] = 0
elseif msgcontains(msg, "bye") then
selfSay("Bye.", cid)
npcHandler:releaseFocus(cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)