#I need help with a rarity system
1 messages · Page 1 of 1 (latest)
hi!
i can try to help you
do u need a system from scratch, or edit a pre existing one
oh nvm
do u think u can help me out with this lua function Bnum.rollRarity(items: any, luck: any) local total = '0e0' luck = luck or '1e0' local adjust = {} for _, item in ipairs(items) do local invLuck = Bnum.toStr(Bnum.div('1e0', luck)) local adj = Bnum.toStr(Bnum.pow(item.Chance, invLuck)) adjust = { Item = item, Chance = adj } total = Bnum.toStr(Bnum.add(total, adj)) end local roll = Bnum.toStr(Bnum.clamp(Bnum.mul(math.random(), total), '0e0', total)) for _, item in ipairs(items) do roll = Bnum.toStr(Bnum.sub(roll, item.Chance)) if Bnum.leeq(roll, {0,0}) then return item end end return items[#items] end
but when i do lua function populateRarityList(scrollFrame, rarities) clearChildren(scrollFrame) sortByChance(rarities) local totalBase = '0e0' for _, r in ipairs(rarities) do totalBase = Bnum.add(totalBase, r.Chance) end local totalAdjusted = '0e0' for _, r in ipairs(rarities) do totalAdjusted = Bnum.add(totalAdjusted, computeAdjustedChance(r, Luck.Value)) end for index, r in ipairs(rarities) do local adjChance = computeAdjustedChance(r, Luck.Value) local yourChance = Bnum.mul(Bnum.div(adjChance, totalAdjusted), 100) local baseChance = Bnum.mul(Bnum.div(r.Chance, totalBase), 100) end end the chances here it not doing what i want
i have it just had to make so it wont be to many since its over 4k lines
for some reason some show less then others
i have a weighted chance system i made, i can send it to you if youd like, youll have to add your spesific luck stats n stuff tho
its accurate and all that
but is urs based off of using Bnum lol
if it does common more then the others then ye
it does
** You are now Level 1! **
hold on ill pull it up
ive been at this for hrs but at least i got the stud ratio setup
all i did was / 12 from chance but the board shows a different story
if not eggTable then return nil end
local baseLuck = game.Players.LocalPlayer:WaitForChild("leaderstats"):WaitForChild("Luck").Value
local effectiveLuck = baseLuck
local entries = {}
local maxWeight = 0
-- rest unchanged until the adjustment loop...
-- Find original max weight
for _, pet in pairs(eggTable) do
if typeof(pet.Weight) == "number" and pet.Weight > 0 then
maxWeight = math.max(maxWeight, pet.Weight)
end
end
if maxWeight == 0 then return nil end
-- Adjust weights with effectiveLuck instead of luck
for _, pet in pairs(eggTable) do
local w = pet.Weight
-- Single calculation for tier boost based on weight and effectiveLuck
local tierBoost = 1 + (effectiveLuck / 10000) * (math.exp(3.5 * (1 - math.log10(w))) - 1) / 2
local newWeight = math.max(w * tierBoost, 0.001)
table.insert(entries, {Name = pet.Name, Weight = newWeight})
end
local total = 0
local POWER = 1
for _, pet in ipairs(entries) do
pet.Weight = pet.Weight ^ POWER
total += pet.Weight
end
local roll = math.random() * total
local cumulative = 0
for _, pet in ipairs(entries) do
cumulative += pet.Weight
if roll <= cumulative then
return pet.Name
end
end
return entries[#entries].Name
end```
i can chance stuff, but this the chance function i use
the table looks like ``` ["Basic"] = {
-- COMMON
["Dog"] = {Name = "Dog", Weight = 25},
["Cat"] = {Name = "Cat", Weight = 22},
["Bunny"] = {Name = "Bunny", Weight = 20},} ```
then js change weight based on how rare you want it
it was for a pet game, so if you do end up using it youll have to change stuff
like "eggTable"
isnt mine basically the same but im using my module that converts to 1e32 as ex from {1, 32} which is 100000000000000000000000000000000
isn't there a way to fix this lua function Bnum.rollRarity(items: any, luck: any) local total = '0e0' luck = luck or '1e0' local adjust = {} for _, item in ipairs(items) do local invLuck = Bnum.toStr(Bnum.div('1e0', luck)) local adj = Bnum.toStr(Bnum.pow(item.Chance, invLuck)) adjust = { Item = item, Chance = adj } total = Bnum.toStr(Bnum.add(total, adj)) end local roll = Bnum.toStr(Bnum.clamp(Bnum.mul(math.random(), total), '0e0', total)) for _, item in ipairs(items) do roll = Bnum.toStr(Bnum.sub(roll, item.Chance)) if Bnum.leeq(roll, {0,0}) then return item end end return items[#items] end
its just using BN as in just math but in higher format
and math.pow(1, pet.Chance) is better lol
or pet.Weight
wat is bnum.leeq
its a rarity roll system that im going to use for the game im making
its basically going to help me with rarity studs and runes rarity roll system
i was saying that anything thats pow 1 u cant math
def not smart @analog timber u should be s1 if u dont know what leeq, le, eq, me, meeq means
what is le and me
because if leeq is lessthan-equal, than what is le
your acronyms are wrong?
hes just yapping about obscure bignum libraries prolly
goes in scripting channel
asks for help
disrespects the person trying to help
???
profit
they've used le for lt and me for gt and say im not smart for not knowing incorrect abbreviations
meeq, me, eq, le, leeq
=, >, ==, <, <=

sad ur not smart
@lofty monolith i c u
ya no one calls le/lte leeq bruh that's just you
plus u cant get help in scripting channel
wanna know what the most common assumption dumb people make about smart people is?

one would think their bignum module would use operator overloads anyway, avoiding this confusion entirely?
lua should allow overloads for functions and shit in general imo
ya they do, they're defined in metatables
i mean just
x = function(a, b)
x = function(a, b, c)
C features it so I don’t see why Lua can’t
anyway in my cosmically big dum dum not smart opinion, this is wrong roll = Bnum.toStr(Bnum.sub(roll, item.Chance)) but i not smirt can you tell us what's wrong with your code @olive thorn and how to fix it?