🌟 | 現在、 鉄壁ヘッドショットには対応済みです。 鉄壁HSは通常HSと同じダメージになります。LMG及びDMR、チャージライフル、ハンマーポイント弾を除き、すべてのダメージ値が一致していることを確認しています。 |
「モジュール:DPSTable」の版間の差分
ナビゲーションに移動
検索に移動
(デフォルトのシールドプリセット設定を変更) |
(ヘッドショットに対する鉄壁倍率を無効化する機能を実装) |
||
73行目: | 73行目: | ||
return table.map(damages, function(key, damage) | return table.map(damages, function(key, damage) | ||
if aw.stringends(key, '_to') then | if aw.stringends(key, '_to') then | ||
return apex.calcPassiveDamage(damage, toperk, { round = opts.args.round }) | if opts.shld_to.sameHeadshotDamageToNormalOnFortified and aw.stringstarts(key, 'hed') then | ||
return damage | |||
else | |||
return apex.calcPassiveDamage(damage, toperk, { round = opts.args.round }) | |||
end | |||
else | else | ||
return apex.calcPassiveDamage(damage, fmperk, { round = opts.args.round }) | if opts.shld_fm.sameHeadshotDamageToNormalOnFortified and aw.stringstarts(key, 'hed') then | ||
return damage | |||
else | |||
return apex.calcPassiveDamage(damage, fmperk, { round = opts.args.round }) | |||
end | |||
end | end | ||
end) | end) | ||
83行目: | 91行目: | ||
return damage | return damage | ||
else | else | ||
return apex.calcPassiveDamage(damage, fmperk, { round = opts.args.round }) | if opts.shld_fm.sameHeadshotDamageToNormalOnFortified and aw.stringstarts(key, 'hed') then | ||
return damage | |||
else | |||
return apex.calcPassiveDamage(damage, fmperk, { round = opts.args.round }) | |||
end | |||
end | end | ||
end) | end) | ||
90行目: | 102行目: | ||
return table.map(damages, function(key, damage) | return table.map(damages, function(key, damage) | ||
if aw.stringends(key, '_to') then | if aw.stringends(key, '_to') then | ||
return apex.calcPassiveDamage(damage, toperk, { round = opts.args.round }) | if opts.shld_to.sameHeadshotDamageToNormalOnFortified and aw.stringstarts(key, 'hed') then | ||
return damage | |||
else | |||
return apex.calcPassiveDamage(damage, toperk, { round = opts.args.round }) | |||
end | |||
else | else | ||
return damage | return damage |
2022年5月11日 (水) 13:42時点における版
このモジュールについての説明文ページを モジュール:DPSTable/doc に作成できます
local p = {} local cfg = mw.loadData('Module:DPSTable/configuration') local aw = require('Module:Utility/Library') local apex = require('Module:Utility/ApexLibrary') local iu = require('Module:Utility/Image') local Shield = require('Module:Stat/Shield') local table = require('Module:TableExtensions') local getArgs -- lazily initialized -- Define values local fromtoValues = { damage = 20, firerate = 10, pellets = 1, head = 2, legs = 0.75, } local fromtoStringValues = { shieldpreset = 'reinforcehelmets', } local booleanValues = { round = false, } local stringValues = { lang = 'ja', } -- Calc the scales local function calcScales(opts) local ret = { hed0_fm = opts.args.head_from, hed1_fm = opts.shld_fm.helmets.level1.func(opts.args.head_from), hed2_fm = opts.shld_fm.helmets.level2.func(opts.args.head_from), hed3_fm = opts.shld_fm.helmets.level3.func(opts.args.head_from), body_fm = 1, legs_fm = opts.args.legs_from, hed0_to = opts.args.head_to, hed1_to = opts.shld_to.helmets.level1.func(opts.args.head_to), hed2_to = opts.shld_to.helmets.level2.func(opts.args.head_to), hed3_to = opts.shld_to.helmets.level3.func(opts.args.head_to), body_to = 1, legs_to = opts.args.legs_to, } return ret end -- Calc the damages local function calcBaseDamages(scales, opts) local ret = { hed0_fm = apex.calcPartDamage(opts.args.damage_from, scales.hed0_fm), hed1_fm = apex.calcPartDamage(opts.args.damage_from, scales.hed1_fm), hed2_fm = apex.calcPartDamage(opts.args.damage_from, scales.hed2_fm), hed3_fm = apex.calcPartDamage(opts.args.damage_from, scales.hed3_fm), body_fm = opts.args.damage_from, legs_fm = apex.calcPartDamage(opts.args.damage_from, scales.legs_fm), hed0_to = apex.calcPartDamage(opts.args.damage_to, scales.hed0_to), hed1_to = apex.calcPartDamage(opts.args.damage_to, scales.hed1_to), hed2_to = apex.calcPartDamage(opts.args.damage_to, scales.hed2_to), hed3_to = apex.calcPartDamage(opts.args.damage_to, scales.hed3_to), body_to = opts.args.damage_to, legs_to = apex.calcPartDamage(opts.args.damage_to, scales.legs_to), } return ret end -- Apply perk scale to base damage as DPS local function applyPerkToDamages(damages, fmperk, toperk, opts) if fmperk ~= 1 then if toperk ~= 1 then return table.map(damages, function(key, damage) if aw.stringends(key, '_to') then if opts.shld_to.sameHeadshotDamageToNormalOnFortified and aw.stringstarts(key, 'hed') then return damage else return apex.calcPassiveDamage(damage, toperk, { round = opts.args.round }) end else if opts.shld_fm.sameHeadshotDamageToNormalOnFortified and aw.stringstarts(key, 'hed') then return damage else return apex.calcPassiveDamage(damage, fmperk, { round = opts.args.round }) end end end) else return table.map(damages, function(key, damage) if aw.stringends(key, '_to') then return damage else if opts.shld_fm.sameHeadshotDamageToNormalOnFortified and aw.stringstarts(key, 'hed') then return damage else return apex.calcPassiveDamage(damage, fmperk, { round = opts.args.round }) end end end) end elseif toperk ~= 1 then return table.map(damages, function(key, damage) if aw.stringends(key, '_to') then if opts.shld_to.sameHeadshotDamageToNormalOnFortified and aw.stringstarts(key, 'hed') then return damage else return apex.calcPassiveDamage(damage, toperk, { round = opts.args.round }) end else return damage end end) else return damages end end -- Calc DPSs local function calcDPSs(damages, opts) return table.map(damages, function(key, damage) if aw.stringends(key, '_to') then return damage * opts.args.firerate_to * opts.args.pellets_to else return damage * opts.args.firerate_from * opts.args.pellets_from end end) end -- Render the cell node base local function getRenderCellFunction(tag, prefix) return function(row, suffix, fmval, toval, opts, colspan) colspan = colspan or 1 local text if fmval ~= toval then if fmval <= 0 then local key = string.format('%s_ft%s_lastonly', prefix, suffix) text = string.format(opts.cfg[key], toval) elseif toval <= 0 then local key = string.format('%s_ft%s_firstonly', prefix, suffix) text = string.format(opts.cfg[key], fmval) else local key = string.format('%s_ft%s', prefix, suffix) text = string.format(opts.cfg[key], fmval, toval) end else local key = prefix .. suffix text = string.format(opts.cfg[key], fmval) end local cell = row:tag(tag) if colspan > 1 then cell:attr('colspan', colspan) end cell:wikitext(text) end end -- Render the header cell node local renderHeaderCell = getRenderCellFunction('th', 'part') -- Render the header node local function renderHeaderRow(tbl, scales, opts) local header = tbl:tag('tr') :tag('th'):wikitext('DPS'):done() if not opts.shld_fm.helmets.level0.disabled or not opts.shld_to.helmets.level0.disabled then renderHeaderCell(header, '_head', scales.hed0_fm, scales.hed0_to, opts) end renderHeaderCell(header, '_head_lvl1', scales.hed1_fm, scales.hed1_to, opts) renderHeaderCell(header, '_head_lvl2', scales.hed2_fm, scales.hed2_to, opts) renderHeaderCell(header, '_head_lvl3', scales.hed3_fm, scales.hed3_to, opts) if opts.nolegs then header:tag('th'):wikitext(opts.cfg.part_bodylegs) else header:tag('th'):wikitext(opts.cfg.part_body) renderHeaderCell(header, '_legs', scales.legs_fm, scales.legs_to, opts) end end -- Render the cell node local renderCell = getRenderCellFunction('td', 'format') -- Render the row node local function renderRow(tbl, suffix, damages, fmperk, toperk, opts) local perkDamages = applyPerkToDamages(damages, fmperk, toperk, opts) if fmperk > 1 and opts.shld_fm.legAsBodyOnLowProfile then perkDamages.legs_fm = perkDamages.body_fm end if toperk > 1 and opts.shld_to.legAsBodyOnLowProfile then perkDamages.legs_to = perkDamages.body_to end local dps = calcDPSs(perkDamages, opts) local row = tbl:tag('tr') local name if fmperk ~= toperk then local key = string.format('perk_ft%s', suffix) name = string.format(opts.cfg[key], 100 * (fmperk - 1), 100 * (toperk - 1)) else local key = string.format('perk%s', suffix) name = string.format(opts.cfg[key], 100 * (fmperk - 1)) end row:tag('th'):wikitext(name) if opts.shld_fm.helmets.level0.disabled then if not opts.shld_to.helmets.level0.disabled then renderCell(row, '', -1, dps.hed0_to, opts) end elseif opts.shld_to.helmets.level0.disabled then renderCell(row, '', dps.hed0_fm, -1, opts) else renderCell(row, '', dps.hed0_fm, dps.hed0_to, opts) end renderCell(row, '_head_lvl1', dps.hed1_fm, dps.hed1_to, opts) renderCell(row, '_head_lvl2', dps.hed2_fm, dps.hed2_to, opts) renderCell(row, '_head_lvl3', dps.hed3_fm, dps.hed3_to, opts) if opts.nolegs then renderCell(row, '', dps.body_fm, dps.body_to, opts) elseif dps.body_fm == dps.legs_fm and dps.body_to == dps.legs_to then renderCell(row, '', dps.body_fm, dps.body_to, opts, 2) else renderCell(row, '', dps.body_fm, dps.body_to, opts) renderCell(row, '', dps.legs_fm, dps.legs_to, opts) end end -- Render the table function p.renderTable(opts) local scales = calcScales(opts) local damages = calcBaseDamages(scales, opts) local tbl = mw.html.create('table') :addClass('numbertable') :addClass('patchnotetable') :addClass('wikitable') -- Header renderHeaderRow(tbl, scales, opts) -- Normal renderRow(tbl, '_normal', damages, 1, 1, opts) -- Low Profile if opts.shld_fm.lowprofile > 1 or opts.shld_to.lowprofile > 1 then renderRow(tbl, '_lowprofile', damages, opts.shld_fm.lowprofile, opts.shld_to.lowprofile, opts) end -- Fortified if opts.shld_fm.fortified < 1 or opts.shld_to.fortified < 1 then renderRow(tbl, '_fortified', damages, opts.shld_fm.fortified, opts.shld_to.fortified, opts) end return tbl end function p._main(args) args = args or {} -- Fix arguments for key, value in pairs(fromtoValues) do local fromKey = key .. '_from' args[fromKey] = aw.getAsNumber(args[fromKey], aw.getAsNumber(args[key], value)) local toKey = key .. '_to' args[toKey] = aw.getAsNumber(args[toKey], aw.getAsNumber(args[key], value)) end for key, value in pairs(fromtoStringValues) do local fromKey = key .. '_from' args[fromKey] = args[fromKey] or args[key] or value local toKey = key .. '_to' args[toKey] = args[toKey] or args[key] or value end for key, value in pairs(booleanValues) do args[key] = aw.getAsBoolean(args[key], value) end for key, value in pairs(stringValues) do args[key] = args[key] or value end -- Load data local opts = { args = args, cfg = cfg[args.lang], shld_fm = Shield[args.shieldpreset_from], shld_to = Shield[args.shieldpreset_to], nolegs = not (args.legs_from > 0 and args.legs_from < 1 and args.legs_to > 0 and args.legs_to < 1), } -- Render the table node local node = p.renderTable(opts) 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, frame) end return p