1
0
Fork 0

loot chance: fix 1 in N chance calculation.

add mc 2nd roll when enchanted to base chance value
remove unused math.floor calculation from num to drop
remove looting_ignore_chance, only used for ghast and
its not needed.
This commit is contained in:
bakawun 2023-12-06 09:03:05 +01:00
parent 4b63ff1c2a
commit 348c96a9e0
1 changed files with 8 additions and 5 deletions

View File

@ -104,20 +104,23 @@ function mob_class:item_drop(cooked, looting_level)
if chance_function then
chance = chance_function(looting_level)
elseif looting_type == "rare" then
chance = chance + (dropdef.looting_factor or 0.01) * looting_level
local enchant_bonus = (dropdef.looting_factor or 0.01) * looting_level
chance = chance + enchant_bonus
--simulate 2nd roll by adding its chance value
local chance_bonus = chance * (looting_level / (looting_level + 1))
chance = chance + chance_bonus
end
end
local num = 0
local do_common_looting = (looting_level > 0 and looting_type == "common")
if math.random() < chance then
chance = math.floor(1 / chance)
if math.random(1, chance) == 1 then
num = math.random(dropdef.min or 1, dropdef.max or 1)
elseif not dropdef.looting_ignore_chance then
do_common_looting = false
end
if do_common_looting then
num = num + math.floor(math.random(0, looting_level) + 0.5)
num = num + math.random(0, looting_level)
end
if num > 0 then