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

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

提供:Apex Data
ナビゲーションに移動 検索に移動
(射撃レートに関する関数を追加)
(射撃レートに関する関数の改善)
101行目: 101行目:


-- [[ 射撃レート計算 ]]
-- [[ 射撃レート計算 ]]
local function chooseData(data, level)
local typename = type(data)
if typename == 'table' then
return data[level]
elseif typename == 'number' then
return data
elseif typename == 'string' then
return tonumber(data)
else
return 0
end
end
function apex.calcFirerate(stat, mode, level)
function apex.calcFirerate(stat, mode, level)
level = (1 + level) or 1
level = (1 + level) or 1
107行目: 120行目:
if mode == apex.BURST then
if mode == apex.BURST then
if aw.isNumberAndGreaterThanZero(stat.mode.burst) then
if aw.isNumberAndGreaterThanZero(stat.mode.burst) then
local typename = type(stat.firerate.burst_delay)
local firerate = chooseData(stat.firerate.single, level)
local burst_delay
if firerate > 0 then
if typename == 'table' then
local delay = chooseData(stat.firerate.burst_delay, level)
burst_delay = stat.firerate.burst_delay[level]
if delay > 0 then
else
rps = stat.mode.burst / ((stat.mode.burst - 1) / firerate + delay)
burst_delay = stat.firerate.burst_delay
else
rps = firerate
end
end
end
rps = stat.mode.burst / ((stat.mode.burst - 1) / stat.firerate.burst + burst_delay)
end
end
elseif mode == apex.AUTO then
elseif mode == apex.AUTO then
if stat.mode.auto then
if stat.mode.auto then
local typename = type(stat.firerate.auto)
rps = chooseData(stat.firerate.auto, level)
if typename == 'table' then
rps = stat.firerate.auto[level]
else
rps = stat.firerate.auto
end
end
end
elseif mode == apex.SINGLE then
elseif mode == apex.SINGLE then
if stat.mode.single then
if stat.mode.single then
local typename = type(stat.firerate.single)
local firerate = chooseData(stat.firerate.single, level)
if typename == 'table' then
if firerate > 0 then
rps = stat.firerate.single[level]
local rechamber = chooseData(stat.firerate.single_rechamber, level)
else
if rechamber > 0 then
rps = stat.firerate.single
rps = 1 / (1 / firerate + rechamber)
end
else
rps = firerate
if aw.isNumberAndGreaterThanZero(stat.firerate.single_rechamber) then
end
rps = 1 / (1 / rps + stat.firerate.single_rechamber)
end
end
end
end
elseif mode == apex.ANVIL_RECEIVER then
elseif mode == apex.ANVIL_RECEIVER then
if stat.firerate.anvil_receiver then
if stat.mode.single then
rps = stat.firerate.anvil_receiver
rps = chooseData(stat.firerate.anvil_receiver, level)
end
end
end
end

2021年3月18日 (木) 09:57時点における版

このモジュールについての説明文ページを モジュール: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.calcDamageFromPartAndPassive(base, partmul, passive, opts)
	-- 部位倍率
	if partmul ~= 1 then
		base = aw.round(partmul * base)
	end
	
	-- 小柄・鉄壁
	if passive == 1.05 then
		if not opts.round then
			base = aw.roundover(passive * base)
		else
			base = aw.round(passive * base)
		end
	elseif passive ~= 1 then
		base = aw.round(passive * base)
	end
	
	return base
end

-- [[ ダメージ計算 ]]
function apex.calcDamage(base, partmul, passive, opts)
	opts = opts or {}
	opts.hammerpointRounds = opts.hammerpointRounds or 0
	
	-- 増幅バリケード
	if opts.ampedCover then
		base = aw.round(1.2 * base)
	end
	
	-- ハンマーポイント弾
	if opts.hammerpointRounds > 1 then
		base = math.floor(opts.hammerpointRounds * base)
	end
	
	-- 部位倍率/小柄・鉄壁
	base = apex.calcDamageFromPartAndPassive(base, partmul, passive, opts)
	
	-- ビームダメージ
	if opts.beam and aw.isNumberAndGreaterThanOrEqualToZero(opts.beam.damage) then
		local beamdamage = apex.calcDamageFromPartAndPassive(opts.beam.damage, partmul, passive, opts)
		base = base + opts.beam.ticks * beamdamage
	end
	
	return base
end

-- 射撃モード
apex.BURST               = 0
apex.DOUBLE_TAP_TRIGGER  = apex.BURST
apex.AUTO                = 100
apex.SINGLE              = 200
apex.ANVIL_RECEIVER      = 201
apex.SELECTFIRE_RECEIVER = 300

-- [[ 複数の射撃レートが定義されているかどうか ]]
function apex.hasMultipleFirerate(stat, mode)
	local firerate = stat.firarate
	if not firarate then
		return false
	end
	
	if mode == apex.BURST then
		return type(firerate.burst_delay) == 'table'
	elseif mode == apex.AUTO then
		return type(firerate.auto) == 'table'
	elseif mode == apex.SINGLE then
		return type(firerate.single) == 'table' or type(firerate.single_rechamber) == 'table'
	else
		return false
	end
end

-- [[ 射撃レート計算 ]]
local function chooseData(data, level)
	local typename = type(data)
	if typename == 'table' then
		return data[level]
	elseif typename == 'number' then
		return data
	elseif typename == 'string' then
		return tonumber(data)
	else
		return 0
	end
end

function apex.calcFirerate(stat, mode, level)
	level = (1 + level) or 1
	
	local rps = 0
	if mode == apex.BURST then
		if aw.isNumberAndGreaterThanZero(stat.mode.burst) then
			local firerate = chooseData(stat.firerate.single, level)
			if firerate > 0 then
				local delay = chooseData(stat.firerate.burst_delay, level)
				if delay > 0 then
					rps = stat.mode.burst / ((stat.mode.burst - 1) / firerate + delay)
				else
					rps = firerate
				end
			end
		end
	elseif mode == apex.AUTO then
		if stat.mode.auto then
			rps = chooseData(stat.firerate.auto, level)
		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 then
			rps = chooseData(stat.firerate.anvil_receiver, level)
		end
	end
	
	return rps
end

return apex