Module:WeaponDPS: Difference between revisions

From HighSpell Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(13 intermediate revisions by the same user not shown)
Line 5: Line 5:
     local parent = frame:getParent()
     local parent = frame:getParent()


     local str = tonumber(args.Strength or parent.args.Strength)
     local str = tonumber(args.Strength or parent.args.Strength) or 0
        or tonumber(args.Magic or parent.args.Magic)
    local acc = tonumber(args.Accuracy or parent.args.Accuracy) or 0
        or tonumber(args.Range or parent.args.Range)
 
     local ticks = tonumber(args.Speed or parent.args.Speed)
     local ticks = tonumber(args.Speed or parent.args.Speed)


     if not str then return "No STR" end
     if (str == 0 and acc == 0) then return "No STR or ACC" end
     if not ticks then return "No speed" end
     if not ticks then return "No speed" end


     local maxHit = str / 8
    local effectiveStr = str + acc
     local maxHit = effectiveStr / 14
     local seconds = ticks * 0.6
     local seconds = ticks * 0.6
     local dps = maxHit / seconds
     local dps = maxHit / seconds


     return string.format("%.2f", (dps * 10))
     return '<abbr title="Theoretical damage per second">' .. string.format('%.2f', dps) .. '</abbr>'
end
end


return p
return p

Latest revision as of 19:30, 12 June 2025

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

local p = {}

function p.dps(frame)
    local args = frame.args
    local parent = frame:getParent()

    local str = tonumber(args.Strength or parent.args.Strength) or 0
    local acc = tonumber(args.Accuracy or parent.args.Accuracy) or 0
    local ticks = tonumber(args.Speed or parent.args.Speed)

    if (str == 0 and acc == 0) then return "No STR or ACC" end
    if not ticks then return "No speed" end

    local effectiveStr = str + acc
    local maxHit = effectiveStr / 14
    local seconds = ticks * 0.6
    local dps = maxHit / seconds

    return '<abbr title="Theoretical damage per second">' .. string.format('%.2f', dps) .. '</abbr>'
end

return p