local generator = Chance.new({
Rare = 30,
Epic = 20,
Legendary = 10,
Mythical = 1,
Exotic = 0.1,
})
local runs = 0
for i = 1, 100 do
runs += 1
local type = generator:Run() or "Common"
if type == "Exotic" or runs == 50 then
type = "Exotic"
runs = 0
end
print(type)
end
With this code, you will get an exotic after 50 attempts. This is unbalanced, but you get the idea.
If you’re making an RNG game like Sol’s RNG, do you find this module hard to use? It’s not necessarily meant for the 1 in x chance system, but it could still work. If it doesn’t work well with RNG games, what interface would you like to see that makes it easiest to work with?
Additionally, it would help if I made a new luck logic system. I currently do not like the luck system, but I’m not sure of how to code a better one.
wait quick question how would you make it so that if a player wins a game their chances to get a role increases like for murder. So like 10 player playing start off with 10% and then player 4 wins and his chance to become the murder increases.
You can utilize Super.fromResult for this! It’s use case is to turn the results from rolling many times into its assumed chances, but you can also use it for weighted chance values. For example, if they all have a weight of 1, they are all equally likely. You can increase a player’s weight by 1 if they don’t get a special role and reduce it to 1 when they do!
It quite literally says weighted in the post title my friend.
Short explanation:
A weighted loot system is <mark>a system that uses weights to determine the likelihood of an item being dropped in a game</mark>. Items with higher weights are more likely to be chosen.
Here is a snippet from the module:
elseif self.Type == "Weight" then
local TotalWeight = 0
for _, Weight in pairs(ItemNums) do
TotalWeight += Weight
end
local Choice = RandItem:NextNumber(0, TotalWeight)
for Item, Weight in pairs(ItemNums) do
Choice -= Weight
if Choice <= 0 then
Found = self.Items[Item]
break
end
end
Sorry, I’ve made a mistake! This module isn’t the same as what I’m using now… it doesn’t use an RNG system like in Sol’s RNG like I just said. It still uses percent chances… My bad for the confusion.
I’m closer to finishing Boost right now, I’d have to be inspired to work on Chance again! I’m also hard at work with a game, so it could take a few months to get around to this. For now, you’re free to editing the module as needed for your projects!