local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
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 megaFish(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
return false
end
if getPlayerSkillLevel(cid, 6) >= 30 then
if getPlayerLearnedInstantSpell(cid, "mega fish") == false then
if getPlayerLevel(cid) >= 50 then
doPlayerLearnInstantSpell(cid, "mega fish")
else
selfSay("You are not level 50.", cid)
end
else
selfSay("You have already learned this spell.", cid)
end
else
selfSay("You need to be level 30 in fishing.", cid)
end
return true
end
function superFish(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
return false
end
if getPlayerSkillLevel(cid, 6) >= 50 then
if getPlayerLearnedInstantSpell(cid, "super fish") == false then
if getPlayerLevel(cid) >= 100 then
doPlayerLearnInstantSpell(cid, "super fish")
else
selfSay("You are not level 100.", cid)
end
else
selfSay("You have already learned this spell.", cid)
end
else
selfSay("You need to be level 50 in fishing.", cid)
end
return true
end
keywordHandler:addKeyword({'help'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I am a teacher and I can teach you spells to {mega fish} and {super fish}."})
local node1 = keywordHandler:addKeyword({'mega fish'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Do you want to learn mega fish?"})
node1:addChildKeyword({'yes'}, megaFish, {npcHandler = npcHandler, onlyFocus = true, reset = true})
node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Are you an alienated!", reset = true})
local node2 = keywordHandler:addKeyword({'super fish'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Do you want to learn super fish?"})
node2:addChildKeyword({'yes'}, superFish, {npcHandler = npcHandler, onlyFocus = true, reset = true})
node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Are you an alienated!", reset = true})
npcHandler:addModule(FocusModule:new())
npcHandler:setMessage(MESSAGE_GREET, "Hello, can I {help} you?")