Formula

CommonFun.calcMonsterModelNpcAttrValue

function CommonFun.calcMonsterModelNpcAttrValue(npcid, npclevel, npctype, edps, ehp, groupid, diff, layer)
  local result = {}
  local data = Table_MonsterModel[npcid]
  if data == nil then
    return result
  end
  local hpnum = data.HpNum
  local dpsnum = data.DpsNum
  local def = data.Def
  local mdef = data.MDef
  local lv = npclevel
  local lvmodel = data.Level
  local lvincrease = 1
  edps = edps * dpsnum
  ehp = ehp * hpnum
  result[CommonFun.RoleData.EATTRTYPE_DAMREDUC] = 0
  result[CommonFun.RoleData.EATTRTYPE_MDAMREDUC] = 0
  result[CommonFun.RoleData.EATTRTYPE_DAMSPIKE] = 0
  result[CommonFun.RoleData.EATTRTYPE_MDAMSPIKE] = 0
  result[CommonFun.RoleData.EATTRTYPE_IgnoreDef] = 0
  result[CommonFun.RoleData.EATTRTYPE_IGNOREMDEF] = 0
  result[CommonFun.RoleData.EATTRTYPE_REFINE] = 0
  result[CommonFun.RoleData.EATTRTYPE_MREFINE] = 0
  result[CommonFun.RoleData.EATTRTYPE_REFINEDAMREDUC] = 0
  result[CommonFun.RoleData.EATTRTYPE_REFINEMDAMREDUC] = 0
  if groupid == 22 then
    local lvPro
    local arrayAttr = {
      {
        0,
        0,
        0.05,
        0.1,
        0.15,
        0.5
      },
      {
        0.1,
        0.1,
        0.2,
        0.3,
        0.4,
        0.8
      },
      {
        0,
        0,
        0,
        0.1,
        0.2,
        0.6
      },
      {
        0,
        0,
        0.05,
        0.1,
        0.15,
        0.7
      }
    }
    lvPro = lv / 10 - 11
    result[CommonFun.RoleData.EATTRTYPE_DAMSPIKE] = arrayAttr[1][lvPro]
    result[CommonFun.RoleData.EATTRTYPE_MDAMSPIKE] = arrayAttr[1][lvPro]
    result[CommonFun.RoleData.EATTRTYPE_IgnoreDef] = arrayAttr[2][lvPro]
    result[CommonFun.RoleData.EATTRTYPE_IGNOREMDEF] = arrayAttr[2][lvPro]
    result[CommonFun.RoleData.EATTRTYPE_REFINEDAMREDUC] = arrayAttr[3][lvPro]
    result[CommonFun.RoleData.EATTRTYPE_REFINEMDAMREDUC] = arrayAttr[3][lvPro]
    result[CommonFun.RoleData.EATTRTYPE_DAMREDUC] = arrayAttr[4][lvPro]
    result[CommonFun.RoleData.EATTRTYPE_MDAMREDUC] = arrayAttr[4][lvPro]
  end
  if groupid == 30 then
    local diffPro
    local arrayAttr = {
      {
        200,
        200,
        200,
        500,
        500,
        500,
        1000,
        1000,
        1000,
        2000,
        2000,
        2000,
        4000,
        4000,
        4000,
        1000,
        1000,
        1000,
        2000,
        2000,
        2000,
        4000,
        4000,
        4000,
        5000,
        5000,
        5000,
        7500,
        7500,
        7500
      },
      {
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0.1,
        0.1,
        0.1,
        0.2,
        0.2,
        0.2
      },
      {
        0,
        0,
        0,
        0.1,
        0.1,
        0.1,
        0.2,
        0.2,
        0.2,
        0.5,
        0.5,
        0.5,
        0.8,
        0.8,
        0.8,
        0.2,
        0.2,
        0.2,
        0.5,
        0.5,
        0.5,
        0.8,
        0.8,
        0.8,
        1,
        1,
        1,
        1.5,
        1.5,
        1.5
      },
      {
        0,
        0,
        0,
        0.1,
        0.1,
        0.1,
        0.2,
        0.2,
        0.2,
        0.4,
        0.4,
        0.4,
        0.5,
        0.5,
        0.5,
        0.2,
        0.2,
        0.2,
        0.4,
        0.4,
        0.4,
        0.5,
        0.5,
        0.5,
        0.7,
        0.7,
        0.7,
        1,
        1,
        1
      },
      {
        0,
        0,
        0,
        0.1,
        0.1,
        0.1,
        0.2,
        0.2,
        0.2,
        0.4,
        0.4,
        0.4,
        0.5,
        0.5,
        0.5,
        0.2,
        0.2,
        0.2,
        0.4,
        0.4,
        0.4,
        0.5,
        0.5,
        0.5,
        0.6,
        0.6,
        0.6,
        0.8,
        0.8,
        0.8
      },
      {
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0.1,
        0.1,
        0.1,
        0.2,
        0.2,
        0.2
      },
      {
        0,
        0,
        0,
        0.1,
        0.1,
        0.1,
        0.2,
        0.2,
        0.2,
        0.3,
        0.3,
        0.3,
        0.4,
        0.4,
        0.4,
        0.2,
        0.2,
        0.2,
        0.3,
        0.3,
        0.3,
        0.4,
        0.4,
        0.4,
        0.5,
        0.5,
        0.5,
        0.75,
        0.75,
        0.75
      },
      {
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0.1,
        0.1,
        0.1,
        0.2,
        0.2,
        0.2
      },
      {
        0,
        0,
        0,
        0.1,
        0.1,
        0.1,
        0.2,
        0.2,
        0.2,
        0.3,
        0.3,
        0.3,
        0.4,
        0.4,
        0.4,
        0.2,
        0.2,
        0.2,
        0.3,
        0.3,
        0.3,
        0.4,
        0.4,
        0.4,
        0.5,
        0.5,
        0.5,
        0.75,
        0.75,
        0.75
      },
      {
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0,
        0.1,
        0.1,
        0.1,
        0.2,
        0.2,
        0.2
      },
      {
        10,
        10,
        10,
        10,
        10,
        10,
        20,
        20,
        20,
        30,
        30,
        30,
        40,
        40,
        40,
        20,
        20,
        20,
        30,
        30,
        30,
        40,
        40,
        40,
        50,
        50,
        50,
        75,
        75,
        75
      },
      {
        0.25,
        0.25,
        0.25,
        0.25,
        0.25,
        0.25,
        0.5,
        0.5,
        0.5,
        1,
        1,
        1,
        2,
        2,
        2,
        0.5,
        0.5,
        0.5,
        1,
        1,
        1,
        2,
        2,
        2,
        3,
        3,
        3,
        4,
        4,
        4
      },
      {
        800,
        900,
        1100,
        1200,
        1300,
        1800,
        2300,
        2700,
        3400,
        3900,
        4700,
        5500,
        8200,
        12400,
        18500,
        1300,
        1600,
        2300,
        2500,
        3100,
        4400,
        4700,
        5800,
        7300,
        7800,
        9900,
        12800,
        14700,
        17700,
        21200
      },
      {
        400,
        500,
        600,
        600,
        700,
        900,
        1100,
        1400,
        1700,
        2000,
        2400,
        2700,
        4100,
        6200,
        9300,
        700,
        800,
        1100,
        1200,
        1600,
        2200,
        2400,
        2900,
        3700,
        3900,
        5000,
        6400,
        7400,
        8800,
        10600
      },
      {
        600,
        675,
        825,
        900,
        975,
        1350,
        1725,
        2025,
        2550,
        2925,
        3525,
        4125,
        6150,
        9300,
        13875,
        975,
        1200,
        1725,
        1875,
        2325,
        3300,
        3525,
        4350,
        5475,
        5850,
        7425,
        9600,
        11025,
        13275,
        15900
      },
      {
        300,
        375,
        450,
        450,
        525,
        675,
        825,
        1050,
        1275,
        1500,
        1800,
        2025,
        3075,
        4650,
        6975,
        525,
        600,
        825,
        900,
        1200,
        1650,
        1800,
        2175,
        2775,
        2925,
        3750,
        4800,
        5550,
        6600,
        7950
      },
      {
        500,
        562,
        687,
        750,
        812,
        1125,
        1437,
        1687,
        2125,
        2437,
        2937,
        3437,
        5125,
        7750,
        11562,
        812,
        1000,
        1437,
        1562,
        1937,
        2750,
        2937,
        3625,
        4562,
        4875,
        6187,
        8000,
        9187,
        11062,
        13250
      },
      {
        250,
        312,
        375,
        375,
        437,
        562,
        687,
        875,
        1062,
        1250,
        1500,
        1687,
        2562,
        3875,
        5812,
        437,
        500,
        687,
        750,
        1000,
        1375,
        1500,
        1812,
        2312,
        2437,
        3125,
        4000,
        4625,
        5500,
        6625
      }
    }
    diffPro = math.floor(diff % 10000 + diff / 10000 * 15)
    result[CommonFun.RoleData.EATTRTYPE_REFINE] = arrayAttr[1][diffPro]
    result[CommonFun.RoleData.EATTRTYPE_MREFINE] = arrayAttr[1][diffPro]
    result[CommonFun.RoleData.EATTRTYPE_REFINEDAMREDUC] = arrayAttr[2][diffPro]
    result[CommonFun.RoleData.EATTRTYPE_REFINEMDAMREDUC] = arrayAttr[2][diffPro]
    result[CommonFun.RoleData.EATTRTYPE_IgnoreDef] = arrayAttr[3][diffPro]
    result[CommonFun.RoleData.EATTRTYPE_IGNOREMDEF] = arrayAttr[3][diffPro]
    result[CommonFun.RoleData.EATTRTYPE_DEFPER] = arrayAttr[4][diffPro]
    result[CommonFun.RoleData.EATTRTYPE_MDEFPER] = arrayAttr[4][diffPro]
    result[CommonFun.RoleData.EATTRTYPE_DAMSPIKE] = arrayAttr[5][diffPro]
    result[CommonFun.RoleData.EATTRTYPE_MDAMSPIKE] = arrayAttr[5][diffPro]
    result[CommonFun.RoleData.EATTRTYPE_DAMREDUC] = arrayAttr[6][diffPro]
    result[CommonFun.RoleData.EATTRTYPE_MDAMREDUC] = arrayAttr[6][diffPro]
    result[CommonFun.RoleData.EATTRTYPE_NORMALATKDAM] = arrayAttr[7][diffPro]
    result[CommonFun.RoleData.EATTRTYPE_SKILLDAM] = arrayAttr[7][diffPro]
    result[CommonFun.RoleData.EATTRTYPE_NORMALATKRES] = arrayAttr[8][diffPro]
    result[CommonFun.RoleData.EATTRTYPE_SKILLRES] = arrayAttr[8][diffPro]
    result[CommonFun.RoleData.EATTRTYPE_WINDATK] = arrayAttr[9][diffPro]
    result[CommonFun.RoleData.EATTRTYPE_EARTHATK] = arrayAttr[9][diffPro]
    result[CommonFun.RoleData.EATTRTYPE_WATERATK] = arrayAttr[9][diffPro]
    result[CommonFun.RoleData.EATTRTYPE_FIREATK] = arrayAttr[9][diffPro]
    result[CommonFun.RoleData.EATTRTYPE_NEUTRALATK] = arrayAttr[9][diffPro]
    result[CommonFun.RoleData.EATTRTYPE_HOLYATK] = arrayAttr[9][diffPro]
    result[CommonFun.RoleData.EATTRTYPE_DARKATK] = arrayAttr[9][diffPro]
    result[CommonFun.RoleData.EATTRTYPE_GHOSTATK] = arrayAttr[9][diffPro]
    result[CommonFun.RoleData.EATTRTYPE_UNDEADATK] = arrayAttr[9][diffPro]
    result[CommonFun.RoleData.EATTRTYPE_POISONINGATK] = arrayAttr[9][diffPro]
    result[CommonFun.RoleData.EATTRTYPE_BEWINDDAMPER] = arrayAttr[10][diffPro]
    result[CommonFun.RoleData.EATTRTYPE_BEEARTHDAMPER] = arrayAttr[10][diffPro]
    result[CommonFun.RoleData.EATTRTYPE_BEWATERDAMPER] = arrayAttr[10][diffPro]
    result[CommonFun.RoleData.EATTRTYPE_BEFIREDAMPER] = arrayAttr[10][diffPro]
    result[CommonFun.RoleData.EATTRTYPE_BENEUTRALDAMPER] = arrayAttr[10][diffPro]
    result[CommonFun.RoleData.EATTRTYPE_BEHOLYDAMPER] = arrayAttr[10][diffPro]
    result[CommonFun.RoleData.EATTRTYPE_BESHADOWDAMPER] = arrayAttr[10][diffPro]
    result[CommonFun.RoleData.EATTRTYPE_BEGHOSTDAMPER] = arrayAttr[10][diffPro]
    result[CommonFun.RoleData.EATTRTYPE_BEUNDEADDAMPER] = arrayAttr[10][diffPro]
    result[CommonFun.RoleData.EATTRTYPE_BEPOISONDAMPER] = arrayAttr[10][diffPro]
    result[CommonFun.RoleData.EATTRTYPE_CRI] = arrayAttr[11][diffPro]
    result[CommonFun.RoleData.EATTRTYPE_CRIRES] = arrayAttr[11][diffPro]
    result[CommonFun.RoleData.EATTRTYPE_CRIDAMPER] = arrayAttr[12][diffPro]
    if npctype == 4 then
      def = arrayAttr[15][diffPro]
      mdef = arrayAttr[16][diffPro]
    elseif npctype == 5 then
      def = arrayAttr[13][diffPro]
      mdef = arrayAttr[14][diffPro]
    else
      def = arrayAttr[17][diffPro]
      mdef = arrayAttr[18][diffPro]
    end
  end
  if groupid == 8 then
    if lv == 70 or lv == 90 or lv == 110 or lv == 130 or lv == 145 or lv == 155 or lv == 165 then
      lvincrease = 0.7
    else
    end
    edps = (12 * layer ^ 2 + 111 * layer + 440) * lvincrease * dpsnum
    result[CommonFun.RoleData.EATTRTYPE_DAMREDUC] = layer * 0.007
    result[CommonFun.RoleData.EATTRTYPE_MDAMREDUC] = layer * 0.007
    result[CommonFun.RoleData.EATTRTYPE_DAMSPIKE] = layer * 0.013
    result[CommonFun.RoleData.EATTRTYPE_MDAMSPIKE] = layer * 0.013
    result[CommonFun.RoleData.EATTRTYPE_IgnoreDef] = layer * 0.013
    result[CommonFun.RoleData.EATTRTYPE_IGNOREMDEF] = layer * 0.013
    result[CommonFun.RoleData.EATTRTYPE_REFINE] = math.floor(200 * layer) / 10
    result[CommonFun.RoleData.EATTRTYPE_MREFINE] = math.floor(200 * layer) / 10
    result[CommonFun.RoleData.EATTRTYPE_REFINEDAMREDUC] = layer * 0.013
    result[CommonFun.RoleData.EATTRTYPE_REFINEMDAMREDUC] = layer * 0.013
    if layer <= 10 then
      ehp = (400000.0 * layer - 300000.0) * lvincrease * hpnum
    else
      ehp = (41139 * layer ^ 2 - 556707 * layer + 5000000.0) * lvincrease * hpnum
    end
    if npctype == 4 then
      ehp = ehp * 5
    elseif npctype == 5 then
      ehp = ehp * 10
    end
  end
  local hit = data.Hit
  local flee = data.Flee
  local actHit = math.min(math.max(175 + lvmodel - (hit - 100), 5), 100)
  local actFlee = math.max(math.min(100 - (5 + flee - (125 + lvmodel)), 95), 0)
  local defRes = (4000 + def) / (4000 + def * 10)
  local mdefRes = (1000 + mdef) / (1000 + mdef * 10)
  local cri = data.Luk / 3 + lv / 3.8
  local aspd = 1 / data.AtkSpd
  local skillvalue = data.Skill
  local dps = math.min(edps * aspd / (1.5 * math.min(cri, 100) / 100 + (1 - math.min(cri, 100) / 100)), edps / skillvalue)
  if groupid == 30 then
    result[CommonFun.RoleData.EATTRTYPE_MAXHP] = ehp
    result[CommonFun.RoleData.EATTRTYPE_ATK] = edps
    result[CommonFun.RoleData.EATTRTYPE_MATK] = edps
  else
    result[CommonFun.RoleData.EATTRTYPE_MAXHP] = math.max(ehp * math.max(defRes, mdefRes), 1)
    result[CommonFun.RoleData.EATTRTYPE_ATK] = math.max(dps, 0)
    result[CommonFun.RoleData.EATTRTYPE_MATK] = math.max(dps, 0)
  end
  result[CommonFun.RoleData.EATTRTYPE_HIT] = 20 - actFlee + 3.8 * lv
  result[CommonFun.RoleData.EATTRTYPE_FLEE] = 80 - actHit + 1.8 * lv
  result[CommonFun.RoleData.EATTRTYPE_DEF] = def
  result[CommonFun.RoleData.EATTRTYPE_MDEF] = mdef
  result[CommonFun.RoleData.EATTRTYPE_CRI] = cri
  result[CommonFun.RoleData.EATTRTYPE_CRIRES] = math.max(lv / 6 - data.Luk / 5, 0)
  result[CommonFun.RoleData.EATTRTYPE_ATKSPD] = 1 / data.AtkSpd
  result[CommonFun.RoleData.EATTRTYPE_STR] = data.Str
  result[CommonFun.RoleData.EATTRTYPE_DEX] = data.Dex
  result[CommonFun.RoleData.EATTRTYPE_INT] = data.Int
  result[CommonFun.RoleData.EATTRTYPE_VIT] = data.Vit
  result[CommonFun.RoleData.EATTRTYPE_AGI] = data.Agi
  result[CommonFun.RoleData.EATTRTYPE_LUK] = data.Luk
  return result
end