local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
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 creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local storage = getPlayerStorageValue(cid,135)
local storage2 = getPlayerStorageValue(cid,136)
local Ranks = {
[0] = {"Initiate"},
[1] = {"Scout"},
[2] = {"Thief"},
[3] = {"Rogue"},
[4] = {"Ninja"},
[5] = {"Assassin"}
}
local Rank = Ranks[storage2]
local RankName = Rank[1]
local pos = getCreaturePosition(cid)
if(msgcontains(msg, 'quest')) then
if getPlayerLevel(cid) >= 90 then
if storage == 11 then
selfSay('Good to see a new face here. You don\'t look like much, but you seem to have survived Bob\'s tasks. Mine are not so easy. The second rule is honour. Honour defeats all other forces. Remember this. Feel free to ask for a {mission}.', cid)
setPlayerStorageValue(cid,135,12)
else
selfSay('You\'ve already begun my quest. Ask me for a {mission} or ask about your {rank}.', cid)
end
else
selfSay('I\'m afraid you\'re going to have to be a higher level. Come back when you\'ve reached level 90.', cid)
end
return true
end
---------------------------------------------------------
--Mission 1--
---------------------------------------------------------
if(msgcontains(msg, 'mission') and storage == 12) then
selfSay('Alright. Here\'s your first mission. It\'s a little different than what you\'re used to so far. You must slay 10 {Demons}. I cannot tell you where to find them.', cid)
setPlayerStorageValue(cid,135,13)
setPlayerStorageValue(cid,8888,1)
elseif(msgcontains(msg, 'mission') and storage == 13) then
selfSay('Your task is killing 10 {Demons}.', cid)
----------------------------------------------------------
elseif(msgcontains(msg, 'demons') and storage == 13) then
selfSay('Have you killed those 10 demons?', cid)
talkState[talkUser] = 1
---------------------------------------------------------
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1 and getPlayerStorageValue(cid, 55551) >= 10) then
setPlayerStorageValue(cid,135,14)
setPlayerStorageValue(cid,8888,-1)
setPlayerStorageValue(cid,15551,-1)
setPlayerStorageValue(cid,55551,-1)
doPlayerAddExperience(cid,35000)
doSendAnimatedText(pos, "35000", COLOR_WHITE)
selfSay('You managed to kill all 10. Impressive. Here\'s your first reward. You can ask for your next {mission} anytime.', cid)
talkState[talkUser] = 0
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1 and getPlayerStorageValue(cid, 55551) < 10) then
selfSay('Do you think I don\'t know when you\'ve killed them? I do. Now go and do it for real.', cid)
talkState[talkUser] = 0
---------------------------------------------------------
--Mission 2--
---------------------------------------------------------
elseif(msgcontains(msg, 'mission') and storage == 14) then
selfSay('Your second mission is similar to your first. Kill 25 {Destroyers} and then come talk to me.', cid)
setPlayerStorageValue(cid,135,15)
setPlayerStorageValue(cid,9899,1)
elseif(msgcontains(msg, 'mission') and storage == 15) then
selfSay('You have to kill 25 {Destroyers}.', cid)
----------------------------------------------------------
elseif(msgcontains(msg, 'destroyers') and storage == 15) then
selfSay('Have you destroyed the 25 destroyers?', cid)
talkState[talkUser] = 2
---------------------------------------------------------
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2 and getPlayerStorageValue(cid, 9889) >= 25) then
setPlayerStorageValue(cid,135,16)
setPlayerStorageValue(cid,9899,-1)
setPlayerStorageValue(cid,9889,-1)
setPlayerStorageValue(cid,9998,-1)
doPlayerAddExperience(cid,40000)
doSendAnimatedText(pos, "40000", COLOR_WHITE)
selfSay('You actually killed them all. Here is a small reward. Ask for another {mission} if you want.', cid)
talkState[talkUser] = 0
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 2 and getPlayerStorageValue(cid, 9889) < 25) then
selfSay('I know you didn\'t kill them so go do it before I change my mind about you!', cid)
talkState[talkUser] = 0
---------------------------------------------------------
--Mission 3--
---------------------------------------------------------
elseif(msgcontains(msg, 'mission') and storage == 16) then
selfSay('Your third mission should prove to be a little more difficult. I seem to have lost my lucky {sabre}. I was stalking a wanted member of the {Mecha Group} and I was found and ambushed. I fought with all my might and got away but I dropped my {sabre}. Go find it please!', cid)
setPlayerStorageValue(cid,135,17)
setPlayerStorageValue(cid,3121,1)
elseif(msgcontains(msg, 'mission') and storage == 17) then
selfSay('Bring back my {sabre} from the caverns of the {Mecha Group}.', cid)
---------------------------------------------------------
elseif(msgcontains(msg, 'sabre') and storage == 17) then
selfSay('Did you infiltrate the caverns and get me my sabre?', cid)
talkState[talkUser] = 3
---------------------------------------------------------
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 3 and getPlayerItemCount(cid, 213) >= 1) then
doPlayerRemoveItem(cid, 213, 1)
setPlayerStorageValue(cid,135,18)
setPlayerStorageValue(cid,136,2)
setPlayerStorageValue(cid,3121,-1)
doPlayerAddExperience(cid,45000)
doSendAnimatedText(pos, "45000", COLOR_WHITE)
selfSay('Ah, thank you! I have missed this blade dearly. For your bravery and sheer skill, I grant you this reward and a brand new {rank} you can ask for a {trade} if you wish.', cid)
talkState[talkUser] = 0
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 3 and getPlayerItemCount(cid, 213) < 1) then
selfSay('Oh? You don\'t have it yet! Please hurry with my {sabre}.', cid)
talkState[talkUser] = 0
---------------------------------------------------------
--Mission 4--
---------------------------------------------------------
elseif(msgcontains(msg, 'mission') and storage == 18) then
selfSay('This task is a riddle. It won\'t be as easy as the first one. I don\'t give options - I\'m swift, nimble and strong. I am not biased and I work for the highest bidder. What is my strongest weapon? - Remember the second rule.', cid)
setPlayerStorageValue(cid,135,19)
elseif(msgcontains(msg, 'mission') and storage == 19) then
selfSay('I\'m swift, nimble and strong. I am not biased and I work for the highest bidder. What is my strongest weapon? - Remember the second rule.', cid)
---------------------------------------------------------
elseif (storage == 19 and not isInArray({4,5}, talkState[talkUser])) then
selfSay('Is that your final answer?', cid)
talkState[talkUser] = msgcontains(msg, 'honour') and 4 or 5
---------------------------------------------------------
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 4) then
setPlayerStorageValue(cid,135,20)
doPlayerAddExperience(cid,25000)
doSendAnimatedText(pos, "25000", COLOR_WHITE)
selfSay('Correct. The second rule is that honour defeats all other forces. Your skills are strong in all areas. I reward you. You may ask for another {mission}.', cid)
talkState[talkUser] = 0
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 5) then
setPlayerStorageValue(cid,135,17)
setPlayerStorageValue(cid,7574,-1)
setPlayerStorageValue(cid,136,1)
selfSay('Honour defeats all other forces. That is the second rule. Your poor listening skills and honour have made me lose my {sabre} again. Now, go find it again. Your {rank} has gone down as well. You will get it back after you find my {sabre} again.', cid)
talkState[talkUser] = 0
---------------------------------------------------------
--Mission 5--
---------------------------------------------------------
elseif(msgcontains(msg, 'mission') and storage == 9) then
selfSay('I think you are doing well. This will be your last mission from me. It is very important. I need you to enter the nearby cave and find my {assassin cloak}. You can\'t miss it. It is currently being guarded by a powerful rogue. I haven\'t the time to get it myself.', cid)
setPlayerStorageValue(cid,135,10)
elseif(msgcontains(msg, 'mission') and storage == 10) then
selfSay('Bring me my {assassin cloak}.', cid)
---------------------------------------------------------
elseif(msgcontains(msg, 'assassin cloak') and storage == 10) then
selfSay('Have you completed my final mission? Did you bring me my assassin cloak?', cid)
talkState[talkUser] = 6
---------------------------------------------------------
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 6 and getPlayerItemCount(cid, 2664) >= 1) then
doPlayerRemoveItem(cid, 2664, 1)
setPlayerStorageValue(cid,135,11)
setPlayerStorageValue(cid,136,1)
doPlayerAddExperience(cid,30000)
doSendAnimatedText(pos, "30000", COLOR_WHITE)
selfSay('Well, I am simply impressed that you have made it this far. Go on and find Bill the Assassin and you can start your training. Your {rank} is now \'Scout\'. Here is your reward.', cid)
talkState[talkUser] = 0
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 6 and getPlayerItemCount(cid, 2664) < 1) then
selfSay('You do not have what I asked for. Go get my {assassin cloak}!', cid)
talkState[talkUser] = 0
end
---------------------------------------------------------
--Rank--
---------------------------------------------------------
if(msgcontains(msg, 'rank') and storage2 > -1) then
selfSay('Your rank is \'' .. RankName .. '\'.', cid)
end
---------------------------------------------------------
--Mecha Group--
---------------------------------------------------------
if(msgcontains(msg, 'mecha group') and storage == 19) then
selfSay('The Mecha Group is a powerful guild made up of different golems and their pets. Worker and War Golems are strong and technologically advanced beings. They have harnessed the power of Energy Elementals of all kinds and made them their pets. Beware the Golem Leader.', cid)
end
---------------------------------------------------------
--Trade--
---------------------------------------------------------
if(msgcontains(msg, 'trade') and storage2 >= 2) then
local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
shopModule:addBuyableItem({'assassin star'}, 7368, 250, 1, 'assassin star')
shopModule:addSellableItem({'gear wheel'}, 9690, 500,'gear wheel')
shopModule:addSellableItem({'gear crystal'}, 10572, 250, 'gear crystal')
shopModule:addSellableItem({'war crystal'}, 10571, 1000, 'war crystal')
end
---------------------------------------------------------
--End--
---------------------------------------------------------
if(msgcontains(msg, 'mission') and storage >= 20) then
selfSay('I am all out of missions. Maybe Brian the Assassin has some jobs for you? In the meantime, you could ask me about your {rank} or ask for a {trade}.', cid)
talkState[talkUser] = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())