• 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!

Max HP/MP in percent (tfs 1.5 8.6) (slot system by oen)

Dran Ryszard

Active Member
Joined
Apr 25, 2023
Messages
136
Reaction score
30
Location
Poland
Hi, i was use a slot system by oen432, and i tried change MAX HP / MP bonus to MAX HP/MP Percent bonus, but everytime when i tried change it gone wrong..
So, i change in upgrade_system_const
CONDITION_PARAM_STAT_MAXHITPOINTS to CONDITION_PARAM_STAT_MAXHITPOINTSPERCENT

LUA:
  [1] = {
    name = "Max HP",
    combatType = US_TYPES.CONDITION,
    condition = CONDITION_ATTRIBUTES,
    param = CONDITION_PARAM_STAT_MAXHITPOINTSPERCENT,
    VALUES_PER_LEVEL = 3,
    format = function(value)
      return "Max HP +" .. value
    end,
    itemType = US_ITEM_TYPES.HELMET + US_ITEM_TYPES.ARMOR + US_ITEM_TYPES.LEGS + US_ITEM_TYPES.BOOTS
  },

and i tried do some change in upgrade_system_core, but what i do it not work
LUA:
        -- apply new
        if item:getType():isUpgradable() then
          local newBonuses = item:getBonusAttributes()
          if newBonuses then
            for key, value in pairs(newBonuses) do
              local attr = US_ENCHANTMENTS[value[1]]
              if attr then
                if attr.combatType == US_TYPES.CONDITION then
                  if not US_CONDITIONS[value[1]] then
                    US_CONDITIONS[value[1]] = {}
                  end
                  if not US_CONDITIONS[value[1]][value[2]] then
                    US_CONDITIONS[value[1]][value[2]] = Condition(attr.condition)
                    if attr.condition ~= CONDITION_MANASHIELD then
                      US_CONDITIONS[value[1]][value[2]]:setParameter(attr.param, attr.percentage == true and 100 + value[2] or value[2])
                      US_CONDITIONS[value[1]][value[2]]:setParameter(CONDITION_PARAM_TICKS, -1)
                      US_CONDITIONS[value[1]][value[2]]:setParameter(CONDITION_PARAM_SUBID, 1000 + math.ceil(value[1] ^ 2) + value[2])
                    else
                      US_CONDITIONS[value[1]][value[2]]:setParameter(CONDITION_PARAM_TICKS, 86400000)
                    end
                    US_CONDITIONS[value[1]][value[2]]:setParameter(CONDITION_PARAM_BUFF_SPELL, true)
                    player:addCondition(US_CONDITIONS[value[1]][value[2]])
                    if attr == BONUS_TYPE_MAXHP then
                      if player:getHealth() == maxHP then
                        player:addHealth((player:getMaxHealth()))
                      end
                    end
                    if attr == BONUS_TYPE_MAXMP then
                      if player:getMana() == maxMP then
                        player:addMana(player:getMaxMana())
                      end
                    end
                  else
                    player:addCondition(US_CONDITIONS[value[1]][value[2]])
                    if attr.param == CONDITION_PARAM_STAT_MAXHITPOINTS then
                      if player:getHealth() == maxHP then
                        player:addHealth(player:getMaxHealth())
                      end
                    end
                    if attr.param == CONDITION_PARAM_STAT_MAXMANAPOINTS then
                      if player:getMana() == maxMP then
                        player:addMana(player:getMaxMana())
                      end
                    end
                  end
                end
              end
            end
          end
        end
      end
    end
  end


And when im change only CONDITION_PARAM_STAT_MAXHITPOINTS to CONDITION_PARAM_STAT_MAXHITPOINTSPERCENT
Then my character have 325k HP, after i equp item with 7% bonus my health gone low to 22k (max health) it back to 325k when i dequip item.

I tried add something like that

Code:
player:addHealth((player:getMaxHealth()/100) * value[2])

but nothing change
 
