Module:Weapon Calculation: Difference between revisions
From HorizonXI Wiki
Starfox9507 (talk | contribs) No edit summary |
Starfox9507 (talk | contribs) No edit summary |
||
| Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
function round(num) | -- http://lua-users.org/wiki/SimpleRound | ||
return math.floor(num * | function round(num, numDecimalPlaces) | ||
local mult = 10^(numDecimalPlaces or 0) | |||
return math.floor(num * mult + 0.5) / mult | |||
end | end | ||
function p. | function p.dmg (frame) | ||
local damage = tonumber(frame.args.dmg) | local damage = tonumber(frame.args.dmg) | ||
local delay = tonumber(frame.args.delay) | local delay = tonumber(frame.args.delay) | ||
| Line 11: | Line 13: | ||
local changes = frame.args.changes or nil | local changes = frame.args.changes or nil | ||
local dps | local dps; | ||
if not ( weapontype == "hand-to-hand" ) then | if not ( weapontype == "hand-to-hand" ) then | ||
dps = round( ( damage * 60 ) / delay ) | dps = round( ( damage * 60 ) / delay, 2 ) | ||
else | else | ||
dps = round( ( damage * 60 ) / ( 480 + delay) * 2 ) | dps = round( (( damage * 60 ) / ( 480 + delay) * 2 ), 2 ) | ||
dps = "+" .. dps | dps = "+" .. dps | ||
end | end | ||
return dps | return dps | ||
end | end | ||
function p.tphit (frame) | |||
local damage = tonumber(frame.args.dmg) | |||
local delay = tonumber(frame.args.delay) | |||
local weapontype = frame.args.type or nil | |||
local changes = frame.args.changes or nil | |||
local tpph; | |||
if not ( weapontype == "hand-to-hand" ) then | |||
if ( damage > 530) then tpph = round( (14.5 + ((( damage - 530) * 3.5) / 470) - 0.05) , 1) * 10 | |||
elseif ( damage >= 480 ) then tpph = round( (13.0 + ((( damage - 480) * 1.5) / 50) - 0.05) , 1) * 10 | |||
elseif ( damage >= 450 ) then tpph = round( (11.5 + ((( damage - 450) * 1.5) / 30) - 0.05) , 1) * 10 | |||
elseif ( damage >= 180 ) then tpph = round( (5.0 + ((( damage - 180) * 6.5) / 270) - 0.05) , 1) * 10 | |||
else tpph = round( (5.0 + ((( damage - 180) * 1.5) / 180) - 0.05) , 1) * 10 | |||
end | |||
else | |||
if ( ( damage + 480 ) >= 530 ) then | |||
tpph = round( (14.5 + ((( damage - 50) * 3.5) / 470) - 14.18), 1) * 10 | |||
else | |||
if ( ( damage + 480 ) > 480 ) then | |||
tpph = round( (13.0 + ((damage * 1.5) / 50) - 13.05), 1) * 10 | |||
else | |||
tpph = 0 | |||
end | |||
end | |||
tpph = "+" .. tpph | |||
end | |||
return tpph | |||
end | |||
return p | return p | ||
Revision as of 11:41, 2 July 2025
Documentation for this module may be created at Module:Weapon Calculation/doc
local p = {}
-- http://lua-users.org/wiki/SimpleRound
function round(num, numDecimalPlaces)
local mult = 10^(numDecimalPlaces or 0)
return math.floor(num * mult + 0.5) / mult
end
function p.dmg (frame)
local damage = tonumber(frame.args.dmg)
local delay = tonumber(frame.args.delay)
local weapontype = frame.args.type or nil
local changes = frame.args.changes or nil
local dps;
if not ( weapontype == "hand-to-hand" ) then
dps = round( ( damage * 60 ) / delay, 2 )
else
dps = round( (( damage * 60 ) / ( 480 + delay) * 2 ), 2 )
dps = "+" .. dps
end
return dps
end
function p.tphit (frame)
local damage = tonumber(frame.args.dmg)
local delay = tonumber(frame.args.delay)
local weapontype = frame.args.type or nil
local changes = frame.args.changes or nil
local tpph;
if not ( weapontype == "hand-to-hand" ) then
if ( damage > 530) then tpph = round( (14.5 + ((( damage - 530) * 3.5) / 470) - 0.05) , 1) * 10
elseif ( damage >= 480 ) then tpph = round( (13.0 + ((( damage - 480) * 1.5) / 50) - 0.05) , 1) * 10
elseif ( damage >= 450 ) then tpph = round( (11.5 + ((( damage - 450) * 1.5) / 30) - 0.05) , 1) * 10
elseif ( damage >= 180 ) then tpph = round( (5.0 + ((( damage - 180) * 6.5) / 270) - 0.05) , 1) * 10
else tpph = round( (5.0 + ((( damage - 180) * 1.5) / 180) - 0.05) , 1) * 10
end
else
if ( ( damage + 480 ) >= 530 ) then
tpph = round( (14.5 + ((( damage - 50) * 3.5) / 470) - 14.18), 1) * 10
else
if ( ( damage + 480 ) > 480 ) then
tpph = round( (13.0 + ((damage * 1.5) / 50) - 13.05), 1) * 10
else
tpph = 0
end
end
tpph = "+" .. tpph
end
return tpph
end
return p
