• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua amendment Reset System (otx-8.60)

Gaber Zen

Active Member
Joined
Apr 22, 2023
Messages
196
Reaction score
44
Location
Egypt
Hi everyone
how Change Script Tfs-to Otx Like Resets System amendment every time get 3500 level Can get resets

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
<talkaction access="0-4" words="!reset" event="script" value="reset_system_talk.lua"/>

Lua:
function onSay(cid, words, param, channel)
    if (param:lower() == "info") then
        local message = "~~~~~~~~~~Reset Infos ~~~~~~~~~~\n"
        local resetsCount = ResetSystem:getCount(cid)
        message = message .. "\nN�mero de Resets: " .. resetsCount .. "."

        local level = getPlayerLevel(cid)
        local vocationInfo = getVocationInfo(getPlayerVocation(cid))
        local baseHealth, extraHealth
        local baseMana, extraMana
        local resetBonus = ResetSystem:getCurrentBonus(cid)
        if (resetBonus and vocationInfo) then
            baseHealth = vocationInfo.healthGain * level
            extraHealth = getCreatureMaxHealth(cid) - baseHealth
            baseMana = vocationInfo.manaGain * level
            extraMana = getCreatureMaxMana(cid) - baseMana
        else
            baseHealth, extraHealth = getCreatureMaxHealth(cid), 0
            baseMana, extraMana = getCreatureMaxMana(cid), 0
        end

        message = message .. "\nVida normal: " .. baseHealth .. " + " .. extraHealth .. "."
        message = message .. "\nMana normal: " .. baseMana .. " + " .. extraMana .. "."
        message = message .. "\nExp Stage Bon�s: " .. getExperienceStage(level) .. "x + " .. ((resetBonus and resetBonus.experiencePercent) or "0") .. "%."
        message = message .. "\nDamage Bon�s: " .. ((resetBonus and resetBonus.damagePercent) or "0") .. "%."
        message = message .. "\nProximo Reset: Lv" .. (resetsCount < ResetSystem.max_count and ((resetsCount + 1) * ResetSystem.needed_level_per_reset) or "0") .. "."
        doShowTextDialog(cid, 8983, message)
    else
        local position = getThingPosition(cid)
        local tileInfo = getTileInfo(position)
        if (tileInfo and not tileInfo.protection) then
            doPlayerSendCancel(cid, "Voc� s� pode usar esse comando em protection zone.")
            doSendMagicEffect(position, CONST_ME_POFF)
            return true
        end

        local resetsCount = ResetSystem:getCount(cid)
        if (resetsCount >= ResetSystem.max_count) then
            doPlayerSendCancel(cid, "Voc� j� atingiu o n�vel m�ximo de resets.")
            doSendMagicEffect(position, CONST_ME_POFF)
            return true
        end

        local levelNeeded = (resetsCount + 1) * ResetSystem.needed_level_per_reset
        if (levelNeeded > getPlayerLevel(cid)) then
            doPlayerSendCancel(cid, "Voc� precisa ser level " .. levelNeeded .. " ou maior.")
            doSendMagicEffect(position, CONST_ME_POFF)
            return true
        end

        ResetSystem:execute(cid)
        doSendMagicEffect(position, CONST_ME_TELEPORT)
        doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
        doSendMagicEffect(getThingPosition(cid), CONST_ME_TELEPORT)
    end
    return true
end
 
Solution
I understand that a lot of people are looking for this reset damage boost system. I decided to share it with you 😉

I managed to implement the damage increase system, and the Discord colleague tested it and confirmed that it is working. It is necessary to add it in the source. Let's go!

OTX 2-3 8.6 tested ok
combat.cpp

look for this line.
C++:
bool Combat::CombatHealthFunc(Creature* caster, Creature* target, const CombatParams& params, void* data)

