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

Slot stone - ADD critical, manaleach, hp leach TFS 1.5 Nekiro 8.0

shakal1994

Member
Joined
Nov 20, 2020
Messages
77
Reaction score
15
Hi....

I would like to make this system work on the TFS 1.5 Nekiro downgrade. 8.0

It even works, but the description and core dump don't appear :(


Or can anyone make this script in revscript
local weaponTypes = {WEAPON_SWORD,WEAPON_CLUB,WEAPON_AXE}

local attrConfig = {maxValue = 10} -- FROM ORIGINAL VALUE,
local attrs = {
--[1] = {code = ITEM_ATTRIBUTE_ARMOR,effect=CONST_ME_MAGIC_RED},
[1] = {code = ITEM_ATTRIBUTE_LIFELEECH,effect=CONST_ME_MAGIC_GREEN},
[2] = {code = ITEM_ATTRIBUTE_MANALEECH,effect=CONST_ME_MAGIC_BLUE},
[3] = {code = ITEM_ATTRIBUTE_CRITICAL,effect=CONST_ME_CRITICAL_DAMAGE},
}
local gemsEeffect = {
[5245] = {
chance = 10,
},
[5246] = {chance = 15},
[5247] = {chance = 35},
[5248] = {chance = 50},
[2178] = {chance = 100},
}

function onUse(player, item, fromPosition, target, toPosition)
if target:isItem() == nil then
return false
end
if not target:isItem() then
return false
end

local itemTarget = target:getId()
local itemtype = ItemType(itemTarget)
local weapontype = itemtype:getWeaponType()

if not table.contains(weaponTypes, weapontype) then
return false
end
local attrEnchantCount = target:getCustomAttribute('maxattr')
if attrEnchantCount == nil then
attrEnchantCount = 1
end
if(attrEnchantCount > 10) then
player:sendTextMessage(MESSAGE_INFO_DESCR, "This equipment cannot be enchanted more than 10 times.")
return false
end

if item:remove(1) then
local currentGem = gemsEeffect[item:getId()]
if math.random(1, 100) <= math.min(math.max(10, currentGem.chance)) then
local randomAttr = math.random(1,#attrs)

local getCurrentAttr = target:getAttribute(attrs[randomAttr].code)

if getCurrentAttr == nil or getCurrentAttr == 0 then
getCurrentAttr = 1
if attrs[randomAttr].base then
if attrs[randomAttr].code == ITEM_ATTRIBUTE_ATTACK then
getCurrentAttr = itemtype:getAttack() + 1
elseif attrs[randomAttr].code == ITEM_ATTRIBUTE_DEFENSE then
getCurrentAttr = itemtype:getDefense() + 1
end
end
else
getCurrentAttr = (getCurrentAttr+1)
end

if math.random(1, 100) <= math.min(math.max(10, (1+attrEnchantCount))) then
if item:getId() ~= 7682 then
player:say('Crack..!', TALKTYPE_MONSTER_SAY)
target:remove()
end
else
target:setAttribute(attrs[randomAttr].code, getCurrentAttr)
target:setCustomAttribute('maxattr',(attrEnchantCount+1))
target:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION,'This equipment was enchanted '..attrEnchantCount..' time'..(attrEnchantCount == 1 and '' or 's')..'.')
player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
end
end
end

return true
end
 
I have something made for this, a little different, I hope it helps you.

Lua:
-- Lista de tipos de armas válidas
local weaponTypes = {WEAPON_SWORD, WEAPON_CLUB, WEAPON_AXE}

-- Configuração dos atributos
local attrConfig = {maxValue = 10}
local attrs = {
    [1] = {code = ITEM_ATTRIBUTE_LIFELEECH, effect = CONST_ME_MAGIC_GREEN},
    [2] = {code = ITEM_ATTRIBUTE_MANALEECH, effect = CONST_ME_MAGIC_BLUE},
    [3] = {code = ITEM_ATTRIBUTE_CRITICAL, effect = CONST_ME_CRITICAL_DAMAGE},
    [4] = {code = ITEM_ATTRIBUTE_ATTACK, effect = CONST_ME_DRAWBLOOD, base = true},
    [5] = {code = ITEM_ATTRIBUTE_DEFENSE, effect = CONST_ME_BLOCKHIT, base = true}
}

