Having trouble with luck boost system

I have a chance/roll system similar to Sol’s RNG. 1 in 3, 1 in 10, 1 in 10.000 and so on. What I am trying to achieve is like 10% luck boost, 20% or even 100% luck boost. How could I implement this without it making easier to pull common ones as well.

local module = {
	getRandomIndex = function(chances, luck)
		for i,v in ipairs(chances) do
			local totalluck = luck
			
			local randomNumber = math.random(1, v[2])
			if randomNumber == 1 and v[2] > chances[1][2] then
				return {
					v[1]; v[2];
				}
			end
		end

		return chances[1]
	end,
}

return module
1 Like

I believe how other RNG-based games do this is by sorting the loottable based on rarity (rarest to most common using table.sort) and then adding the amount of luck boost on 3/4 of the loot table, subtracting the amount of luck boost from the last quarter (1/4). You could also add a minimum rarity amount that get their chances boosted