local topos = {x=133, y=362, z=7, stackpos = STACKPOS_TOP_CREATURE}
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
-- OTServ event handling functions end
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
if msgcontains(msg, 'boat') or msgcontains(msg, 'transportation') or msgcontains(msg, 'pirate') or msgcontains(msg, 'helmet') then
selfSay('Give me my Royal Helmet', cid)
if getPlayerItemCount(cid, 2498) > 0 then
if getPlayerSlotItem(cid, 6).itemid == 2498 then
selfSay('You really want to go?', cid)
talk_state = 1642
else
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, 'Put the helmet in your right hand, below you necklace slot.')
end
else
selfSay('You don\'t even have a royal helmet !', cid)
end
elseif talk_state == 1642 then
if msgcontains(msg, 'yes') then
local pos = getCreaturePosition(cid)
doPlayerRemoveItem(cid, 2498, 1)
doTeleportThing(cid, topos, TRUE)
doSendMagicEffet(pos, CONST_ME_ENERGYAREA)
elseif msgcontains(msg, 'no') then
selfSay('Well, ok.', cid)
end
talk_state = 0
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())