-- Efeitos das gemas
local gemsEffect = {
    [5245] = {successChance = 40, breakChance = 25, noEffectChance = 35}, -- Chance de sucesso de 40%, chance de quebrar de 25%, chance de nada acontecer de 35%
    [5246] = {successChance = 50, breakChance = 15, noEffectChance = 35}, -- Chance de sucesso de 50%, chance de quebrar de 15%, chance de nada acontecer de 35%
    [5247] = {successChance = 60, breakChance = 10, noEffectChance = 30}, -- Chance de sucesso de 60%, chance de quebrar de 10%, chance de nada acontecer de 30%
    [5248] = {successChance = 70, breakChance = 5, noEffectChance = 25}, -- Chance de sucesso de 70%, chance de quebrar de 5%, chance de nada acontecer de 25%
    [5249] = {successChance = 80, breakChance = 3, noEffectChance = 17}  -- Chance de sucesso de 80%, chance de quebrar de 3%, chance de nada acontecer de 17%
}

-- Função para manipular o uso da gema
function onUse(player, item, fromPosition, target, toPosition)
    -- Verifica se o alvo é um item
    if not target or not target:isItem() then
        return false
    end

    local itemTarget = target:getId()
    local itemType = ItemType(itemTarget)
    local weaponType = itemType:getWeaponType()

    -- Verifica se o tipo de arma é válido
    if not table.contains(weaponTypes, weaponType) then
        return false
    end

    -- Obtém o número de encantamentos do item
    local attrEnchantCount = target:getAttribute(ITEM_ATTRIBUTE_CUSTOM_MAXATTR) or 0

    -- Verifica se o item já foi encantado 10 vezes
    if attrEnchantCount >= 10 then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "This equipment is already enchanted 10 times.")
        return false
    end

    -- Remove a gema usada
    if item:remove(1) then
        local currentGem = gemsEffect[item:getId()]
        local randomNumber = math.random(1, 100)
        if randomNumber <= currentGem.successChance then
            -- Encantamento bem-sucedido
            local randomAttr = math.random(1, #attrs)
            local getCurrentAttr = target:getAttribute(attrs[randomAttr].code) or 0

            -- Incrementa o valor do atributo
            if getCurrentAttr == 0 then
                getCurrentAttr = attrs[randomAttr].base and (attrs[randomAttr].code == ITEM_ATTRIBUTE_ATTACK and itemType:getAttack() + 1 or itemType:getDefense() + 1) or 1
            else
                getCurrentAttr = getCurrentAttr + 1
            end

            -- Aplica o encantamento e atualiza os atributos
            target:setAttribute(attrs[randomAttr].code, getCurrentAttr)
            target:setAttribute(ITEM_ATTRIBUTE_CUSTOM_MAXATTR, (attrEnchantCount + 1))
            target:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, 'This equipment is enchanted.')
            target:getPosition():sendMagicEffect(attrs[randomAttr].effect)
        elseif randomNumber <= currentGem.successChance + currentGem.breakChance then
            -- A gema falhou e o item quebrou
            player:say('Crack..!', TALKTYPE_MONSTER_SAY)
            target:remove()
        else
            -- A gema falhou e nada aconteceu
            player:say('Failed to enchant.', TALKTYPE_MONSTER_SAY)
        end
    end

    return true
end
 
Post the original script without modifications!


local weaponTypes = {WEAPON_SWORD,WEAPON_CLUB,WEAPON_AXE}

