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
local voices = { {text = "Best weapons in Noob'Vale. Come check them out!"} }
npcHandler:addModule(VoiceModule:new(voices))
local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
local ratMsg = {
"Rats have infested the town's water supply. They are jumping down the well just south of my shop.",
"They are contaminating everything and have even destroyed some of my supplies. Go deal with the pests and I will reward you with some coin."
}
local function greetCallback(cid)
local player = Player(cid)
if not player then return true end
local pQuest = player:getStorageValue(STORAGE_MAINQUEST)
if pQuest < 2 then
selfSay('Hello there, what brings you to my shop today? {trade}, {quest}', cid)
elseif pQuest == 2 then
selfSay("Please help me, they have taken my daughter! {who}", cid)
elseif pQuest == 3 then
selfSay("Any news on where my daughter is or do you need a {trade}?", cid)
end
return true
end
keywordHandler:addKeyword({'stuff'}, StdModule.say, {npcHandler = npcHandler, text = 'Just ask me for a {trade} to see my offers.'})
keywordHandler:addAliasKeyword({'wares'})
keywordHandler:addAliasKeyword({'offer'})
shopModule:addBuyableItem({'sword', 'sword'}, 2376, 20, 'sword')
shopModule:addBuyableItem({'hatchet', 'hatchet'}, 2388, 20, 'hatchet')
shopModule:addBuyableItem({'dagger', 'dagger'}, 2379, 10, 'dagger')
shopModule:addBuyableItem({'naginata', 'naginata'}, 2426, 30, 'naginata')
shopModule:addBuyableItem({'spear', 'spear'}, 2389, 20, 'spear')
shopModule:addBuyableItem({'sabre', 'sabre'}, 2385, 45, 'sabre')
-- shopModule:addSellableItem({'wand of vortex', 'vortex'}, 2190, 250, 'wand of vortex')
function creatureSayCallback(cid, type, msg)
if not npcHandler:isFocused(cid) then
return false
end
local player = Player(cid)
if not player then return true end
if msg == "quest" then
local pQuest = player:getStorageValue(STORAGE_MAINQUEST)
if pQuest == -1 then
player:setStorageValue(STORAGE_MAINQUEST, 0)
end
if pQuest == 0 then
npcHandler:doNPCTalkALot(ratMsg, 4000, cid)
player:setStorageValue(STORAGE_MAINQUEST, pQuest + 1)
return true
elseif pQuest == 1 then
selfSay("Kill some rats in the draw well located just south of my shop. Your quest log will be updated when you have finished.", cid)
return true
elseif pQuest == 2 then
selfSay("Please help me, they have taken my daughter! {who}", cid)
player:setStorageValue(STORAGE_MAINQUEST, pQuest + 1)
return true
elseif pQuest == 3 then
selfSay("You should talk to some of the people around town to see if they saw anything.", cid)
return true
end
elseif msg == "who" then
local pQuest = player:getStorageValue(STORAGE_MAINQUEST)
if pQuest == 2 then
player:addMoney(35)
selfSay("First, here is some money for killing those rats. You should try {talk}ing {to Suzie}. Her balcony oversees the city.", cid)
player:setStorageValue(STORAGE_MAINQUEST, pQuest + 1)
elseif pQuest > 2 and pQuest < 4 then
selfSay("You should talk to some of the people around town to see if they saw anything.", cid)
return true
end
end
return true
end
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())