Module:Boss collection log calculator

local p = {}

function p.main(frame) local args = frame:getParent.args if args.boss == "TzHaar" then return TzHaar(args) elseif args.boss == "Kalphite Queen" then return KalphiteQueen(args) end end

function KalphiteQueen(args) math.randomseed(os.time) local petDropRate = 2500--Kalphite egg local loops = petDropRate * 800 local petThreshold = 500 local dragonChainbodyDropRate = 128 --Dragon chainbody local dragon2hSwordDropRate = 128 --Dragon 2h sword 1/128, 1/2 local dragon2hSwordHMDropRate = 128 --Dragon 2h sword HM local kalphiteQueenHeadDropRate = 128 --Kalphite queen head local killCount = 0 killCount = tonumber(args.killCount) or 0 local currentKillCount = 0 currentKillCount = killCount local kalphiteEgg = 0 local dragonChainbody = 0 local dragon2hSword = 0 local dragon2hSwordHM = 0 local kalphiteQueenHead = 0 local rangeCount = 0

for i=1,loops do   local petRNG = math.random(1, petDropRate) local dragonChainbodyRNG = math.random(1, dragonChainbodyDropRate) local dragon2hSwordRNG = math.random(1, dragon2hSwordDropRate) local dragon2hSwordHMRNG = math.random(1, dragon2hSwordHMDropRate) local kalphiteQueenHeadRNG = math.random(1, kalphiteQueenHeadDropRate) currentKillCount = currentKillCount + 1 if currentKillCount >= petThreshold * 9 then if petRNG >= 1 and petRNG <= 10 then drop[1] = drop[1] + 1 end elseif currentKillCount >= petThreshold * 8 then if petRNG >= 1 and petRNG <= 9 then kalphiteEgg = kalphiteEgg + 1 end elseif currentKillCount >= petThreshold * 7 then if petRNG >= 1 and petRNG <= 8 then kalphiteEgg = kalphiteEgg + 1 end elseif currentKillCount >= petThreshold * 6 then if petRNG >= 1 and petRNG <= 7 then kalphiteEgg = kalphiteEgg + 1 end elseif currentKillCount >= petThreshold * 5 then if petRNG >= 1 and petRNG <= 6 then kalphiteEgg = kalphiteEgg + 1 end elseif currentKillCount >= petThreshold * 4 then if petRNG >= 1 and petRNG <= 5 then kalphiteEgg = kalphiteEgg + 1 end elseif currentKillCount >= petThreshold * 3 then if petRNG >= 1 and petRNG <= 4 then kalphiteEgg = kalphiteEgg + 1 end elseif currentKillCount >= petThreshold * 2 then if petRNG >= 1 and petRNG <= 3 then kalphiteEgg = kalphiteEgg + 1 end elseif currentKillCount >= petThreshold * 1 then if petRNG >= 1 and petRNG <= 2 then kalphiteEgg = kalphiteEgg + 1 end elseif petRNG == 1 then kalphiteEgg = kalphiteEgg + 1 end if dragonChainbodyRNG == 1 then dragonChainbody = dragonChainbody +1 end if dragon2hSwordRNG == 1 then if math.random(1, 2) == 2 then dragon2hSword = dragon2hSword +1 end end if kalphiteQueenHeadRNG == 1 then kalphiteQueenHead = kalphiteQueenHead +1 end if kalphiteEgg >= 1 and dragonChainbody >= 1 and dragon2hSword >= 1 and kalphiteQueenHead >= 1 then rangeCount = rangeCount + 1 kalphiteEgg = 0 dragonChainbody = 0 dragon2hSword = 0 dragon2hSwordHM = 0 kalphiteQueenHead = 0 currentKillCount = killCount end end local averageKills = loops / rangeCount local s = "" .. "The selected boss collection log was completed in " .. string.format("%.0f", averageKills) .. " kills on average, across a simulation of " .. string.format("%.0f", loops) .. " kills." .. " " return s end

function TzHaar(args) math.randomseed(os.time) local petDropRate = 200--Volcanic shard local loops = petDropRate * 1000 local killCount = 0 killCount = tonumber(args.killCount) or 0 local currentKillCount = 0 currentKillCount = killCount local threshold = 40 local drop = {0} local range = {0} local rangeCount = 0

for i=1,loops do   local value = math.random(1, petDropRate) currentKillCount = currentKillCount + 1 if currentKillCount >= threshold * 9 then if value >= 1 and value <= 10 then drop[1] = drop[1] + 1 range[1] = range[1] + 1 currentKillCount = killCount end elseif currentKillCount >= threshold * 8 then if value >= 1 and value <= 9 then drop[1] = drop[1] + 1 range[1] = range[1] + 1 currentKillCount = killCount end elseif currentKillCount >= threshold * 7 then if value >= 1 and value <= 8 then drop[1] = drop[1] + 1 range[1] = range[1] + 1 currentKillCount = killCount end elseif currentKillCount >= threshold * 6 then if value >= 1 and value <= 7 then drop[1] = drop[1] + 1 range[1] = range[1] + 1 currentKillCount = killCount end elseif currentKillCount >= threshold * 5 then if value >= 1 and value <= 6 then drop[1] = drop[1] + 1 range[1] = range[1] + 1 currentKillCount = killCount end elseif currentKillCount >= threshold * 4 then if value >= 1 and value <= 5 then drop[1] = drop[1] + 1 range[1] = range[1] + 1 currentKillCount = killCount end elseif currentKillCount >= threshold * 3 then if value >= 1 and value <= 4 then drop[1] = drop[1] + 1 range[1] = range[1] + 1 currentKillCount = killCount end elseif currentKillCount >= threshold * 2 then if value >= 1 and value <= 3 then drop[1] = drop[1] + 1 range[1] = range[1] + 1 currentKillCount = killCount end elseif currentKillCount >= threshold * 1 then if value >= 1 and value <= 2 then drop[1] = drop[1] + 1 range[1] = range[1] + 1 currentKillCount = killCount end elseif value == 1 then drop[1] = drop[1] + 1 range[1] = range[1] + 1 currentKillCount = killCount end if range[1] > 0 then if currentKillCount < 3 then i = i + currentKillCount end range[1] = 0 rangeCount = rangeCount + 1 currentKillCount = killCount end end local averageKills = loops / drop[1] local finalRangeCount = loops / rangeCount local s = "" .. "The selected boss collection log was completed in " .. string.format("%.0f", averageKills) .. " kills on average, across a simulation of " .. string.format("%.0f", loops) .. " kills." .. " " return s end

return p