RevScript Attack % Increased using Item

Alex

Miembro del equipo
Webdesigner
LV
58
 
Awards
38
Hola a todos,

Les comparto el Increase Attack system, este sistema esta basado en el % de augmento al usar un item en ello,
Se puede modificar el augmento en % para evitar augmentarlo demasiado

Stats: Attack / Defense / ExtraDefense/ Armor / HitChance

Video Password: lepiigortv

Video link:

Script: a poner en data/scripts/action

Código:
local stones = {
      [21402] = {
              minLevel = 0, -- minimum level to use
              maxLevel = 15, -- maximum level to you can use
            chance = 75, -- probability of leveling up
            extraPercent = 0 -- extra attribute increase percentage
      },
      [21403] = {
              minLevel = 15,
            maxLevel = 30,
            chance = 50,
            extraPercent = 1
      },
      [6666] = {
              minLevel = 30,
            maxLevel = 50,
            chance = 25,
            extraPercent = 2
      }
}

local attributes = {
    [ITEM_ATTRIBUTE_ATTACK] = {
        getValue = ItemType.getAttack,
        percent = 5 -- attribute increase percentage in this case for attack
    },
    [ITEM_ATTRIBUTE_DEFENSE] = {
        getValue = ItemType.getDefense,
        percent = 5 -- attribute increase percentage in this case for defense
    },
    [ITEM_ATTRIBUTE_EXTRADEFENSE] = {
        getValue = ItemType.getExtraDefense,
        percent = 5 -- attribute increase percentage in this case for extraDefense
    },
    [ITEM_ATTRIBUTE_ARMOR] = {
        getValue = ItemType.getArmor,
        percent = 5 -- attribute increase percentage in this case for armor
    },
    [ITEM_ATTRIBUTE_HITCHANCE] = {
        getValue = ItemType.getHitChance,
        percent = 5 -- attribute increase percentage in this case for hitChance
    }
}

local function onUpgradeLvl(level, chance, config)
    local nextLevel = math.min(config.maxLevel, level +1)
    if math.random(1, chance) <= config.chance then
        return nextLevel
    end
    return level
end

local function isUpgradeable(item)
    local it = item:getType()
    return it:getAttack() > 0 or it:getDefense() > 0 or it:getArmor() > 0 or it:getExtraDefense() > 0
end

local function getItemLevel(item)
    return item:getCustomAttribute("upgradeLevel") or 0
end

local function setItemLevel(item, level)
    return item:setCustomAttribute("upgradeLevel", level)
end

local function upgradeValue(value, level, info, stone)
    return value * ((1.0 + ((info.percent + stone.extraPercent) / 100)) * level)
end

local function doUpgrade(item, level, stone)
    local itemType = item:getType()
    if level <= 0 then
        setItemLevel(item, level)
        item:setAttribute(ITEM_ATTRIBUTE_NAME, itemType:getName())
        for attribute, info in pairs(attributes) do
            item:setAttribute(attribute, info.getValue(itemType))
        end
        return true
    end
    setItemLevel(item, level)
    item:setAttribute(ITEM_ATTRIBUTE_NAME, string.format("%s +%u", itemType:getName(), level))
    for attribute, info in pairs(attributes) do
        local value = info.getValue(itemType)
        if value ~= 0 then
            item:setAttribute(attribute, upgradeValue(value, level, info, stone))
        end
    end
    return true
end

