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

RemoveCondition 1.3 Attributes

arthurluna

Member
Joined
Apr 12, 2008
Messages
178
Reaction score
12
Hi guys, I'm in need of a big help, someone who has their free time and could help me solve this problem, I'm looking for a solution in attribute removal.
I wanted it to remove only the attributes of the moved item from the Slot and not from all the slots.

when an item with no attributes is moved, the attributes of all items in the slots are removed


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_DISTANCEPERCENT},
         [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},
        [19] = {"%[" .. stats[41].attribute.name .. ": ", CONDITION_PARAM_HEALTHGAIN},
        [20] = {"%[" .. stats[42].attribute.name .. ": ", CONDITION_PARAM_MANAGAIN},
    }
    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 = 0 -- 100% + % do item [Crit Amount: +47%] == 147% -- 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 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 == 12 then
                    local w = k + 1
                    if player:getCondition(CONDITION_ATTRIBUTES, CONDITIONID_COMBAT, w) == nil then
                        local condition = Condition(CONDITION_ATTRIBUTES)
                        condition:setParameter(CONDITION_PARAM_SUBID, w)
                        condition:setParameter(CONDITION_PARAM_TICKS, -1)
                        condition:setParameter(attributes[w][2], 10) -- 10%
                        player:addCondition(condition)
                    end
                end
                if k == 15 or k == 17 then
                    local j = k - 1
                    if player:getCondition(CONDITION_ATTRIBUTES, CONDITIONID_COMBAT, j) == nil then
                        local condition = Condition(CONDITION_ATTRIBUTES)
                        condition:setParameter(CONDITION_PARAM_SUBID, j)
                        condition:setParameter(CONDITION_PARAM_TICKS, -1)
                        condition:setParameter(attributes[j][2], 10) -- 100%
                        player:addCondition(condition)
                    end
                end
                if k == 18 then
                    if player:getCondition(CONDITION_HASTE, CONDITIONID_COMBAT, k) == nil then
                        local condition = Condition(CONDITION_HASTE)
                        condition:setParameter(CONDITION_PARAM_SUBID, k)
                        condition:setParameter(CONDITION_PARAM_TICKS, -1)
                        condition:setParameter(attributes[k][2], skillBonus*2)
                        player:addCondition(condition)
                    end
                end
                if k == 19 or k == 20 or k == 19 and k == 20  then
                    if player:getCondition(CONDITION_REGENERATION, CONDITIONID_COMBAT, k) == nil then
                        local condition = Condition(CONDITION_REGENERATION)
                        condition:setParameter(CONDITION_PARAM_SUBID, k)
                        condition:setParameter(CONDITION_PARAM_TICKS, -1)
                        condition:setParameter(attributes[k][2], skillBonus*2)
                        player:addCondition(condition)
                    end
                end
                if player:getCondition(CONDITION_ATTRIBUTES, CONDITIONID_COMBAT, k) == nil then
                    local condition = Condition(CONDITION_ATTRIBUTES)
                    condition:setParameter(CONDITION_PARAM_SUBID, k)
                    condition:setParameter(CONDITION_PARAM_TICKS, -1)
                    condition:setParameter(attributes[k][2], skillBonus)
                    player:addCondition(condition)
                end
            end
        end
    end
function rollConditionremove(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_DISTANCEPERCENT},
         [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},
        [19] = {"%[" .. stats[41].attribute.name .. ": ", CONDITION_PARAM_HEALTHGAIN},
        [20] = {"%[" .. stats[42].attribute.name .. ": ", CONDITION_PARAM_MANAGAIN},
    }
    local itemDesc = item:getAttribute(ITEM_ATTRIBUTE_DESCRIPTION)
    for k = 1,#attributes do
        local attributeSearchValue = "%+(%d+)%]" -- "+10]"
        local attributeString = attributes[k][1] .. attributeSearchValue -- "%[Attack: %+(%d+)%]"
        if string.match(itemDesc, attributeString) == nil then -- "[Attack: +10]"
            if attributes[k][2] ~= nil then
                player:removeCondition(CONDITION_ATTRIBUTES, CONDITIONID_COMBAT, k)
            end
        end
    end
end
Post automatically merged:

Can you improve a little, anyone to optimize?