local attrConfig = {maxValue = 10} -- FROM ORIGINAL VALUE,
local attrs = {
--[1] = {code = ITEM_ATTRIBUTE_ARMOR,effect=CONST_ME_MAGIC_RED},
[1] = {code = ITEM_ATTRIBUTE_LIFELEECH,effect=CONST_ME_MAGIC_GREEN},
[2] = {code = ITEM_ATTRIBUTE_MANALEECH,effect=CONST_ME_MAGIC_BLUE},
[3] = {code = ITEM_ATTRIBUTE_CRITICAL,effect=CONST_ME_CRITICAL_DAMAGE},
[4] = {code = ITEM_ATTRIBUTE_ATTACK,effect=CONST_ME_DRAWBLOOD,base=true},
[5] = {code = ITEM_ATTRIBUTE_DEFENSE,effect=CONST_ME_BLOCKHIT,base=true}
}
local gemsEeffect = {
[5245] = {
chance = 10,
},
[5246] = {chance = 15},
[5247] = {chance = 35},
[5248] = {chance = 50},
[5249] = {chance = 100},
}

function onUse(player, item, fromPosition, target, toPosition)
if target:isItem() == nil then
return false
end
if not target:isItem() then
return false
end

local itemTarget = target:getId()
local itemtype = ItemType(itemTarget)
local weapontype = itemtype:getWeaponType()

if not table.contains(weaponTypes, weapontype) then
return false
end
local attrEnchantCount = target:getCustomAttribute('maxattr')
if attrEnchantCount == nil then
attrEnchantCount = 1
end
if(attrEnchantCount > 10) then
player:sendTextMessage(MESSAGE_INFO_DESCR, "This equipment cannot be enchanted more than 10 times.")
return false
end

if item:remove(1) then
local currentGem = gemsEeffect[item:getId()]
if math.random(1, 100) <= math.min(math.max(10, currentGem.chance)) then
local randomAttr = math.random(1,#attrs)

local getCurrentAttr = target:getAttribute(attrs[randomAttr].code)

if getCurrentAttr == nil or getCurrentAttr == 0 then
getCurrentAttr = 1
if attrs[randomAttr].base then
if attrs[randomAttr].code == ITEM_ATTRIBUTE_ATTACK then
getCurrentAttr = itemtype:getAttack() + 1
elseif attrs[randomAttr].code == ITEM_ATTRIBUTE_DEFENSE then
getCurrentAttr = itemtype:getDefense() + 1
end
end
else
getCurrentAttr = (getCurrentAttr+1)
end

if math.random(1, 100) <= math.min(math.max(10, (1+attrEnchantCount))) then
if item:getId() ~= 5249 then
player:say('Crack..!', TALKTYPE_MONSTER_SAY)
target:remove()
end
else
target:setAttribute(attrs[randomAttr].code, getCurrentAttr)
target:setCustomAttribute('maxattr',(attrEnchantCount+1))
target:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION,'This equipment was enchanted '..attrEnchantCount..' time'..(attrEnchantCount == 1 and '' or 's')..'.')
target:getPosition():sendMagicEffect(attrs[randomAttr].effect)
end
end
end

return true
end
 
I've finished the script here, everything's fine, okay? Check out the video on how it's working well. However, I suggest adding the 'updated Slot System' to your server. If it's not added, it won't work properly, just like 'critical and life leech + mana leech', etc. That's why it's necessary to add it. I'll post a link for you to add everything before testing, okay? The script is working fine, okay? However, I can't add the description look of the item with attributes like 'critical + life leech, etc.' If someone could do that and post it here, I would greatly appreciate it. But the script is all good.
GIF:


target:setMaxSockets(10) <<This line says that enchanting is limited to a maximum of 10.

target:addStat(enhancementEffect.effect, "+1") << This line will add +1 to the item. If used again, it will be +1 more, totaling 2 and so on. Feel free to adjust the value to your preference.
Revscripts
data/scripts/slot-stone.lua

