Script Robo de Mana y Reflejo de Daño

itsjorge98

Miembro
Mensajes
7
Puntos
73
Hola me pueden ayudar con 2 scripts? Tengo un ot con tfs 0.2 y quiero que una rod te de 1% de mana por cada hit y tambein que el shield refleje un % de daño que le hacen
 
Hola me pueden ayudar con 2 scripts? Tengo un ot con tfs 0.2 y quiero que una rod te de 1% de mana por cada hit y tambein que el shield refleje un % de daño que le hacen

Hola,
En 0.2 no se las funciones que tienes ( me basé en un 1.4 que utiliza getPlayerMagLevel ), pero podrías probar con este,


Código:
function onUseWeapon(cid, var)
    local magLevel = getPlayerMagLevel(cid, true)
    local mat = 0.1 * magLevel + (getPlayerLevel(cid) / 5)

    local min = 5
    local max = 15
    local addmana = math.random((mat * (min / 100)), (mat * (max / 100)))

    if getPlayerLevel(cid) >= 15 then
        doCreatureAddMana(cid, addmana)
        doSendAnimatedText(getPlayerPosition(cid), "+" .. math.floor(addmana), TEXTCOLOR_LIGHTBLUE)
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
        doCombat(cid, combat, var)
    else
        doPlayerSendCancel(cid, "You need level 15 to use this wand.")
    end
end

Para el reflejo complicado no estoy seguro pero creo que no se usa onHealthChange pero onStatChange:
Código:
function onStatsChange(cid, attacker, type, combat, value)
    if isPlayer(cid) and isCreature(attacker) and type == STATSCHANGE_HEALTHLOSS then
        local reflectPercent = 10 --- Porcentaje
        local reflectedDamage = math.floor(value * (reflectPercent / 100))

        local shield = getPlayerSlotItem(cid, CONST_SLOT_LEFT) -- shield slot
        if shield.itemid == 2537 then -- Item ID Shield
            doCreatureAddHealth(attacker, -reflectedDamage)
            doSendMagicEffect(getThingPos(attacker), CONST_ME_HITAREA)
            doSendAnimatedText(getThingPos(attacker), "-" .. reflectedDamage, TEXTCOLOR_RED)
        end
    end

    return true
end

Agregar en .xml
Código:
<event type="statschange" name="ReflectShield" script="reflect.lua"/>

Y registrarlo en login para llamarlo
Código:
registerCreatureEvent(cid, "ReflectShield")
 
Arriba