Just replace all the code here.
C++:
bool Combat::CombatHealthFunc(Creature* caster, Creature* target, const CombatParams& params, void* data)
{
    int32_t change = 0;
    if (Combat2Var* var = (Combat2Var*)data)
    {
        change = var->change;
        if (!change)...
Lua:
local ResetSystem = {
    storage = 14335,

    back_to_level = 100,
    needed_level_per_reset = 3500,
    max_count = 1000,

    bonus_per_reset = {
        experiencePercent = 10,
        damagePercent = 2.5,
        healthAndManaGainPercent = 5
    }
}

function ResetSystem:getCount(pid)
    return math.max(0, (getPlayerStorageValue(pid, self.storage) or 0))
end

function ResetSystem:setCount(pid, count)
    setPlayerStorageValue(pid, self.storage, count)
    db.executeQuery("UPDATE `players` SET `reset` = '"..count.."' WHERE `id` = '"..getPlayerGUIDByName(pid).."';")
end

function ResetSystem:addCount(pid)
    db.executeQuery("UPDATE `players` SET `reset` = '".. (self:getCount(pid) + 1) .."' WHERE `id` = '"..getPlayerGUIDByName(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
        doPlayerSetDamageMultiplier(pid, 1.0 + (bonus.damagePercent / 100.0))
    else
        doPlayerSetDamageMultiplier(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 o 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


Lua:
function onSay(cid, words, param, channel)
    if (param:lower() == "info") then
        local message = "~~~~~~~~~~ Reset Infos ~~~~~~~~~~\n"
        local resetsCount = ResetSystem:getCount(cid)
        message = message .. "\nNúmero de Resets: " .. resetsCount .. "."

        local level = getPlayerLevel(cid)
        local vocationInfo = getVocationInfo(getPlayerVocation(cid))
        local baseHealth, extraHealth
        local baseMana, extraMana
        local resetBonus = ResetSystem:getCurrentBonus(cid)
        if (resetBonus and vocationInfo) then
            baseHealth = vocationInfo.healthGain * level
            extraHealth = getCreatureMaxHealth(cid) - baseHealth
            baseMana = vocationInfo.manaGain * level
            extraMana = getCreatureMaxMana(cid) - baseMana
        else
            baseHealth, extraHealth = getCreatureMaxHealth(cid), 0
            baseMana, extraMana = getCreatureMaxMana(cid), 0
        end

        message = message .. "\nVida normal: " .. baseHealth .. " + " .. extraHealth .. "."
        message = message .. "\nMana normal: " .. baseMana .. " + " .. extraMana .. "."
        message = message .. "\nExp Stage Bônus: " .. getExperienceStage(level) .. "x + " .. ((resetBonus and resetBonus.experiencePercent) or "0") .. "%."
        message = message .. "\nDamage Bônus: " .. ((resetBonus and resetBonus.damagePercent) or "0") .. "%."
        message = message .. "\nPróximo Reset: Lv" .. (resetsCount < ResetSystem.max_count and ((resetsCount + 1) * ResetSystem.needed_level_per_reset) or "0") .. "."
        doShowTextDialog(cid, 8983, message)
    else
        local position = getThingPosition(cid)
        local tileInfo = getTileInfo(position)
        if (tileInfo and not tileInfo.protection) then
            doPlayerSendCancel(cid, "Você só pode usar esse comando em protection zone.")
            doSendMagicEffect(position, CONST_ME_POFF)
            return TRUE
        end

        local resetsCount = ResetSystem:getCount(cid)
        if (resetsCount >= ResetSystem.max_count) then
            doPlayerSendCancel(cid, "Você já atingiu o nível máximo de resets.")
            doSendMagicEffect(position, CONST_ME_POFF)
            return TRUE
        end

        local levelNeeded = (resetsCount + 1) * ResetSystem.needed_level_per_reset
        if (levelNeeded > getPlayerLevel(cid)) then
            doPlayerSendCancel(cid, "Você precisa ser level " .. levelNeeded .. " ou maior.")
            doSendMagicEffect(position, CONST_ME_POFF)
            return TRUE
        end

        ResetSystem:execute(cid)
        doSendMagicEffect(position, CONST_ME_TELEPORT)
        doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
        doSendMagicEffect(getThingPosition(cid), CONST_ME_TELEPORT)
    end
    return TRUE
end
 
If an error occurs, I can try to identify it and figure out how to fix it. Only it will be possible to do that tomorrow, okay?

Lua:
function onSay(cid, words, param, channel)
    local requiredLevel = 3500
    local playerLevel = getPlayerLevel(cid)
    
    if param:lower() == "info" then
        local message = "~~~~~~~~~~ Reset Infos ~~~~~~~~~~\n"
        
        local resetsCount = 5 -- Fetch the actual resets count from your database
        local baseHealth = 100 -- Example base health
        local extraHealth = 50 -- Example extra health
        local baseMana = 80 -- Example base mana
        local extraMana = 40 -- Example extra mana
        local experiencePercent = 10 -- Example experience bonus
        local damagePercent = 5 -- Example damage bonus
        
        message = message .. "\nNúmero de Resets: " .. resetsCount .. "."
        message = message .. "\nVida normal: " .. baseHealth .. " + " .. extraHealth .. "."
        message = message .. "\nMana normal: " .. baseMana .. " + " .. extraMana .. "."
        message = message .. "\nExp Stage Bônus: " .. experiencePercent .. "%."
        message = message .. "\nDamage Bônus: " .. damagePercent .. "%."
        message = message .. "\nPróximo Reset: Lv" .. ((resetsCount + 1) * 100) .. "."
        doShowTextDialog(cid, 8983, message)
    else
        local position = getThingPosition(cid)
        local tileInfo = getTileInfo(position)
        if tileInfo and not tileInfo.protection then
            doPlayerSendCancel(cid, "Você só pode usar esse comando em uma Protection Zone.")
            doSendMagicEffect(position, CONST_ME_POFF)
            return TRUE
        end
        
        if playerLevel < requiredLevel then
            doPlayerSendCancel(cid, "Você precisa ser level " .. requiredLevel .. " ou maior para resetar.")
            return TRUE
        end
        
        local resetsCount = 5 -- Fetch the actual resets count from your database
        if resetsCount >= 10 then
            doPlayerSendCancel(cid, "Você já atingiu o nível máximo de resets.")
            return TRUE
        end
        
      
        
        doSendMagicEffect(position, CONST_ME_TELEPORT)
        doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
        doSendMagicEffect(getThingPosition(cid), CONST_ME_TELEPORT)
        
      
        doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "Você resetou suas stats!")
    end
    
    return TRUE
end
 
<!-- Reset System -->
<event type="login" name="RSLogin" script="reset_system_creature.lua"/>
<event type="advance" name="RSAdvance" script="reset_system_creature.lua"/>
Lua:
function onLogin(cid)
    ResetSystem:applyBonuses(cid)
    ResetSystem:updateHealthAndMana(cid)
    registerCreatureEvent(cid, "RSAdvance")
    return true
end

function onAdvance(cid, skill, oldLevel, newLevel)
    if (skill == SKILL__LEVEL) then
        ResetSystem:updateHealthAndMana(cid)
    end
    return true
end
lib
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
<talkaction access="0-4" words="!reset" event="script" value="reset_system_talk.lua"/>
function onSay(cid, words, param, channel)
if (param:lower() == "info") then
local message = "~~~~~~~~~~Reset Infos ~~~~~~~~~~\n"
local resetsCount = ResetSystem:getCount(cid)
message = message .. "\nNْmero de Resets: " .. resetsCount .. "."

local level = getPlayerLevel(cid)
local vocationInfo = getVocationInfo(getPlayerVocation(cid))
local baseHealth, extraHealth
local baseMana, extraMana
local resetBonus = ResetSystem:getCurrentBonus(cid)
if (resetBonus and vocationInfo) then
baseHealth = vocationInfo.healthGain * level
extraHealth = getCreatureMaxHealth(cid) - baseHealth
baseMana = vocationInfo.manaGain * level
extraMana = getCreatureMaxMana(cid) - baseMana
else
baseHealth, extraHealth = getCreatureMaxHealth(cid), 0
baseMana, extraMana = getCreatureMaxMana(cid), 0
end

message = message .. "\nVida normal: " .. baseHealth .. " + " .. extraHealth .. "."
message = message .. "\nMana normal: " .. baseMana .. " + " .. extraMana .. "."
message = message .. "\nExp Stage Bonْs: " .. getExperienceStage(level) .. "x + " .. ((resetBonus and resetBonus.experiencePercent) or "0") .. "%."
message = message .. "\nDamage Bonْs: " .. ((resetBonus and resetBonus.damagePercent) or "0") .. "%."
message = message .. "\nProximo Reset: Lv" .. (resetsCount < ResetSystem.max_count and ((resetsCount + 1) * ResetSystem.needed_level_per_reset) or "0") .. "."
doShowTextDialog(cid, 8983, message)
else
local position = getThingPosition(cid)
local tileInfo = getTileInfo(position)
if (tileInfo and not tileInfo.protection) then
doPlayerSendCancel(cid, "Você sَ pode usar esse comando em protection zone.")
doSendMagicEffect(position, CONST_ME_POFF)
return true
end

local resetsCount = ResetSystem:getCount(cid)
if (resetsCount >= ResetSystem.max_count) then
doPlayerSendCancel(cid, "Você jل atingiu o nيvel mلximo de resets.")
doSendMagicEffect(position, CONST_ME_POFF)
return true
end

local levelNeeded = (resetsCount + 1) * ResetSystem.needed_level_per_reset
if (levelNeeded > getPlayerLevel(cid)) then
doPlayerSendCancel(cid, "Você precisa ser level " .. levelNeeded .. " ou maior.")
doSendMagicEffect(position, CONST_ME_POFF)
return true
end

ResetSystem:execute(cid)
doSendMagicEffect(position, CONST_ME_TELEPORT)
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
doSendMagicEffect(getThingPosition(cid), CONST_ME_TELEPORT)
end
return true
end
 
I understand that a lot of people are looking for this reset damage boost system. I decided to share it with you 😉

I managed to implement the damage increase system, and the Discord colleague tested it and confirmed that it is working. It is necessary to add it in the source. Let's go!

OTX 2-3 8.6 tested ok
combat.cpp

look for this line.
C++:
bool Combat::CombatHealthFunc(Creature* caster, Creature* target, const CombatParams& params, void* data)

Just replace all the code here.
C++:
bool Combat::CombatHealthFunc(Creature* caster, Creature* target, const CombatParams& params, void* data)
{
    int32_t change = 0;
    if (Combat2Var* var = (Combat2Var*)data)
    {
        change = var->change;
        if (!change)
            change = random_range(var->minChange, var->maxChange, DISTRO_NORMAL);
    }

    if (g_game.combatBlockHit(params.combatType, caster, target, change, params.blockedByShield, params.blockedByArmor, params.itemId != 0))
        return false;

    CombatParams _params = params;
    if (_params.element.damage && _params.element.type != COMBAT_NONE)
        g_game.combatBlockHit(_params.element.type, caster, target, _params.element.damage, params.blockedByShield, params.blockedByArmor, params.itemId != 0, true);

    if (g_config.getBool(ConfigManager::USE_BLACK_SKULL))
    {
        if (caster && caster->getPlayer() && target->getPlayer() && target->getSkull() != SKULL_BLACK)
        {
            _params.element.damage /= 2;
            if (change < 0)
                change /= 2;
        }
    }
    else
    {
        if (caster && caster->getPlayer() && target->getPlayer())
        {
            _params.element.damage /= 2;
            if (change < 0)
                change /= 2;
        }
    }

 
{
    std::string value;
    caster->getStorage("14335", value);
    int32_t plus = (int32_t)(atoi(value.c_str()));

  
    double resetpower = pow(2.0, plus - 1);

    if (plus > 0 && params.combatType != COMBAT_HEALING) {
     
        change = (int32_t)std::ceil(change * resetpower);
    }
}


    if (!g_game.combatChangeHealth(_params, caster, target, change, false))
        return false;

    CombatConditionFunc(caster, target, params, NULL);
    CombatDispelFunc(caster, target, params, NULL);
    return true;
}

yet again look for that line.
C++:
bool Combat::CombatManaFunc(Creature* caster, Creature* target, const CombatParams& params, void* data)

Just replace all the code here.
C++:
bool Combat::CombatManaFunc(Creature* caster, Creature* target, const CombatParams& params, void* data)
{
    int32_t change = 0;
    if (Combat2Var* var = (Combat2Var*)data)
    {
        change = var->change;
        if (!change)
            change = random_range(var->minChange, var->maxChange, DISTRO_NORMAL);
    }

    if (g_game.combatBlockHit(COMBAT_MANADRAIN, caster, target, change, false, false, params.itemId != 0))
        return false;

    if (g_config.getBool(ConfigManager::USE_BLACK_SKULL))
    {
        if (change < 0 && caster && caster->getPlayer() && target->getPlayer() && target->getSkull() != SKULL_BLACK)
            change /= 2;
    }
    else
    {
        if (change < 0 && caster && caster->getPlayer() && target->getPlayer())
            change /= 2;
    }

 
  
{
    std::string value;
    caster->getStorage("14335", value);
    int32_t plus = (int32_t)(atoi(value.c_str()));

  
    double resetpower = pow(2.0, plus - 1);

    if (plus > 0 && params.combatType != COMBAT_MANADRAIN) {
    
        change = (int32_t)std::ceil(change * resetpower / 100);
    }
}


    if (!g_game.combatChangeMana(caster, target, change))
        return false;

    CombatConditionFunc(caster, target, params, NULL);
    CombatDispelFunc(caster, target, params, NULL);
    return true;
}

Just compile, then let's add a script to the lib here
lib/systemReset.lua
Lua:
ResetSystem = {
    storage = 14335,
    back_to_level = 3500,
    needed_level_per_reset = 1000,
    max_count = 1000,
    bonus_per_reset = {
        experiencePercent = 10,
        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: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:updateHealthAndMana(pid)
    local bonus = self:getCurrentBonus(pid)
    if (bonus) then
        local message = "Você efetuou seu " .. self:getCount(pid) .. "° reset."
 
        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

If you don't want to use the !reset command, you can reset it through an NPC, and it does work.
Lua:
local config = {
    minlevel = 3500, --- initial level to reset
    price = 100000000, ---initial price to reset
    newlevel = 20, --- level after reset
    priceByReset = 100000000, --- price added per reset
    percent = 40, ---- percentage of health/mana you will have upon reset (relative to your old total health)
    maxresets = 20,
    levelbyreset = 100 --- how much more level will you need in the next reset
}

function getResets(uid)
    resets = getPlayerStorageValue(uid, 14335)
    if resets < 0 then
        resets = 0
    end
    return resets
end

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
 
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink()                  npcHandler:onThink()                  end
 
function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

    function addReset(cid)
        if(npcHandler:isFocused(cid)) then
            npcHandler:releaseFocus(cid)
        end
     
        talkState[talkUser] = 0
        resets = getResets(cid)
        setPlayerStorageValue(cid, 14335, resets+1)
        doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
        local hp = getCreatureMaxHealth(cid)
        local resethp = hp*(config.percent/100)
        setCreatureMaxHealth(cid, resethp)
        local differencehp = (hp - resethp)
        doCreatureAddHealth(cid, -differencehp)
        local mana = getCreatureMaxMana(cid)
        local resetmana = mana*(config.percent/100)
        setCreatureMaxMana(cid, resetmana)
        local differencemana = (mana - resetmana)
        doCreatureAddMana(cid, -differencemana)
        doRemoveCreature(cid)    
        local description = resets+1
        db.query("UPDATE `players` SET `description` = ' [Reset: "..description.."]' WHERE `players`.`id`= ".. playerid .."")
        db.query("UPDATE `players` SET `level`="..config.newlevel..",`experience`= 0 WHERE `players`.`id`= ".. playerid .."")
        return true
    end
 
    local newPrice = config.price + (getResets(cid) * config.priceByReset)
    local newminlevel = config.minlevel + (getResets(cid) * config.levelbyreset)

    if msgcontains(msg, 'reset') then
        if getResets(cid) < config.maxresets then
            selfSay('Voce gostaria de resetar? Isso vai custar '..newPrice..' gp\'s!', cid)
            talkState[talkUser] = 1
        else
            selfSay('Voce ja atingiu o nivel maximo de resets!', cid)
        end
     
    elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
        if getPlayerMoney(cid) < newPrice then
            selfSay('E necessesario ter '..newPrice..' gp\'s para resetar!', cid)
        elseif getPlayerLevel(cid) < newminlevel then
            selfSay('O level minimo para resetar e '..newminlevel..'!', cid)
        else
            doPlayerRemoveMoney(cid,newPrice)
            playerid = getPlayerGUID(cid)
            addEvent(function()
                if isPlayer(cid) then
                    addReset(cid)
                end
            end, 3000)
            local number = getResets(cid)+1
            local msg ="---[Reset: "..number.."]-- Voce resetou!  Voce sera disconectado em 3 segundos."
            doPlayerPopupFYI(cid, msg)
            talkState[talkUser] = 0
            npcHandler:releaseFocus(cid)
        end
        talkState[talkUser] = 0
    elseif(msgcontains(msg, 'no')) and isInArray({1}, talkState[talkUser]) == TRUE then
        talkState[talkUser] = 0
        npcHandler:releaseFocus(cid)
        selfSay('Ok.', cid)
    elseif msgcontains(msg, 'quantity') then
        selfSay('You have a total of '..getResets(cid)..' reset(s).', cid)
        talkState[talkUser] = 0
    end
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

#Note: 2.0 equals twice the original value, not twenty times. So when you multiply something by 2.0 you are doubling the original value.
double resetpower = plus * 2.0;
I recommend setting the value to 1.5 as it will increase damage with each reset.

Any system reset that uses storage, just change the value of your system reset.

caster->getStorage("14335", value);
Post automatically merged:

TFS 0.4
combat.cpp

look for this line.
C++:
bool Combat::CombatHealthFunc(Creature* caster, Creature* target, const CombatParams& params, void* data)

Just replace all the code here.
C++:
bool Combat::CombatHealthFunc(Creature* caster, Creature* target, const CombatParams& params, void* data)
{
    int32_t change = 0;
    if (Combat2Var* var = (Combat2Var*)data)
    {
        change = var->change;
        if (!change)
            change = random_range(var->minChange, var->maxChange, DISTRO_NORMAL);
    }

    if (g_game.combatBlockHit(params.combatType, caster, target, change, params.blockedByShield, params.blockedByArmor))
        return false;

    if (change < 0 && caster && caster->getPlayer() && target->getPlayer() && target->getPlayer()->getSkull() != SKULL_BLACK)
        change = change / 2;

  
std::string value;
caster->getStorage("378378", value);
int32_t plus = (int32_t)(atoi(value.c_str()));


double resetpower = pow(2.0, plus - 1);

if (plus > 0 && params.combatType != COMBAT_HEALING) {
   
    change = (int32_t)std::ceil(change * resetpower);
}

    if (!g_game.combatChangeHealth(params.combatType, caster, target, change, params.effects.hit, params.effects.color))
        return false;

    CombatConditionFunc(caster, target, params, NULL);
    CombatDispelFunc(caster, target, params, NULL);
    return true;
}

yet again look for that line.
C++:
bool Combat::CombatManaFunc(Creature* caster, Creature* target, const CombatParams& params, void* data)
Just replace all the code here.
C++:
bool Combat::CombatManaFunc(Creature* caster, Creature* target, const CombatParams& params, void* data)
{
    int32_t change = 0;
    if (Combat2Var* var = (Combat2Var*)data)
    {
        change = var->change;
        if (!change)
            change = random_range(var->minChange, var->maxChange, DISTRO_NORMAL);
    }

    if (change < 0 && caster && caster->getPlayer() && target->getPlayer() && target->getPlayer()->getSkull() != SKULL_BLACK)
        change = change / 2;

 
std::string value;
caster->getStorage("378378", value);
int32_t plus = (int32_t)(atoi(value.c_str()));


double resetpower = pow(2.0, plus - 1);

if (plus > 0 && params.combatType != COMBAT_HEALING) {
  
    change = (int32_t)std::ceil(change * resetpower);
}

    if (!g_game.combatChangeMana(caster, target, change))
        return false;

    CombatConditionFunc(caster, target, params, NULL);
    CombatDispelFunc(caster, target, params, NULL);
    return true;
}


the end 😉
 
Last edited:
Solution
Hello, thank you very much for the script, I tried to compile for TFS 0.4 with your settings but I got this error

1696278549784.png
I understand that a lot of people are looking for this reset damage boost system. I decided to share it with you 😉

I managed to implement the damage increase system, and the Discord colleague tested it and confirmed that it is working. It is necessary to add it in the source. Let's go!

OTX 2-3 8.6 tested ok
combat.cpp

look for this line.
C++:
bool Combat::CombatHealthFunc(Creature* caster, Creature* target, const CombatParams& params, void* data)

Just replace all the code here.
C++:
bool Combat::CombatHealthFunc(Creature* caster, Creature* target, const CombatParams& params, void* data)
{
    int32_t change = 0;
    if (Combat2Var* var = (Combat2Var*)data)
    {
        change = var->change;
        if (!change)
            change = random_range(var->minChange, var->maxChange, DISTRO_NORMAL);
    }

    if (g_game.combatBlockHit(params.combatType, caster, target, change, params.blockedByShield, params.blockedByArmor, params.itemId != 0))
        return false;

    CombatParams _params = params;
    if (_params.element.damage && _params.element.type != COMBAT_NONE)
        g_game.combatBlockHit(_params.element.type, caster, target, _params.element.damage, params.blockedByShield, params.blockedByArmor, params.itemId != 0, true);

    if (g_config.getBool(ConfigManager::USE_BLACK_SKULL))
    {
        if (caster && caster->getPlayer() && target->getPlayer() && target->getSkull() != SKULL_BLACK)
        {
            _params.element.damage /= 2;
            if (change < 0)
                change /= 2;
        }
    }
    else
    {
        if (caster && caster->getPlayer() && target->getPlayer())
        {
            _params.element.damage /= 2;
            if (change < 0)
                change /= 2;
        }
    }

 
{
    std::string value;
    caster->getStorage("14335", value);
    int32_t plus = (int32_t)(atoi(value.c_str()));

 
    double resetpower = pow(2.0, plus - 1);

    if (plus > 0 && params.combatType != COMBAT_HEALING) {
   
        change = (int32_t)std::ceil(change * resetpower);
    }
}


    if (!g_game.combatChangeHealth(_params, caster, target, change, false))
        return false;

    CombatConditionFunc(caster, target, params, NULL);
    CombatDispelFunc(caster, target, params, NULL);
    return true;
}

yet again look for that line.
C++:
bool Combat::CombatManaFunc(Creature* caster, Creature* target, const CombatParams& params, void* data)

Just replace all the code here.
C++:
bool Combat::CombatManaFunc(Creature* caster, Creature* target, const CombatParams& params, void* data)
{
    int32_t change = 0;
    if (Combat2Var* var = (Combat2Var*)data)
    {
        change = var->change;
        if (!change)
            change = random_range(var->minChange, var->maxChange, DISTRO_NORMAL);
    }

    if (g_game.combatBlockHit(COMBAT_MANADRAIN, caster, target, change, false, false, params.itemId != 0))
        return false;

    if (g_config.getBool(ConfigManager::USE_BLACK_SKULL))
    {
        if (change < 0 && caster && caster->getPlayer() && target->getPlayer() && target->getSkull() != SKULL_BLACK)
            change /= 2;
    }
    else
    {
        if (change < 0 && caster && caster->getPlayer() && target->getPlayer())
            change /= 2;
    }

 
 
{
    std::string value;
    caster->getStorage("14335", value);
    int32_t plus = (int32_t)(atoi(value.c_str()));

 
    double resetpower = pow(2.0, plus - 1);

    if (plus > 0 && params.combatType != COMBAT_MANADRAIN) {
  
        change = (int32_t)std::ceil(change * resetpower / 100);
    }
}


    if (!g_game.combatChangeMana(caster, target, change))
        return false;

    CombatConditionFunc(caster, target, params, NULL);
    CombatDispelFunc(caster, target, params, NULL);
    return true;
}

Just compile, then let's add a script to the lib here
lib/systemReset.lua
Lua:
ResetSystem = {
    storage = 14335,
    back_to_level = 3500,
    needed_level_per_reset = 1000,
    max_count = 1000,
    bonus_per_reset = {
        experiencePercent = 10,
        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: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:updateHealthAndMana(pid)
    local bonus = self:getCurrentBonus(pid)
    if (bonus) then
        local message = "Você efetuou seu " .. self:getCount(pid) .. "° reset."
 
        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

If you don't want to use the !reset command, you can reset it through an NPC, and it does work.
Lua:
local config = {
    minlevel = 3500, --- initial level to reset
    price = 100000000, ---initial price to reset
    newlevel = 20, --- level after reset
    priceByReset = 100000000, --- price added per reset
    percent = 40, ---- percentage of health/mana you will have upon reset (relative to your old total health)
    maxresets = 20,
    levelbyreset = 100 --- how much more level will you need in the next reset
}

function getResets(uid)
    resets = getPlayerStorageValue(uid, 14335)
    if resets < 0 then
        resets = 0
    end
    return resets
end

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
 
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink()                  npcHandler:onThink()                  end
 
function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid

    function addReset(cid)
        if(npcHandler:isFocused(cid)) then
            npcHandler:releaseFocus(cid)
        end
   
        talkState[talkUser] = 0
        resets = getResets(cid)
        setPlayerStorageValue(cid, 14335, resets+1)
        doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
        local hp = getCreatureMaxHealth(cid)
        local resethp = hp*(config.percent/100)
        setCreatureMaxHealth(cid, resethp)
        local differencehp = (hp - resethp)
        doCreatureAddHealth(cid, -differencehp)
        local mana = getCreatureMaxMana(cid)
        local resetmana = mana*(config.percent/100)
        setCreatureMaxMana(cid, resetmana)
        local differencemana = (mana - resetmana)
        doCreatureAddMana(cid, -differencemana)
        doRemoveCreature(cid)  
        local description = resets+1
        db.query("UPDATE `players` SET `description` = ' [Reset: "..description.."]' WHERE `players`.`id`= ".. playerid .."")
        db.query("UPDATE `players` SET `level`="..config.newlevel..",`experience`= 0 WHERE `players`.`id`= ".. playerid .."")
        return true
    end
 
    local newPrice = config.price + (getResets(cid) * config.priceByReset)
    local newminlevel = config.minlevel + (getResets(cid) * config.levelbyreset)

    if msgcontains(msg, 'reset') then
        if getResets(cid) < config.maxresets then
            selfSay('Voce gostaria de resetar? Isso vai custar '..newPrice..' gp\'s!', cid)
            talkState[talkUser] = 1
        else
            selfSay('Voce ja atingiu o nivel maximo de resets!', cid)
        end
   
    elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
        if getPlayerMoney(cid) < newPrice then
            selfSay('E necessesario ter '..newPrice..' gp\'s para resetar!', cid)
        elseif getPlayerLevel(cid) < newminlevel then
            selfSay('O level minimo para resetar e '..newminlevel..'!', cid)
        else
            doPlayerRemoveMoney(cid,newPrice)
            playerid = getPlayerGUID(cid)
            addEvent(function()
                if isPlayer(cid) then
                    addReset(cid)
                end
            end, 3000)
            local number = getResets(cid)+1
            local msg ="---[Reset: "..number.."]-- Voce resetou!  Voce sera disconectado em 3 segundos."
            doPlayerPopupFYI(cid, msg)
            talkState[talkUser] = 0
            npcHandler:releaseFocus(cid)
        end
        talkState[talkUser] = 0
    elseif(msgcontains(msg, 'no')) and isInArray({1}, talkState[talkUser]) == TRUE then
        talkState[talkUser] = 0
        npcHandler:releaseFocus(cid)
        selfSay('Ok.', cid)
    elseif msgcontains(msg, 'quantity') then
        selfSay('You have a total of '..getResets(cid)..' reset(s).', cid)
        talkState[talkUser] = 0
    end
    return true
end

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

#Note: 2.0 equals twice the original value, not twenty times. So when you multiply something by 2.0 you are doubling the original value.

I recommend setting the value to 1.5 as it will increase damage with each reset.

Any system reset that uses storage, just change the value of your system reset.


Post automatically merged:

TFS 0.4
combat.cpp

look for this line.
C++:
bool Combat::CombatHealthFunc(Creature* caster, Creature* target, const CombatParams& params, void* data)

Just replace all the code here.
C++:
bool Combat::CombatHealthFunc(Creature* caster, Creature* target, const CombatParams& params, void* data)
{
    int32_t change = 0;
    if (Combat2Var* var = (Combat2Var*)data)
    {
        change = var->change;
        if (!change)
            change = random_range(var->minChange, var->maxChange, DISTRO_NORMAL);
    }

    if (g_game.combatBlockHit(params.combatType, caster, target, change, params.blockedByShield, params.blockedByArmor))
        return false;

    if (change < 0 && caster && caster->getPlayer() && target->getPlayer() && target->getPlayer()->getSkull() != SKULL_BLACK)
        change = change / 2;

 
std::string value;
caster->getStorage("378378", value);
int32_t plus = (int32_t)(atoi(value.c_str()));


double resetpower = pow(2.0, plus - 1);

if (plus > 0 && params.combatType != COMBAT_HEALING) {
 
    change = (int32_t)std::ceil(change * resetpower);
}

    if (!g_game.combatChangeHealth(params.combatType, caster, target, change, params.effects.hit, params.effects.color))
        return false;

    CombatConditionFunc(caster, target, params, NULL);
    CombatDispelFunc(caster, target, params, NULL);
    return true;
}

yet again look for that line.
C++:
bool Combat::CombatManaFunc(Creature* caster, Creature* target, const CombatParams& params, void* data)
Just replace all the code here.
C++:
bool Combat::CombatManaFunc(Creature* caster, Creature* target, const CombatParams& params, void* data)
{
    int32_t change = 0;
    if (Combat2Var* var = (Combat2Var*)data)
    {
        change = var->change;
        if (!change)
            change = random_range(var->minChange, var->maxChange, DISTRO_NORMAL);
    }

    if (change < 0 && caster && caster->getPlayer() && target->getPlayer() && target->getPlayer()->getSkull() != SKULL_BLACK)
        change = change / 2;

 
std::string value;
caster->getStorage("378378", value);
int32_t plus = (int32_t)(atoi(value.c_str()));


double resetpower = pow(2.0, plus - 1);

if (plus > 0 && params.combatType != COMBAT_HEALING) {
 
    change = (int32_t)std::ceil(change * resetpower);
}

    if (!g_game.combatChangeMana(caster, target, change))
        return false;

    CombatConditionFunc(caster, target, params, NULL);
    CombatDispelFunc(caster, target, params, NULL);
    return true;
}


the end 😉
Post automatically merged:

ok I just removed the quotes like this caster->getStorage(14335, value); and it worked but now I have this error when I say !reset
1696280888838.png
Can someone help me please ?
 
Last edited:
Hello, thank you very much for the script, I tried to compile for TFS 0.4 with your settings but I got this error

View attachment 78980

Post automatically merged:

ok I just removed the quotes like this caster->getStorage(14335, value); and it worked but now I have this error when I say !reset
View attachment 78982
Can someone help me please ?
Please open another topic so we can help you.
 
Why should he create a new topic if your Script is the problem or im confused
What part made you confused? I tested it with OTX and it works perfectly, and it also works with TFS 0.4. In fact, I didn't use talkaction to reset, but rather an NPC. For example, without a reset, a character at level 200 deals an average damage of 400-600. With one reset, the damage increases to 1200-1300 maximum... I just provided an example. I didn't understand why some people want to use talkactions. I know it might work or not work sometimes...


sometimes it's the problem with google translate so it sucks 😐
 
Last edited:
Back
Top