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

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

提供:Apex Data
ナビゲーションに移動 検索に移動
(射撃レートに関する関数を追加)
(ヘルメット - レベル3の計算が間違っていた問題の修正)
 
(同じ利用者による、間の26版が非表示)
18行目: 18行目:
return 0.2 + 0.8 * headmul
return 0.2 + 0.8 * headmul
elseif part == apex.HEAD_HLMLV2 then
elseif part == apex.HEAD_HLMLV2 then
return 0.4 + 0.6 * headmul
return 0.5 + 0.5 * headmul
elseif part == apex.HEAD_HLMLV3 then
elseif part == apex.HEAD_HLMLV3 then
return 0.5 + 0.5 * headmul
return 0.65 + 0.35 * headmul
else
else
return headmul
return headmul
26行目: 26行目:
end
end


-- [[ 部位倍率とパッシブ倍率を考慮したダメージ計算 ]]
-- [[ ハンマーポイント弾倍率を考慮したダメージ計算 ]]
function apex.calcDamageFromPartAndPassive(base, partmul, passive, opts)
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
if partmul ~= 1 then
base = aw.round(partmul * base)
return aw.round(partmul * base)
else
return base
end
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 passive == 1.05 then
if not opts.round then
if not opts.round then
base = aw.roundover(passive * base)
return aw.roundover(passive * base)
else
else
base = aw.round(passive * base)
return aw.round(passive * base)
end
end
elseif passive ~= 1 then
elseif passive ~= 1 then
base = aw.round(passive * base)
return aw.round(passive * base)
else
return base
end
end
 
-- [[ 部位倍率とパッシブ倍率を考慮したダメージ計算 ]]
function apex.calcDamageFromPartAndPassive(base, partmul, passive, opts)
-- 部位倍率
base = apex.calcPartDamage(base, partmul)
-- 小柄・鉄壁
if (opts and not opts.ignorePassiveForHeadshot) or partmul <= 1 then
base = apex.calcPassiveDamage(base, passive, opts)
end
end
51行目: 82行目:
opts = opts or {}
opts = opts or {}
opts.hammerpointRounds = opts.hammerpointRounds or 0
opts.hammerpointRounds = opts.hammerpointRounds or 0
opts.passthrough      = opts.passthrough or 1
opts.disruptorRounds  = opts.disruptorRounds or 0
-- 増幅バリケード
-- 増幅バリケード
if opts.ampedCover then
if opts.ampedCover then
base = aw.round(1.2 * base)
base = aw.round(1.2 * base)
else
base = aw.round(base)
end
-- チャージ倍率
if opts.charged > 1 then
base = aw.round(opts.charged * base)
end
end
-- ハンマーポイント弾
-- ハンマーポイント弾
if opts.hammerpointRounds > 1 then
if opts.hammerpointRounds > 1 then
base = math.floor(opts.hammerpointRounds * base)
base = apex.calcHammerpointDamage(base, opts.hammerpointRounds)
end
-- 貫通減衰倍率
if opts.passthrough < 1 then
base = apex.calcPassthroughDamage(base, opts.passthrough)
end
end
-- 部位倍率/小柄・鉄壁
-- 部位倍率、小柄・鉄壁
base = apex.calcDamageFromPartAndPassive(base, partmul, passive, opts)
base = apex.calcDamageFromPartAndPassive(base, partmul, passive, opts)
-- ディスラプター弾
if opts.disruptorRounds > 1 then
base = apex.calcDisruptorDamage(base, opts.disruptorRounds)
end
-- ビームダメージ
-- ビームダメージ
if opts.beam and aw.isNumberAndGreaterThanOrEqualToZero(opts.beam.damage) then
if aw.isNumberAndGreaterThanZero(opts.beamdamage) and aw.isNumberAndGreaterThanZero(opts.beamticks)then
local beamdamage = apex.calcDamageFromPartAndPassive(opts.beam.damage, partmul, passive, opts)
local beamdamage = apex.calcDamageFromPartAndPassive(opts.beamdamage, partmul, passive, opts)
base = base + opts.beam.ticks * beamdamage
base = base + opts.beamticks * beamdamage
end
end
74行目: 124行目:
end
end


