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 oracle(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
return false
end
local cityNode = node:getParent():getParent()
local vocNode = node:getParent()
local destination = cityNode:getParameters().destination
local town = cityNode:getParameters().town
local vocation = vocNode:getParameters().vocation
if(destination ~= nil and vocation ~= nil and town ~= nil) then
if(getPlayerLevel(cid) < parameters.level) then
npcHandler:say('You must first reach level ' .. parameters.level .. '!', cid)
npcHandler:resetNpc()
else
if(getPlayerVocation(cid) > 0) then
npcHandler:say('Lo siento, pero ya tienes vocacion y no puedes cambiarla!')
npcHandler:resetNpc()
else
doPlayerSetVocation(cid, vocation)
doPlayerSetTown(cid, town)
npcHandler:resetNpc()
local tmp = getCreaturePosition(cid)
doTeleportThing(cid, destination)
doSendMagicEffect(tmp, CONST_ME_POFF)
doSendMagicEffect(destination, CONST_ME_TELEPORT)
end
end
end
return true
end
function greetCallback(cid)
if(getPlayerLevel(cid) < 1) then
npcHandler:say('PORFAVOR VUELVE CUANDO TENGAS MAS EXPERIENCIA!')
return false
else
return true
end
end
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setMessage(MESSAGE_GREET, 'Hola |PLAYERNAME|. Estas preparado para enfrentar al destino? PORFAVOR RESPONDE EN ESPAÑOL')
local yesNode = KeywordNode:new({'si'}, oracle, {level = 1})
local noNode = KeywordNode:new({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, moveup = 1, text = 'Entonces vuelve cuando estes seguro'})
local node1 = keywordHandler:addKeyword({'si'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Entonces, ¿que quieres ser: {sorcerer}, {druid}, {paladin} o {knight}?'})
local node2 = node1:addChildKeyword({'sorcerer'}, StdModule.say, {npcHandler = npcHandler, vocation = 1, onlyFocus = true, text = '¿Entonces quieres convertirte en un gran mago? Recuerda que esto es irreversible!'})
node2:addChildKeywordNode(yesNode)
node2:addChildKeywordNode(noNode)
node2 = node1:addChildKeyword({'druid'}, StdModule.say, {npcHandler = npcHandler, vocation = 2, onlyFocus = true, text = '¿Estas seguro de que quieres ser un druida? Recuerda que esto es irreversible!'})
node2:addChildKeywordNode(yesNode)
node2:addChildKeywordNode(noNode)
node2 = node1:addChildKeyword({'paladin'}, StdModule.say, {npcHandler = npcHandler, vocation = 3, onlyFocus = true, text = 'Wow, ¿un gran maestro de las armas a distancia? Recuerda que esto es irreversible!'})
node2:addChildKeywordNode(yesNode)
node2:addChildKeywordNode(noNode)
node2 = node1:addChildKeyword({'knight'}, StdModule.say, {npcHandler = npcHandler, vocation = 4, onlyFocus = true, text = '¿Un gran caballero en servicio a los dioses? Recuerda que esto es irreversible'})
node2:addChildKeywordNode(yesNode)
node2:addChildKeywordNode(noNode)
keywordHandler:addKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Entonces vuelve cuando estes seguro'})
npcHandler:addModule(FocusModule:new())