local berserk = Condition(CONDITION_ATTRIBUTES)
berserk:setParameter(CONDITION_PARAM_TICKS, 10 * 60 * 1000)
berserk:setParameter(CONDITION_PARAM_SKILL_MELEE, 5)
berserk:setParameter(CONDITION_PARAM_SKILL_SHIELD, -10)
berserk:setParameter(CONDITION_PARAM_BUFF_SPELL, true)
local mastermind = Condition(CONDITION_ATTRIBUTES)
mastermind:setParameter(CONDITION_PARAM_TICKS, 10 * 60 * 1000)
mastermind:setParameter(CONDITION_PARAM_STAT_MAGICPOINTS, 3)
mastermind:setParameter(CONDITION_PARAM_BUFF_SPELL, true)
local bullseye = Condition(CONDITION_ATTRIBUTES)
bullseye:setParameter(CONDITION_PARAM_TICKS, 10 * 60 * 1000)
bullseye:setParameter(CONDITION_PARAM_SKILL_DISTANCE, 5)
bullseye:setParameter(CONDITION_PARAM_SKILL_SHIELD, -10)
bullseye:setParameter(CONDITION_PARAM_BUFF_SPELL, true)
local potions = {
[5090] = {
-- strong health potion
health = {250, 350},
vocations = {3, 4, 7, 8},
level = 50,
levelScaling = 1.0,
flask = 0,
description = "Only knights and paladins of level 50 or above may drink this fluid."
},
[5091] = {
-- strong mana potion
mana = {115, 185},
vocations = {1, 2, 3, 5, 6, 7},
level = 50,
levelScaling = 1.0,
flask = 0,
description = "Only sorcerers, druids and paladins of level 50 or above may drink this fluid."
},
[5092] = {
-- great mana potion
mana = {150, 250},
vocations = {1, 2, 5, 6},
level = 80,
levelScaling = 1.0,
flask = 0,
description = "Only druids and sorcerers of level 80 or above may drink this fluid."
},
[5093] = {
-- great health potion
health = {425, 575},
vocations = {4, 8},
level = 80,
levelScaling = 1.0,
flask = 0,
description = "Only knights of level 80 or above may drink this fluid."
},
[5094] = {
-- health potion
health = {125, 175},
levelScaling = 1.0,
flask = 0
},
[5095] = {
-- mana potion
mana = {75, 125},
levelScaling = 1.0,
flask = 0
},
[5099] = {
-- great spirit potion
health = {250, 350},
mana = {100, 200},
vocations = {3, 7},
level = 80,
levelScaling = 1.0,
flask = 0,
description = "Only paladins of level 80 or above may drink this fluid."
}
}
local table_name = "potion_exhaust"
local function setExhaust(tableName, player, method, duration)
if not PLAYER_EXHAUSTS2 then
PLAYER_EXHAUSTS2 = {}
end
if not PLAYER_EXHAUSTS2[tableName] then
PLAYER_EXHAUSTS2[tableName] = {}
end
-- if not PLAYER_EXHAUSTS2[tableName][player:getGuid()] then
-- PLAYER_EXHAUSTS2[tableName][player:getGuid()] = {}
-- end
local interval = 0
if string.find(method, "second") then
interval = duration
elseif string.find(method, "minute") then
interval = duration * 1000 * 60
elseif string.find(method, "hour") then
interval = duration * 1000 * 60 * 60
end
PLAYER_EXHAUSTS2[tableName][player:getGuid()] = os.time() + interval
end
local function getExhaust(tableName, player)
if not PLAYER_EXHAUSTS2 then
return false
end
if not PLAYER_EXHAUSTS2[tableName] then
return false
end
if not PLAYER_EXHAUSTS2[tableName][player:getGuid()] then
return false
end
if PLAYER_EXHAUSTS2[tableName][player:getGuid()] > os.time() then
return true
end
return false
end
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if type(target) == "userdata" and not target:isPlayer() then
return false
end
local potion = potions[item:getId()]
if not potion then
return true
end
if getExhaust(table_name, player) then
player:sendCancelMessage("You are exhausted.")
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return true
end
if
potion.level and player:getLevel() < potion.level or
potion.vocations and not table.contains(potion.vocations, player:getVocation():getId())
then
player:say(potion.description, TALKTYPE_MONSTER_SAY)
return true
end
if potion.condition then
player:addCondition(potion.condition)
player:say(potion.text, TALKTYPE_MONSTER_SAY)
player:getPosition():sendMagicEffect(potion.effect)
elseif potion.transform then
local reward = potion.transform[math.random(#potion.transform)]
if fromPosition.x == CONTAINER_POSITION then
local targetContainer = Container(item:getParent().uid)
targetContainer:addItem(reward, 1)
else
Game.createItem(reward, 1, fromPosition)
end
item:getPosition():sendMagicEffect(potion.effect)
item:remove(1)
return true
else
local level = player:getLevel()
if potion.health then
doTargetCombat(0, target, COMBAT_HEALING, potion.health[1] + math.floor(level * potion.levelScaling), potion.health[2] + math.floor(level * potion.levelScaling))
end
if potion.mana then
doTargetCombat(0, target, COMBAT_MANADRAIN, potion.mana[1] + math.floor(level * potion.levelScaling), potion.mana[2] + math.floor(level * potion.levelScaling))
end
if potion.antidote then
target:removeCondition(CONDITION_POISON)
end
player:addAchievementProgress("Potion Addict", 100000)
print("Flask: " .. potion.flask)
player:addItem(potion.flask)
target:say("Aaaah...", TALKTYPE_MONSTER_SAY)
target:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
end
if not configManager.getBoolean(configKeys.REMOVE_POTION_CHARGES) then
return true
end
item:remove(1)
setExhaust(table_name, player, "second", 1, 5)
return true
end