🌟現在、鉄壁 鉄壁ヘッドショットには対応済みです。
鉄壁HSは通常HSと同じダメージになります。LMG及びDMR、チャージライフル、ハンマーポイント弾を除き、すべてのダメージ値が一致していることを確認しています。

「モジュール:StatTable/DamagePerSecond」の版間の差分

提供:Apex Data
ナビゲーションに移動 検索に移動
(シャッターキャップのチャージショット周りの判定を修正)
(スカルピアサーライフリングに対応)
 
(同じ利用者による、間の3版が非表示)
2行目: 2行目:
local apex          = require('Module:Utility/ApexLibrary')
local apex          = require('Module:Utility/ApexLibrary')
local iu            = require('Module:Utility/Image')
local iu            = require('Module:Utility/Image')
local inu          = require('Module:Utility/ImageWithName')
local tableutil    = require('Module:Utility/TableUtil/Apex')
local tableutil    = require('Module:Utility/TableUtil/Apex')
local Hopup        = mw.loadData('Module:Stat/Hopup')
local Hopup        = mw.loadData('Module:Stat/Hopup')
7行目: 8行目:
local getArgs  -- lazily initialized
local getArgs  -- lazily initialized


local function _addData(dataset, data, firerate, fn)
local function _getAddData(fn)
local head = data.head
fn = fn or function(val) return val end
local lvl1 = apex.calcHeadshotMultiplier(head, apex.HEAD_HLMLV1)
return function(dataset, data, firerate)
local lvl2 = apex.calcHeadshotMultiplier(head, apex.HEAD_HLMLV2)
local head = data.head
local lvl3 = apex.calcHeadshotMultiplier(head, apex.HEAD_HLMLV3)
local lvl1 = apex.calcHeadshotMultiplier(head, apex.HEAD_HLMLV1)
local legs = data.legs
local lvl2 = apex.calcHeadshotMultiplier(head, apex.HEAD_HLMLV2)
local mul  = firerate * data.pellets
local lvl3 = apex.calcHeadshotMultiplier(head, apex.HEAD_HLMLV3)
data.bodyDPS = fn(data.damage, 1, 1)                              * mul
local legs = data.legs
data.headDPS = fn(apex.calcPartDamage(data.damage, head), head, 1) * mul
local mul  = firerate * data.pellets
data.lvl1DPS = fn(apex.calcPartDamage(data.damage, lvl1), lvl1, 1) * mul
data.bodyDPS = fn(data.damage, 1, 1)                              * mul
data.lvl2DPS = fn(apex.calcPartDamage(data.damage, lvl2), lvl2, 1) * mul
data.headDPS = fn(apex.calcPartDamage(data.damage, head), head, 1) * mul
data.lvl3DPS = fn(apex.calcPartDamage(data.damage, lvl3), lvl3, 1) * mul
data.lvl1DPS = fn(apex.calcPartDamage(data.damage, lvl1), lvl1, 1) * mul
data.legsDPS = fn(apex.calcPartDamage(data.damage, legs), legs, 1) * mul
data.lvl2DPS = fn(apex.calcPartDamage(data.damage, lvl2), lvl2, 1) * mul
data.flL1DPS = fn(apex.calcDamageFromPartAndPassive(data.damage, lvl1, 0.85), lvl1, 0.85) * mul
data.lvl3DPS = fn(apex.calcPartDamage(data.damage, lvl3), lvl3, 1) * mul
data.flLgDPS = fn(apex.calcDamageFromPartAndPassive(data.damage, legs, 0.85), legs, 0.85) * mul
data.legsDPS = fn(apex.calcPartDamage(data.damage, legs), legs, 1) * mul
table.insert(dataset, data)
data.flLgDPS = fn(apex.calcDamageFromPartAndPassive(data.damage, legs, 0.85), legs, 0.85) * mul
table.insert(dataset, data)
end
end
end