Lua:
local config = {
    itemEnhancementConfig = {
        [8302] = { -- Crit
            effect = "Crit",
            message = "Your item has been enhanced with Crit +1",
            successChance = 70,
            breakChance = 10
        },
        [8303] = { -- Crit%
            effect = "Crit%",
            message = "Your item has been enhanced with Crit% +1",
            successChance = 70,
            breakChance = 10
        },
        --[8304] = { -- Life Leech
         --effect = "Life Leech",
         --message = "Your item has been enhanced with Life Leech +1",
        --successChance = 70,
        --breakChance = 10
       --},
       --[8305] = { -- Life Leech%
       --effect = "Life Leech%",
       --message = "Your item has been enhanced with Life Leech% +1",
       --uccessChance = 70,
       --breakChance = 10
     --},

        weaponTypes = {WEAPON_SWORD, WEAPON_CLUB, WEAPON_AXE}
    },
    weaponAttributeConfig = {
        attrConfig = {maxValue = 10},
        attrs = {
            [ITEM_ATTRIBUTE_ATTACK] = {effect = CONST_ME_DRAWBLOOD, base = true},
            [ITEM_ATTRIBUTE_DEFENSE] = {effect = CONST_ME_BLOCKHIT, base = true}
        },
        gemsEffect = {
            [2193] = {successChance = 70, breakChance = 10, attribute = ITEM_ATTRIBUTE_ATTACK},
            [2194] = {successChance = 70, breakChance = 10, attribute = ITEM_ATTRIBUTE_DEFENSE}
        }
    }
}

local function tableContains(table, element)
    for _, value in pairs(table) do
        if value == element then
            return true
        end
    end
    return false
end

local function isValidWeaponType(itemType)
    local weaponType = itemType:getWeaponType()
    return tableContains(config.itemEnhancementConfig.weaponTypes, weaponType)
end

local function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local enhancementEffect = config.itemEnhancementConfig[item:getId()]
    if enhancementEffect then
        if target:isItem() then
            if enhancementEffect.weaponTypes and not isValidWeaponType(target:getType()) then
                player:sendTextMessage(MESSAGE_EVENT_DEFAULT, "This enhancement can only be applied to weapons.")
                return false
            end
            
            local maxSockets = target:getMaxSockets()
            if maxSockets then
                target:setMaxSockets(10)
                target:addStat(enhancementEffect.effect, "+1")
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, enhancementEffect.message)
                item:remove(1)
                
                return true
            else
                print("The target item does not have a maximum number of sockets defined.")
                return false
            end
        else
            print("The target object is not a valid item.")
            return false
        end
    end
    
    local weaponAttributeEffect = config.weaponAttributeConfig.gemsEffect[item:getId()]
    if weaponAttributeEffect then
        if not player or not target:isItem() then
            return false
        end

        local attrEnchantCount = target:getCustomAttribute('maxattr') or 0

        if attrEnchantCount >= config.weaponAttributeConfig.attrConfig.maxValue then
            player:sendTextMessage(MESSAGE_INFO_DESCR, "This equipment cannot be enchanted more than " .. config.weaponAttributeConfig.attrConfig.maxValue .. " times.")
            return false
        end

        if item:remove(1) then
            local randomNumber = math.random(1, 100)
            if randomNumber <= weaponAttributeEffect.successChance then
                local attributeInfo = config.weaponAttributeConfig.attrs[weaponAttributeEffect.attribute]
                local getCurrentAttr = target:getAttribute(weaponAttributeEffect.attribute) or 0

                if getCurrentAttr == 0 then
                    getCurrentAttr = 1
                    if attributeInfo.base then
                        getCurrentAttr = target:getAttack() + 1
                    end
                else
                    getCurrentAttr = (getCurrentAttr + 1)
                end

                target:setAttribute(weaponAttributeEffect.attribute, getCurrentAttr)
                target:setCustomAttribute('maxattr', (attrEnchantCount + 1))
                target:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, 'This equipment was enchanted ' .. attrEnchantCount .. ' time' .. (attrEnchantCount == 1 and '' or 's') .. '.')
                target:getPosition():sendMagicEffect(attributeInfo.effect)
                player:say('Your item has been successfully enhanced!', TALKTYPE_MONSTER_SAY)
                return true
            elseif randomNumber <= weaponAttributeEffect.successChance + weaponAttributeEffect.breakChance then
                player:say('Crack..!', TALKTYPE_MONSTER_SAY)
                target:remove()
                return true
            else
                player:say('Oops! The item failed to enchant.', TALKTYPE_MONSTER_SAY)
                return true
            end
        end
    end