-- 射撃モード
-- [[ マガジン計算 ]]
apex.BURST              = 0
function apex.calcMagazineWithModdedLoader(magazine)
apex.DOUBLE_TAP_TRIGGER  = apex.BURST
return aw.round(1.15 * magazine)
apex.AUTO                = 100
end
apex.SINGLE              = 200
apex.ANVIL_RECEIVER      = 201
apex.SELECTFIRE_RECEIVER = 300


-- [[ 複数の射撃レートが定義されているかどうか ]]
function apex.calcMagazinesWithModdedLoader(magazines)
function apex.hasMultipleFirerate(stat, mode)
return {
local firerate = stat.firarate
aw.round(1.15 * magazines[1]),
if not firarate then
aw.round(1.15 * magazines[2]),
return false
aw.round(1.15 * magazines[3]),
end
aw.round(1.15 * magazines[4]),
}
if mode == apex.BURST then
end
return type(firerate.burst_delay) == 'table'
 
elseif mode == apex.AUTO then
function apex.getMagazineWithModdedLoader(magazines)
return type(firerate.auto) == 'table'
local magazinesType = type(magazines)
elseif mode == apex.SINGLE then
if magazinesType == 'table' then
return type(firerate.single) == 'table' or type(firerate.single_rechamber) == 'table'
return apex.calcMagazinesWithModdedLoader(magazines)
elseif magazinesType == 'number' then
return apex.calcMagazineWithModdedLoader(magazines)
else
else
return false
return nil
end
end
end
end


-- [[ 射撃レート計算 ]]
-- [[ 射撃レート計算 ]]
function apex.calcFirerate(stat, mode, level)
function apex.calcBurstAverageFirerate(count, delay, firerate)
level = (1 + level) or 1
return count / ((count - 1) / firerate + delay)
end
 
local function calcBurstAverageFirerate(stat, delay)
return apex.calcBurstAverageFirerate(stat.burst_count, delay, stat.firerate)
end
 
function apex.calcRechamberFirerate(firerate, rechamber)
return 1 / (1 / firerate + rechamber)
end
 