local function addData(dataset, data, special, fn)
local fnRatio
fn = fn or function(val) return val end
local function _getAddDataComplex(fns)
local bf = fns.unsd or function(val) return val end
local at = fns.shld or function(val) return val end
return function(dataset, data, firerate)
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
local unsdDamage = bf(data.damage)
data.unsdBodyDPS = unsdDamage                            * mul
data.unsdHeadDPS = apex.calcPartDamage(unsdDamage, head) * mul
data.unsdLvl1DPS = apex.calcPartDamage(unsdDamage, lvl1) * mul
data.unsdLvl2DPS = apex.calcPartDamage(unsdDamage, lvl2) * mul
data.unsdLvl3DPS = apex.calcPartDamage(unsdDamage, lvl3) * mul
data.unsdLegsDPS = apex.calcPartDamage(unsdDamage, legs) * mul
data.unsdFlLgDPS = apex.calcDamageFromPartAndPassive(unsdDamage, legs, 0.85) * mul
data.shldBodyDPS = at(data.damage, 1, 1)                              * mul
data.shldHeadDPS = at(apex.calcPartDamage(data.damage, head), head, 1) * mul
data.shldLvl1DPS = at(apex.calcPartDamage(data.damage, lvl1), lvl1, 1) * mul
data.shldLvl2DPS = at(apex.calcPartDamage(data.damage, lvl2), lvl2, 1) * mul
data.shldLvl3DPS = at(apex.calcPartDamage(data.damage, lvl3), lvl3, 1) * mul
data.shldLegsDPS = at(apex.calcPartDamage(data.damage, legs), legs, 1) * mul
data.shldFlLgDPS = at(apex.calcDamageFromPartAndPassive(data.damage, legs, 0.85), legs, 0.85) * mul
for _, target in ipairs(fnRatio) do
local data2 = aw.shallowCopy(data)
data2.option  = target.name
data2.bodyDPS = target.fn(data.unsdBodyDPS, data.shldBodyDPS)
data2.headDPS = target.fn(data.unsdHeadDPS, data.shldHeadDPS)
data2.lvl1DPS = target.fn(data.unsdLvl1DPS, data.shldLvl1DPS)
data2.lvl2DPS = target.fn(data.unsdLvl2DPS, data.shldLvl2DPS)
data2.lvl3DPS = target.fn(data.unsdLvl3DPS, data.shldLvl3DPS)
data2.legsDPS = target.fn(data.unsdLegsDPS, data.shldLegsDPS)
data2.flLgDPS = target.fn(data.unsdFlLgDPS, data.shldFlLgDPS)
table.insert(dataset, data2)
end
end
end
 
