GA
pedido

Item que ao usar em outro, da reflect.

Por gabriel28, 05 de ago. de 2015 em Scripts

5
1.1k
gabriel28G
05 de agosto de 2015 às 14:31

Já vi por ai alguns scripts de reflect, mas não do jeito que eu gostaria. Gostaria de um item que ao usar em outro, desse o bônus de reflect. Seria mais ou menos assim: O item daria 2% de bônus de reflect e só poderia ser usado uma vez em cada item, tendo chance de falhar. O item poderia ser usado em qualquer equipament (colar, helmet, armor, legs, shield e boots), mas armas(axe, sword, club, bow/crossbow) e wands e rods, não poderiam receber o item.

 

Se alguém puder ajudar, agradeço.


up


up

zipter98Z
05 de agosto de 2015 às 19:46
Melhor resposta
Action:
local config = {
    reflectBonus = 2,               --Bônus de reflect, em %.
    failChance = 50,                --Chance de falhar, em porcentagem.
    types = {"armor", "legs", "helmet", "boots"},
    noReflect = {1, 2, 3, 5, 6}     --Tipos de armamento bloqueados (valores podem ser conferidos em 000-constant.lua, data/lib)
}
function onUse(cid, item, fromPos, itemEx, toPos)
    if itemEx.itemid < 100 then
        return doPlayerSendCancel(cid, "Use this in valid itens.")
    elseif isInArray(config.noReflect, getItemWeaponType(itemEx.uid)) then
        return doPlayerSendCancel(cid, "Use this in valid itens.")
    elseif getItemAttribute(itemEx.uid, "reflect") then
        return doPlayerSendCancel(cid, "This item has already a reflect bonus.")
    elseif math.random(1, 100) > config.failChance then
        return doPlayerSendTextMessage(cid, 27, "Sorry, your item didn't get a reflect bonus. Good luck at the next try! =]"), doRemoveItem(item.uid, 1)
    end
    local checkItemName
    for i = 1, #config.types do
        if getItemNameById(itemEx.itemid):find(config.types[i]) then
            checkItemName = true
            break
        end
    end
    if not checkItemName then
        return doPlayerSendCancel(cid, "Use this in valid itens.")
    end
    doPlayerSendTextMessage(cid, 27, "Congratulations, now your item has a reflect bonus of "..config.reflectBonus.."%!")
    doItemSetAttribute(itemEx.uid, "reflect", config.reflectBonus)
    doItemSetAttribute(itemEx.uid, "name", getItemNameById(itemEx.itemid).." ref "..config.reflectBonus.."%")
    doRemoveItem(item.uid, 1)
    return true
end
Creaturescript (não se esqueça de registrar o evento em login.lua):
function onStatsChange(cid, attacker, type, combat, value)
    if isPlayer(cid) and isCreature(attacker) and type == STATSCHANGE_HEALTHLOSS then
        local bonusReflect = 0
        for i = 1, 10 do
            local item = getPlayerSlotItem(cid, i).uid
            if item > 0 and getItemAttribute(item, "reflect") then
                bonusReflect = bonusReflect + getItemAttribute(item, "reflect")
            end
        end
        if bonusReflect > 0 then
            local damage = value * bonusReflect / 100
            doSendAnimatedText(getThingPos(attacker), -damage, COLOR_RED)
            doCreatureAddHealth(attacker, -damage)
        end
    end
    return true
end

 

Editado Agosto 5 por zipter98

3 semanas depois...
LumusL
20 de agosto de 2015 às 02:51

Dúvida resolvida?

gabriel28G
21 de agosto de 2015 às 20:05

Sim.

LumusL
22 de agosto de 2015 às 01:15

Dúvida sanada tópico movido.