function apex.getFirerate(stat, opts)
stat = stat or mw.loadData('Module:Stat/Weapon')[opts.name]
local rps = 0
-- Altfire mode
if mode == apex.BURST then
if opts.useAltfire and aw.isNumberAndGreaterThanZero(stat.altfire.firerate, stat.firerate) then
if aw.isNumberAndGreaterThanZero(stat.mode.burst) then
return stat.altfire.firerate
local typename = type(stat.firerate.burst_delay)
end
local burst_delay
if typename == 'table' then
-- Burst mode
burst_delay = stat.firerate.burst_delay[level]
if aw.isNumberAndGreaterThanOrEqualToX(stat.burst_count, 2) then
else
local delay = stat.burst_delay
burst_delay = stat.firerate.burst_delay
if type(delay) == 'table' then
end
return {
calcBurstAverageFirerate(stat, delay[1]),
rps = stat.mode.burst / ((stat.mode.burst - 1) / stat.firerate.burst + burst_delay)
calcBurstAverageFirerate(stat, delay[2]),
calcBurstAverageFirerate(stat, delay[3]),
calcBurstAverageFirerate(stat, delay[4]),
}
elseif aw.isNumberAndGreaterThanZero(delay) then
return calcBurstAverageFirerate(stat, delay)
end
end
elseif mode == apex.AUTO then
end
if stat.mode.auto then
local typename = type(stat.firerate.auto)
-- Revved Up
if typename == 'table' then
if opts.useRevvedUpMode and aw.isNumberAndGreaterThanOrEqualToX(stat.firerate_revvedup, stat.firerate) then
rps = stat.firerate.auto[level]
return stat.firerate_revvedup
else
end
rps = stat.firerate.auto
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/Double Tap Trigger
if opts.useDoubleTapTrigger and stat.double_tap_trigger and aw.isNumberAndGreaterThanOrEqualToX(stat.double_tap_trigger.burst_count, 2) then
local delay = stat.double_tap_trigger.burst_delay
if type(delay) == 'table' then
return {
calcBurstAverageFirerate(stat.double_tap_trigger, delay[1]),
calcBurstAverageFirerate(stat.double_tap_trigger, delay[2]),
calcBurstAverageFirerate(stat.double_tap_trigger, delay[3]),
calcBurstAverageFirerate(stat.double_tap_trigger, delay[4]),
}
elseif aw.isNumberAndGreaterThanZero(delay) then
return calcBurstAverageFirerate(stat.double_tap_trigger, delay)
end
end
elseif mode == apex.SINGLE then
end
if stat.mode.single then
local typename = type(stat.firerate.single)
-- w/Deadeye's Tempo
if typename == 'table' then
if opts.useDeadeyesTempo and stat.deadeyes_tempo then
rps = stat.firerate.single[level]
if aw.isNumberAndGreaterThanZero(stat.deadeyes_tempo.charge) then
if aw.isNumberAndGreaterThanZero(stat.deadeyes_tempo.charge_minimum) then
return {
apex.calcRechamberFirerate(stat.firerate, stat.deadeyes_tempo.charge_minimum),
apex.calcRechamberFirerate(stat.firerate, stat.deadeyes_tempo.charge),
}
else
else
rps = stat.firerate.single
return apex.calcRechamberFirerate(stat.firerate, stat.deadeyes_tempo.charge)
end
if aw.isNumberAndGreaterThanZero(stat.firerate.single_rechamber) then
rps = 1 / (1 / rps + stat.firerate.single_rechamber)
end
end
elseif aw.isNumberAndGreaterThanZero(stat.deadeyes_tempo.rechamber) then
return apex.calcRechamberFirerate(stat.firerate, stat.deadeyes_tempo.rechamber)
end
end
elseif mode == apex.ANVIL_RECEIVER then
end
if stat.firerate.anvil_receiver then
rps = stat.firerate.anvil_receiver
-- w/Charge
if aw.isNumberAndGreaterThanZero(stat.charge) then
if aw.isNumberAndGreaterThanZero(stat.charge_minimum) then
return {
apex.calcRechamberFirerate(stat.firerate, stat.charge_minimum),
apex.calcRechamberFirerate(stat.firerate, stat.charge),
}
elseif aw.isNumberAndGreaterThanZero(stat.rechamber) then
return {
apex.calcRechamberFirerate(stat.firerate, stat.rechamber),
apex.calcRechamberFirerate(stat.firerate, stat.rechamber + stat.charge),
}
else
return {
stat.firerate,
apex.calcRechamberFirerate(stat.firerate, stat.charge),
}
end
end
end
end
return rps
-- w/Rechamber
if type(stat.rechamber) == 'table' then
return {
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]),
}
elseif aw.isNumberAndGreaterThanZero(stat.rechamber) then
return apex.calcRechamberFirerate(stat.firerate, stat.rechamber)
end
return stat.firerate
end
end


return apex
return apex

2022年5月26日 (木) 00:01時点における最新版

このモジュールについての説明文ページを モジュール: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.5 + 0.5 * headmul
	elseif part == apex.HEAD_HLMLV3 then
		return 0.65 + 0.35 * 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)
	
	-- 小柄・鉄壁
	if (opts and not opts.ignorePassiveForHeadshot) or partmul <= 1 then
		base = apex.calcPassiveDamage(base, passive, opts)
	end
	
	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

-- [[ マガジン計算 ]]
function apex.calcMagazineWithModdedLoader(magazine)
	return aw.round(1.15 * magazine)
end

function apex.calcMagazinesWithModdedLoader(magazines)
	return {
		aw.round(1.15 * magazines[1]),
		aw.round(1.15 * magazines[2]),
		aw.round(1.15 * magazines[3]),
		aw.round(1.15 * magazines[4]),
	}
