🌟 | 現在、 鉄壁ヘッドショットには対応済みです。 鉄壁HSは通常HSと同じダメージになります。LMG及びDMR、チャージライフル、ハンマーポイント弾を除き、すべてのダメージ値が一致していることを確認しています。 |
モジュール:StatTable/DamagePerSecond
ナビゲーションに移動
検索に移動
このモジュールについての説明文ページを モジュール:StatTable/DamagePerSecond/doc に作成できます
local aw = require('Module:Utility/Library') local apex = require('Module:Utility/ApexLibrary') local iu = require('Module:Utility/Image') local tableutil = require('Module:Utility/TableUtil/Apex') local Hopup = mw.loadData('Module:Stat/Hopup') local configuration = mw.loadData('Module:StatTable/configuration') local getArgs -- lazily initialized local function _addData(dataset, data, firerate, fn) local head = data.head local lvl1 = apex.calcHeadshotMultiplier(head, apex.HEAD_HLMLV1) local lvl2 = apex.calcHeadshotMultiplier(head, apex.HEAD_HLMLV2) local lvl3 = apex.calcHeadshotMultiplier(head, apex.HEAD_HLMLV3) local legs = data.legs local mul = firerate * data.pellets data.bodyDPS = fn(data.damage, 1, 1) * mul data.headDPS = fn(apex.calcPartDamage(data.damage, head), head, 1) * mul data.lvl1DPS = fn(apex.calcPartDamage(data.damage, lvl1), lvl1, 1) * mul data.lvl2DPS = fn(apex.calcPartDamage(data.damage, lvl2), lvl2, 1) * mul data.lvl3DPS = fn(apex.calcPartDamage(data.damage, lvl3), lvl3, 1) * mul data.legsDPS = fn(apex.calcPartDamage(data.damage, legs), legs, 1) * mul data.flL1DPS = fn(apex.calcDamageFromPartAndPassive(data.damage, lvl1, 0.85), lvl1, 0.85) * mul data.flLgDPS = fn(apex.calcDamageFromPartAndPassive(data.damage, legs, 0.85), legs, 0.85) * mul table.insert(dataset, data) end local function addData(dataset, data, special, fn) fn = fn or function(val) return val end local fireratesType = type(data.firerates) -- ファイアレートが可変 if fireratesType == 'table' then if special then _addData(dataset, data, data.firerates[4], fn) else for level, firerate in ipairs(data.firerates) do local data2 = aw.shallowCopy(data) data2.level = level - 1 _addData(dataset, data2, firerate, fn) end end -- ファイアレートが固定 elseif fireratesType == 'number' then _addData(dataset, data, data.firerates, fn) end end local function getDataAsCharge(baseData, stat, root, additional, level) local charge = (stat.charge or root.charge) * (level - 1) / (root.charge_levels - 1) local firerate = stat.firerate or root.firerate local fullcharge = level == root.charge_levels local chargeData = aw.shallowCopy(baseData) if fullcharge and stat.damage.charged then chargeData.damage = stat.damage.charged end if type(additional) == 'table' then chargeData.firerates = { apex.calcRechamberFirerate(firerate, charge + additional[1]), apex.calcRechamberFirerate(firerate, charge + additional[2]), apex.calcRechamberFirerate(firerate, charge + additional[3]), apex.calcRechamberFirerate(firerate, charge + additional[4]), } else chargeData.firerates = apex.calcRechamberFirerate(firerate, charge + additional) end if fullcharge and stat.damage.headshot_charged then chargeData.head = stat.damage.headshot_charged end if fullcharge and stat.damage.legshot_charged then chargeData.legs = stat.damage.legshot_charged end return chargeData end local function createDataset(dataset, stats, res, addData, __debug) for name, stat in pairs(stats) do local baseData = { ammo = stat.ammo, ammoicon = stat.ammo, damage = stat.damage.base, firerates = stat.firerate, head = stat.damage.headshot, legs = stat.damage.legshot, level = -1, name = name, pellets = stat.pellet or 1, shortname = stat.localization['Japanese_Short'], } local special = aw.stringstarts(stat.ammo, 'special_') -- Altfire mode if type(stat.altfire) == 'table' and aw.isNumberAndGreaterThanZero(stat.altfire.firerate) then local burstfireData = aw.shallowCopy(baseData) burstfireData.firerates = apex.calcBurstAverageFirerate(stat.burst_count, stat.burst_delay, stat.firerate) burstfireData.option = res.burst addData(dataset, burstfireData, special) local altfireData = aw.shallowCopy(baseData) altfireData.firerates = stat.altfire.firerate altfireData.semiauto = stat.altfire.is_semi_auto == nil and stat.is_semi_auto or stat.altfire.is_semi_auto altfireData.option = altfireData.semiauto and res.single or res.auto addData(dataset, altfireData, special) -- Burst mode elseif aw.isNumberAndGreaterThanOrEqualToX(stat.burst_count, 2) then local burstfireData = aw.shallowCopy(baseData) burstfireData.firerates = apex.calcBurstAverageFirerate(stat.burst_count, stat.burst_delay, stat.firerate) addData(dataset, burstfireData, special) -- Rechamber fire elseif type(stat.rechamber) == 'table' then baseData.firerates = { apex.calcRechamberFirerate(stat.firerate, stat.rechamber[1]), apex.calcRechamberFirerate(stat.firerate, stat.rechamber[2]), apex.calcRechamberFirerate(stat.firerate, stat.rechamber[3]), apex.calcRechamberFirerate(stat.firerate, stat.rechamber[4]), } -- Chargefire if aw.isNumberAndGreaterThanZero(stat.charge) then baseData.option = res.nocharge addData(dataset, baseData, special) if stat.charge_levels == 2 then local maxData = getDataAsCharge(baseData, stat, stat, stat.rechamber, 2) maxData.option = res.maxcharge addData(dataset, maxData, special) else for lvl = 2, stat.charge_levels do local chargeData = getDataAsCharge(baseData, stat, stat, stat.rechamber, lvl) chargeData.option = aw.getQuantityString(res.charges, lvl - 1) addData(dataset, chargeData, special) end end else addData(dataset, baseData, special) end elseif aw.isNumberAndGreaterThanZero(stat.rechamber) then -- Chargefire if aw.isNumberAndGreaterThanOrEqualToX(stat.charge_levels, 2) and aw.isNumberAndGreaterThanZero(stat.charge) then if aw.isNumberAndGreaterThanZero(stat.charge_minimum) then baseData.firerates = apex.calcRechamberFirerate(stat.firerate, stat.rechamber + stat.charge_minimum) baseData.option = res.mincharge else baseData.firerates = apex.calcRechamberFirerate(stat.firerate, stat.rechamber) baseData.option = res.nocharge end addData(dataset, baseData, special) local maxData = getDataAsCharge(baseData, stat, stat, stat.rechamber, stat.charge_levels) maxData.option = res.maxcharge addData(dataset, maxData, special) -- Amped mode elseif aw.isNumberAndGreaterThanX(stat.damage.amped, stat.damage.base) then baseData.firerates = apex.calcRechamberFirerate(stat.firerate, stat.rechamber) addData(dataset, baseData, special) local ampedData = aw.shallowCopy(baseData) ampedData.ammoicon = stat.ammo .. '_amped' ampedData.damage = stat.damage.amped ampedData.option = iu.item('シールドセル') .. ' <span class="text-desktoponly">増幅モード</span>' addData(dataset, ampedData) else baseData.firerates = apex.calcRechamberFirerate(stat.firerate, stat.rechamber) addData(dataset, baseData, special) end -- Chargefire elseif aw.isNumberAndGreaterThanOrEqualToX(stat.charge_levels, 2) and aw.isNumberAndGreaterThanZero(stat.charge) then if aw.isNumberAndGreaterThanZero(stat.charge_minimum) then baseData.firerates = apex.calcRechamberFirerate(stat.firerate, stat.charge_minimum) baseData.option = res.mincharge else baseData.option = res.nocharge end addData(dataset, baseData, special) if stat.charge_levels == 2 or stat.charge_levels > 4 then local maxData = getDataAsCharge(baseData, stat, stat, 0, stat.charge_levels) maxData.option = res.maxcharge addData(dataset, maxData, special) else for lvl = 2, stat.charge_levels do local chargeData = getDataAsCharge(baseData, stat, stat, 0, lvl) chargeData.option = aw.getQuantityString(res.charges, lvl - 1) addData(dataset, chargeData, special) end end -- Charge Rifle elseif aw.isNumberAndGreaterThanZero(stat.sustained_discharge_duration) then baseData.firerates = apex.calcRechamberFirerate(stat.firerate, stat.sustained_discharge_duration) addData(dataset, baseData, special, function(val, part, passive) return val + apex.calcDamageFromPartAndPassive(stat.damage.beam.base, part, passive) * stat.damage.beam.ticks end) -- Other else addData(dataset, baseData, special) end -- Revved Up mode if aw.isNumberAndGreaterThanOrEqualToX(stat.firerate_revvedup, stat.firerate) then local revvedUpData = aw.shallowCopy(baseData) revvedUpData.ammoicon = stat.ammo .. '_revved_up' revvedUpData.firerates = stat.firerate_revvedup revvedUpData.option = iu.grenade('テルミットグレネード') .. ' <span class="text-desktoponly">連射速度上昇モード</span>' addData(dataset, revvedUpData, special) end -- Turbocharger --[[if (__debug or Hopup.turbocharger.enabled) and type(stat.turbocharger) == 'table' and aw.isNumberAndGreaterThanZero(stat.turbocharger.raise) then local turbochargerData = aw.shallowCopy(baseData) turbochargerData.hopup = { 'turbocharger' } turbochargerData.raise = stat.turbocharger.raise or stat.raise or 0 addData(dataset, turbochargerData, special) end]] -- Selectfire Receiver if (__debug or Hopup.selectfire_receiver.enabled) and type(stat.selectfire_receiver) == 'table' and aw.isNumberAndGreaterThanZero(stat.selectfire_receiver.firerate) then local semiauto if stat.selectfire_receiver.is_semi_auto then semiauto = stat.selectfire_receiver.is_semi_auto else semiauto = stat.is_semi_auto end local firerate if semiauto then local raiseTime = stat.selectfire_receiver.raise or stat.raise or 0 if raiseTime > 0 then firerate = apex.calcRechamberFirerate(stat.selectfire_receiver.firerate, raiseTime) else firerate = stat.selectfire_receiver.firerate end else firerate = stat.selectfire_receiver.firerate end local selectfireReceiverData = aw.shallowCopy(baseData) selectfireReceiverData.firerates = firerate selectfireReceiverData.hopup = { 'selectfire_receiver' } if stat.selectfire_receiver.damage then selectfireReceiverData.damage = stat.selectfire_receiver.damage.base or stat.damage.base selectfireReceiverData.head = stat.selectfire_receiver.damage.headshot or stat.damage.headshot selectfireReceiverData.legs = stat.selectfire_receiver.damage.legshot or stat.damage.legshot end addData(dataset, selectfireReceiverData, special) end -- Hammerpoint Rounds if (__debug or Hopup.hammerpoint_rounds.enabled) and aw.isNumberAndGreaterThanX(stat.damage.hammerpoint_rounds, 1) then local hammerpointRoundsData = aw.shallowCopy(baseData) hammerpointRoundsData.damage = math.floor(stat.damage.hammerpoint_rounds * stat.damage.base) hammerpointRoundsData.hopup = { 'hammerpoint_rounds' } addData(dataset, hammerpointRoundsData, special) end -- Disruptor Rounds if (__debug or Hopup.disruptor_rounds.enabled or special) and aw.isNumberAndGreaterThanX(stat.damage.disruptor_rounds, 1) then local disruptorRoundsData = aw.shallowCopy(baseData) disruptorRoundsData.hopup = { 'disruptor_rounds' } addData(dataset, disruptorRoundsData, special, function(val) return apex.calcDisruptorDamage(val, stat.damage.disruptor_rounds) end) end -- Anvil Receiver if (__debug or Hopup.anvil_receiver.enabled) and type(stat.anvil_receiver) == 'table' and aw.isNumberAndGreaterThanZero(stat.anvil_receiver.firerate) then local anvilReceiverData = aw.shallowCopy(baseData) anvilReceiverData.damage = stat.anvil_receiver.damage.base anvilReceiverData.firerates = stat.anvil_receiver.firerate if stat.anvil_receiver.damage.headshot then anvilReceiverData.head = stat.anvil_receiver.damage.headshot end anvilReceiverData.hopup = { 'anvil_receiver' } if stat.anvil_receiver.damage.legshot then anvilReceiverData.legs = stat.anvil_receiver.damage.legshot end addData(dataset, anvilReceiverData, special) end -- Double Tap Trigger if (__debug or Hopup.double_tap_trigger.enabled) and type(stat.double_tap_trigger) == 'table' and aw.isNumberAndGreaterThanOrEqualToX(stat.double_tap_trigger.burst_count, 2) then local doubleTapTriggerData = aw.shallowCopy(baseData) local delay = stat.double_tap_trigger.burst_delay if type(delay) == 'table' then doubleTapTriggerData.firerates = { apex.calcBurstAverageFirerate(stat.double_tap_trigger.burst_count, delay[1], stat.double_tap_trigger.firerate), apex.calcBurstAverageFirerate(stat.double_tap_trigger.burst_count, delay[2], stat.double_tap_trigger.firerate), apex.calcBurstAverageFirerate(stat.double_tap_trigger.burst_count, delay[3], stat.double_tap_trigger.firerate), apex.calcBurstAverageFirerate(stat.double_tap_trigger.burst_count, delay[4], stat.double_tap_trigger.firerate), } else doubleTapTriggerData.firerates = apex.calcBurstAverageFirerate(stat.double_tap_trigger.burst_count, delay, stat.double_tap_trigger.firerate) end doubleTapTriggerData.hopup = { 'double_tap_trigger' } addData(dataset, doubleTapTriggerData, special) end -- Shatter Caps if (__debug or Hopup.shatter_caps.enabled) and type(stat.shatter_caps) == 'table' and aw.isNumberAndGreaterThanX(stat.shatter_caps.damage.base, 1) and aw.isNumberAndGreaterThanX(stat.shatter_caps.pellet, 1) then local shatterCapsData = aw.shallowCopy(baseData) shatterCapsData.damage = stat.shatter_caps.damage.base if stat.shatter_caps.damage.headshot then shatterCapsData.head = stat.shatter_caps.damage.headshot end shatterCapsData.hopup = { 'shatter_caps' } if stat.shatter_caps.damage.legshot then shatterCapsData.legs = stat.shatter_caps.damage.legshot end shatterCapsData.pellets = stat.shatter_caps.pellet -- Chargefire if aw.isNumberAndGreaterThanOrEqualToX(stat.charge_levels, 2) and aw.isNumberAndGreaterThanZero(stat.charge) then if aw.isNumberAndGreaterThanZero(stat.charge_minimum) then shatterCapsData.firerates = apex.calcRechamberFirerate(stat.firerate, stat.charge_minimum) shatterCapsData.option = res.mincharge else shatterCapsData.option = res.nocharge end addData(dataset, shatterCapsData) local maxShatterCapsData = getDataAsCharge(shatterCapsData, stat.shatter_caps, stat, stat.rechamber or 0, stat.charge_levels) maxShatterCapsData.option = res.maxcharge addData(dataset, maxShatterCapsData) else addData(dataset, shatterCapsData) end -- Deadeye's Tempo if (__debug or Hopup.deadeyes_tempo.enabled) and type(stat.deadeyes_tempo) == 'table' then local deadeyesTempoShatterCapsData = aw.shallowCopy(shatterCapsData) if aw.isNumberAndGreaterThanZero(stat.deadeyes_tempo.charge_minimum) then deadeyesTempoShatterCapsData.firerates = apex.calcRechamberFirerate(stat.firerate, stat.deadeyes_tempo.charge_minimum) elseif aw.isNumberAndGreaterThanZero(stat.deadeyes_tempo.rechamber) then deadeyesTempoShatterCapsData.firerates = apex.calcRechamberFirerate(stat.firerate, stat.deadeyes_tempo.rechamber) end deadeyesTempoShatterCapsData.hopup = { 'shatter_caps', 'deadeyes_tempo' } -- Chargefire if aw.isNumberAndGreaterThanOrEqualToX(stat.charge_levels, 2) and aw.isNumberAndGreaterThanZero(stat.charge) and aw.isNumberAndGreaterThanX(stat.shatter_caps.damage.charged, stat.shatter_caps.damage.base) then deadeyesTempoShatterCapsData.option = res.mincharge addData(dataset, deadeyesTempoShatterCapsData) local maxDeadeyesTempoShatterCapsData = getDataAsCharge(deadeyesTempoShatterCapsData, stat.shatter_caps, stat, stat.deadeyes_tempo.charge, stat.charge_levels) maxDeadeyesTempoShatterCapsData.option = res.maxcharge addData(dataset, maxDeadeyesTempoShatterCapsData) else addData(dataset, deadeyesTempoShatterCapsData) end end end -- Deadeye's Tempo if (__debug or Hopup.deadeyes_tempo.enabled) and type(stat.deadeyes_tempo) == 'table' then local deadeyesTempoData = aw.shallowCopy(baseData) if aw.isNumberAndGreaterThanZero(stat.deadeyes_tempo.charge_minimum) then deadeyesTempoData.firerates = apex.calcRechamberFirerate(stat.firerate, stat.deadeyes_tempo.charge_minimum) elseif aw.isNumberAndGreaterThanZero(stat.deadeyes_tempo.rechamber) then deadeyesTempoData.firerates = apex.calcRechamberFirerate(stat.firerate, stat.deadeyes_tempo.rechamber) end deadeyesTempoData.hopup = { 'deadeyes_tempo' } -- Chargefire if aw.isNumberAndGreaterThanOrEqualToX(stat.charge_levels, 2) and aw.isNumberAndGreaterThanZero(stat.deadeyes_tempo.charge) and aw.isNumberAndGreaterThanX(stat.damage.charged, stat.damage.base) then deadeyesTempoData.option = res.mincharge addData(dataset, deadeyesTempoData) local maxDeadeyesTempoData = getDataAsCharge(deadeyesTempoData, stat, stat, stat.deadeyes_tempo.charge, stat.charge_levels) maxDeadeyesTempoData.option = res.maxcharge addData(dataset, maxDeadeyesTempoData) else addData(dataset, deadeyesTempoData, special) end -- Amped mode if aw.isNumberAndGreaterThanX(stat.damage.amped, stat.damage.base) then local ampedDeadeyesTempoData = aw.shallowCopy(deadeyesTempoData) ampedDeadeyesTempoData.ammoicon = stat.ammo .. '_amped' ampedDeadeyesTempoData.damage = stat.damage.amped ampedDeadeyesTempoData.option = iu.item('シールドセル') .. ' <span class="text-desktoponly">増幅モード</span>' addData(dataset, ampedDeadeyesTempoData) end end end end local p = {} function p._main(args, __debug) args = args or {} if __debug == nil then __debug = true end local lang = args.lang or 'ja' local res = configuration[lang] local stats = mw.loadData('Module:Stat/Weapon') local dataset = {} createDataset(dataset, stats, res, addData, __debug) local formatFunction = function(dps) return string.format('%.1f', dps) end local metadata = { tableutil.RankCell.new('', 'bodyDPS', true), tableutil.AmmoCell.new('', 'ammoicon', { attributes = { align = 'center' }, cellClass = 'st-desktop', footerClass = 'st-desktop', headerClass = 'st-desktop', headerStyle = { width = '36px' }, }), tableutil.WeaponNameCell.new(res.weaponname, 'name', { ammoIndex = 'ammo', attributes = { align = 'left' }, cellClass = 'st-dashed-right st-mobile-none-right st-mobile-padding0-right', headerColspan = 3, optionIndex = 'option', shortnameIndex = 'shortname', }), tableutil.MagazineCell.new(res.mag, 'level', { ammoIndex = 'ammo', attributes = { align = 'left' }, cellClass = 'st-dashed-right st-mobile-none-right st-mobile-padding0-both', headerColspan = 0, }), tableutil.HopupCell.new(res.hopup, 'hopup', { attributes = { align = 'left' }, cellClass = 'st-mobile-padding0-both', headerColspan = 0, }), tableutil.ValueCell.new(res.legsshot, 'legsDPS', { cellClass = 'st-desktop', footerClass = 'st-desktop', format = formatFunction, headerClass = 'st-desktop', headerStyle = { ['min-width'] = '50px', ['max-width'] = '4em', }, }), tableutil.LineValueCell.new(res.bodyshot, 'bodyDPS', { startIndex = 'legsDPS', endIndex = 'lvl1DPS', subStartIndex = 'flLgDPS', subEndIndex = 'flL1DPS', cellClass = 'st-mobile-graph st-mobile-medium st-mobile-textshadow', footerClass = 'st-mobile-axis', format = formatFunction, headerStyle = { ['min-width'] = '50px', ['max-width'] = '4em', }, itemName = res.normal, subItemName = res.fortified, maximumValue = 400, preferredGridCount = 3, }), tableutil.ValueCell.new(res.headlvl3, 'lvl3DPS', { cellClass = 'st-desktop', footerClass = 'st-desktop', format = formatFunction, headerClass = 'st-desktop', headerStyle = { ['min-width'] = '50px', ['max-width'] = '4em', }, }), tableutil.ValueCell.new(res.headlvl2, 'lvl2DPS', { cellClass = 'st-desktop', footerClass = 'st-desktop', format = formatFunction, headerClass = 'st-desktop', headerStyle = { ['min-width'] = '50px', ['max-width'] = '4em', }, }), tableutil.ValueCell.new(res.headlvl1, 'lvl1DPS', { cellClass = 'st-mobile-last', footerClass = 'st-mobile-last', format = formatFunction, headerClass = 'st-mobile-last', headerStyle = { ['min-width'] = '50px', ['max-width'] = '4em', }, }), tableutil.LineCell.new(res.graph, 'bodyDPS', { startIndex = 'legsDPS', endIndex = 'lvl1DPS', subStartIndex = 'flLgDPS', subEndIndex = 'flL1DPS', cellClass = 'st-desktop st-desktop-graph', footerClass = 'st-desktop', headerClass = 'st-desktop', headerStyle = { ['min-width'] = '200px', }, hoverEnabled = true, hoverFormat = formatFunction, itemName = res.normal, subItemName = res.fortified, maximumValue = 500, }), } local node = tableutil.createTable(dataset, metadata) return tostring(node) end function p.main(frame) if not getArgs then getArgs = require('Module:Arguments').getArgs end args = getArgs(frame) return p._main(args, false) end return p