jareczekjsp
Member
Hello I have revescript reborn give damage and exp +10 all resets
and I have problem I would like when player make reset back to level 8 with hp150 and mana 35 with bonuses(damage and exp) can somebody help me ?please
My script
and I have problem I would like when player make reset back to level 8 with hp150 and mana 35 with bonuses(damage and exp) can somebody help me ?please
My script
Lua:
local config = {
talk = "!reset",
storageResets = 525000,
backToLevel = 8,
redskull = true,
battle = true,
pz = true,
defaultGainMaxHealth = 0.3,
defaultGainMaxMana = 0.3,
resetCostItemId = 2157, -- Item ID required for reset
resetCostAmount = 100, -- Amount of item required for reset
expBonus = 10, -- Initial experience bonus in percentage (10%)
damageBonus = 10, -- Initial damage bonus in percentage (10%)
stages = {
{levelRequired = 2000, cost = 100},
{levelRequired = 3000, cost = 100},
{levelRequired = 4000, cost = 100},
{levelRequired = 5000, cost = 100},
-- Add more stages as needed
}
}
-- Function to get experience required for a specific level
local function getExperienceForLevel(lv)
lv = lv - 1
return ((50 * lv * lv * lv) - (150 * lv * lv) + (400 * lv)) / 3
end
local resetSys = TalkAction(config.talk)
function resetSys.onSay(player, words, param)
-- Check if the player meets reset conditions
if config.redskull and player:getSkull() == SKULL_RED then
player:sendCancelMessage("You need to be without red skull to reset.")
return false
elseif config.pz and not getTilePzInfo(player:getPosition()) then
player:sendCancelMessage("You need to be in a protection zone to reset.")
return false
elseif config.battle and player:getCondition(CONDITION_INFIGHT) then
player:sendCancelMessage("You need to be out of battle to reset.")
return false
end
-- Find the appropriate stage based on player's resets
local playerResets = math.max(0, player:getStorageValue(config.storageResets))
local stage = nil
for _, _stage in ipairs(config.stages) do
if playerResets < _stage.levelRequired then
stage = _stage
break
end
end
if not stage then
player:sendCancelMessage("Stage not found for your resets.")
return false
end
-- Check if the player has the required level
local playerLevel = player:getLevel()
if playerLevel < stage.levelRequired then
player:sendCancelMessage("You need to be level " .. stage.levelRequired .. " or higher to reset.")
return false
end
-- Check if the player has enough items to perform the reset
if not player:removeItem(config.resetCostItemId, config.resetCostAmount) then
player:sendCancelMessage("You need " .. config.resetCostAmount .. " of item " .. config.resetCostItemId .. " to perform the reset.")
return false
end
-- Perform the reset
playerResets = playerResets + 1
player:setStorageValue(config.storageResets, playerResets)
player:removeExperience(getExperienceForLevel(playerLevel) - getExperienceForLevel(config.backToLevel))
local maxHealth = player:getMaxHealth()
local maxMana = player:getMaxMana()
local newMaxHealth = maxHealth + math.ceil(maxHealth * config.defaultGainMaxHealth)
local newMaxMana = maxMana + math.ceil(maxMana * config.defaultGainMaxMana)
player:setMaxHealth(newMaxHealth)
player:setMaxMana(newMaxMana)
player:addHealth(newMaxHealth)
player:addMana(newMaxMana)
player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_RED)
player:sendTextMessage(MESSAGE_INFO_DESCR, "Now you have " .. playerResets .. " " .. (playerResets == 1 and "reset" or "resets") .. ".")
return false
end
resetSys:register()
local ec = EventCallback
ec.onGainExperience = function(self, source, exp, rawExp)
if not source:isMonster() then
return exp
end
local playerResets = math.max(0, self:getStorageValue(config.storageResets))
local bonusPercent = playerResets * config.expBonus
local percent = 1 + (bonusPercent / 100)
exp = exp * percent
return exp
end
ec:register()
local resetSysEvent = CreatureEvent("resetSys")
function resetSysEvent.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
if not creature or not attacker then
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
local playerResets = 0
if attacker:isPlayer() then
playerResets = attacker:getStorageValue(config.storageResets)
end
if playerResets == -1 then
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
playerResets = math.max(0, playerResets)
local bonusPercent = playerResets * config.damageBonus
if bonusPercent > 0 then
local bonusDamage = primaryDamage * bonusPercent / 100
primaryDamage = primaryDamage + bonusDamage
secondaryDamage = secondaryDamage + bonusDamage
end
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
resetSysEvent:register()
local eventCallback = EventCallback
function eventCallback.onSpawn(creature, position, startup, artificial)
if creature:isMonster() then
creature:registerEvent("resetSys")
end
return true
end
eventCallback:register(-666)