Formula

CommonFun.calcMDamReDuc

function CommonFun.calcMDamReDuc(srcUser, targetUser)
  if srcUser == nil or targetUser == nil then
    return 0
  end
  local MDamSpike = srcUser:GetProperty("MDamSpike_MPEN")
  local MDamReduc2 = targetUser:GetProperty("MDamReduc")
  local ReduceLv = CommonFun.calcSpikeLv(srcUser, targetUser)
  local SkillMDamReduc = CommonFun.calcSkillMDamReduc(srcUser, targetUser)
  if srcUser:HasBuffID(138002_23_:MAX_STACK_0) then
    local DamSpike = srcUser:GetProperty("DamSpike_PEN")
    MDamSpike = MDamSpike + DamSpike
  end
  if targetUser:GetNpcID() ~= 0 and srcUser:HasBuffID(57720_23_:MAX_STACK_0) and srcUser:HasBuffID(138002_23_:MAX_STACK_0) then
    MDamSpike = MDamSpike + 0.2
  elseif targetUser:GetNpcID() ~= 0 and srcUser:HasBuffID(57720_23_:MAX_STACK_0) then
    MDamSpike = MDamSpike + 0.1
  end
  local A = 1 - (1 + 0.009 * ReduceLv + MDamSpike - MDamReduc2) * SkillMDamReduc
  local mapid, maptype = srcUser:GetMapInfo()
  if (maptype == PVP_MAPS) and targetUser:GetNpcID() ~= 40022_EMPERIUM then
    A = A < -1 and -1 or 1 < A and 1 or A
    A = math.floor(A * 1000) / 1000
    A = A + 0.4 * (1 - math.sin(A * 3.14 / 2))
  end
  if 0.85 <= A then
    A = 0.85
  end
  return A
end