• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Rust remover

nawyrus

Member
Joined
Jan 16, 2014
Messages
37
Reaction score
10
Found this in some polish site. I removed wrong items and some lines, fixed the rates according to the wiki statistics. Tested on TFS 1.0.

One alert: chain armor rate in the common rusty armor in the wiki is 30,14%, here you will see 6966 resulting from the way the script is structured, 6966=3014(actual rate)+2450+1305+197(the rates below), scale armor 3952=2450+1305+197 and so on.


Code:
function onUse(cid, item, frompos, item2, topos)
    local effect_renew = 28
    local effect_broke = 3
    local storage = 0
    local const = item2.itemid
    local pos = getCreaturePosition(cid)
    local itemy = {
                    [9808] = {
                                [1] = {id = 2464, name = "Chain Armor", chance = 6966},
                                [2] = {id = 2483, name = "Scale Armor", chance = 3952},
                                [3] = {id = 2465, name = "Brass Armor", chance = 1502},
                                [4] = {id = 2463, name = "Plate Armor", chance = 197}
                            },
                           
                    [9809] = {
                                [1] = {id = 2483, name = "Scale Armor", chance = 6437},                   
                                [2] = {id = 2464, name = "Chain Armor", chance = 4606},
                                [3] = {id = 2465, name = "Brass Armor", chance = 3029},
                                [4] = {id = 2463, name = "Plate Armor", chance = 1559},
                                [5] = {id = 2476, name = "Knight Armor", chance = 595},
                                [6] = {id = 8891, name = "Paladin Armor", chance = 283},
                                [7] = {id = 2487, name = "Crown Armor", chance = 49}
                            },
                           
                    [9810] = {
                                [1] = {id = 2465, name = "Brass Armor", chance = 6681},
                                [2] = {id = 2463, name = "Plate Armor", chance = 3767},
                                [3] = {id = 2476, name = "Knight Armor", chance = 1832},
                                [4] = {id = 2487, name = "Crown Armor", chance = 177},
                                [5] = {id = 8891, name = "Paladin Armor", chance = 31},
                                [6] = {id = 2466, name = "Golden Armor", chance = 10}
                            },
                           
                    [9811] = {
                                [1] = {id = 2648, name = "Chain Legs", chance = 6949},                   
                                [2] = {id = 2468, name = "Studded Legs", chance = 3692},
                                [3] = {id = 2478, name = "Brass Legs", chance = 1307},
                                [4] = {id = 2647, name = "Plate Legs", chance = 133}
                            },
                           
                    [9812] = {
                                [1] = {id = 2468, name = "Studded Legs", chance = 5962},
                                [2] = {id = 2648, name = "Chain Legs", chance = 4037},
                                [3] = {id = 2478, name = "Brass Legs", chance = 2174},
                                [4] = {id = 2647, name = "Plate Legs", chance = 1242},
                                [5] = {id = 2477, name = "Knight Legs", chance = 186},
                            },
                           
                    [9813] = {
                                [1] = {id = 2478, name = "Brass Legs", chance = 6500},
                                [2] = {id = 2647, name = "Plate Legs", chance = 3800},
                                [3] = {id = 2477, name = "Knight Legs", chance = 200},
                                [4] = {id = 2488, name = "Crown Legs", chance = 52},
                                [5] = {id = 2470, name = "Golden Legs", chance = 30}
                            }
                } 

                local random_item = math.random(10000)
    if itemy[const] then
        for i = 1, #itemy[const] do
            if random_item <= itemy[const][i].chance then
                storage = i
            end
        end  
       
        if storage > 0 then
            doSendMagicEffect(topos, effect_renew)
            doTransformItem(item2.uid, itemy[const][storage].id)
            doCreatureSay(cid, "You have renewed the ".. itemy[const][storage].name .." !", TALKTYPE_ORANGE_1)
            doRemoveItem(item.uid, 1)
        else
            doSendMagicEffect(topos, effect_broke)
            doRemoveItem(item2.uid, 1)
            doRemoveItem(item.uid, 1)
            doCreatureSay(cid, "The armor was already damaged so badly that it broke when you tried to clean it.", TALKTYPE_ORANGE_1)
            return 0
        end
    else
        return 0
    end
return true
end

Code:
<action itemid="9930" script="rustremover.lua"/>
 
