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

「モジュール:Utility/ApexLibrary」の版間の差分

提供:Apex Data
ナビゲーションに移動 検索に移動
(ビームダメージの計算に用いる変数を標準的な変数名に変更)
(ファイアレート計算部分を刷新)
122行目: 122行目:
end
end


-- 射撃モード
-- [[ 射撃レート計算 ]]
apex.BURST              = 0
local function calcBurstAverageFirerate(stat, delay)
apex.DOUBLE_TAP_TRIGGER  = apex.BURST
return stat.burst_count / ((stat.burst_count - 1) / stat.firerate + delay)
apex.AUTO                = 100
end
apex.SINGLE              = 200
 
apex.ANVIL_RECEIVER      = 201
local function calcRechamberFirerate(stat, rechamber)
apex.SELECTFIRE_RECEIVER = 300
return 1 / (1 / stat.firerate + rechamber)
end


-- [[ 複数の射撃レートが定義されているかどうか ]]
function apex.getFirerate(stat, opts)
function apex.hasMultipleFirerate(stat, mode)
stat = stat or mw.loadData('Module:Stat/Weapon')[opts.name]
local firerate = stat.firarate
if not firarate then
-- Altfire mode
return false
if opts.useAltfire and aw.isNumberAndGreaterThanZero(stat.altfire.firerate, stat.firerate) then
return stat.altfire.firerate
end
-- Burst mode
if aw.isNumberAndGreaterThanOrEqualToX(stat.burst_count, 2) then
if type(stat.burst_delay) == 'table' then
return {
calcBurstAverageFirerate(stat, stat.burst_delay[1]),
calcBurstAverageFirerate(stat, stat.burst_delay[2]),
calcBurstAverageFirerate(stat, stat.burst_delay[3]),
calcBurstAverageFirerate(stat, stat.burst_delay[4]),
}
elseif aw.isNumberAndGreaterThanZero(stat.burst_delay) then
return calcBurstAverageFirerate(stat, stat.burst_delay)
else
return 0
end
end
-- Revved Up
if opts.useRevvedUpMode and aw.isNumberAndGreaterThanOrEqualToX(stat.firerate_revvedup, stat.firerate) then
return stat.firerate_revvedup
end
end
if mode == apex.BURST then
-- w/Turbocharger
return type(firerate.burst_delay) == 'table'
if opts.useTurbocharger and stat.turbocharger then
elseif mode == apex.AUTO then
return {
return type(firerate.auto) == 'table'
stat.turbocharger.firerate         or stat.firerate,
elseif mode == apex.SINGLE then
stat.turbocharger.firerate_maximum or stat.firerate_maximum,
return type(firerate.single) == 'table' or type(firerate.single_rechamber) == 'table'
}
else
return false
end
end
end
 
-- Variable firerate
-- [[ 射撃レート計算 ]]
if aw.isNumberAndGreaterThanOrEqualToX(stat.firerate_maximum, stat.firerate) then
local function chooseData(data, level)
return {
local typename = type(data)
stat.firerate,
if typename == 'table' then
stat.firerate_maximum,
return data[level]
}
elseif typename == 'number' then
end
return data
elseif typename == 'string' then
-- w/Anvil Receiver
return tonumber(data)
if opts.useAnvilReceiver and stat.anvil_receiver then
else
return stat.anvil_receiver.firerate
return 0
end
end
end
function apex.calcFirerate(stat, mode, level)
level = (1 + level) or 1
local rps = 0
-- w/Charge
if mode == apex.BURST then
if aw.isNumberAndGreaterThanZero(stat.charge) then
if aw.isNumberAndGreaterThanZero(stat.mode.burst) then
if aw.isNumberAndGreaterThanZero(stat.charge_minimum) then
local firerate = chooseData(stat.firerate.burst, level)
return {
if firerate > 0 then
calcRechamberFirerate(stat, stat.charge_minimum),
local delay = chooseData(stat.firerate.burst_delay, level)
calcRechamberFirerate(stat, stat.charge),
if delay > 0 then
}
rps = stat.mode.burst / ((stat.mode.burst - 1) / firerate + delay)
elseif aw.isNumberAndGreaterThanZero(stat.rechamber) then
else
return {
rps = firerate
calcRechamberFirerate(stat, stat.rechamber),
end
calcRechamberFirerate(stat, stat.rechamber + stat.charge),
end
}
end
else
elseif mode == apex.AUTO then
return {
if stat.mode.auto then
stat.firerate,
rps = chooseData(stat.firerate.auto, level)
calcRechamberFirerate(stat, stat.charge),
end
}
elseif mode == apex.SINGLE then
if stat.mode.single then
local firerate = chooseData(stat.firerate.single, level)
if firerate > 0 then
local rechamber = chooseData(stat.firerate.single_rechamber, level)
if rechamber > 0 then
rps = 1 / (1 / firerate + rechamber)
else
rps = firerate
end
end
end
elseif mode == apex.ANVIL_RECEIVER then
if stat.mode.single and stat.anvil_receiver then
rps = chooseData(stat.anvil_receiver.firerate.single, level)
end
end
end
end
return rps
-- w/Rechamber
if type(stat.rechamber) == 'table' then
return {
calcRechamberFirerate(stat, stat.rechamber[1]),
calcRechamberFirerate(stat, stat.rechamber[2]),
calcRechamberFirerate(stat, stat.rechamber[3]),
calcRechamberFirerate(stat, stat.rechamber[4]),
}
elseif aw.isNumberAndGreaterThanZero(stat.rechamber) then
return calcRechamberFirerate(stat, stat.rechamber)
end
return stat.firerate
end
end