Lua:
--// Do not touch
local conditionSlots = {
    [CONST_SLOT_HEAD]     = {condition = Condition(CONDITION_ATTRIBUTES, CONDITIONID_HEAD),     id = CONDITIONID_HEAD},
    [CONST_SLOT_NECKLACE] = {condition = Condition(CONDITION_ATTRIBUTES, CONDITIONID_NECKLACE), id = CONDITIONID_NECKLACE},
    [CONST_SLOT_BACKPACK] = {condition = Condition(CONDITION_ATTRIBUTES, CONDITIONID_BACKPACK), id = CONDITIONID_BACKPACK},
    [CONST_SLOT_ARMOR]    = {condition = Condition(CONDITION_ATTRIBUTES, CONDITIONID_ARMOR),    id = CONDITIONID_ARMOR},
    [CONST_SLOT_RIGHT]    = {condition = Condition(CONDITION_ATTRIBUTES, CONDITIONID_RIGHT),    id = CONDITIONID_RIGHT},
    [CONST_SLOT_LEFT]     = {condition = Condition(CONDITION_ATTRIBUTES, CONDITIONID_LEFT),     id = CONDITIONID_LEFT},
    [CONST_SLOT_LEGS]     = {condition = Condition(CONDITION_ATTRIBUTES, CONDITIONID_LEGS),     id = CONDITIONID_LEGS},
    [CONST_SLOT_FEET]     = {condition = Condition(CONDITION_ATTRIBUTES, CONDITIONID_FEET),     id = CONDITIONID_FEET},
    [CONST_SLOT_RING]     = {condition = Condition(CONDITION_ATTRIBUTES, CONDITIONID_RING),     id = CONDITIONID_RING},
    [CONST_SLOT_AMMO]     = {condition = Condition(CONDITION_ATTRIBUTES, CONDITIONID_AMMO),     id = CONDITIONID_AMMO}
}
-- 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_DISTANCEPERCENT},
         [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},
        [19] = {"%[" .. stats[41].attribute.name .. ": ", CONDITION_PARAM_HEALTHGAIN},
        [20] = {"%[" .. stats[42].attribute.name .. ": ", CONDITION_PARAM_MANAGAIN},
    }
    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 = 0 -- 100% + % do item [Crit Amount: +47%] == 147% -- These conditions require absolutes (108%, 145% etc.)
            end
        end
        local attributeString = attributes[k][1] .. attributeSearchValue -- "%[Attack: %+(%d+)%]"
        for i = 1, #conditionSlots do
            if string.match(itemDesc, attributeString) ~= nil then -- "[Attack: +10]"
                local skillBonus = skillBonus + tonumber(string.match(itemDesc, attributeString)) -- Raw (%d+) value
                local conditionId = conditionSlots[slot].id
                local condition = conditionSlots[slot].condition
                -- (!) 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 == 12 then
                local w = k + 1
                if player:getCondition(CONDITION_ATTRIBUTES, conditionId, w) == nil then
                    condition:setParameter(CONDITION_PARAM_TICKS, -1)
                    condition:setParameter(attributes[w][2], 15) -- 10%
                    player:addCondition(condition)
                end
            end
            if k == 15 or k == 17 then
            local j = k - 1
                if player:getCondition(CONDITION_ATTRIBUTES, conditionId, j) == nil then
                    condition:setParameter(CONDITION_PARAM_TICKS, -1)
                    condition:setParameter(attributes[j][2], 50) -- 100%
                    player:addCondition(condition)
                end
            end
            if k == 18 then
                if player:getCondition(CONDITION_HASTE, conditionId, k) == nil then
                    local conditionH = Condition(CONDITION_HASTE)
                    conditionH:setParameter(CONDITION_PARAM_TICKS, -1)
                    conditionH:setParameter(attributes[k][2], skillBonus*2)
                    player:addCondition(conditionH)
                end
            end
            if k == 19 or k == 20 or k == 19 and k == 20  then
                if player:getCondition(CONDITION_REGENERATION, conditionId, k) == nil then
                    local conditionR = Condition(CONDITION_REGENERATION)
                    conditionR:setParameter(CONDITION_PARAM_TICKS, -1)
                    conditionR:setParameter(attributes[k][2], skillBonus*2)
                    player:addCondition(conditionR)
                end
            end
                if player:getCondition(CONDITION_ATTRIBUTES, conditionId, k) == nil then
                    condition:setParameter(CONDITION_PARAM_TICKS, -1)
                    condition:setParameter(attributes[k][2], skillBonus)
                    player:addCondition(condition)
                end
            end
        end
    end
end
function rollConditionremove(player, item, slot)
    local attributes = {
        CONDITION_PARAM_SKILL_SWORD,
        CONDITION_PARAM_SKILL_AXE,
        CONDITION_PARAM_SKILL_CLUB,
        CONDITION_PARAM_SKILL_MELEE,
        CONDITION_PARAM_SKILL_DISTANCEPERCENT,
        CONDITION_PARAM_SKILL_SHIELD,
        CONDITION_PARAM_STAT_MAGICPOINTS,
        CONDITION_PARAM_STAT_MAXHITPOINTS,
        CONDITION_PARAM_STAT_MAXMANAPOINTS,
        CONDITION_PARAM_STAT_MAXHITPOINTSPERCENT,
        CONDITION_PARAM_STAT_MAXMANAPOINTSPERCENT,
        CONDITION_PARAM_SKILL_CRITICAL_HIT_DAMAGE,
        CONDITION_PARAM_SKILL_CRITICAL_HIT_CHANCE,
        CONDITION_PARAM_SKILL_LIFE_LEECH_CHANCE,
        CONDITION_PARAM_SKILL_LIFE_LEECH_AMOUNT,
        CONDITION_PARAM_SKILL_MANA_LEECH_CHANCE,
        CONDITION_PARAM_SKILL_MANA_LEECH_AMOUNT,
        CONDITION_PARAM_SPEED,
        CONDITION_PARAM_HEALTHGAIN,
        CONDITION_PARAM_MANAGAIN,
    }
    for i = 1, #conditionSlots do 
        local condition = conditionSlots[slot].condition
        local conditionId = conditionSlots[slot].id
        player:removeCondition(CONDITION_ATTRIBUTES, conditionId)
        player:removeCondition(CONDITION_HASTE)
        player:removeCondition(CONDITION_REGENERATION)
        for k = 1, #attributes do
            condition:setParameter(attributes[k], 0)
        end
    end
end
 
Last edited:
Back
Top