hello everyone
Simple modification Reset system Script! lib
My Script working like 1k+ Can get reset.
How Change player Up level 1000- 1500-2000-2500-2700-2800-2900-3000 Can get Reset
TFS 1.2-Tibia 8.60
Simple modification Reset system Script! lib
My Script working like 1k+ Can get reset.
How Change player Up level 1000- 1500-2000-2500-2700-2800-2900-3000 Can get Reset
TFS 1.2-Tibia 8.60
Lua:
ResetSystem = {
storage = 14335,
back_to_level = 100,
needed_level_per_reset = 1000,
max_count = 1000,
bonus_per_reset = {
experiencePercent = 10,
damagePercent = 2.5,
healthAndManaGainPercent = 5
}
}
function ResetSystem:getCount(pid)
return math.max(0, (tonumber(getCreatureStorage(pid, self.storage)) or 0))
end
function ResetSystem:setCount(pid, count)
doCreatureSetStorage(pid, self.storage, count)
db.executeQuery("UPDATE `players` SET `reset` = '"..count.."' WHERE `id` = '"..getPlayerGUID(pid).."';")
end
function ResetSystem:addCount(pid)
db.executeQuery("UPDATE `players` SET `reset` = '".. (self:getCount(pid) + 1) .."' WHERE `id` = '"..getPlayerGUID(pid).."';")
self:setCount(pid, self:getCount(pid) + 1)
end
function ResetSystem:getCurrentBonus(pid)
local resets = math.min(self:getCount(pid), self.max_count)
if (resets > 0) then
local currentBonus = {}
for bonus, value in pairs(self.bonus_per_reset) do
currentBonus[bonus] = value * resets
end
return currentBonus
end
return nil
end
function ResetSystem:applyBonuses(pid)
local bonus = self:getCurrentBonus(pid)
if (bonus and bonus.damagePercent) then
setPlayerDamageMultiplier(pid, 1.0 + (bonus.damagePercent / 100.0))
else
setPlayerDamageMultiplier(pid, 1.0)
end
end
function ResetSystem:updateHealthAndMana(pid)
local bonus = self:getCurrentBonus(pid)
if (bonus and bonus.healthAndManaGainPercent) then
local vocationInfo = getVocationInfo(getPlayerVocation(pid))
if (vocationInfo) then
local oldMaxHealth = getCreatureMaxHealth(pid)
local oldMaxMana = getCreatureMaxMana(pid)
local level = getPlayerLevel(pid)
local totalHealth = (vocationInfo.healthGain * level)
local totalMana = (vocationInfo.manaGain * level)
local newMaxHealth = math.floor(totalHealth + (totalHealth * (bonus.healthAndManaGainPercent / 100)))
local newMaxMana = math.floor(totalMana + (totalMana * (bonus.healthAndManaGainPercent / 100)))
setCreatureMaxHealth(pid, newMaxHealth)
setCreatureMaxMana(pid, newMaxMana)
if (newMaxHealth > oldMaxHealth) then
doCreatureAddHealth(pid, newMaxHealth - oldMaxHealth)
elseif (newMaxHealth < oldMaxHealth) then
doCreatureAddHealth(pid, 1) -- evita barra bugada
end
if (newMaxMana > oldMaxMana) then
doCreatureAddMana(pid, newMaxMana - oldMaxMana)
elseif (newMaxMana < oldMaxMana) then
doCreatureAddMana(pid, 1)
end
end
end
end
function ResetSystem:execute(pid)
self:addCount(pid)
local playerLevel = getPlayerLevel(pid)
if (playerLevel > self.back_to_level) then
doPlayerAddExperience(pid, getExperienceForLevel(self.back_to_level) - getPlayerExperience(pid))
playerLevel = self.back_to_level
end
self:applyBonuses(pid)
self:updateHealthAndMana(pid)
local bonus = self:getCurrentBonus(pid)
if (bonus) then
local message = "Você efetuou seu " .. self:getCount(pid) .. "° reset."
if (bonus.damagePercent) then
message = message .. "\n+" .. bonus.damagePercent .. "% de dano"
end
if (bonus.healthAndManaGainPercent) then
message = message .. "\n+" .. bonus.healthAndManaGainPercent .. "% de vida e mana"
local vocationInfo = getVocationInfo(getPlayerVocation(pid))
if (vocationInfo) then
local healthAndManaMultiplier = 1.0 + (bonus.healthAndManaGainPercent / 100.0)
local healthBonusSum = (vocationInfo.healthGain * playerLevel) * healthAndManaMultiplier
local manaBonusSum = (vocationInfo.manaGain * playerLevel) * healthAndManaMultiplier
setCreatureMaxHealth(pid, healthBonusSum)
setCreatureMaxMana(pid, manaBonusSum)
doCreatureAddHealth(pid, healthBonusSum)
doCreatureAddMana(pid, manaBonusSum)
end
end
if (bonus.experiencePercent) then
message = message .. "\n+" .. bonus.experiencePercent .. "% de EXP"
end
doPlayerSendTextMessage(pid, MESSAGE_EVENT_ADVANCE, message)
end
end