Last edited:
Code:
local breakChance = 60
local rustyItems = {
    [9808] = {2464, 2465, 2483, 2463, 2476}, --common rusty armor
    [9809] = {2464, 2465, 2483, 2463, 2476, 8891}, --semi-rare rusty armor
    [9810] = {2464, 2465, 2483, 2463, 2476, 8891, 2487, 2466, 2472}, --rare rusty armor
    [9811] = {2468, 2648, 2478, 2647, 2477}, --common rusty legs
    [9812] = {2468, 2648, 2478, 2647, 2477, 2488}, --semi-rare rusty legs
    [9813] = {2468, 2648, 2478, 2647, 2477, 2488, 2470}, --rare rusty legs
    [9814] = {2511, 2510, 2530, 2509, 2513, 2515}, --common rusty shield
    [9815] = {2511, 2510, 2530, 2509, 2513, 2515, 2516, 2519}, --semi-rare rusty shield
    [9816] = {2511, 2510, 2530, 2509, 2513, 2515, 2516, 2519, 2520, 2514}, --rare rusty shield
    [9817] = {2643, 3982, 5462, 7457}, --common rusty boots
    [9818] = {2643, 3982, 5462, 7457, 2195}, --semi-rare rusty boots
    [9819] = {2643, 3982, 5462, 7457, 2195, 2645}, --rare rusty boots
    [9820] = {2458, 2460, 2480, 2481, 2457, 2491}, --common rusty helmet
    [9821] = {2458, 2460, 2480, 2481, 2457, 2491, 2497}, --semi rare rusty helmet
    [9822] = {2458, 2460, 2480, 2481, 2457, 2491, 2497, 2475, 2498} --rare rusty helmet
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if rustyItems[itemEx.itemid] ~= nil then
        if math.random(30000) <= breakChance then
            doRemoveItem(itemEx.uid)
            doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You broke it.")
        else
            local newId = rustyItems[itemEx.itemid][math.random(#rustyItems[itemEx.itemid])]
            doTransformItem(itemEx.uid,newId)
            doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You removed the rust, revealing a "..getItemNameById(newId))
        end
        doRemoveItem(item.uid,1)
        return TRUE
    end
    return FALSE
end

is this good too ?
 
Code:
local breakChance = 60
local rustyItems = {
    [9808] = {2464, 2465, 2483, 2463, 2476}, --common rusty armor
    [9809] = {2464, 2465, 2483, 2463, 2476, 8891}, --semi-rare rusty armor
    [9810] = {2464, 2465, 2483, 2463, 2476, 8891, 2487, 2466, 2472}, --rare rusty armor
    [9811] = {2468, 2648, 2478, 2647, 2477}, --common rusty legs
    [9812] = {2468, 2648, 2478, 2647, 2477, 2488}, --semi-rare rusty legs
    [9813] = {2468, 2648, 2478, 2647, 2477, 2488, 2470}, --rare rusty legs
    [9814] = {2511, 2510, 2530, 2509, 2513, 2515}, --common rusty shield
    [9815] = {2511, 2510, 2530, 2509, 2513, 2515, 2516, 2519}, --semi-rare rusty shield
    [9816] = {2511, 2510, 2530, 2509, 2513, 2515, 2516, 2519, 2520, 2514}, --rare rusty shield
    [9817] = {2643, 3982, 5462, 7457}, --common rusty boots
    [9818] = {2643, 3982, 5462, 7457, 2195}, --semi-rare rusty boots
    [9819] = {2643, 3982, 5462, 7457, 2195, 2645}, --rare rusty boots
    [9820] = {2458, 2460, 2480, 2481, 2457, 2491}, --common rusty helmet
    [9821] = {2458, 2460, 2480, 2481, 2457, 2491, 2497}, --semi rare rusty helmet
    [9822] = {2458, 2460, 2480, 2481, 2457, 2491, 2497, 2475, 2498} --rare rusty helmet
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if rustyItems[itemEx.itemid] ~= nil then
        if math.random(30000) <= breakChance then
            doRemoveItem(itemEx.uid)
            doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You broke it.")
        else
            local newId = rustyItems[itemEx.itemid][math.random(#rustyItems[itemEx.itemid])]
            doTransformItem(itemEx.uid,newId)
            doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR,"You removed the rust, revealing a "..getItemNameById(newId))
        end
        doRemoveItem(item.uid,1)
        return TRUE
    end
    return FALSE
end

is this good too ?

The problem in your script is that every item gets the same chance, golden armor has a 0,10% rate in real Tibia, with it to obtain one will be as likely as a brass or plate armor.
 
Last edited:
Back
Top