-- Configuration Table
local config = {
mountId = 58, -- ID of the Sparkion mount, adjust if necessary
permBonusStorage = 10001, -- A unique storage value to track the permanent bonus
bonusPercent = 0.05, -- Percentage of the HP and MANA bonus
vibrantEggId = 2160 -- ID of the Vibrant Egg
}
-- Action for the Vibrant Egg
local vibrant_egg = Action()
function vibrant_egg.onUse(player, item, fromPosition, target, toPosition, isHotkey)
-- Check if the player already has the Sparkion mount
if player:hasMount(config.mountId) then
player:sendTextMessage(MESSAGE_STATUS_WARNING, "You already have the Sparkion mount.")
return true
end
-- Grant the Sparkion mount to the player
player:addMount(config.mountId)
player:sendTextMessage(MESSAGE_INFO_DESCR, "You have received the Sparkion mount and a 5% bonus to HP and MANA.")
-- Add the permanent 5% HP and MANA bonus if not already given
if player:getStorageValue(config.permBonusStorage) ~= 1 then
player:setStorageValue(config.permBonusStorage, 1)
-- Calculate the new max HP and MANA values
local newMaxHealth = math.floor(player:getMaxHealth() * (1 + config.bonusPercent))
local newMaxMana = math.floor(player:getMaxMana() * (1 + config.bonusPercent))
-- Store the new max HP and MANA values in separate storage entries
player:setStorageValue(config.permBonusStorage .. "_MAX_HEALTH", newMaxHealth)
player:setStorageValue(config.permBonusStorage .. "_MAX_MANA", newMaxMana)
player:setMaxHealth(newMaxHealth)
player:setMaxMana(newMaxMana)
end
-- Remove the Vibrant Egg from the player's inventory
player:removeItem(item.itemid, 1)
return true
end
vibrant_egg:id(config.vibrantEggId) -- ID of the Vibrant Egg
vibrant_egg:register() -- Register the action