local ID_STORAGE_QUESTA = 37411
talk_state = {}
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
function onCreatureAppear(cid)
talk_state[cid] = 0
npcHandler:onCreatureAppear(cid)
end
function onCreatureDisappear(cid)
talk_state[cid] = 0
npcHandler:onCreatureDisappear(cid)
end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
function creatureSayCallback(cid, type, message)
if(not npcHandler:isFocused(cid)) then
return false
end
if(getPlayerStorageValue(cid, ID_STORAGE_QUESTA) == 0) then
if(msgcontains(string.lower(message), 'no') == true) or (msgcontains(string.lower(message), 'nie') == true) then
selfSay('Wroc kiedy bedziesz mial troche czasu i checi, zeby mi pomoc.', cid)
talk_state[cid] = 0
elseif((msgcontains(string.lower(message), 'yes') == true) or (msgcontains(string.lower(message), 'tak') == true)) and talk_state[cid] == 1 then
selfSay('Dziekuje. Mam nadzieje, ze jeszcze pamieta moje imie.', cid)
setPlayerStorageValue(cid, ID_STORAGE_QUESTA, 1)
talk_state[cid] = 0
else
selfSay('Moglbys znalezc Mistrza Warlockow i zapytac sie o mnie?', cid)
talk_state[cid] = 1
end
elseif getPlayerStorageValue(cid, ID_STORAGE_QUESTA) == 1 or (getPlayerStorageValue(cid, ID_STORAGE_QUESTA) == 2) then
if(msgcontains(string.lower(message), 'no') == true) then
selfSay('Przyjdz kiedy zdobedziesz ulaskawienie od mistrza.', cid)
talk_state[cid] = 0
elseif((msgcontains(string.lower(message), 'yes') == true) or (msgcontains(string.lower(message), 'tak') == true)) and talk_state[cid] == 1 then
local item = getPlayerItemById(cid, 1, 8370)
if item.actionid == ID_STORAGE_QUESTA then
doRemoveItem(item.uid)
selfSay('Dzieki za pomoc. Zaraz bede mogl wrocic na zajecia. Masz tu nagrode za przekonanie mojego mistrza.', cid)
doPlayerAddItem(cid, 2656, 1, 1)
doPlayerAddMoney(cid, 20000)
setPlayerStorageValue(cid, ID_STORAGE_QUESTA, 3)
else
selfSay('Przyjdz jak bedziesz mial ulaskawienie od mistrza.', cid)
end
talk_state[cid] = 0
else
selfSay('Masz dla mnie list z ulaskawieniem od Mistrza Warlockow?', cid)
talk_state[cid] = 1
end
else
selfSay('Raz juz mi pomogles, a ja znowu wpadlem w tarapaty, wiecej juz Ci nie zaufa Mistrz Warlockow.', cid)
talk_state[cid] = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
function greetCallback(cid)
talk_state[cid] = 0
if(getPlayerStorageValue(cid, ID_STORAGE_QUESTA) == -1) then
doCreateMonster('Stone Golem', getClosestFreeTile(cid, getCreaturePosition(cid)))
setPlayerStorageValue(cid, ID_STORAGE_QUESTA, 0)
return false
else
return true
end
end
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setMessage(MESSAGE_GREET, 'Czesc |PLAYERNAME|. Mistrz znowu mnie tu zamknal. Czy to moja wina, ze Fireball wymknal mi sie spod kontroli i spalil pare ksiazek?! Czy moglbys mi pomoc?')
npcHandler:setMessage(MESSAGE_FAREWELL, 'Do zobaczenia |PLAYERNAME|.')
npcHandler:setMessage(MESSAGE_WALKAWAY, 'Do zobaczenia |PLAYERNAME|.')
npcHandler:addModule(FocusModule:new())