return apex
return apex

2021年8月22日 (日) 20:55時点における版

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

local apex = {}

local aw = require('Module:Utility/Library')

-- 部位ダメージ用定数
apex.HEAD        = 1
apex.HEAD_NOHLM  = 1
apex.HEAD_HLMLV1 = 2
apex.HEAD_HLMLV2 = 3
apex.HEAD_HLMLV3 = 4
apex.BODY        = 10
apex.LEGS        = 100
apex.SKY         = 1000

-- [[ ヘッドショット倍率の計算 ]]
function apex.calcHeadshotMultiplier(headmul, part)
	if part == apex.HEAD_HLMLV1 then
		return 0.2 + 0.8 * headmul
	elseif part == apex.HEAD_HLMLV2 then
		return 0.4 + 0.6 * headmul
	elseif part == apex.HEAD_HLMLV3 then
		return 0.5 + 0.5 * headmul
	else
		return headmul
	end
end

-- [[ ハンマーポイント弾倍率を考慮したダメージ計算 ]]
function apex.calcHammerpointDamage(base, hammerpoint)
	return math.floor(hammerpoint * base)
end

-- [[ 貫通減衰倍率を考慮したダメージ計算 ]]
function apex.calcPassthroughDamage(base, passthrough)
	return aw.round(passthrough * base)
end

-- [[ 部位倍率を考慮したダメージ計算 ]]
function apex.calcPartDamage(base, partmul)
	if partmul ~= 1 then
		return aw.round(partmul * base)
	else
		return base
	end
end

-- [[ ディスラプター弾倍率を考慮したダメージ計算 ]]
function apex.calcDisruptorDamage(base, disruptor)
	return math.floor(disruptor * base)
end

-- [[ パッシブ倍率を考慮したダメージ計算 ]]
function apex.calcPassiveDamage(base, passive, opts)
	if passive == 1.05 then
		if not opts.round then
			return aw.roundover(passive * base)
		else
			return aw.round(passive * base)
		end
	elseif passive ~= 1 then
		return aw.round(passive * base)
	else
		return base
	end
end

-- [[ 部位倍率とパッシブ倍率を考慮したダメージ計算 ]]
function apex.calcDamageFromPartAndPassive(base, partmul, passive, opts)
	-- 部位倍率
	base = apex.calcPartDamage(base, partmul)
	
	-- 小柄・鉄壁
	base = apex.calcPassiveDamage(base, passive, opts)
	
	return base
end

