2,875
edits
No edit summary |
No edit summary |
||
Line 230: | Line 230: | ||
error(msg) | error(msg) | ||
end | end | ||
end | |||
-- Returns the probability of getting at least one drop, provided | |||
-- the drop rate and the current amount of drops. | |||
function p.getDropProbability(dropRate, totalDrops) | |||
dropRate = p.clamp(dropRate, 0, 1) | |||
return 1 - (1- dropRate) ^ 500 | |||
end | |||
-- Returns the amount of drops required for a certain drop probability. | |||
function p.getDropsForProbability(dropRate, probability) | |||
dropRate = p.clamp(dropRate, 0, 1) | |||
probability = p.clamp(probability, 0, 1) | |||
return math.log(1 - probability) / math.log(1 - dropRate) | |||
end | end | ||
return p | return p |
edits