local function addData(dataset, data, special, fn, bf, at)
local __addData
if type(fn) == 'table' then
__addData = _getAddDataComplex(fn)
else
__addData = _getAddData(fn)
end
local fireratesType  = type(data.firerates)
local fireratesType  = type(data.firerates)
33行目: 86行目:
if fireratesType == 'table' then
if fireratesType == 'table' then
if special then
if special then
_addData(dataset, data, data.firerates[4], fn)
__addData(dataset, data, data.firerates[4])
else
else
for level, firerate in ipairs(data.firerates) do
for level, firerate in ipairs(data.firerates) do
local data2 = aw.shallowCopy(data)
local data2 = aw.shallowCopy(data)
data2.level = level - 1
data2.level = level - 1
_addData(dataset, data2, firerate, fn)
__addData(dataset, data2, firerate)
end
end
end
end
44行目: 97行目:
-- ファイアレートが固定
-- ファイアレートが固定
elseif fireratesType == 'number' then
elseif fireratesType == 'number' then
_addData(dataset, data, data.firerates, fn)
__addData(dataset, data, data.firerates)
end
end
end
end
253行目: 306行目:
end
end
addData(dataset, selectfireReceiverData, special)
addData(dataset, selectfireReceiverData, special)
end
-- Skullpiercer Rifling
if (__debug or Hopup.skullpiercer_rifling.enabled) and type(stat.skullpiercer_rifling) == 'table' and aw.isNumberAndGreaterThanX(stat.skullpiercer_rifling.damage_head_scale, 1) then
local skullpiercerRiflingData = aw.shallowCopy(baseData)
skullpiercerRiflingData.head = stat.skullpiercer_rifling.damage_head_scale
skullpiercerRiflingData.hopup = { 'skullpiercer_rifling' }
addData(dataset, skullpiercerRiflingData, special)
end
end
258行目: 319行目:
if (__debug or Hopup.hammerpoint_rounds.enabled) and type(stat.hammerpoint_rounds) == 'table' and aw.isNumberAndGreaterThanX(stat.hammerpoint_rounds.damage_unshielded_scale, 1) then
if (__debug or Hopup.hammerpoint_rounds.enabled) and type(stat.hammerpoint_rounds) == 'table' and aw.isNumberAndGreaterThanX(stat.hammerpoint_rounds.damage_unshielded_scale, 1) then
local hammerpointRoundsData  = aw.shallowCopy(baseData)
local hammerpointRoundsData  = aw.shallowCopy(baseData)
hammerpointRoundsData.damage = math.floor(stat.hammerpoint_rounds.damage_unshielded_scale * stat.damage.base)
hammerpointRoundsData.hopup  = { 'hammerpoint_rounds' }
hammerpointRoundsData.hopup  = { 'hammerpoint_rounds' }
addData(dataset, hammerpointRoundsData, special)
addData(dataset, hammerpointRoundsData, special, { unsd = function(val)
return math.floor(stat.hammerpoint_rounds.damage_unshielded_scale * val)
end })
end
end
267行目: 329行目:
local disruptorRoundsData = aw.shallowCopy(baseData)
local disruptorRoundsData = aw.shallowCopy(baseData)
disruptorRoundsData.hopup = { 'disruptor_rounds' }
disruptorRoundsData.hopup = { 'disruptor_rounds' }
addData(dataset, disruptorRoundsData, special, function(val)
addData(dataset, disruptorRoundsData, special, { shld = function(val)
return apex.calcDisruptorDamage(val, stat.disruptor_rounds.damage_shield_scale)
return apex.calcDisruptorDamage(val, stat.disruptor_rounds.damage_shield_scale)
end)
end })
end
end
288行目: 350行目:
-- Double Tap Trigger
-- 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
if (__debug or Hopup.double_tap_trigger.enabled or special) and type(stat.double_tap_trigger) == 'table' and aw.isNumberAndGreaterThanOrEqualToX(stat.double_tap_trigger.burst_count, 2) then
local doubleTapTriggerData    = aw.shallowCopy(baseData)
local doubleTapTriggerData    = aw.shallowCopy(baseData)
local delay = stat.double_tap_trigger.burst_delay
local delay = stat.double_tap_trigger.burst_delay
410行目: 472行目:
local res  = configuration[lang]
local res  = configuration[lang]
local stats = mw.loadData('Module:Stat/Weapon')
local stats = mw.loadData('Module:Stat/Weapon')
local desktopOnlyAndNoLinkObj = { desktopOnly = true, lang = lang, link = '' }
fnRatio = {
{ name = inu.gear('backpack', 4, desktopOnlyAndNoLinkObj),  fn = function(a, b) return (7 * a + 5 * b) / 12 end },
{ name = inu.gear('evo_shield', 1, desktopOnlyAndNoLinkObj), fn = function(a, b) return (2 * a +    b) / 3 end },
{ name = inu.gear('evo_shield', 2, desktopOnlyAndNoLinkObj), fn = function(a, b) return (4 * a + 3 * b) / 7 end },
{ name = inu.gear('evo_shield', 3, desktopOnlyAndNoLinkObj), fn = function(a, b) return (    a +    b) / 2 end },
{ name = inu.gear('evo_shield', 5, desktopOnlyAndNoLinkObj), fn = function(a, b) return (4 * a + 5 * b) / 9 end },
{ name = res.maxvalue,                                      fn = function(a, b) return math.max(a, b)      end },
}
local dataset = {}
local dataset = {}
459行目: 531行目:
endIndex      = 'lvl1DPS',
endIndex      = 'lvl1DPS',
subStartIndex = 'flLgDPS',
subStartIndex = 'flLgDPS',
subEndIndex  = 'flL1DPS',
subEndIndex  = 'lvl1DPS',
cellClass    = 'st-mobile-graph st-mobile-medium st-mobile-textshadow',
cellClass    = 'st-mobile-graph st-mobile-medium st-mobile-textshadow',
footerClass  = 'st-mobile-axis',
footerClass  = 'st-mobile-axis',
506行目: 578行目:
endIndex      = 'lvl1DPS',
endIndex      = 'lvl1DPS',
subStartIndex = 'flLgDPS',
subStartIndex = 'flLgDPS',
subEndIndex  = 'flL1DPS',
subEndIndex  = 'lvl1DPS',
cellClass    = 'st-desktop st-desktop-graph',
cellClass    = 'st-desktop st-desktop-graph',
footerClass  = 'st-desktop',
footerClass  = 'st-desktop',

2022年8月10日 (水) 13:45時点における最新版

このモジュールについての説明文ページを モジュール:StatTable/DamagePerSecond/doc に作成できます

