Untitled

mail@pastecode.io avatar
unknown
plain_text
15 days ago
4.3 kB
2
Indexable
Never
local c = {
    [9735] = {12656, 101},
    [12643] = {12607, 101},
    [2504] = {11355, 101},
    [11117] = {11240, 101},
    [10220] = {10221, 101},
    [10137] = {10138, 101},
    [11259] = {11258, 101},
    [8858] = {10944, 101},
    [11307] = {12649, 101},
    [12327] = {12648, 101},
    [12613] = {7450, 101},
    [12644] = {2537, 101},
    [12647] = {2537, 101},
    [2298] = {2282, 101},
    [10521] = {10522, 101},
    Effect = CONST_ME_YELLOWENERGY,
    Distance = CONST_ANI_HOLY, 
  }
   
local d = {
    [{0}] = {attr = {'armor'}, get = function(x) return {getItemInfo(x).armor} end},
    [{1,2,3,4}] = {attr = {'attack', 'defense'}, get = function(x) return {getItemInfo(x).attack, getItemInfo(x).defense} end},
    [{5}] = {attr = {'defense'}, get = function(x) return {getItemInfo(x).defense} end}
}

local function getItemLevel(uid)
    uid = uid or 0
    local name = getItemName(uid.uid) or getItemInfo(uid.itemid).name or ''
    local lvl = string.match(name,'%s%+(%d+)%s*')
    return tonumber(lvl) or 0
end

local function getBoostLevel(item)
    local name = ""
    local level = getItemAttribute(item.uid, "boostTimes") or 0
    if level >= 1 and level < 3 then
        name = "Unique "
    elseif level >= 3 and level < 5 then
        name = "Super "
    elseif level >= 5 then
        name = "Epic "
    end
    return name
end
   
function onUse(cid, item, fromPosition, itemEx, toPosition)
     if item.aid == 3822 then
        return false
    end

    if getPlayerStorageValue(cid, 72345) < 100 then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You need 100 rebirths to transform saint to eclipse items.")
        return true
    end

    local t = c[itemEx.itemid]
    if t then

        for s = 1, 10 do
            local item_boost = itemEx
            if (getPlayerSlotItem(cid, s).uid == item_boost.uid) then
                return doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, "Please unEquip your item to transform it.")
            end
        end

        if itemEx.type > 1 then
            return doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, "Please unstack the rune to transform it.")
        end

        doSendDistanceShoot(getThingPos(cid), toPosition, c.Distance)
        doRemoveItem(item.uid, 1)

        if math.random(0,100) < t[2] then
            local name = {getItemNameById(itemEx.itemid),getItemNameById(t[1])}
            local newName = name[2]
            local itemLevel = getItemLevel(itemEx)
            local boostLevel = getItemAttribute(itemEx.uid, "boostTimes") or 0
            doTransformItem(itemEx.uid, t[1])
            doSendMagicEffect(toPosition, c.Effect)
            if boostLevel > 0 then
                newName = getBoostLevel(itemEx)..name[2]
            end
            if itemLevel > 0 then
                newName = newName.." +"..itemLevel
                for a,b in pairs (d) do
                    for i = 1, #a do
                        local _type = a[i]
                        if getItemWeaponType(itemEx.uid) == _type then
                            for x = 1, #b.attr do
                                local attr = b.attr[x]
                                if b.get(itemEx.itemid)[x] ~= 0 then
                                    local newstat = (getItemAttribute(itemEx.uid, attr) - b.get(itemEx.itemid)[x]) + b.get(t[1])[x]
                                    doItemSetAttribute(itemEx.uid, attr, newstat)
                                end
                            end

                            break
                        end
                    end
                end
            end
            doItemSetAttribute(itemEx.uid,'name', newName)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Has transformado "..getItemNameById(itemEx.itemid).." en "..getItemNameById(t[1]).." ") 
        else
            doSendMagicEffect(toPosition, CONST_ME_POFF)
            doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, "La piedra se desintegro sin poder transformar el objeto.")
        end
    else
        doPlayerSendCancel(cid, "Solo puedes forjar equipment P6 (Armas, Helmet, Armor, Legs, Boots, Amulet, Shield, Backpack, MrUh, Talisman Ring and Holy Lotus).")
    end
    return true
end
Leave a Comment