Solution
Im using this: CreatureEvent - [TFS 1.3 / 1.4] Upgrade System (https://otland.net/threads/tfs-1-3-1-4-upgrade-system.264672/)
And no that not help me.. I was past here fragments of code about HP/MP bonus, and its not that easy for me, i tried few things and still can't make it to percent
missing tag percetage on your config.
LUA:
 [1] = {
    name = "Max HP",
    combatType = US_TYPES.CONDITION,
    condition = CONDITION_ATTRIBUTES,
    percentage = true, -- need definition for percent work!
    param = CONDITION_PARAM_STAT_MAXHITPOINTSPERCENT,
    VALUES_PER_LEVEL = 3,
    format = function(value)
      return "Max HP +" .. value
    end,
    itemType = US_ITEM_TYPES.HELMET + US_ITEM_TYPES.ARMOR + US_ITEM_TYPES.LEGS +...
LUA:
local HEALTH_SCROLL = scrollid
local BOOST_DURATION = 30
local BOOST_PERCENT = 10 -- "10%"

function onUse(player, item, fromPosition, target, toPosition, isHotkey)

    local maxHealth = player:getMaxHealth()
    local heal = math.floor(maxHealth * BOOST_PERCENT / 100)

    local condition = Condition(CONDITION_ATTRIBUTES)
    condition:setParameter(CONDITION_PARAM_SUBID, HEALTH_SCROLL)
    condition:setParameter(CONDITION_PARAM_TICKS, BOOST_DURATION * 1000)
    condition:setParameter(CONDITION_PARAM_STAT_MAXHITPOINTSPERCENT, 100 + BOOST_PERCENT)

    player:addCondition(condition)

    player:addHealth(heal)
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
    item:remove(1)
    return true
end
 
Last edited:
LUA:
local HEALTH_SCROLL = scrollid
local BOOST_DURATION = 30
local BOOST_PERCENT = 10 -- "10%"

function onUse(player, item, fromPosition, target, toPosition, isHotkey)

    local maxHealth = player:getMaxHealth()
    local heal = math.floor(maxHealth * BOOST_PERCENT / 100)

    local condition = Condition(CONDITION_ATTRIBUTES)
    condition:setParameter(CONDITION_PARAM_SUBID, HEALTH_SCROLL)
    condition:setParameter(CONDITION_PARAM_TICKS, BOOST_DURATION * 1000)
    condition:setParameter(CONDITION_PARAM_STAT_MAXHITPOINTSPERCENT, 100 + BOOST_PERCENT)

    player:addCondition(condition)

    player:addHealth(heal)
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
    item:remove(1)
    return true
end

?
Why u give me script for item what adding % of life? xD
I need change default value of health to percent value in @oen432 slot system, not need any scrolls xD
 
?
Why u give me script for item what adding % of life? xD
I need change default value of health to percent value in @oen432 slot system, not need any scrolls xD
From what i understand, if you want this on a percentage base, this is an example, you can take it and test if it is as you wanted and then apply the example in your script.
 
From what i understand, if you want this on a percentage base, this is an example, you can take it and test if it is as you wanted and then apply the example in your script.

Im using this: CreatureEvent - [TFS 1.3 / 1.4] Upgrade System (https://otland.net/threads/tfs-1-3-1-4-upgrade-system.264672/)
And no that not help me.. I was past here fragments of code about HP/MP bonus, and its not that easy for me, i tried few things and still can't make it to percent
 
Im using this: CreatureEvent - [TFS 1.3 / 1.4] Upgrade System (https://otland.net/threads/tfs-1-3-1-4-upgrade-system.264672/)
And no that not help me.. I was past here fragments of code about HP/MP bonus, and its not that easy for me, i tried few things and still can't make it to percent
missing tag percetage on your config.
LUA:
 [1] = {
    name = "Max HP",
    combatType = US_TYPES.CONDITION,
    condition = CONDITION_ATTRIBUTES,
    percentage = true, -- need definition for percent work!
    param = CONDITION_PARAM_STAT_MAXHITPOINTSPERCENT,
    VALUES_PER_LEVEL = 3,
    format = function(value)
      return "Max HP +" .. value
    end,
    itemType = US_ITEM_TYPES.HELMET + US_ITEM_TYPES.ARMOR + US_ITEM_TYPES.LEGS + US_ITEM_TYPES.BOOTS
  },
i find this if "true" percentage!
LUA:
 US_CONDITIONS[value[1]][value[2]]:setParameter(attr.param, attr.percentage == true and 100 + value[2] or value[2])
note if false then use value[2], but this value work, you need add number 100 (is real max health in percent) + 10 (value[2], aditional percent).
Exemple 110. is 10% more from max health in percent!
 
Last edited:
Solution
missing tag percetage on your config.
LUA:
 [1] = {
    name = "Max HP",
    combatType = US_TYPES.CONDITION,
    condition = CONDITION_ATTRIBUTES,
    percentage = true, -- need definition for percent work!
    param = CONDITION_PARAM_STAT_MAXHITPOINTSPERCENT,
    VALUES_PER_LEVEL = 3,
    format = function(value)
      return "Max HP +" .. value
    end,
    itemType = US_ITEM_TYPES.HELMET + US_ITEM_TYPES.ARMOR + US_ITEM_TYPES.LEGS + US_ITEM_TYPES.BOOTS
  },
i find this if "true" percentage!
LUA:
 US_CONDITIONS[value[1]][value[2]]:setParameter(attr.param, attr.percentage == true and 100 + value[2] or value[2])

Fuck off its that simple... Not saw that.
I was sit with it 2 hours and im surrended..


Thanks you so much <3
 
Back
Top