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

TFS 1.X+ Rarity Rolls: Set new Attributes

Allan Silva

Member
Joined
May 30, 2018
Messages
39
Solutions
1
Reaction score
7
Hi
I'm trying to add new attributes (speed) on this scripts:
[TFS 1.X] Rarity Rolls & Custom Attributes Library (https://otland.net/threads/tfs-1-x-rarity-rolls-custom-attributes-library.268888/)

This is the file that was edited to contain the new attribute:
data/lib/core/attributes.lua

Lua:
local stats = {
[40] = { -- Speed
        attribute = {
            name = 'Speed',
            common = {10, 20},
            rare = {21, 30},
            epic = {31, 50},
            legendary = {51, 70},
        },
        value = "Static",

Lua:
local v = {
[ITEM_ATTRIBUTE_SPEED] = id:getSpeed(),

Here I put speed only in armor to make tests
Code:
if it_id:getArmor() > 0 then -- Ignore clothing/things with no armor stat
                    table.insert(available_stats, stats[40]) -- Speed

Lua:
local attributes = {
[18] = {"%[" .. stats[40].attribute.name .. ": ", CONDITION_PARAM_SPEED},

Now the result later make the changes:
1617034745664.png
The item receives the attribute in the description, but does not assign the attribute to the player. In this case, when equipping the item the player does not gain 15 speed.

I believe the problem lies in assigning the value to the item, in this part of the code:

Lua:
-- Apply condition
function rollCondition(player, item, slot)
    local attributes = {
         [1] = {"%[" .. stats[25].attribute.name .. ": ", CONDITION_PARAM_SKILL_SWORD}, -- "[Sword Skill: "
         [2] = {"%[" .. stats[26].attribute.name .. ": ", CONDITION_PARAM_SKILL_AXE},
         [3] = {"%[" .. stats[27].attribute.name .. ": ", CONDITION_PARAM_SKILL_CLUB},
         [4] = {"%[" .. stats[28].attribute.name .. ": ", CONDITION_PARAM_SKILL_MELEE},
         [5] = {"%[" .. stats[29].attribute.name .. ": ", CONDITION_PARAM_SKILL_DISTANCE},
         [6] = {"%[" .. stats[30].attribute.name .. ": ", CONDITION_PARAM_SKILL_SHIELD},
         [7] = {"%[" .. stats[31].attribute.name .. ": ", CONDITION_PARAM_STAT_MAGICPOINTS},
         [8] = {"%[" .. stats[32].attribute.name .. ": ", CONDITION_PARAM_STAT_MAXHITPOINTS},
         [9] = {"%[" .. stats[33].attribute.name .. ": ", CONDITION_PARAM_STAT_MAXMANAPOINTS},
        [10] = {"%[" .. stats[34].attribute.name .. ": ", CONDITION_PARAM_STAT_MAXHITPOINTSPERCENT, percent = true, absolute = true},
        [11] = {"%[" .. stats[35].attribute.name .. ": ", CONDITION_PARAM_STAT_MAXMANAPOINTSPERCENT, percent = true, absolute = true},
        [12] = {"%[" .. stats[11].attribute.name .. ": ", CONDITION_PARAM_SKILL_CRITICAL_HIT_DAMAGE, percent = true, absolute = true},
        [13] = {"%[" .. stats[10].attribute.name .. ": ", CONDITION_PARAM_SKILL_CRITICAL_HIT_CHANCE, percent = true},
        [14] = {"%[" .. stats[36].attribute.name .. ": ", CONDITION_PARAM_SKILL_LIFE_LEECH_CHANCE, percent = true},
        [15] = {"%[" .. stats[37].attribute.name .. ": ", CONDITION_PARAM_SKILL_LIFE_LEECH_AMOUNT, percent = true},
        [16] = {"%[" .. stats[38].attribute.name .. ": ", CONDITION_PARAM_SKILL_MANA_LEECH_CHANCE, percent = true},
        [17] = {"%[" .. stats[39].attribute.name .. ": ", CONDITION_PARAM_SKILL_MANA_LEECH_AMOUNT, percent = true},
        [18] = {"%[" .. stats[40].attribute.name .. ": ", CONDITION_PARAM_SPEED},
    }
    local itemDesc = item:getAttribute(ITEM_ATTRIBUTE_DESCRIPTION)
    for k = 1,#attributes do
        local skillBonus = 0 -- reset
        local attributeSearchValue = "%+(%d+)%]" -- "+10]"
        if attributes[k].percent ~= nil then
            attributeSearchValue = "%+(%d+)%%%]" -- "+10%]"
            if attributes[k].absolute ~= nil then
                skillBonus = 100 -- These conditions require absolutes (108%, 145% etc.)
            end
        end
        local attributeString = attributes[k][1] .. attributeSearchValue -- "%[Attack: %+(%d+)%]"
        if string.match(itemDesc, attributeString) ~= nil then -- "[Attack: +10]"
            local offset = (10 * k) + slot -- ((CONST_SLOT_LAST) * k) + slot
            local skillBonus = skillBonus + tonumber(string.match(itemDesc, attributeString)) -- Raw (%d+) value
  
            -- (!) Comment this code out if you want to use CHANCE/AMOUNT rolls (they will need to be rolled together)
            -- Leech amount is not used, set to 100%
            -- Crit amount is not used, set to 100%
            if k == 13 or k == 15 or k == 17 then
                local j = k - 1
                if player:getCondition(CONDITION_ATTRIBUTES, CONDITIONID_COMBAT, (10 * j) + slot) == nil then
                    local condition = Condition(CONDITION_ATTRIBUTES)
                    condition:setParameter(CONDITION_PARAM_SUBID, (10 * j) + slot)
                    condition:setParameter(CONDITION_PARAM_TICKS, -1)
                    condition:setParameter(attributes[j][2], 100) -- 100%
                    player:addCondition(condition)
                else
                    player:removeCondition(CONDITION_ATTRIBUTES, CONDITIONID_COMBAT, (10 * j) + slot)
                end
            end
  
            if player:getCondition(CONDITION_ATTRIBUTES, CONDITIONID_COMBAT, offset) == nil then
                local condition = Condition(CONDITION_ATTRIBUTES)
                condition:setParameter(CONDITION_PARAM_SUBID, offset)
                condition:setParameter(CONDITION_PARAM_TICKS, -1)
                condition:setParameter(attributes[k][2], skillBonus)
                player:addCondition(condition)
            else
                player:removeCondition(CONDITION_ATTRIBUTES, CONDITIONID_COMBAT, offset)
            end
        end
    end
end

I try to make changes without sucess. Any can give me a sugestion about this? Thanks!
 
Last edited:
Solution

You can check here, and see how I did it.
Speed needs to be assigned using CONDITION_HASTE instead of CONDITION_ATTRIBUTES.

You can check here, and see how I did it.
Speed needs to be assigned using CONDITION_HASTE instead of CONDITION_ATTRIBUTES.
 
Solution

You can check here, and see how I did it.
Speed needs to be assigned using CONDITION_HASTE instead of CONDITION_ATTRIBUTES.

EDITED: Solution

Lua:
if k == 18 then
                if player:getCondition(CONDITION_HASTE, CONDITIONID_COMBAT, offset) == nil then
                    local condition = Condition(CONDITION_HASTE)
                        condition:setParameter(CONDITION_PARAM_SUBID, offset)
                        condition:setParameter(CONDITION_PARAM_TICKS, -1)
                        condition:setParameter(attributes[k][2], skillBonus*2)
                        player:addCondition(condition)
                else
                    player:removeCondition(CONDITION_HASTE, CONDITIONID_COMBAT, offset)
                end
            end

Thanks, your script made me think about what I should modify to make the code work.

EDITED:
@Xikini
Now i'm try to input attackspeed (attr attackspeed in items.xml are working)
1617053393954.png
I don't have condition to attackspeed in source, what I can do?
 
Last edited:
I don't think there is a way to buff attack speed.. or at least I've never seen one.
 
Back
Top