local aw            = require('Module:Utility/Library')
local apex          = require('Module:Utility/ApexLibrary')
local iu            = require('Module:Utility/Image')
local inu           = require('Module:Utility/ImageWithName')
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 _getAddData(fn)
	fn = fn or function(val) return val end
	return function(dataset, data, firerate)
		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.flLgDPS = fn(apex.calcDamageFromPartAndPassive(data.damage, legs, 0.85), legs, 0.85) * mul
		table.insert(dataset, data)
	end
end

local fnRatio
local function _getAddDataComplex(fns)
	local bf = fns.unsd or function(val) return val end
	local at = fns.shld or function(val) return val end
	
	return function(dataset, data, firerate)
		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
		
		local unsdDamage = bf(data.damage)
		data.unsdBodyDPS = unsdDamage                            * mul
		data.unsdHeadDPS = apex.calcPartDamage(unsdDamage, head) * mul
		data.unsdLvl1DPS = apex.calcPartDamage(unsdDamage, lvl1) * mul
		data.unsdLvl2DPS = apex.calcPartDamage(unsdDamage, lvl2) * mul
		data.unsdLvl3DPS = apex.calcPartDamage(unsdDamage, lvl3) * mul
		data.unsdLegsDPS = apex.calcPartDamage(unsdDamage, legs) * mul
		data.unsdFlLgDPS = apex.calcDamageFromPartAndPassive(unsdDamage, legs, 0.85) * mul
		
		data.shldBodyDPS = at(data.damage, 1, 1)                               * mul
		data.shldHeadDPS = at(apex.calcPartDamage(data.damage, head), head, 1) * mul
		data.shldLvl1DPS = at(apex.calcPartDamage(data.damage, lvl1), lvl1, 1) * mul
		data.shldLvl2DPS = at(apex.calcPartDamage(data.damage, lvl2), lvl2, 1) * mul
		data.shldLvl3DPS = at(apex.calcPartDamage(data.damage, lvl3), lvl3, 1) * mul
		data.shldLegsDPS = at(apex.calcPartDamage(data.damage, legs), legs, 1) * mul
		data.shldFlLgDPS = at(apex.calcDamageFromPartAndPassive(data.damage, legs, 0.85), legs, 0.85) * mul
		
		for _, target in ipairs(fnRatio) do
			local data2 = aw.shallowCopy(data)
			data2.option  = target.name
			data2.bodyDPS = target.fn(data.unsdBodyDPS, data.shldBodyDPS)
			data2.headDPS = target.fn(data.unsdHeadDPS, data.shldHeadDPS)
			data2.lvl1DPS = target.fn(data.unsdLvl1DPS, data.shldLvl1DPS)
			data2.lvl2DPS = target.fn(data.unsdLvl2DPS, data.shldLvl2DPS)
			data2.lvl3DPS = target.fn(data.unsdLvl3DPS, data.shldLvl3DPS)
			data2.legsDPS = target.fn(data.unsdLegsDPS, data.shldLegsDPS)
			data2.flLgDPS = target.fn(data.unsdFlLgDPS, data.shldFlLgDPS)
			table.insert(dataset, data2)
		end
	end
end

