|
|
Line 1: |
Line 1: |
| local p = {} | | 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/2 of a damage stat)
| |
| function p.dps(frame) | | function p.dps(frame) |
| local args = frame:getParent().args
| | local str = tonumber(frame.args.str) |
| local accuracy = tonumber(args["accuracy"]) or 0
| | local ticks = tonumber(frame.args.ticks) |
| local strength = tonumber(args["strength"]) or 0
| |
| local magic = tonumber(args["magic"]) or 0
| |
| local range = tonumber(args["range"]) or 0
| |
| local speed = tonumber(mw.text.trim(args["speed"] or "")) or 0
| |
| | |
| if speed <= 0 then
| |
| return "Invalid speed"
| |
| end
| |
| | |
| local attacksPerSecond = getAttacksPerSecond(speed)
| |
|
| |
|
| -- Weight accuracy as one-third of a damage stat
| | if not str or not ticks or ticks == 0 then |
| local weightedStat = (accuracy / 2) + strength + magic + range
| | return "Invalid input" |
| | end |
|
| |
|
| -- Scaled DPS calculation
| | local maxHit = str / 8 |
| local dps = weightedStat * attacksPerSecond * 0.2
| | local seconds = ticks * 0.6 |
| | local dps = maxHit / seconds |
|
| |
|
| return string.format("%.2f", dps)
| | return string.format("%.2f DPS (Max Hit: %.2f)", dps, maxHit) |
| end | | end |
|
| |
|
| return p | | return p |