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 = 16002
local sorcspells = {
["Flame Strike"] = {upgrade = 5, cost = 2, storage = 18001},
["Hells Core"] = {upgrade = 3, cost = 5, storage = 18002}
}
local druidspells = {
["Frigo Strike"] = {upgrade = 5, cost = 2, storage = 18101},
["Eternal Winter"] = {upgrade = 3, cost = 5, storage = 18102}
}
local pallyspells = {
["Ethereal Spear"] = {upgrade = 5, cost = 2, storage = 18201},
["Divine Caldera"] = {upgrade = 3, cost = 5, storage = 18202}
}
local knightspells = {
["Berserk"] = {upgrade = 5, cost = 2, storage = 18301},
["Fierce Berserk"] = {upgrade = 3, cost = 5, storage = 18302}
}
for v = 18000, 18400 do
if getPlayerStorageValue(cid, v) == -1 then
setPlayerStorageValue(cid, v, 0)
end
end
if(getPlayerVocation(cid) == 1) or (getPlayerVocation(cid) == 5) then
x = sorcspells[msg]
end
if(getPlayerVocation(cid) == 2) or (getPlayerVocation(cid) == 6) then
x = druidspells[msg]
end
if(getPlayerVocation(cid) == 3) or (getPlayerVocation(cid) == 7) then
x = pallyspells[msg]
end
if(getPlayerVocation(cid) == 4) or (getPlayerVocation(cid) == 8) then
x = knightspells[msg]
end
if x then
if getPlayerStorageValue(cid, storage) >= x.cost then
if getPlayerStorageValue(cid, x.storage) < x.upgrade then
setPlayerStorageValue(cid, storage, getPlayerStorageValue(cid, storage) - x.cost)
setPlayerStorageValue(cid, x.storage, getPlayerStorageValue(cid, x.storage) + 1)
selfSay('You have upgraded the spell "'..msg..'" to ['..getPlayerStorageValue(cid, x.storage)..'/'..x.upgrade..'] for '..x.cost..' points. You now have '..getPlayerStorageValue(cid, storage)..' points left.', cid)
else
selfSay('You have already upgraded this spell '..x.upgrade..' times.', cid)
end
else
selfSay('You need '..x.cost..' points to upgrade this spell. You only have '..getPlayerStorageValue(cid, storage)..' points currently. ', cid)
end
end
local info = (msgcontains(msg, 'info'))
if info then
selfSay('Each time you level up, you receive 1 point, with those points you can upgrade your spells. You currently have '..getPlayerStorageValue(cid, storage)..' points. You can see the spells you can upgrade in the {list}.', cid)
end
local list = (msgcontains(msg, 'list'))
if list then
if(getPlayerVocation(cid) == 1) or (getPlayerVocation(cid) == 5) then
text = 'Spells available for Sorcerers:\n'
for i, x in pairs(sorcspells) do
text = text .. "\n" .. i .. " - ["..getPlayerStorageValue(cid, x.storage).."/"..x.upgrade.."]"
end
doShowTextDialog(cid, 6120, "" .. text)
end
if(getPlayerVocation(cid) == 2) or (getPlayerVocation(cid) == 6) then
text = 'Spells available for Druids:\n'
for i, x in pairs(druidspells) do
text = text .. "\n" .. i .. " - ["..getPlayerStorageValue(cid, x.storage).."/"..x.upgrade.."]"
end
doShowTextDialog(cid, 6120, "" .. text)
end
if(getPlayerVocation(cid) == 3) or (getPlayerVocation(cid) == 7) then
text = 'Spells available for Paladins:\n'
for i, x in pairs(pallyspells) do
text = text .. "\n" .. i .. " - ["..getPlayerStorageValue(cid, x.storage).."/"..x.upgrade.."]"
end
doShowTextDialog(cid, 6120, "" .. text)
end
if(getPlayerVocation(cid) == 4) or (getPlayerVocation(cid) == 8) then
text = 'Spells available for Knights:\n'
for i, x in pairs(knightspells) do
text = text .. "\n" .. i .. " - ["..getPlayerStorageValue(cid, x.storage).."/"..x.upgrade.."]"
end
doShowTextDialog(cid, 6120, "" .. text)
end
end
if not x and not list and not info then
selfSay('What? If you want to get a spell make sure to be proper. Example: Frigo Strike = {Frigo Strike}. Not "frigo strike."', cid)
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())