🌟 | 現在、 鉄壁ヘッドショットには対応済みです。 鉄壁HSは通常HSと同じダメージになります。LMG及びDMR、チャージライフル、ハンマーポイント弾を除き、すべてのダメージ値が一致していることを確認しています。 |
「モジュール:MultipleStatTable」の版間の差分
ナビゲーションに移動
検索に移動
(ブーステッドローダーに対応) |
(ブーステッドローダーの構造変更に対応) |
||
446行目: | 446行目: | ||
-- ブーステッドローダー (ヘムロックバーストAR) | -- ブーステッドローダー (ヘムロックバーストAR) | ||
if type(stat.boosted_loader) == 'table' then | if stat.boosted_loader ~= nil and type(stat.boosted_loader.magazine) == 'table' then | ||
local opts2 = aw.shallowCopy(opts) | local opts2 = aw.shallowCopy(opts) | ||
opts2.useBoostedLoader = true | opts2.useBoostedLoader = true | ||
458行目: | 458行目: | ||
-- ブーステッドローダー (ヘムロックバーストAR) | -- ブーステッドローダー (ヘムロックバーストAR) | ||
if type(stat.boosted_loader) == 'table' then | if stat.boosted_loader ~= nil and type(stat.boosted_loader.magazine) == 'table' then | ||
local opts2 = aw.shallowCopy(opts) | local opts2 = aw.shallowCopy(opts) | ||
opts2.useBoostedLoader = true | opts2.useBoostedLoader = true | ||
537行目: | 537行目: | ||
-- ブーステッドローダー (ウィングマン) | -- ブーステッドローダー (ウィングマン) | ||
if type(stat.boosted_loader) == 'table' then | if stat.boosted_loader ~= nil and type(stat.boosted_loader.magazine) == 'table' then | ||
local opts2 = aw.shallowCopy(opts) | local opts2 = aw.shallowCopy(opts) | ||
opts2.useBoostedLoader = true | opts2.useBoostedLoader = true |
2021年8月6日 (金) 14:37時点における版
このモジュールについての説明文ページを モジュール:MultipleStatTable/doc に作成できます
require('Module:Utility/mw.html Extensions') local p = {} local aw = require('Module:Utility/Library') local apex = require('Module:Utility/ApexLibrary') local iu = require('Module:Utility/Image') local nu = require('Module:Utility/Name') local inu = require('Module:Utility/ImageWithName') local formatter -- lazily initialized local getArgs -- lazily initialized -- [[ リソース キャッシュ ]] local cache = {} local function getModdedLoader() if cache.moddedLoader then return cache.moddedLoader end cache.moddedLoader = iu.passive('modded_loader') .. ' <span class="text-desktoponly">改造ローダー</span>' return cache.moddedLoader end local function getAmpedMode() if cache.ampedMode then return cache.ampedMode end cache.ampedMode = iu.item('シールドセル') .. ' <span class="text-desktoponly">増幅モード</span>' return cache.ampedMode end local function getHammerpointRounds() if cache.hammerpointRounds then return cache.hammerpointRounds end cache.hammerpointRounds = iu.hopup('hammerpoint_rounds') .. ' [[ホップアップによる武器一覧#ハンマーポイント弾|' .. formatter:epic('ハンマーポイント弾', 'text-desktoponly') .. ']]' return cache.hammerpointRounds end local function getShatterCaps() if cache.shatterCaps then return cache.shatterCaps end cache.shatterCaps = iu.hopup('shatter_caps') .. ' [[ホップアップによる武器一覧#シャッターキャップ|' .. formatter:epic('シャッターキャップ', 'text-desktoponly') .. ']]' return cache.shatterCaps end local function getAnvilReceiver() if cache.anvilReceiver then return cache.anvilReceiver end cache.anvilReceiver = iu.hopup('anvil_receiver') .. ' [[ホップアップによる武器一覧#アンビルレシーバー|' .. formatter:legendary('アンビルレシーバー', 'text-desktoponly') .. ']]' return cache.anvilReceiver end local function getTurbocharger() if cache.turbocharger then return cache.turbocharger end cache.turbocharger = iu.hopup('turbocharger') .. ' [[ホップアップによる武器一覧#ターボチャージャー|' .. formatter:legendary('ターボチャージャー', 'text-desktoponly') .. ']]' return cache.turbocharger end local function getBoostedLoader() if cache.boostedLoader then return cache.boostedLoader end cache.boostedLoader = iu.hopup('boosted_loader') .. ' [[ホップアップによる武器一覧#ブーステッドローダー|' .. formatter:legendary('ブーステッドローダー', 'text-desktoponly') .. ']]' return cache.boostedLoader end local function getCharged() if cache.charged then return cache.charged end cache.charged = iu.scope('スロット') .. ' <span class="text-desktoponly">フルチャージ</span>' return cache.charged end local function getMagazineLabel(ammo, level, force) if not force and level == 0 then return '' end if aw.stringstarts(ammo, 'special_') then ammo = string.sub(ammo, 9) end if not cache[ammo] then cache[ammo] = {} end if cache[ammo] and cache[ammo][1 + level] then return cache[ammo][1 + level] end if ammo == 'shotgun' then cache[ammo][1 + level] = inu.bolt(level, { desktopOnly = true }) else cache[ammo][1 + level] = inu.extmag(ammo, level, { desktopOnly = true }) end return cache[ammo][1 + level] end local getEmphasizableText = aw.getEmphasizableTextFunc('%s', '<span class="text-desktoponly">%s</span>', '<span class="text-desktoponly">%s</span>') local function getWeaponLink(name, ammo, shortname) local classSuffix = aw.stringstarts(ammo, 'special_') and 'special' or ammo local suitableName = getEmphasizableText(name, shortname) return string.format('[[%s|<span class="text-ammo-%s">%s</span>]]', name, classSuffix, suitableName) end -- [[ 設定 ]] local columns = { '通常', '鉄壁', '+ガンシールド' } local columnCount = #columns local config = { -- 通常 { gunshield = 0, passive = 1, }, -- 小柄 --{ -- gunshield = 0, -- passive = 1.05, --}, -- 鉄壁 { gunshield = 0, passive = 0.85, }, -- +ガンシールド { gunshield = 50, passive = 0.85, }, } -- [[ テーブル生成 ]] local function passthrough(num) return num end local function createStatTable(itemname, slots, headers, fn, numformat, isdesc, zero) numformat = numformat or passthrough if isdesc == nil then isdesc = true end zero = zero or 0 local stat = mw.loadData('Module:Stat/Weapon') local data = {} for key, value in pairs(stat) do fn(data, key, value) end if isdesc then table.sort(data, function(a, b) return a.values[1] > b.values[1] end) else table.sort(data, function(a, b) return a.values[1] < b.values[1] end) end local tbl = mw.html.create('table') :addClass('wikitable') :addClass('graphtable') :addClass('numbertable') :addClass('stattable') :addClass('sortable') local header = tbl:tag('tr') :addClass('row-sticky') :tag('th') :addClass('stattable-cell-header') :addClass('stattable-cell-header-ammo') :done() :tag('th') :addClass('stattable-cell-header') :addClass('stattable-cell-header-name') :attrIf(slots > 2, { colspan = slots - 1 }) :wikitext('武器名') :done() for _, item in ipairs(headers) do header:tag('th') :addClass('graphtable-cell-header') :addClass('graphtable-cell-header-both') :addClass('stattable-cell-header') :addClass('stattable-cell-header-value') :wikitext(item) end local rank = 1 local max = 0 for i = 1, #data do local value = math.max(unpack(data[i].values)) if value ~= math.huge then max = math.max(max, value) end end local current = max for i, obj in ipairs(data) do local row = tbl:tag('tr') if slots > 1 then for i = 1, slots do local classname if i == 1 then classname = 'stattable-cell-ammo' elseif i == 2 then classname = 'stattable-cell-name' else classname = 'stattable-cell-attachment' end row:tag('td') :addClass('stattable-cell') :addClass(classname) :addClassIf(i == slots, 'stattable-cell-attachment-last') :wikitext(obj[i]) :attr('align', 'left') end else row:tag('td') :addClass('stattable-cell') :addClass('stattable-cell-name') :wikitext(obj.name) :attr('align', 'left') end for _, value in ipairs(obj.values) do local percentage = 0.001 * aw.round(100000 * (value - zero) / (1.05 * max - zero)) local graph = string.format('linear-gradient(to right, #A7D7F9 %s%%, transparent %s%%)', percentage, percentage) row:tag('td') :addClass('graphtable-cell') :addClass('graphtable-cell-both') :addClass('stattable-cell') :addClass('stattable-cell-value') :attr('align', 'right') :css('background-image', graph .. ' !important') :wikitext(numformat(value)) end end return tbl end local function add(data, name, values) if values == nil or type(values) == 'number' then error(string.format('The "%s" value is nil or number', name)) end if type(name) == 'table' then name.values = values table.insert(data, name) else local obj = { name = name, values = values, } table.insert(data, obj) end end -- [[ キルタイム ]] local function getSTKs(stat, opts, health, shield, STKCalculator) local ret = {} local stkc = STKCalculator.newFromStat(stat, opts) for passive = 1, #config do local c = config[passive] stkc:calcShotToKill(health, shield, c.gunshield, c.passive) table.insert(ret, stkc:get()) stkc:reset() end return ret end local function getTTKs(stat, stks, mode, opts, TTKCalculator) local ttkc = TTKCalculator.newFromStat(stat, mode, opts) local ret = {} for _, stk in ipairs(stks) do local obj = { ttkc:getAsLevel(stk, 0), ttkc:getAsLevel(stk, 1), ttkc:getAsLevel(stk, 2), ttkc:getAsLevel(stk, 3), } table.insert(ret, obj) end return ret end local function isDiffTTKs(ttks, a, b) for passive = 1, columnCount do if 0.0001 * aw.round(10000 * ttks[passive][a]) ~= 0.0001 * aw.round(10000 * ttks[passive][b]) then return true end end return false end local function compareTTKs(ttks1, ttks2) for passive = 1, columnCount do for level = 1, 4 do local ttk1 = 0.0001 * aw.round(10000 * ttks1[passive][level]) local ttk2 = 0.0001 * aw.round(10000 * ttks2[passive][level]) if ttk1 ~= ttk2 then return false end end end return true end local function repackTTKs(ttks, level) local ret = {} for _, ttk in ipairs(ttks) do table.insert(ret, ttk[level]) end return ret end local function addFromTTKs(ammo, data, ammoname, basename, hopup, ttks) if isDiffTTKs(ttks, 3, 4) then add(data, { ammoname, basename, getMagazineLabel(ammo, 3), hopup }, repackTTKs(ttks, 4)) add(data, { ammoname, basename, getMagazineLabel(ammo, 2), hopup }, repackTTKs(ttks, 3)) if isDiffTTKs(ttks, 1, 2) then add(data, { ammoname, basename, getMagazineLabel(ammo, 1), hopup }, repackTTKs(ttks, 2)) add(data, { ammoname, basename, getMagazineLabel(ammo, 0, true), hopup }, repackTTKs(ttks, 1)) else add(data, { ammoname, basename, getMagazineLabel(ammo, 0, true) .. '<br>' .. getMagazineLabel(ammo, 1), hopup }, repackTTKs(ttks, 1)) end elseif isDiffTTKs(ttks, 2, 3) then add(data, { ammoname, basename, getMagazineLabel(ammo, 2) .. '<br>' .. getMagazineLabel(ammo, 3), hopup }, repackTTKs(ttks, 3)) if isDiffTTKs(ttks, 1, 2) then add(data, { ammoname, basename, getMagazineLabel(ammo, 1), hopup }, repackTTKs(ttks, 2)) add(data, { ammoname, basename, getMagazineLabel(ammo, 0, true), hopup }, repackTTKs(ttks, 1)) else add(data, { ammoname, basename, getMagazineLabel(ammo, 0, true) .. '<br>' .. getMagazineLabel(ammo, 1), hopup }, repackTTKs(ttks, 1)) end elseif isDiffTTKs(ttks, 1, 2) then add(data, { ammoname, basename, getMagazineLabel(ammo, 1) .. '<br>' .. getMagazineLabel(ammo, 2) .. '<br>' .. getMagazineLabel(ammo, 3), hopup }, repackTTKs(ttks, 2)) add(data, { ammoname, basename, getMagazineLabel(ammo, 0, true), hopup }, repackTTKs(ttks, 1)) else add(data, { ammoname, basename, '', hopup }, repackTTKs(ttks, 1)) end end local function parsePattern(str) local type = type(str) if type == 'table' then return str elseif str == nil or type ~= 'string' then return nil end local pattern = {} local head = false for i = 1, #str do local c = string.sub(str, i, i) local cont = false if head then head = false if c == '1' then table.insert(pattern, apex.HEAD_HLMLV1) cont = true elseif c == '2' then table.insert(pattern, apex.HEAD_HLMLV2) cont = true elseif c == '3' then table.insert(pattern, apex.HEAD_HLMLV3) cont = true elseif c == '0' then table.insert(pattern, apex.HEAD_NOHLM) cont = true else table.insert(pattern, apex.HEAD_NOHLM) end end if not cont then if c == 'H' then head = true elseif c == 'L' then table.insert(pattern, apex.LEGS) elseif c == 'S' then table.insert(pattern, apex.SKY) elseif c == ',' or c == ' ' then if head then head = false table.insert(pattern, apex.HEAD_NOHLM) end else table.insert(pattern, apex.BODY) end end end if head then table.insert(pattern, apex.HEAD_NOHLM) end return pattern end function p.bytimetokill(frame, args) formatter = require('Module:Utility/Formatter').new(frame) if not getArgs then getArgs = require('Module:Arguments').getArgs end args = args or getArgs(frame) args.health = aw.getAsNumber(args.health, 100) args.shield = aw.getAsNumber(args.shield, 125) local opts = { pattern = { first = parsePattern(args.firstPattern), loop = parsePattern(args.loopPattern), }, } local STKCalculator = require('Module:Apex/STKCalculator') local TTKCalculator = require('Module:Apex/TTKCalculator') local tbl = createStatTable('キルタイム [s]', 4, columns, function(data, name, stat) if stat.time == nil or stat.time.reload == nil then return end local ammo = stat.ammo local ammoname = iu.ammo(ammo, { size = 20 }) local basename = getWeaponLink(name, ammo, stat.localization['Japanese_Short']) local stks = getSTKs(stat, opts, args.health, args.shield, STKCalculator) if stat.mode.burst > 1 then if stat.mode.auto then local ttks = getTTKs(stat, stks, TTKCalculator.AUTO, opts, TTKCalculator) addFromTTKs(ammo, data, ammoname, basename .. ' (オート)', '', ttks) else local ttks = getTTKs(stat, stks, TTKCalculator.SINGLE, opts, TTKCalculator) addFromTTKs(ammo, data, ammoname, basename .. ' (単発)', '', ttks) -- ブーステッドローダー (ヘムロックバーストAR) if stat.boosted_loader ~= nil and type(stat.boosted_loader.magazine) == 'table' then local opts2 = aw.shallowCopy(opts) opts2.useBoostedLoader = true local burstttks2 = getTTKs(stat, stks, TTKCalculator.SINGLE, opts2, TTKCalculator) addFromTTKs(ammo, data, ammoname, basename .. ' (単発)', getBoostedLoader(), burstttks2) end end local burstttks = getTTKs(stat, stks, TTKCalculator.BURST, opts, TTKCalculator) addFromTTKs(ammo, data, ammoname, basename .. ' (バースト)', '', burstttks) -- ブーステッドローダー (ヘムロックバーストAR) if stat.boosted_loader ~= nil and type(stat.boosted_loader.magazine) == 'table' then local opts2 = aw.shallowCopy(opts) opts2.useBoostedLoader = true local burstttks2 = getTTKs(stat, stks, TTKCalculator.BURST, opts2, TTKCalculator) addFromTTKs(ammo, data, ammoname, basename .. ' (バースト)', getBoostedLoader(), burstttks2) end else local mode = stat.mode.auto and TTKCalculator.AUTO or TTKCalculator.SINGLE local ttks = getTTKs(stat, stks, mode, opts, TTKCalculator) addFromTTKs(ammo, data, ammoname, basename, '', ttks) -- ライトマシンガン (ディヴォーションLMG・M600スピットファイア・L-スターEMG) if stat.category == 'light_machine_gun' then local opts2 = aw.shallowCopy(opts) opts2.useModdedLoader = true local ttks2 = getTTKs(stat, stks, TTKCalculator.AUTO, opts2, TTKCalculator) if not compareTTKs(ttks, ttks2) then addFromTTKs(ammo, data, ammoname, basename, getModdedLoader(), ttks2) end end -- 最高速から local ttksmax = nil if aw.isNumberAndGreaterThanOrEqualToZero(stat.firerate.auto_start) and aw.isNumber(stat.firerate.auto_maximum) and stat.firerate.auto_maximum > 1 then local maxname = basename .. ' (最高速)' local opts2 = aw.shallowCopy(opts) opts2.startMaximum = true ttksmax = getTTKs(stat, stks, TTKCalculator.AUTO, opts2, TTKCalculator) addFromTTKs(ammo, data, ammoname, maxname, '', ttksmax) if stat.category == 'light_machine_gun' then local opts3 = aw.shallowCopy(opts2) opts3.useModdedLoader = true local ttks3 = getTTKs(stat, stks, TTKCalculator.AUTO, opts3, TTKCalculator) if not compareTTKs(ttksmax, ttks3) then addFromTTKs(ammo, data, ammoname, maxname, getModdedLoader(), ttks3) end end end -- センチネルの増幅モード if aw.isNumberAndGreaterThanZero(stat.damage.amped) then local opts2 = aw.shallowCopy(opts) opts2.useAmpedMode = true local stks2 = getSTKs(stat, opts2, args.health, args.shield, STKCalculator) local ttks2 = getTTKs(stat, stks2, TTKCalculator.SINGLE, opts2, TTKCalculator) if not compareTTKs(ttks, ttks2) then addFromTTKs(ammo, data, ammoname, basename, getAmpedMode(), ttks2) end end -- 30-30リピーターのフルチャージ if aw.isNumberAndGreaterThanZero(stat.damage.charged) then local opts2 = aw.shallowCopy(opts) opts2.useCharged = true local stks2 = getSTKs(stat, opts2, args.health, args.shield, STKCalculator) local ttks2 = getTTKs(stat, stks2, TTKCalculator.SINGLE, opts2, TTKCalculator) addFromTTKs(ammo, data, ammoname, basename, getCharged(), ttks2) end -- ハンマーポイント弾 (モザンビーク・P2020) if aw.isNumber(stat.damage.hammerpoint_rounds) and stat.damage.hammerpoint_rounds > 1 then local opts2 = aw.shallowCopy(opts) opts2.useHammerpointRounds = true local stks2 = getSTKs(stat, opts2, args.health, args.shield, STKCalculator) local ttks2 = getTTKs(stat, stks2, TTKCalculator.SINGLE, opts2, TTKCalculator) addFromTTKs(ammo, data, ammoname, basename, getHammerpointRounds(), ttks2) end -- アンビルレシーバー (VK-47フラットライン・R-301カービン) if stat.anvil_receiver then local opts2 = aw.shallowCopy(opts) opts2.useAnvilReceiver = true local stks2 = getSTKs(stat, opts2, args.health, args.shield, STKCalculator) local ttks2 = getTTKs(stat, stks2, TTKCalculator.SINGLE_ANVIL_RECEIVER, opts2, TTKCalculator) addFromTTKs(ammo, data, ammoname, basename, getAnvilReceiver(), ttks2) end -- ブーステッドローダー (ウィングマン) if stat.boosted_loader ~= nil and type(stat.boosted_loader.magazine) == 'table' then local opts2 = aw.shallowCopy(opts) opts2.useBoostedLoader = true local ttks2 = getTTKs(stat, stks, TTKCalculator.SINGLE, opts2, TTKCalculator) addFromTTKs(ammo, data, ammoname, basename, getBoostedLoader(), ttks2) end -- シャッターキャップ (30-30リピーター・ボセックコンポウンドボウ) if stat.shatter_caps then local opts2 = aw.shallowCopy(opts) opts2.useShatterCaps = true local stks2 = getSTKs(stat, opts2, args.health, args.shield, STKCalculator) local ttks2 = getTTKs(stat, stks2, TTKCalculator.SINGLE, opts2, TTKCalculator) addFromTTKs(ammo, data, ammoname, basename, getShatterCaps(), ttks2) if aw.isNumberAndGreaterThanZero(stat.shatter_caps.damage.charged) then local opts3 = aw.shallowCopy(opts2) opts3.useCharged = true local stks3 = getSTKs(stat, opts3, args.health, args.shield, STKCalculator) local ttks3 = getTTKs(stat, stks3, TTKCalculator.SINGLE, opts3, TTKCalculator) addFromTTKs(ammo, data, ammoname, basename, getShatterCaps() .. '<br>' .. getCharged(), ttks3) end end -- ターボチャージャー (ハボックライフル・ディヴォーションLMG) if aw.isNumberAndGreaterThanOrEqualToZero(stat.firerate.auto_raise_turbocharger) or aw.isNumberAndGreaterThanOrEqualToZero(stat.firerate.auto_start_turbocharger) then local opts2 = aw.shallowCopy(opts) opts2.useTurbocharger = true local ttks2 = getTTKs(stat, stks, TTKCalculator.AUTO, opts2, TTKCalculator) addFromTTKs(ammo, data, ammoname, basename, getTurbocharger(), ttks2) -- 最高速から if aw.isNumberAndGreaterThanOrEqualToZero(stat.firerate.auto_start_turbocharger) and aw.isNumber(stat.firerate.auto_maximum_turbocharger) and stat.firerate.auto_maximum_turbocharger > 1 then local maxname = basename .. ' (最高速)' local opts3 = aw.shallowCopy(opts2) opts3.startMaximum = true local ttks3 = getTTKs(stat, stks, TTKCalculator.AUTO, opts3, TTKCalculator) if ttksmax ~= nil and not compareTTKs(ttksmax, ttks3) then addFromTTKs(ammo, data, ammoname, maxname, getTurbocharger(), ttks3) end if stat.category == 'light_machine_gun' then local opts4 = aw.shallowCopy(opts3) opts4.useModdedLoader = true local ttks4 = getTTKs(stat, stks, TTKCalculator.AUTO, opts4, TTKCalculator) if not compareTTKs(ttks3, ttks4) then addFromTTKs(ammo, data, ammoname, maxname, getTurbocharger() .. '<br>' .. getModdedLoader(), ttks4) end end end -- ライトマシンガン (ディヴォーションLMG) if stat.category == 'light_machine_gun' then local opts3 = aw.shallowCopy(opts2) opts3.useModdedLoader = true local ttks3 = getTTKs(stat, stks, TTKCalculator.AUTO, opts3, TTKCalculator) if not compareTTKs(ttks2, ttks3) then addFromTTKs(ammo, data, ammoname, basename, getTurbocharger() .. '<br>' .. getModdedLoader(), ttks3) end end end end end, function(num) return 0.001 * aw.round(1000 * num) end, false, -0.1) return tostring(tbl) end return p