Formula

CommonFun.calcBuff_8470

function CommonFun.calcBuff_8470(srcUser, targetUser, a, b, c, d, lv, damage)
  if srcUser == nil or targetUser == nil then
    return 0
  end
  local skilllv = srcUser:GetLernedSkillLevel(4214_SORCERER:REMOVE_THE_SHADOW)
  local Luk = srcUser:GetProperty("Luk")
  local Dex = srcUser:GetProperty("Dex")
  local Vit2 = targetUser:GetProperty("Vit")
  local Rate2 = Vit2 / 8
  local Rate = math.min(skilllv * 3 + (Luk + Dex) / 16, 90) - math.min(Rate2, 50)
  if CommonFun.IsInRate(Rate, srcUser:GetRandom()) then
    local optionalPos = {
      CommonFun.EquipPos.EEQUIPPOS_SHIELD,
      CommonFun.EquipPos.EEQUIPPOS_ARMOUR,
      CommonFun.EquipPos.EEQUIPPOS_ROBE,
      CommonFun.EquipPos.EEQUIPPOS_SHOES,
      CommonFun.EquipPos.EEQUIPPOS_ACCESSORY1,
      CommonFun.EquipPos.EEQUIPPOS_ACCESSORY2
    }
    local validPos = {}
    for i = 1, #optionalPos do
      local pos = optionalPos[i]
      local equip = targetUser:getEquip(CommonFun.PackType.EPACKTYPE_SHADOWEQUIP, pos)
      if targetUser:IsShadowEquipForceOff(pos) == false and equip.id ~= 0 then
        table.insert(validPos, pos)
      end
    end
    local randomPos = 0
    if 0 < #validPos then
      local randomIndex = math.random(1, #validPos)
      randomPos = validPos[randomIndex]
    end
    return randomPos
  end
  return 0
end