local function addData(dataset, data, special, fn, bf, at)
	local __addData
	if type(fn) == 'table' then
		__addData = _getAddDataComplex(fn)
	else
		__addData = _getAddData(fn)
	end
	
	local fireratesType  = type(data.firerates)
	
	-- ファイアレートが可変
	if fireratesType == 'table' then
		if special then
			__addData(dataset, data, data.firerates[4])
		else
			for level, firerate in ipairs(data.firerates) do
				local data2 = aw.shallowCopy(data)
				data2.level = level - 1
				__addData(dataset, data2, firerate)
			end
		end
	
	-- ファイアレートが固定
	elseif fireratesType == 'number' then
		__addData(dataset, data, data.firerates)
	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_head_scale,
			legs      = stat.damage_legs_scale,
			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   = res.amped
				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    = res.revvedup
			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.damage    = stat.selectfire_receiver.damage and stat.selectfire_receiver.damage.base or stat.damage.base
			selectfireReceiverData.firerates = firerate
			if stat.selectfire_receiver.damage_head_scale then
				selectfireReceiverData.head  = stat.selectfire_receiver.damage_head_scale
			end
			selectfireReceiverData.hopup     = { 'selectfire_receiver' }
			if stat.selectfire_receiver.damage_legs_scale then
				selectfireReceiverData.legs  = stat.selectfire_receiver.damage_legs_scale
			end
			addData(dataset, selectfireReceiverData, special)
		end
		
		-- Skullpiercer Rifling 
		if (__debug or Hopup.skullpiercer_rifling.enabled) and type(stat.skullpiercer_rifling) == 'table' and aw.isNumberAndGreaterThanX(stat.skullpiercer_rifling.damage_head_scale, 1) then
			local skullpiercerRiflingData = aw.shallowCopy(baseData)
			skullpiercerRiflingData.head = stat.skullpiercer_rifling.damage_head_scale
			skullpiercerRiflingData.hopup = { 'skullpiercer_rifling' }
			addData(dataset, skullpiercerRiflingData, special)
		end
		
		-- Hammerpoint Rounds
		if (__debug or Hopup.hammerpoint_rounds.enabled) and type(stat.hammerpoint_rounds) == 'table' and aw.isNumberAndGreaterThanX(stat.hammerpoint_rounds.damage_unshielded_scale, 1) then
			local hammerpointRoundsData  = aw.shallowCopy(baseData)
			hammerpointRoundsData.hopup  = { 'hammerpoint_rounds' }
			addData(dataset, hammerpointRoundsData, special, { unsd = function(val)
				return math.floor(stat.hammerpoint_rounds.damage_unshielded_scale * val)
			end })
		end
		
		-- Disruptor Rounds
		if (__debug or Hopup.disruptor_rounds.enabled or special) and type(stat.disruptor_rounds) == 'table' and aw.isNumberAndGreaterThanX(stat.disruptor_rounds.damage_shield_scale, 1) then
			local disruptorRoundsData = aw.shallowCopy(baseData)
			disruptorRoundsData.hopup = { 'disruptor_rounds' }
			addData(dataset, disruptorRoundsData, special, { shld = function(val)
				return apex.calcDisruptorDamage(val, stat.disruptor_rounds.damage_shield_scale)
			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_head_scale then
				anvilReceiverData.head  = stat.anvil_receiver.damage_head_scale
			end
			anvilReceiverData.hopup     = { 'anvil_receiver' }
			if stat.anvil_receiver.damage_legs_scale then
				anvilReceiverData.legs  = stat.anvil_receiver.damage_legs_scale
			end
			addData(dataset, anvilReceiverData, special)
		end
			
		-- Double Tap Trigger
		if (__debug or Hopup.double_tap_trigger.enabled or special) 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)
			if stat.shatter_caps.charge then
				shatterCapsData.charge = stat.shatter_caps.charge
			end
			if stat.shatter_caps.charge_levels then
				shatterCapsData.charge_levels = stat.shatter_caps.charge_levels
			end
			shatterCapsData.damage   = stat.shatter_caps.damage.base
			if stat.shatter_caps.damage_head_scale then
				shatterCapsData.head = stat.shatter_caps.damage_head_scale
			end
			shatterCapsData.hopup    = { 'shatter_caps' }
			if stat.shatter_caps.damage_legs_scale then
				shatterCapsData.legs = stat.shatter_caps.damage_legs_scale
			end
			shatterCapsData.option   = nil
			shatterCapsData.pellets  = stat.shatter_caps.pellet
			
			-- Chargefire
			if aw.isNumberAndGreaterThanOrEqualToX(shatterCapsData.charge_levels, 2) and aw.isNumberAndGreaterThanZero(shatterCapsData.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, shatterCapsData.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(shatterCapsData.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, shatterCapsData.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 desktopOnlyAndNoLinkObj = { desktopOnly = true, lang = lang, link = '' }
	fnRatio = {
		{ name = inu.gear('backpack', 4, desktopOnlyAndNoLinkObj),   fn = function(a, b) return (7 * a + 5 * b) / 12 end },
		{ name = inu.gear('evo_shield', 1, desktopOnlyAndNoLinkObj), fn = function(a, b) return (2 * a +     b) / 3 end },
		{ name = inu.gear('evo_shield', 2, desktopOnlyAndNoLinkObj), fn = function(a, b) return (4 * a + 3 * b) / 7 end },
		{ name = inu.gear('evo_shield', 3, desktopOnlyAndNoLinkObj), fn = function(a, b) return (    a +     b) / 2 end },
		{ name = inu.gear('evo_shield', 5, desktopOnlyAndNoLinkObj), fn = function(a, b) return (4 * a + 5 * b) / 9 end },
		{ name = res.maxvalue,                                       fn = function(a, b) return math.max(a, b)      end },
	}
	
	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   = 'lvl1DPS',
			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   = 'lvl1DPS',
			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