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
-- Buff Config beginning --
-- configs
local config = {
storage = 77720,
value = 1,
level = 100,
}
money = 0
invisibleseconds = 600
magicshieldseconds = 600
regeseconds = 600
speedseconds = 30
skillsseconds = 600
skillsupgrade = {}
skillsupgrade['fist'] = 20
skillsupgrade['club'] = 20
skillsupgrade['sword'] = 20
skillsupgrade['axe'] = 20
skillsupgrade['distance'] = 20
skillsupgrade['shield'] = 20
skillsupgrade['ml'] = 10
-- end configs
-- Configs of buffs
local conditionMagic = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(conditionMagic, CONDITION_PARAM_BUFF, true)
setConditionParam(conditionMagic, CONDITION_PARAM_TICKS, skillsseconds * 1000)
setConditionParam(conditionMagic, CONDITION_PARAM_STAT_MAGICLEVEL, skillsupgrade['ml'])
local combatInvisible = createConditionObject(CONDITION_INVISIBLE)
setConditionParam(combatInvisible, CONDITION_PARAM_BUFF, true)
setConditionParam(combatInvisible, CONDITION_PARAM_TICKS, invisibleseconds*1000)
local conditionMelee = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(conditionMelee, CONDITION_PARAM_BUFF, true)
setConditionParam(conditionMelee, CONDITION_PARAM_TICKS, skillsseconds*1000)
setConditionParam(conditionMelee, CONDITION_PARAM_SKILL_FIST, skillsupgrade['fist'])
setConditionParam(conditionMelee, CONDITION_PARAM_SKILL_CLUB, skillsupgrade['club'])
setConditionParam(conditionMelee, CONDITION_PARAM_SKILL_SWORD, skillsupgrade['sword'])
setConditionParam(conditionMelee, CONDITION_PARAM_SKILL_AXE, skillsupgrade['axe'])
local conditionDistance = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(conditionDistance, CONDITION_PARAM_BUFF, true)
setConditionParam(conditionDistance, CONDITION_PARAM_TICKS, skillsseconds*1000)
setConditionParam(conditionDistance, CONDITION_PARAM_SKILL_DISTANCE, skillsupgrade['distance'])
local conditionShield = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(conditionShield, CONDITION_PARAM_BUFF, true)
setConditionParam(conditionShield, CONDITION_PARAM_TICKS, skillsseconds*1000)
setConditionParam(conditionShield, CONDITION_PARAM_SKILL_SHIELD, skillsupgrade['shield'])
local combatUtamo = createConditionObject(CONDITION_MANASHIELD)
setConditionParam(combatUtamo, CONDITION_PARAM_BUFF, true)
setConditionParam(combatUtamo, CONDITION_PARAM_TICKS, magicshieldseconds*1000)
local conditionRege = createConditionObject(CONDITION_REGENERATION)
setConditionParam(conditionRege, CONDITION_PARAM_BUFF, true)
setConditionParam(conditionRege, CONDITION_PARAM_TICKS, regeseconds*1000)
setConditionParam(conditionRege, CONDITION_PARAM_HEALTHGAIN, 20)
setConditionParam(conditionRege, CONDITION_PARAM_HEALTHTICKS, 2000)
local conditionspeed = createConditionObject(CONDITION_HASTE)
setConditionParam(conditionspeed, CONDITION_PARAM_BUFF, true)
setConditionParam(conditionspeed, CONDITION_PARAM_TICKS, speedseconds*1000)
setConditionFormula(conditionspeed, 1.0, -86, 1.0, -86)
function getclass(cid)
local player = Player(cid)
for voc, x in pairs(config) do
local v = player:getVocation():getId()
end
return player:getVocation():getId()
end
-- Configs of buffs
function magicl(cid, message, keywords, parameters, node)
local guid = getPlayerGUID(cid)
local player = Player(cid)
player:getLevel()
if not npcHandler:isFocused(cid) then
return false
end
if player:getLevel(cid) < config.level then
if getclass(cid) == 1 or getclass(cid) == 5 or getclass(cid) == 2 or getclass(cid) == 6 or getclass(cid) == 12 or getclass(cid) == 13 and os.time() > player:getStorageValue(config.storage) then
if getPlayerMoney(cid) >= money then
doPlayerRemoveMoney(cid, money)
doAddCondition(cid, conditionMagic)
npcHandler:say('Your magic level has increased for 10 minutes!', cid)
player:setStorageValue(config.storage, os.time()+ skillsseconds) else
npcHandler:say('You don\'t have such money.', cid)
end
else
npcHandler:say('You must be a druid or a sorcerer or a shaman to receive this increment.', cid)
end
else
npcHandler:say('You need to be below level ' .. config.level .. ' .', cid)
end
end
function invisible(cid, message, keywords, parameters, node)
local guid = getPlayerGUID(cid)
local player = Player(cid)
player:getLevel()
if not npcHandler:isFocused(cid) then
return false
end
if player:getLevel(cid) < config.level then
if getclass(cid) == 1 or getclass(cid) == 5 or getclass(cid) == 2 or getclass(cid) == 6 or getclass(cid) == 12 or getclass(cid) == 13 and os.time() > player:getStorageValue(config.storage) then
if getPlayerMoney(cid) >= money then
doPlayerRemoveMoney(cid, money)
npcHandler:say('You received invisibility for 10 minutes!', cid)
doAddCondition(cid, combatInvisible)
player:setStorageValue(config.storage, os.time()+ invisibleseconds)
else
npcHandler:say('You don\'t have such money.', cid)
end
else
npcHandler:say('You must be a druid or a sorcerer to receive this increment.', cid)
end
else
npcHandler:say('You need to be below level ' .. config.level .. ' .', cid)
end
end
function melee(cid, message, keywords, parameters, node)
local guid = getPlayerGUID(cid)
local player = Player(cid)
player:getLevel()
if not npcHandler:isFocused(cid) then
return false
end
if player:getLevel(cid) < config.level then
if getclass(cid) == 4 or getclass(cid) == 8 or getclass(cid) == 12 or getclass(cid) == 13 or getclass(cid) == 10 or getclass(cid) == 11 and os.time() > player:getStorageValue(config.storage) then
if getPlayerMoney(cid) >= money then
doPlayerRemoveMoney(cid, money)
doAddCondition(cid, conditionMelee)
npcHandler:say('Your Melee Skills has increased for 10 minutes!', cid)
player:setStorageValue(config.storage, os.time()+ skillsseconds)
else
npcHandler:say('You don\'t have such money.', cid)
end
else
npcHandler:say('You must be a knight to receive this increment.', cid)
end
else
npcHandler:say('You need to be below level ' .. config.level .. ' .', cid)
end
end
function distance(cid, message, keywords, parameters, node)
local guid = getPlayerGUID(cid)
local player = Player(cid)
player:getLevel()
if not npcHandler:isFocused(cid) then
return false
end
if player:getLevel(cid) < config.level then
if getclass(cid) == 3 or getclass(cid) == 7 and os.time() > player:getStorageValue(config.storage) then
if getPlayerMoney(cid) >= money then
doPlayerRemoveMoney(cid, money)
doAddCondition(cid, conditionDistance)
npcHandler:say('Your Distance Skill has increased for 10 minutes!', cid)
player:setStorageValue(config.storage, os.time()+ skillsseconds)
else
npcHandler:say('You don\'t have such money.', cid)
end
else
npcHandler:say('You must be a Paladin to receive this increment.', cid)
end
else
npcHandler:say('You need to be below level ' .. config.level .. ' .', cid)
end
end
function shield(cid, message, keywords, parameters, node)
local guid = getPlayerGUID(cid)
local player = Player(cid)
player:getLevel()
if not npcHandler:isFocused(cid) then
return false
end
if player:getLevel(cid) < config.level then
if getclass(cid) == 3 or getclass(cid) == 7 or getclass(cid) == 2 or getclass(cid) == 4 and os.time() > player:getStorageValue(config.storage) then
if getPlayerMoney(cid) >= money then
doPlayerRemoveMoney(cid, money)
doAddCondition(cid, conditionShield)
npcHandler:say('Your Shielding Skill has increased for 10 minutes!', cid)
player:setStorageValue(config.storage, os.time()+ skillsseconds)
else
npcHandler:say('You don\'t have such money.', cid)
end
else
npcHandler:say('You must be a Paladin or a Knight to receive this increment.', cid)
end
else
npcHandler:say('You need to be below level ' .. config.level .. ' .', cid)
end
end
function magicshield(cid, message, keywords, parameters, node)
local guid = getPlayerGUID(cid)
local player = Player(cid)
player:getLevel()
if not npcHandler:isFocused(cid) then
return false
end
if player:getLevel(cid) < config.level then
if getclass(cid) == 1 or getclass(cid) == 5 or getclass(cid) == 2 or getclass(cid) == 6 or getclass(cid) == 12 or getclass(cid) == 13 and os.time() > player:getStorageValue(config.storage) then
if getPlayerMoney(cid) >= money then
doPlayerRemoveMoney(cid, money)
doAddCondition(cid, combatUtamo)
npcHandler:say('You received a Magic Shield for 10 minutes!', cid)
player:setStorageValue(config.storage, os.time()+ magicshieldseconds)
else
npcHandler:say('You don\'t have such money.', cid)
end
else
npcHandler:say('Knights can\'t receive this increment.', cid)
end
else
npcHandler:say('You need to be below level ' .. config.level .. ' .', cid)
end
end
function regener(cid, message, keywords, parameters, node)
local guid = getPlayerGUID(cid)
local player = Player(cid)
player:getLevel()
if not npcHandler:isFocused(cid) then
return false
end
if player:getLevel(cid) < config.level then
if isPlayer(cid) and os.time() > player:getStorageValue(config.storage) then
if getPlayerMoney(cid) >= money then
doPlayerRemoveMoney(cid, money)
doAddCondition(cid, conditionRege)
npcHandler:say('Your regeneration has increased for 10 minutes!', cid)
player:setStorageValue(config.storage, os.time()+ regeseconds)
else
npcHandler:say('You don\'t have such money.', cid)
end
else
npcHandler:say('You can\'t receive more than two increases.', cid)
end
else
npcHandler:say('You need to be below level ' .. config.level .. ' .', cid)
end
end
function speed(cid, message, keywords, parameters, node)
local guid = getPlayerGUID(cid)
local player = Player(cid)
player:getLevel()
if not npcHandler:isFocused(cid) then
return false
end
if player:getLevel(cid) < config.level then
if isPlayer(cid) and os.time() > player:getStorageValue(config.storage) then
if getPlayerMoney(cid) >= money then
doPlayerRemoveMoney(cid, money)
doAddCondition(cid, conditionspeed)
npcHandler:say('Your speed has increased for 10 minutes!', cid)
player:setStorageValue(config.storage, os.time()+ speedseconds)
else
npcHandler:say('You don\'t have such money.', cid)
end
else
npcHandler:say('You can\'t receive more than two increases.', cid)
end
else
npcHandler:say('You need to be below level ' .. config.level .. ' .', cid)
end
end
-- Buff Config End --
keywordHandler:addKeyword({'help'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "I can increase your {melee}, {distance}, {shielding}, {magic level}, {regeneration}, {magic shield} and {speed} if you are below 1000 lvl."})
local node1 = keywordHandler:addKeyword({'magic level'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to increase your magic level for a certain time?'})
node1:addChildKeyword({'yes'}, magicl, {npcHandler = npcHandler, onlyFocus = true, reset = true})
node1:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})
--local node2 = keywordHandler:addKeyword({'invisibility'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to be invisible for a certain time?'})
-- node2:addChildKeyword({'yes'}, invisible, {npcHandler = npcHandler, onlyFocus = true, reset = true})
-- node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})
local node3 = keywordHandler:addKeyword({'melee'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to increase your melee skills for a certain time?'})
node3:addChildKeyword({'yes'}, melee, {npcHandler = npcHandler, onlyFocus = true, reset = true})
node3:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})
local node4 = keywordHandler:addKeyword({'distance'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to increase your distance skills for a certain time?'})
node4:addChildKeyword({'yes'}, distance, {npcHandler = npcHandler, onlyFocus = true, reset = true})
node4:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})
local node5 = keywordHandler:addKeyword({'shielding'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to increase your shielding skill for a certain time?'})
node5:addChildKeyword({'yes'}, shield, {npcHandler = npcHandler, onlyFocus = true, reset = true})
node5:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})
local node6 = keywordHandler:addKeyword({'magic shield'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to receive a magic shield for a certain time?'})
node6:addChildKeyword({'yes'}, magicshield, {npcHandler = npcHandler, onlyFocus = true, reset = true})
node6:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})
local node7 = keywordHandler:addKeyword({'regeneration'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to increase your regeneration for a certain time?'})
node7:addChildKeyword({'yes'}, regener, {npcHandler = npcHandler, onlyFocus = true, reset = true})
node7:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})
local node8 = keywordHandler:addKeyword({'speed'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Do you want to increase your speed for a certain time?'})
node8:addChildKeyword({'yes'}, speed, {npcHandler = npcHandler, onlyFocus = true, reset = true})
node8:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then. Come back if you want an upgrade in your skills.', reset = true})
npcHandler:addModule(FocusModule:new())