- TFS 1.5 Downgrade by: Nekiro
- Lua / C++
LUA:
local config = {
gemId = 11208, -- ID do item
storageKey = 31085, -- Chave de armazenamento para verificar o uso
effects = {
maxHpPercent = 2, -- Aumento percentual na vida máxima
maxManaPercent = 2, -- Aumento percentual na mana máxima
criticalAmount = 2, -- Bônus de dano crítico
criticalChance = 1 -- Bônus de chance crítica
},
effect = CONST_ME_MAGIC_RED -- Efeito visual ao usar o item
}
local action = Action()
function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
local storageValue = player:getStorageValue(config.storageKey)
-- Verifica se o jogador já usou o item
if storageValue > 0 then
player:sendTextMessage(MESSAGE_STATUS_SMALL, "Você já usou este item.")
player:getPosition():sendMagicEffect(CONST_ME_POFF)
return true
end
-- Obter os valores atuais de CriticalHit
local currentCriticalAmount = player:getSpecialSkill(SPECIALSKILL_CRITICALHITAMOUNT)
local currentCriticalChance = player:getSpecialSkill(SPECIALSKILL_CRITICALHITCHANCE)
-- Aplica os efeitos permanentemente
player:setMaxHealth(math.floor(player:getMaxHealth() * (1 + config.effects.maxHpPercent / 100)))
player:setMaxMana(math.floor(player:getMaxMana() * (1 + config.effects.maxManaPercent / 100)))
-- Atualiza as habilidades especiais de CriticalHit
player:addSpecialSkill(SPECIALSKILL_CRITICALHITAMOUNT, currentCriticalAmount + config.effects.criticalAmount)
player:addSpecialSkill(SPECIALSKILL_CRITICALHITCHANCE, currentCriticalChance + config.effects.criticalChance)
-- Armazena os valores no storage
local storageString = string.format("%d;%d;%d;%d", config.effects.maxHpPercent, config.effects.maxManaPercent, config.effects.criticalAmount, config.effects.criticalChance)
player:setStorageValue(config.storageKey, storageString)
-- Mensagem de sucesso e efeito visual
player:sendTextMessage(MESSAGE_STATUS_SMALL, "Você recebeu os bônus do item permanentemente!")
player:getPosition():sendMagicEffect(config.effect)
-- Remove o item do jogador
item:remove(1)
return true
end
action:id(config.gemId)
action:register()
Im trying to make a Buff that when Player use (ITEM ID), he take a permanent buff. The problem is when player leave and login again on the server, SpecialSkill buff dont "keep" on the player, just Health and Mana buff.
Example:
On first use
1000 HP > 1020 HP
1000 MP > 1020 MP
Critical Chance > 1
Critical Amount > 2
Player relog:
1000 HP > 1020 HP
1000 MP > 1020 MP
Critical Chance > 0
Critical Amount > 0