local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
local npcHandlerfocus = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
NpcSystem.parseParameters(npcHandler)
-- OTServ event handling functions start
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
local function creatureSayCallback(cid, type, msg)
if (getPlayerStorageValue(cid, 1029) ~= 1) then
return 0
end
if (msgcontains(msg:lower(), "djanni'hah")) then
npcHandler:say('What do you want from me, ' .. getPlayerName(cid) .. '?')
npcHandler.focus = cid
npcHandlerfocus = 0
elseif (msgcontains(msg:lower(), "mission") and npcHandlerfocus == 0 and getPlayerStorageValue(cid, 8131) ~= 1) then
npcHandler:say("So Baa'leal thinks you are up to do a mission for us? ...")
npcHandler:say("I think he is getting old, entrusting human scum such as you are with an important mission like that. ..."
, cid, 3000)
npcHandler:say("Personally, I don't understand why you haven't been slaughtered right at the gates. ...", cid, 5000)
npcHandler:say("Anyway. Are you prepared to embark on a dangerous mission for us?", cid, 7000)
npcHandlerfocus = 1
elseif (msgcontains(msg:lower(), "yes") and npcHandlerfocus == 1) then
setPlayerStorageValue(cid, 8131, 1)
npcHandler:say("All right then, human. Have you ever heard of the 'Tears of Daraman'? ...")
npcHandler:say("They are precious gemstones made of some unknown blue mineral and possess enormous magical power. ..."
, cid, 3000)
npcHandler:say("If you want to learn more about these gemstones don't forget to visit our library. ...", cid, 5000)
npcHandler:say("Anyway, one of them is enough to create thousands of our mighty djinn blades. ...", cid, 7000)
npcHandler:say("Unfortunately my last gemstone broke and therefore I'm not able to create new blades anymore. ...", cid
, 9000)
npcHandler:say("To my knowledge there is only one place where you can find these gemstones - I know for a fact that the Marid have at least one of them. ..."
, cid, 11000)
npcHandler:say("Well... to cut a long story short, your mission is to sneak into Ashta'daramai and to steal it. ...",
cid, 13000)
npcHandler:say("Needless to say, the Marid won't be too eager to part with it. Try not to get killed until you have delivered the stone to me."
, cid, 15000)
npcHandler.focus = cid
npcHandlerfocus = 4
elseif (msgcontains(msg:lower(), "no") and npcHandlerfocus == 1) then
npcHandler:say("I wouldn't expect anything different from a human.")
npcHandler.focus = cid
npcHandlerfocus = 0
elseif (
msgcontains(msg:lower(), "mission") and getPlayerStorageValue(cid, 8131) == 1 and
getPlayerStorageValue(cid, 10229) ~= 1) then
npcHandler:say("You still haven't gotten the item I asked for. Go to the blue djinn fortress and bring her back.")
npcHandler.focus = cid
npcHandlerfocus = 0
elseif (
msgcontains(msg:lower(), "mission") and getPlayerStorageValue(cid, 10229) == 1 and
getPlayerStorageValue(cid, 10230) ~= 1) then
npcHandler:say('Did you find the tear of Daraman?')
npcHandler.focus = cid
npcHandlerfocus = 2
elseif (msgcontains(msg:lower(), "yes") and npcHandlerfocus == 2) then
if getPlayerItemCount(cid, 2346) >= 1 then
npcHandler:say("So you have made it? You have really managed to steal a Tear of Daraman? ...")
npcHandler:say("Amazing how you humans are just impossible to get rid of. Incidentally, you have this character trait in common with many insects and with other vermin. ..."
, cid, 2000)
npcHandler:say("Nevermind. I hate to say it, but it you have done us a favour, human. That gemstone will serve us well. ..."
, cid, 4000)
npcHandler:say("Baa'leal, wants you to talk to Malor concerning some new mission. ...", cid, 6000)
npcHandler:say("Looks like you have managed to extended your life expectancy - for just a bit longer.", cid, 8000)
setPlayerStorageValue(cid, 1032, 1)
setPlayerStorageValue(cid, 10230, 1)
doPlayerRemoveItem(cid, 2346, 1)
npcHandler.focus = cid
npcHandlerfocus = 3
elseif (msgcontains(msg:lower(), "no") and npcHandlerfocus == 2) then
npcHandler:say("You do not have the Tear of Daraman.")
npcHandler.focus = cid
npcHandlerfocus = 0
end
elseif (
msgcontains(msg:lower(), "mission") and getPlayerStorageValue(cid, 1032) == 1 and
getPlayerStorageValue(cid, 10230) == 1) then
npcHandler:say("I have no more missions for you. See if Malor has something for you, he's at the top of the tower.")
npcHandler.focus = cid
npcHandlerfocus = 0
elseif (msgcontains(msg:lower(), "sell") or msgcontains(msg:lower(), "buy")) and getPlayerStorageValue(cid, 1038) ~= 1 then
npcHandler:say("I don't do business with humans.")
npcHandler.focus = cid
npcHandlerfocus = 0
end
return 1
end
local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
npcHandler:addModule(ShopModule:new({ 'scimitar' }, 2419, 150, 'scimitar'))
addSellableItem({ 'giant sword' }, 2393, 17000, 'giant sword')
addSellableItem({ 'serpent sword' }, 2409, 900, 'serpent sword')
addSellableItem({ 'poison dagger' }, 2411, 50, 'poison dagger')
addSellableItem({ 'knight axe' }, 2430, 2000, 'knight axe')
addSellableItem({ 'dragon hammer' }, 2434, 2000, 'dragon hammer')
addSellableItem({ 'skull staff' }, 2436, 6000, 'skull staff')
addSellableItem({ 'dark armor' }, 2489, 400, 'dark armor')
addSellableItem({ 'knight armor' }, 2476, 5000, 'knight armor')
addSellableItem({ 'dark helmet' }, 2490, 250, 'dark helmet')
addSellableItem({ 'warrior helmet' }, 2475, 5000, 'warrior helmet')
addSellableItem({ 'strange helmet' }, 2479, 500, 'strange helmet')
addSellableItem({ 'mystic turban' }, 2663, 150, 'mystic turban')
addSellableItem({ 'knight legs' }, 2477, 5000, 'knight legs')
addSellableItem({ 'tower shield' }, 2528, 8000, 'tower shield')
addSellableItem({ 'black shield' }, 2529, 800, 'black shield')
addSellableItem({ 'ancient shield' }, 2532, 900, 'ancient shield')
addSellableItem({ 'vampire shield' }, 2534, 15000, 'vampire shield')
addBuyableItem({ 'ice rapier' }, 2396, 5000, 'ice rapier')
addBuyableItem({ 'serpent sword' }, 2409, 6000, 'serpent sword')
addBuyableItem({ 'dark armor' }, 2489, 1500, 'dark armor')
addBuyableItem({ 'dark helmet' }, 2490, 1000, 'dark helmet')
addBuyableItem({ 'ancient shield' }, 2532, 5000, 'ancient shield')
npcHandler:setMessage(MESSAGE_GREET, "What do you want from me, |PLAYERNAME|?")
npcHandler:setMessage(MESSAGE_PLACEDINQUEUE,
"It might have escaped your limited human perception, but I am already talking to somebody else.")
npcHandler:setMessage(MESSAGE_WALKAWAY, "Farewell, human.")
npcHandler:setMessage(MESSAGE_FAREWELL,
"Farewell, human. When I have taken my rightful place I shall remember those who served me well. Even if they are only humans.")
local function onTradeRequest(cid)
if Player(cid):getStorageValue(1038) ~= 1 then
npcHandler:say('Sorry, you need to complete the mission.', cid)
return false
end
return true
end
npcHandler:setCallback(CALLBACK_ONTRADEREQUEST, onTradeRequest)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())