So i have a rng system setup and its kinda like this
{Name = "Trash", Weight = 70.0, BasePrice = 1},
{Name = "Common", Weight = 18.0, BasePrice = 6},
{Name = "Uncommon", Weight = 8.0, BasePrice = 30},
{Name = "Rare", Weight = 3.0, BasePrice = 150},
{Name = "Legendary", Weight = 0.9, BasePrice = 750},
{Name = "Mythic", Weight = 0.09, BasePrice = 3750},
{Name = "Divine", Weight = 0.01, BasePrice = 18750}
but the rarity doesnt seem to work properly?
local function rollForFish()
local roll = math.random() * 100
local counter = 0
local sizeMult = (math.random(100, 250) / 100)
for _, rarity in ipairs(FishData.Rarities) do
counter += rarity.Weight
if roll <= counter then
local list = FishData.Fish[rarity.Name]
if rarity.Name == "Trash" and math.random(1, 10) == 1 then
list = FishData.Fish["RareTrash"]
end
local fishName = list[math.random(1, #list)]
return {
Name = fishName,
Price = math.floor(rarity.BasePrice * sizeMult),
Weight = string.format("%.2f", sizeMult * 5),
Rarity = rarity.Name
}
end
end
end
but it doesnt seems to work so can someone help :D
** You are now Level 1! **