Module:WeaponDPS: Difference between revisions

From HighSpell Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 10: Line 10:
end
end


-- Theoretical DPS formula (accuracy removed, balanced)
-- Theoretical DPS formula (accuracy = 1/3 of a damage stat)
function p.dps(frame)
function p.dps(frame)
local args = frame:getParent().args
local args = frame:getParent().args
local accuracy = tonumber(args["accuracy"]) or 0
local strength = tonumber(args["strength"]) or 0
local strength = tonumber(args["strength"]) or 0
local magic = tonumber(args["magic"]) or 0
local magic = tonumber(args["magic"]) or 0
Line 19: Line 20:


if speed <= 0 then
if speed <= 0 then
return 0.0
return "Invalid speed"
end
end


local attacksPerSecond = getAttacksPerSecond(speed)
local attacksPerSecond = getAttacksPerSecond(speed)
local offensiveStat = strength + magic + range


-- Scaled-down DPS formula
-- Weight accuracy as one-third of a damage stat
local dps = offensiveStat * attacksPerSecond * 0.25
local weightedStat = (accuracy / 3) + strength + magic + range
 
-- Scaled DPS calculation
local dps = weightedStat * attacksPerSecond * 0.1


return string.format("%.2f", dps)
return string.format("%.2f", dps)

Revision as of 12:31, 22 May 2025

Documentation for this module may be created at Module:WeaponDPS/doc

local p = {}

-- Converts speed to attacks per second
local function getAttacksPerSecond(speed)
	if speed <= 0 then
		return 0
	end
	local attackTimeSeconds = speed * 0.6
	return 1 / attackTimeSeconds
end

-- Theoretical DPS formula (accuracy = 1/3 of a damage stat)
function p.dps(frame)
	local args = frame:getParent().args
	local accuracy = tonumber(args["accuracy"]) or 0
	local strength = tonumber(args["strength"]) or 0
	local magic = tonumber(args["magic"]) or 0
	local range = tonumber(args["range"]) or 0
	local speed = tonumber(args["speed"]) or 0

	if speed <= 0 then
		return "Invalid speed"
	end

	local attacksPerSecond = getAttacksPerSecond(speed)

	-- Weight accuracy as one-third of a damage stat
	local weightedStat = (accuracy / 3) + strength + magic + range

	-- Scaled DPS calculation
	local dps = weightedStat * attacksPerSecond * 0.1

	return string.format("%.2f", dps)
end

return p