Module:Sandbox/User:Sfoxrs/4
Documentation for this module may be created at Module:Sandbox/User:Sfoxrs/4/doc
-- <pre>
local p = {}
local yesno = require ("Module:Yesno")
function p.main(frame)
math.randomseed(os.time())
local args = frame:getParent().args
local min_hit = tonumber(args.minHit) or 0
local max_hit = tonumber(args.maxHit) or 0
local gearLevel20 = yesno(args.level20) or false
local proc = .20
if gearLevel20 then
proc = proc * 1.1
end
local absorbativeDamage = 0
local totalDamage = 0
local averageDamageBetweenProcs = {0,0,0}
local averageDamageRatioOverTime = {0,0,0}
local pastHits = 0 --hits that failed to proc.
local absorbativeHit = 0
local res = ""
if min_hit > max_hit then
return "The minimum hit must not be higher than the maximum hit."
end
for perkRank = 1,3 do
absorbativeDamage=0
totalDamage=0
for n = 0,2499 do
pastHits=0
for iHitsNoProc = 1,n do
local randomHit = math.floor(math.random(min_hit,max_hit))
pastHits = pastHits + randomHit
end
absorbativeHit = math.floor(math.random(min_hit,max_hit))
absorbativeDamage = absorbativeDamage + (math.pow(1-proc,n)*proc * (pastHits + math.floor(absorbativeHit - .05*perkRank*absorbativeHit)) )
totalDamage = totalDamage + (math.pow(1-proc,n)*proc * (pastHits + absorbativeHit))
--averageDamageBetweenProcs[perkRank] = averageDamageBetweenProcs[perkRank] + (math.pow(1-proc[perkRank],n)*proc[perkRank] * (pastHits + 1) / (pastHits + luckyHit) )
end
averageDamageRatioOverTime[perkRank] = averageDamageRatioOverTime[perkRank] + absorbativeDamage/totalDamage
end
for perkRank = 1,3 do
res = res .. "Average damage reduction from Absorbative " .. perkRank .. " : " .. string.format("%2.2f",(1-averageDamageRatioOverTime[perkRank])*100) .. "%<br/>"
end
--[[
res = res .. "<br/>"
for perkRank = 1,3 do
res = res .. "Average damage reduction between procs from Absorbative " .. perkRank .. " : " .. string.format("%2.2f",(1-averageDamageBetweenProcs[perkRank])*100) .. "%<br/>"
end
]]--
return res
end
return p