-- [[ ダメージ計算 ]]
function apex.calcDamage(base, partmul, passive, opts)
	opts = opts or {}
	opts.hammerpointRounds = opts.hammerpointRounds or 0
	opts.passthrough       = opts.passthrough or 1
	opts.disruptorRounds   = opts.disruptorRounds or 0
	
	-- 増幅バリケード
	if opts.ampedCover then
		base = aw.round(1.2 * base)
	else
		base = aw.round(base)
	end
	
	-- チャージ倍率
	if opts.charged > 1 then
		base = aw.round(opts.charged * base)
	end
	
	-- ハンマーポイント弾
	if opts.hammerpointRounds > 1 then
		base = apex.calcHammerpointDamage(base, opts.hammerpointRounds)
	end
	
	-- 貫通減衰倍率
	if opts.passthrough < 1 then
		base = apex.calcPassthroughDamage(base, opts.passthrough)
	end
	
	-- 部位倍率、小柄・鉄壁
	base = apex.calcDamageFromPartAndPassive(base, partmul, passive, opts)
	
	-- ディスラプター弾
	if opts.disruptorRounds > 1 then
		base = apex.calcDisruptorDamage(base, opts.disruptorRounds)
	end
	
	-- ビームダメージ
	if aw.isNumberAndGreaterThanZero(opts.beamdamage) and aw.isNumberAndGreaterThanZero(opts.beamticks)then
		local beamdamage = apex.calcDamageFromPartAndPassive(opts.beamdamage, partmul, passive, opts)
		base = base + opts.beamticks * beamdamage
	end
	
	return base
end

-- [[ 射撃レート計算 ]]
local function calcBurstAverageFirerate(stat, delay)
	return stat.burst_count / ((stat.burst_count - 1) / stat.firerate + delay)
end

local function calcRechamberFirerate(stat, rechamber)
	return 1 / (1 / stat.firerate + rechamber)
end

function apex.getFirerate(stat, opts)
	stat = stat or mw.loadData('Module:Stat/Weapon')[opts.name]
	
	-- Altfire mode
	if opts.useAltfire and aw.isNumberAndGreaterThanZero(stat.altfire.firerate, stat.firerate) then
		return stat.altfire.firerate
	end
	
	-- Burst mode
	if aw.isNumberAndGreaterThanOrEqualToX(stat.burst_count, 2) then
		if type(stat.burst_delay) == 'table' then
			return {
				calcBurstAverageFirerate(stat, stat.burst_delay[1]),
				calcBurstAverageFirerate(stat, stat.burst_delay[2]),
				calcBurstAverageFirerate(stat, stat.burst_delay[3]),
				calcBurstAverageFirerate(stat, stat.burst_delay[4]),
			}
		elseif aw.isNumberAndGreaterThanZero(stat.burst_delay) then
			return calcBurstAverageFirerate(stat, stat.burst_delay)
		else
			return 0
		end
	end
	
	-- Revved Up
	if opts.useRevvedUpMode and aw.isNumberAndGreaterThanOrEqualToX(stat.firerate_revvedup, stat.firerate) then
		return stat.firerate_revvedup
	end
	
	-- w/Turbocharger
	if opts.useTurbocharger and stat.turbocharger then
		return {
			 stat.turbocharger.firerate         or stat.firerate,
			 stat.turbocharger.firerate_maximum or stat.firerate_maximum,
		}
	end
	
	-- Variable firerate
	if aw.isNumberAndGreaterThanOrEqualToX(stat.firerate_maximum, stat.firerate) then
		return {
			 stat.firerate,
			 stat.firerate_maximum,
		}
	end
	
	-- w/Anvil Receiver
	if opts.useAnvilReceiver and stat.anvil_receiver then
		return stat.anvil_receiver.firerate
	end
	
	-- w/Charge
	if aw.isNumberAndGreaterThanZero(stat.charge) then
		if aw.isNumberAndGreaterThanZero(stat.charge_minimum) then
			return {
				calcRechamberFirerate(stat, stat.charge_minimum),
				calcRechamberFirerate(stat, stat.charge),
			}
		elseif aw.isNumberAndGreaterThanZero(stat.rechamber) then
			return {
				calcRechamberFirerate(stat, stat.rechamber),
				calcRechamberFirerate(stat, stat.rechamber + stat.charge),
			}
		else
			return {
				stat.firerate,
				calcRechamberFirerate(stat, stat.charge),
			}
		end
	end
	
	-- w/Rechamber
	if type(stat.rechamber) == 'table' then
		return {
			calcRechamberFirerate(stat, stat.rechamber[1]),
			calcRechamberFirerate(stat, stat.rechamber[2]),
			calcRechamberFirerate(stat, stat.rechamber[3]),
			calcRechamberFirerate(stat, stat.rechamber[4]),
		}
	elseif aw.isNumberAndGreaterThanZero(stat.rechamber) then
		return calcRechamberFirerate(stat, stat.rechamber)
	end
	
	return stat.firerate
end

return apex