local upgrade = Action()
function upgrade.onUse(player, item, fromPos, target, toPos, isHotkey)
    if not target or not target:isItem() then
        player:sendCancelMessage("You cannot use this object.")
        return true
    end
    local stone = stones[item:getId()]
    if not stone then
        return false
    end
    if not isUpgradeable(target) then
        player:sendCancelMessage("This item cannot be upgrade.")
        return true
    end
    local level = getItemLevel(target)
    if level < stone.minLevel then
        player:sendCancelMessage(string.format("The minimum level to use is %d.", stone.minLevel))
        return true
    end
    local newLevel = onUpgradeLvl(level, 100, stone)
    if level >= stone.maxLevel then
        player:getPosition():sendMagicEffect(CONST_ME_POFF, player)
        player:sendCancelMessage("This item is already at its maximum level.")
        return true
    elseif newLevel == level then
        player:say("Failed!", TALKTYPE_MONSTER_SAY)
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
    elseif newLevel > level then
        player:say("Success!", TALKTYPE_MONSTER_SAY)
        player:getPosition():sendMagicEffect(CONST_ME_FIREWORK_YELLOW)
    end
    doUpgrade(target, newLevel, stone)
    item:remove(1)
    return true
end
for aid, _ in pairs(stones) do
    upgrade:id(aid)
end
upgrade:register()


Lineas que pueden ser retocadas: ( Numeros 5 en cada linea )

Código:
percent = 5 -- attribute increase percentage in this case for extraDefense

21402, 21403 y 6666 , son los items usados, reemplazarlos por los que deseais usar en vuestro juego, Nivel Minimo / Max Level de upgrade, la chance y el extra percent pueden ser retocados:

Código:
[21402] = {
              minLevel = 0, -- minimum level to use
              maxLevel = 15, -- maximum level to you can use
            chance = 75, -- probability of leveling up
            extraPercent = 0 -- extra attribute increase percentage
      },
      [21403] = {
              minLevel = 15,
            maxLevel = 30,
            chance = 50,
            extraPercent = 1
      },
      [6666] = {
              minLevel = 30,
            maxLevel = 50,
            chance = 25,
            extraPercent = 2
      }
 

Alex

Miembro del equipo
Webdesigner
LV
58
 
Awards
38
tendras uno que le suba el atack alas rods y wands?

Para hacer esto, hay que agregar cambios en sources para que agregues "attaque" en las wands/rods, y en ese caso, con upgrade, puedes subir el ataque de las wands, pero tiene un problema, esque las wands despues, sin upgrade tienen un ataque fijo, o malo algunos.

Aqui tienes el codigo ( para canary )

Código:
[Player][Magic%20Level][Level]%20Wands%20and%20Rods%20Damage%20Weapon%20Attack.zip?dl=1
 

misaki1124

Miembro
LV
7
 
Awards
5
Para hacer esto, hay que agregar cambios en sources para que agregues "attaque" en las wands/rods, y en ese caso, con upgrade, puedes subir el ataque de las wands, pero tiene un problema, esque las wands despues, sin upgrade tienen un ataque fijo, o malo algunos.

Aqui tienes el codigo ( para canary )

Código:
[Player][Magic%20Level][Level]%20Wands%20and%20Rods%20Damage%20Weapon%20Attack.zip?dl=1
Agrege y remplaze lo que decia y sigue atancando igual, :c solo se agrego la descripcion de Attack

02:05 You see a soultainter +6 (Atk:159, critical hit chance 10%, critical extra damage +10%, magic level +5, protection death +12%).
02:05 A training machine loses 113 hitpoints due to your attack.
ayuda :c
 

Alex

Miembro del equipo
Webdesigner
LV
58
 
Awards
38
Agrege y remplaze lo que decia y sigue atancando igual, :c solo se agrego la descripcion de Attack

02:05 You see a soultainter +6 (Atk:159, critical hit chance 10%, critical extra damage +10%, magic level +5, protection death +12%).
02:05 A training machine loses 113 hitpoints due to your attack.
ayuda :c
En teoria en tus armas en xml, agregas el attributo attack, como si fuera una arma, y de ahi, incrementando sube el attaque.

Funciono en 13.11, porque hize un update con esos cambios y funcionaba, pero reverti el cambio porqué habia algunos problemas, aqui puedes verlo:

un poco por abajo, aparece, agregado el attributo attaque en las wands y rods, y varias personas lo testearon funcionaba bien con el upgrade, solo que despues algunos reportaron problemas con las wands y rods, que tenian ataques raros.
 
Arriba