Formula

CommonFun.calcBuff_5990

function CommonFun.calcBuff_5990(srcUser, targetUser, a, b, c, d, lv)
  local Int = srcUser:GetProperty("Int")
  local Vit = srcUser:GetProperty("Vit")
  local MAtk = srcUser:GetProperty("MAtk")
  local MAtkPer = srcUser:GetProperty("MAtkPer")
  local MDamIncrease = CommonFun.calcMDamIncrease(srcUser, targetUser)
  local IgnoreMDef = srcUser:GetProperty("IgnoreMDef")
  if 1 <= IgnoreMDef then
    IgnoreMDef = 1
  end
  local MRefine = srcUser:GetProperty("MRefine")
  local srcAtkElement = 5
  local targetDefElement = targetUser:GetProperty("DefAttr")
  local ElementRate = CommonFun.GetElementRate(srcUser, srcAtkElement, targetUser, targetDefElement)
  if (srcUser:HasBuffID(69650_8608_:MAX_STACK_0) or srcUser:HasBuffID(71090_10658_:MAX_STACK_0)) and 1 < ElementRate then
    ElementRate = ElementRate * 1.1
  end
  if targetUser:HasBuffID(49130_DIVINE_HYMN_CARVER_:MAX_STACK_0) then
    ElementRate = math.min(ElementRate, 1)
  end
  if srcUser:HasBuffID(49210_7892_:MAX_STACK_0) then
    ElementRate = ElementRate + 0.15
  end
  if nil == CommonFun.NatureProps[srcAtkElement] or nil == CommonFun.NatureProps[targetDefElement] or nil == targetDefElement then
    return 0
  end
  local NeutralAtk = srcUser:GetProperty("NeutralAtk")
  local GemValue = srcUser:GetGemValue(82161_TWISTED_BOMB_S_NEUTRAL_ATK_PERCENTAGE)
  local ele = ElementRate * (1 + NeutralAtk + GemValue / 100000)
  local RefineMDamReduc = targetUser:GetProperty("RefineMDamReduc")
  local NpcParam = CommonFun.NpcParam(srcUser, targetUser, params, damageParam, logger)
  local BaseMAtk = Int + math.floor(Int * Int / 100)
  local MAtkFinal = ((MAtk - BaseMAtk) * (1 + MAtkPer) + BaseMAtk) * NpcParam
  local damChangePer = lv + 5
  local skilllv_zd = srcUser:GetLernedSkillLevel(3227_MECHANIC:TWISTED_BOMB_ENHANCE)
  local MDamSpike = srcUser:GetProperty("MDamSpike_MPEN")
  local ResultDamInc = srcUser:GetProperty("ResultDamInc")
  local ResultDamRes = targetUser:GetProperty("ResultDamRes")
  local Result = 1 + ResultDamInc - ResultDamRes
  Result = math.max(Result, 0.1)
  if srcUser:HasBuffID(22000130_TWISTED_BOMB_INHERITS_THE_ORIGINAL_DMG_:MAX_STACK_0) and a == 0.5 then
    a = 1
  end
  local A = -((MAtkFinal * (1 + MDamSpike) + MRefine) * damChangePer * (1 - RefineMDamReduc) * (1 + MDamIncrease)) * ele * a * (1 + skilllv_zd * 0.05) * Result
  local AttrFunction = srcUser:GetProperty("AttrFunction")
  local bitfunc = CommonFun.getBits(AttrFunction)
  if (targetUser.boss or targetUser.mini or targetUser.changelinepunish) and (targetUser.zoneType == 1 or targetUser.zoneType == 22) and targetUser.noPunishBoss == false and bitfunc[CommonFun.AttrFunction.JustInViceZone] == 1 and targetUser.isBossFromBranch == false then
    A = 0
  end
  if CommonFun.checkAttrFunctionMiss(targetUser, srcUser) then
    A = 0
  end
  if targetUser.boss and targetUser.zoneType == 22 and CommonFun.CheckStormBossMiss(targetUser, srcUser) then
    A = 0
  end
  if targetUser:GetNpcID() == 30043_YEAR or targetUser:GetNpcID() == 280303_WILDNESS_SPIRIT_BEAST or targetUser:GetNpcID() == 56008_GOMORA or targetUser:GetNpcID() == 56009_BALTAN or targetUser:GetNpcID() == 56010_GOLZA or targetUser:GetNpcID() == 56011_BEMSTAR or targetUser:GetNpcID() == 56012_ELEKING or targetUser:GetNpcID() == 56013_KING_JOE then
    A = -1
  end
  if targetUser:DamageAlways1() then
    A = -1
  end
  return A
end