local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = 0
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 onCreatureMove(creature, oldPos, newPos)
if not isPlayer(creature) then
doSendMagicEffect(newPos, CONST_ME_SMALLPLANTS)
end
end
local choosenVocation = 1
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
if msgcontains(msg, "vocation") then
npcHandler:say("What vocation do you want to be? {Sorcerer}, {druid}, {paladin} or {knight}?", cid)
talkState = 1
elseif talkState == 1 then
if msgcontains(msg, "sorcerer") then
npcHandler:say("Do you want to become a sorcerer?", cid)
talkState = 2
choosenVocation = 1
elseif msgcontains(msg, "druid") then
npcHandler:say("Do you want to become a druid?", cid)
talkState = 2
choosenVocation = 2
elseif msgcontains(msg, "paladin") then
npcHandler:say("Do you want to become a paladin?", cid)
talkState = 2
choosenVocation = 3
elseif msgcontains(msg, "knight") then
npcHandler:say("Do you want to become a knight?", cid)
talkState = 2
choosenVocation = 4
else
npcHandler:say("I guess not then.", cid)
talkState = 0
end
elseif msgcontains(msg, "yes") then
if talkState == 2 then
doPlayerSetVocation(cid, choosenVocation)
npcHandler:say("Trolololol, there we go. It's done!", cid)
-- effects
doSendMagicEffect(cid, CONST_ME_MAGIC_BLUE)
doCreatureSay(cid, "You have changed your vocation.", TALKTYPE_ORANGE_1)
talkState = 0
end
elseif msgcontains(msg, "no") then
if talkState == 2 then
npcHandler:say("As you wish.", cid)
talkState = 0
end
end
end
npcHandler:setCallback(CALLBACK_ONTHINK, thinkCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())