end

local combinedCallbacks = {}

for itemId, _ in pairs(config.itemEnhancementConfig) do
    combinedCallbacks[itemId] = true
end

for itemId, _ in pairs(config.weaponAttributeConfig.gemsEffect) do
    combinedCallbacks[itemId] = true
end

for itemId, _ in pairs(combinedCallbacks) do
    local action = Action(itemId)
    action.onUse = onUse
    action:id(itemId)
    action:register()
end

@OTcreator
What were you interested in about +1 crit etc.? So, let's experiment and test it out xD.
 
Last edited:
I've finished the script here, everything's fine, okay? Check out the video on how it's working well. However, I suggest adding the 'updated Slot System' to your server. If it's not added, it won't work properly, just like 'critical and life leech + mana leech', etc. That's why it's necessary to add it. I'll post a link for you to add everything before testing, okay? The script is working fine, okay? However, I can't add the description look of the item with attributes like 'critical + life leech, etc.' If someone could do that and post it here, I would greatly appreciate it. But the script is all good.
GIF:


target:setMaxSockets(10) <<This line says that enchanting is limited to a maximum of 10.

target:addStat(enhancementEffect.effect, "+1") << This line will add +1 to the item. If used again, it will be +1 more, totaling 2 and so on. Feel free to adjust the value to your preference.
Revscripts
data/scripts/slot-stone.lua

Lua:
local config = {
    itemEnhancementConfig = {
        [8302] = { -- Crit
            effect = "Crit",
            message = "Your item has been enhanced with Crit +1",
            successChance = 70,
            breakChance = 10
        },
        [8303] = { -- Crit%
            effect = "Crit%",
            message = "Your item has been enhanced with Crit% +1",
            successChance = 70,
            breakChance = 10
        },
        [8304] = { -- Life Leech
            effect = "Life Leech",
            message = "Your item has been enhanced with Life Leech +1",
            successChance = 70,
            breakChance = 10
        },
        [8305] = { -- Life Leech%
            effect = "Life Leech%",
            message = "Your item has been enhanced with Life Leech% +1",
            successChance = 70,
            breakChance = 10
        },
        weaponTypes = {WEAPON_SWORD, WEAPON_CLUB, WEAPON_AXE}
    },
    weaponAttributeConfig = {
        attrConfig = {maxValue = 10},
        attrs = {
            [ITEM_ATTRIBUTE_ATTACK] = {effect = CONST_ME_DRAWBLOOD, base = true},
            [ITEM_ATTRIBUTE_DEFENSE] = {effect = CONST_ME_BLOCKHIT, base = true}
        },
        gemsEffect = {
            [2193] = {successChance = 70, breakChance = 10, attribute = ITEM_ATTRIBUTE_ATTACK},
            [2194] = {successChance = 70, breakChance = 10, attribute = ITEM_ATTRIBUTE_DEFENSE}
        }
    }
}

local function tableContains(table, element)
    for _, value in pairs(table) do
        if value == element then
            return true
        end
    end
    return false
end

local function isValidWeaponType(itemType)
    local weaponType = itemType:getWeaponType()
    return tableContains(config.itemEnhancementConfig.weaponTypes, weaponType)
end

