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)
local config = {
storage = 24558, -- npcstorage and startstorage for the monsters
pos = {x = 1000, y = 1000, z = 7},
dragonlord = {amount = 15, storage = 32000},
wyrm = {amount = 5, storage = 32001}
}
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if not npcHandler:isFocused(cid) then
if msgcontains(msg, 'hello') or msg == 'hi' then
if getPlayerStorageValue(cid, config.storage) == -1 then
selfSay("Hello, to pass here I want you to kill 15 Dragon Lords and 5 Wyrms. Can you do that?", cid)
talkState[talkUser] = 1
elseif getPlayerStorageValue(cid, config.storage) == 1 then
selfSay("Oh, so you completed the task I gave you?", cid)
talkState[talkUser] = 1
else
selfSay("You can go now to the {next floor}.", cid)
talkState[talkUser] = 2
end
npcHandler:addFocus(cid)
else
return false
end
end
if(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if getPlayerStorageValue(cid, config.storage) == -1 then
selfSay("Perfect, come and talk to me when you finished your task.", cid)
setPlayerStorageValue(cid, config.storage, 1)
talkState[talkUser] = 0
elseif getPlayerStorageValue(cid, config.storage) == 1 then
local dragonlordcount = config.dragonlord.amount - (getPlayerStorageValue(cid, config.dragonlord.storage) +1)
local wyrmcount = config.wyrm.amount - (getPlayerStorageValue(cid, config.wyrm.storage) +1)
if getPlayerStorageValue(cid, config.dragonlord.storage) == config.dragonlord.amount and getPlayerStorageValue(cid, config.wyrm.storage) == config.wyrm.amount then
selfSay("Alright, you proven yourself worthy of to acces the {next floor}.", cid)
setPlayerStorageValue(cid, config.storage, 2)
talkState[talkUser] = 2
elseif getPlayerStorageValue(cid, config.dragonlord.storage) == config.dragonlord.amount then
selfSay("You still need to kill "..wyrmcount.." "..(wyrmcount == 1 and "Wyrm" or "Wyrms")..".", cid)
elseif getPlayerStorageValue(cid, config.wyrm.storage) == config.wyrm.amount then
selfSay("You still need to kill "..dragonlordcount.." "..(dragonlordcount == 1 and "Dragon Lord" or "Dragon Lords")..".", cid)
else
selfSay("You still need to kill "..wyrmcount.." "..(wyrmcount == 1 and "Wyrm" or "Wyrms").." and "..dragonlordcount.." "..(dragonlordcount == 1 and "Dragon Lord" or "Dragon Lords")..".", cid)
end
end
elseif(msgcontains(msg, 'next floor') and talkState[talkUser] == 2) then
selfSay("There we go.", cid)
doTeleportThing(cid, config.pos)
elseif (msgcontains(msg, 'no')) then
selfSay("Oh well, I guess not then.", cid)
elseif (msgcontains(msg, 'bye')) then
selfSay("Bye.", cid)
npcHandler:releaseFocus(cid)
end
return true
end
npcHandler:setMessage(MESSAGE_FAREWELL, "Well, what are you waiting for, I don't have all day!")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Bye!")
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)