end

function apex.getMagazineWithModdedLoader(magazines)
	local magazinesType = type(magazines)
	if magazinesType == 'table' then
		return apex.calcMagazinesWithModdedLoader(magazines)
	elseif magazinesType == 'number' then
		return apex.calcMagazineWithModdedLoader(magazines)
	else
		return nil
	end
end

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

local function calcBurstAverageFirerate(stat, delay)
	return apex.calcBurstAverageFirerate(stat.burst_count, delay, stat.firerate)
end

function apex.calcRechamberFirerate(firerate, rechamber)
	return 1 / (1 / 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
		local delay = stat.burst_delay
		if type(delay) == 'table' then
			return {
				calcBurstAverageFirerate(stat, delay[1]),
				calcBurstAverageFirerate(stat, delay[2]),
				calcBurstAverageFirerate(stat, delay[3]),
				calcBurstAverageFirerate(stat, delay[4]),
			}
		elseif aw.isNumberAndGreaterThanZero(delay) then
			return calcBurstAverageFirerate(stat, delay)
		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/Double Tap Trigger
	if opts.useDoubleTapTrigger and stat.double_tap_trigger and aw.isNumberAndGreaterThanOrEqualToX(stat.double_tap_trigger.burst_count, 2) then
		local delay = stat.double_tap_trigger.burst_delay
		if type(delay) == 'table' then
			return {
				calcBurstAverageFirerate(stat.double_tap_trigger, delay[1]),
				calcBurstAverageFirerate(stat.double_tap_trigger, delay[2]),
				calcBurstAverageFirerate(stat.double_tap_trigger, delay[3]),
				calcBurstAverageFirerate(stat.double_tap_trigger, delay[4]),
			}
		elseif aw.isNumberAndGreaterThanZero(delay) then
			return calcBurstAverageFirerate(stat.double_tap_trigger, delay)
		end
	end
	
	-- w/Deadeye's Tempo
	if opts.useDeadeyesTempo and stat.deadeyes_tempo then
		if aw.isNumberAndGreaterThanZero(stat.deadeyes_tempo.charge) then
			if aw.isNumberAndGreaterThanZero(stat.deadeyes_tempo.charge_minimum) then
				return {
					apex.calcRechamberFirerate(stat.firerate, stat.deadeyes_tempo.charge_minimum),
					apex.calcRechamberFirerate(stat.firerate, stat.deadeyes_tempo.charge),
				}
			else
				return apex.calcRechamberFirerate(stat.firerate, stat.deadeyes_tempo.charge)
			end
		elseif aw.isNumberAndGreaterThanZero(stat.deadeyes_tempo.rechamber) then
			return apex.calcRechamberFirerate(stat.firerate, stat.deadeyes_tempo.rechamber)
		end
	end
	
	-- w/Charge
	if aw.isNumberAndGreaterThanZero(stat.charge) then
		if aw.isNumberAndGreaterThanZero(stat.charge_minimum) then
			return {
				apex.calcRechamberFirerate(stat.firerate, stat.charge_minimum),
				apex.calcRechamberFirerate(stat.firerate, stat.charge),
			}
		elseif aw.isNumberAndGreaterThanZero(stat.rechamber) then
			return {
				apex.calcRechamberFirerate(stat.firerate, stat.rechamber),
				apex.calcRechamberFirerate(stat.firerate, stat.rechamber + stat.charge),
			}
		else
			return {
				stat.firerate,
				apex.calcRechamberFirerate(stat.firerate, stat.charge),
			}
		end
	end
	
	-- w/Rechamber
	if type(stat.rechamber) == 'table' then
		return {
			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]),
		}
	elseif aw.isNumberAndGreaterThanZero(stat.rechamber) then
		return apex.calcRechamberFirerate(stat.firerate, stat.rechamber)
	end
	
	return stat.firerate
end

return apex