local function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local enhancementEffect = config.itemEnhancementConfig[item:getId()]
    if enhancementEffect then
        if target:isItem() then
            if enhancementEffect.weaponTypes and not isValidWeaponType(target:getType()) then
                player:sendTextMessage(MESSAGE_EVENT_DEFAULT, "This enhancement can only be applied to weapons.")
                return false
            end
         
            local maxSockets = target:getMaxSockets()
            if maxSockets then
                target:setMaxSockets(10)
                target:addStat(enhancementEffect.effect, "+1")
                player:sendTextMessage(MESSAGE_EVENT_ADVANCE, enhancementEffect.message)
                return true
            else
                print("The target item does not have a maximum number of sockets defined.")
                return false
            end
        else
            print("The target object is not a valid item.")
            return false
        end
    end
 
    local weaponAttributeEffect = config.weaponAttributeConfig.gemsEffect[item:getId()]
    if weaponAttributeEffect then
        if not player or not target:isItem() then
            return false
        end

        local attrEnchantCount = target:getCustomAttribute('maxattr') or 0

        if attrEnchantCount >= config.weaponAttributeConfig.attrConfig.maxValue then
            player:sendTextMessage(MESSAGE_INFO_DESCR, "This equipment cannot be enchanted more than " .. config.weaponAttributeConfig.attrConfig.maxValue .. " times.")
            return false
        end

        if item:remove(1) then
            local randomNumber = math.random(1, 100)
            if randomNumber <= weaponAttributeEffect.successChance then
                local attributeInfo = config.weaponAttributeConfig.attrs[weaponAttributeEffect.attribute]
                local getCurrentAttr = target:getAttribute(weaponAttributeEffect.attribute) or 0

                if getCurrentAttr == 0 then
                    getCurrentAttr = 1
                    if attributeInfo.base then
                        getCurrentAttr = target:getAttack() + 1
                    end
                else
                    getCurrentAttr = (getCurrentAttr + 1)
                end

                target:setAttribute(weaponAttributeEffect.attribute, getCurrentAttr)
                target:setCustomAttribute('maxattr', (attrEnchantCount + 1))
                target:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, 'This equipment was enchanted ' .. attrEnchantCount .. ' time' .. (attrEnchantCount == 1 and '' or 's') .. '.')
                target:getPosition():sendMagicEffect(attributeInfo.effect)
                player:say('Your item has been successfully enhanced!', TALKTYPE_MONSTER_SAY)
                return true
            elseif randomNumber <= weaponAttributeEffect.successChance + weaponAttributeEffect.breakChance then
                player:say('Crack..!', TALKTYPE_MONSTER_SAY)
                target:remove()
                return true
            else
                player:say('Oops! The item failed to enchant.', TALKTYPE_MONSTER_SAY)
                return true
            end
        end
    end
end

local combinedCallbacks = {}

for itemId, _ in pairs(config.itemEnhancementConfig) do
    combinedCallbacks[itemId] = true
end

for itemId, _ in pairs(config.weaponAttributeConfig.gemsEffect) do
    combinedCallbacks[itemId] = true
end

for itemId, _ in pairs(combinedCallbacks) do
    local action = Action(itemId)
    action.onUse = onUse
    action:id(itemId)
    action:register()
end

@OTcreator
What were you interested in about +1 crit etc.? So, let's experiment and test it out xD.
1707397896612.png
 
You have to add the Zbizu system with 'CreatureScript' and 'event/player.lua' to display statistics and attributes normally. Without adding both, errors will appear in the console, so it's important to understand that.
 
I wanted a stone that when used in a weapon it gains critical, that's all, I no longer need life and mana leech

This system you tell me about seems to be very complex and I'm afraid of unbalancing it.
 
Thus, you can remove the lines you do not want, just keep the criticisms. The post has been updated, and I forgot to add 'item:remove(1)' when using the stone to enchant the item and remove the stone.

I edited the post!
 
Last edited:
Back
Top