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
local shopModule = ShopModule:new()
npcHandler:addModule(shopModule)
-- These have to be here so they won't mess up the keywords
shopModule:addBuyableItem({'energy field', 'ef'}, 2277, 115, 3, 'energy field rune')
shopModule:addBuyableItem({'fire field', 'ff'}, 2301, 85, 3, 'fire field rune')
shopModule:addBuyableItem({'poison field', 'pf'}, 2285, 65, 3, 'poison field rune')
shopModule:addBuyableItem({'blank rune'}, 2260, 10, 'blank rune')
local node1 = keywordHandler:addKeyword({'runes'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can sell you Antidote, Intense Healing, and Ultimate Healing Runes.'})
shopModule:addBuyableItem({'antidote', 'antidote'}, 2266, 65, 1, 'antidote rune')
shopModule:addBuyableItem({'intense healing', 'ih'}, 2265, 95, 1, 'intense healing rune')
shopModule:addBuyableItem({'ultimate healing', 'uh'}, 2273, 175, 1, 'ultimate healing rune')
local node2 = keywordHandler:addKeyword({'support'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can sell you Chameleon, Desintegrate, Destroy Field, Magic Wall, and Paralyze Runes.'})
shopModule:addBuyableItem({'chameleon', 'chameleon'}, 2291, 210, 1, 'chameleon rune')
shopModule:addBuyableItem({'desintegrate', 'desintegrate'}, 2310, 80, 3, 'desintegrate rune')
shopModule:addBuyableItem({'destroy field', 'destroy field'}, 2261, 45, 3, 'destroy field rune')
local node3 = keywordHandler:addKeyword({'attack'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can sell you Avalanche, Explosion, Fireball, Great Fireball, Heavy Magic Missile, Icicle, Light Magic Missile, Soulfire, Stalagmite, Stone Shower, Sudden Death, Thunderstorm Runes.'})
shopModule:addBuyableItem({'avalanche', 'avalanche'}, 2274, 180, 4, 'avalanche rune')
shopModule:addBuyableItem({'explosion', 'explo'}, 2313, 190, 6, 'explosion rune')
shopModule:addBuyableItem({'great fireball', 'gfb'}, 2304, 180, 4, 'great fireball rune')
shopModule:addBuyableItem({'fireball', 'fb'}, 2302, 150, 5, 'fireball rune')
shopModule:addBuyableItem({'heavy magic missile', 'hmm'}, 2311, 120, 10, 'heavy magic missile rune')
shopModule:addBuyableItem({'icicle', 'icicle'}, 2271, 150, 5, 'icicle rune')
shopModule:addBuyableItem({'light magic missile', 'lmm'}, 2287, 40, 10, 'light magic missile rune')
shopModule:addBuyableItem({'soulfire', 'sf'}, 2308, 140, 3, 'soulfire rune')
shopModule:addBuyableItem({'stalagmite', 'stalagmite'}, 2292, 120, 10, 'stalagmite rune')
shopModule:addBuyableItem({'sudden death', 'sd'}, 2268, 325, 3, 'sudden death rune')
local node4 = keywordHandler:addKeyword({'field'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I can sell you Energy Bomb, Energy Field, Energy Wall, Fire Bomb, Fire Field, Fire Wall, Poison Bomb, Poison Field, and Poison Wall Runes.'})
shopModule:addBuyableItem({'energy bomb', 'energybomb'}, 2262, 325, 2, 'energy bomb rune')
shopModule:addBuyableItem({'energy wall', 'ew'}, 2279, 340, 4, 'energy wall rune')
shopModule:addBuyableItem({'fire bomb', 'firebomb'}, 2305, 235, 2, 'fire bomb rune')
shopModule:addBuyableItem({'fire wall', 'fw'}, 2303, 245, 4, 'fire wall rune')
shopModule:addBuyableItem({'poison bomb', 'pb'}, 2286, 170, 2, 'poison bomb rune')
shopModule:addBuyableItem({'poison wall', 'pw'}, 2289, 210, 4, 'poison wall rune')
local node5 = keywordHandler:addKeyword({'potions'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I sell Health, Mana, Strong Health, Strong Mana, Great Health, Great Mana, Ultimate Health, and Great Spirit Potions.'})
shopModule:addBuyableItem({'great spirit potion', 'gsp'}, 8472, 190, 'great spirit potion')
shopModule:addBuyableItem({'ultimate health potion', 'uhp'}, 8473, 310, 'ultimate health potion')
shopModule:addBuyableItem({'great mana potion', 'gmp'}, 7590, 120, 'great mana potion')
shopModule:addBuyableItem({'great health potion', 'ghp'}, 7591, 190, 'great health potion')
shopModule:addBuyableItem({'strong health potion', 'shp'}, 7588, 100, 'strong health potion')
shopModule:addBuyableItem({'strong mana potion', 'smp'}, 7589, 80, 'strong mana potion')
shopModule:addBuyableItem({'health potion', 'hp'}, 7618, 45, 'health potion')
shopModule:addBuyableItem({'mana potion', 'mp'}, 7620, 50, 'mana potion')
local node6 = keywordHandler:addKeyword({'wands'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I sell Wand of Vortex, Wand of Dragonbreath, Wand of Decay, Wand of Cosmic Energy, and Wand of Inferno.'})
shopModule:addBuyableItem({'wand of vortex', 'wov'}, 2190, 100, 'wand of vortex')
shopModule:addBuyableItem({'wand of dragonbreath', 'wodb'}, 2191, 1000, 'wand of dragonbreath')
shopModule:addBuyableItem({'wand of decay', 'wod'}, 2188, 5000, 'wand of decay')
shopModule:addBuyableItem({'wand of cosmic energy', 'woce'}, 2189, 10000, 'wand of cosmic energy')
shopModule:addBuyableItem({'wand of inferno', 'woi'}, 2187, 15000, 'wand of inferno')
local node7 = keywordHandler:addKeyword({'rods'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I sell Snakebite Rod, Moonlight Rod, Necrotic Rod, Terra Rod, and Hailstorm Rod.'})
shopModule:addBuyableItem({'snakebite rod', 'sbr'}, 2182, 100, 'snakebite rod')
shopModule:addBuyableItem({'moonlight rod', 'mlr'}, 2186, 1000, 'moonlight rod')
shopModule:addBuyableItem({'necrotic rod', 'nr'}, 2185, 5000, 'necrotic rod')
shopModule:addBuyableItem({'terra rod', 'tr'}, 2181, 10000, 'terra rod')
shopModule:addBuyableItem({'hailstorm rod', 'hsr'}, 2183, 15000, 'hailstorm rod')
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 items = {[1] = 2190, [2] = 2182, [5] = 2190, [6] = 2182}
if(msgcontains(msg, 'first rod') or msgcontains(msg, 'first wand')) then
if(isSorcerer(cid) or isDruid(cid)) then
if(getPlayerStorageValue(cid, 30002) == -1) then
selfSay('So you ask me for a {' .. getItemNameById(items[getPlayerVocation(cid)]) .. '} to begin your advanture?', cid)
talkState[talkUser] = 1
else
selfSay('What? I have already gave you one {' .. getItemNameById(items[getPlayerVocation(cid)]) .. '}!', cid)
end
else
selfSay('Sorry, you aren\'t a druid either a sorcerer.', cid)
end
elseif(msgcontains(msg, 'yes')) then
if(talkState[talkUser] == 1) then
doPlayerAddItem(cid, items[getPlayerVocation(cid)], 1)
selfSay('Here you are young adept, take care yourself.', cid)
setPlayerStorageValue(cid, 30002, 1)
end
talkState[talkUser] = 0
elseif(msgcontains(msg, 'no') and isInArray({1}, talkState[talkUser]) == TRUE) then
selfSay('Ok then.', cid)
talkState[talkUser] = 0
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())