Module:Weapon Calculation: Difference between revisions
From Horizon Wiki Mirror
Content deleted Content added
imported>Starfox9507 No edit summary |
imported>Starfox9507 No edit summary |
||
| (19 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
local p = {} |
local p = {} |
||
-- http://lua-users.org/wiki/SimpleRound |
|||
function round(num) |
function round(num, numDecimalPlaces) |
||
| ⚫ | |||
local mult = 10^(numDecimalPlaces or 0) |
|||
| ⚫ | |||
end |
end |
||
-- this calculation is done in the game engine, |
|||
| ⚫ | |||
-- highlighting that the delays used in the DATs |
|||
-- are not precisely accurate within the game engine calcs |
|||
function getTrueDelay ( delay ) |
|||
return math.floor( math.floor(delay * 1000 / 60) * 60 / 1000) |
|||
end |
|||
| ⚫ | |||
local damage = tonumber(frame.args.dmg) |
local damage = tonumber(frame.args.dmg) |
||
local delay = tonumber(frame.args.delay) |
local delay = tonumber(frame.args.delay) |
||
delay = getTrueDelay ( delay ) |
|||
| ⚫ | |||
local weapontype = frame.args.type or nil |
local weapontype = frame.args.type or nil |
||
local changes = frame.args.changes or nil |
local changes = frame.args.changes or nil |
||
local dps |
local dps; |
||
if |
if not ( weapontype == "hand-to-hand" ) then |
||
dps = round( ( damage * 60 ) / delay ) |
dps = round( ( damage * 60 ) / delay, 2 ) |
||
else |
|||
dps = round( (( damage * 60 ) / ( 480 + delay) * 2 ), 2 ) |
|||
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) |
|||
delay = getTrueDelay ( 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 ( delay > 530) then tpph = (14.5 + ((( delay - 530) * 3.5) / 470) ) * 10 |
|||
elseif ( delay >= 480 ) then tpph = (13.0 + ((( delay - 480) * 1.5) / 50) ) * 10 |
|||
elseif ( delay >= 450 ) then tpph = (11.5 + ((( delay - 450) * 1.5) / 30) ) * 10 |
|||
elseif ( delay >= 180 ) then tpph = (5.0 + ((( delay - 180) * 6.5) / 270) ) * 10 |
|||
else tpph = (5.0 + ((( delay - 180) * 1.5) / 180) ) * 10 |
|||
end |
|||
tpph = math.floor(tpph) |
|||
else |
|||
delay = delay + 480 |
|||
if ( delay >= 530 ) then |
|||
| ⚫ | |||
else |
|||
if ( delay > 480 ) then |
|||
tpph = (13.0 + ((delay * 1.5) / 50) - 13.05) * 10 |
|||
else |
|||
tpph = 0 |
|||
end |
|||
end |
|||
tpph = math.floor(tpph) |
|||
tpph = "+" .. tpph |
|||
-- 2 == DMG, 3 == DELAY |
|||
end |
|||
-- {{#switch:{{{1|}}} |
|||
-- | dps | damage per second = {{#iferror:{{#expr:{{{2}}} + {{{3}}}}}||{{#ifeq:hand-to-hand|{{lc:{{{type}}}}}|+{{#expr: ({{{2}}} * 60) / (480 + {{{3}}}) * 2 round 2}}|{{#expr: ({{{2}}} * 60) / {{{3}}} round 2}} }} }} |
|||
return tpph |
|||
-- | tp per hit = {{#iferror:{{#expr:{{{2|}}}}}||{{#ifeq:hand-to-hand|{{lc:{{{type}}}}}|+<!--- |
|||
end |
|||
| ⚫ | |||
-- --->{{#ifexpr:({{{2}}} + 480) > 480|{{#expr:(13.0 + ((({{{2}}} + 0) * 1.5) / 50) - 13.05 round 1) * 10}}|0}} }}|<!--- |
|||
-- --->{{#ifexpr:{{{2}}} >= 530|{{#expr:(14.5 + ((({{{2}}} - 530) * 3.5) / 470) - 0.05 round 1) * 10}}|<!--- |
|||
-- --->{{#ifexpr:{{{2}}} >= 480|{{#expr:(13.0 + ((({{{2}}} - 480) * 1.5) / 50) - 0.05 round 1) * 10}}|<!--- |
|||
-- --->{{#ifexpr:{{{2}}} >= 450|{{#expr:(11.5 + ((({{{2}}} - 450) * 1.5) / 30) - 0.05 round 1) * 10}}|<!--- |
|||
-- --->{{#ifexpr:{{{2}}} >= 180|{{#expr:(5.0 + ((({{{2}}} - 180) * 6.5) / 270) - 0.05 round 1) * 10}}|<!--- |
|||
-- --->{{#ifexpr:{{{2}}} >= 0|{{#expr:(5.0 + ((({{{2}}} - 180) * 1.5) / 180) - 0.05 round 1) * 10}}|}} }} }} }} }} }} }} |
|||
-- }} |
|||
Latest revision as of 18:05, 4 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
-- this calculation is done in the game engine,
-- highlighting that the delays used in the DATs
-- are not precisely accurate within the game engine calcs
function getTrueDelay ( delay )
return math.floor( math.floor(delay * 1000 / 60) * 60 / 1000)
end
function p.dps (frame)
local damage = tonumber(frame.args.dmg)
local delay = tonumber(frame.args.delay)
delay = getTrueDelay ( 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)
delay = getTrueDelay ( 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 ( delay > 530) then tpph = (14.5 + ((( delay - 530) * 3.5) / 470) ) * 10
elseif ( delay >= 480 ) then tpph = (13.0 + ((( delay - 480) * 1.5) / 50) ) * 10
elseif ( delay >= 450 ) then tpph = (11.5 + ((( delay - 450) * 1.5) / 30) ) * 10
elseif ( delay >= 180 ) then tpph = (5.0 + ((( delay - 180) * 6.5) / 270) ) * 10
else tpph = (5.0 + ((( delay - 180) * 1.5) / 180) ) * 10
end
tpph = math.floor(tpph)
else
delay = delay + 480
if ( delay >= 530 ) then
tpph = (14.5 + ((( delay - 50) * 3.5) / 470) - 14.18) * 10
else
if ( delay > 480 ) then
tpph = (13.0 + ((delay * 1.5) / 50) - 13.05) * 10
else
tpph = 0
end
end
tpph = math.floor(tpph)
tpph = "+" .. tpph
end
return tpph
end
return p