#How would you add a rng system that can account for luck such as a double luck gamepass

1 messages · Page 1 of 1 (latest)

uneven condor
#

I’ve been looking everywhere I can for the past day and so and I haven’t found anything helpful, no YouTube videos or anything? Does anyone actually know how to do it properly and can help me.

#

I understand and know how to make a basic rng system, and I understand the base concept of multiplying the “rare” values to create a increase luck effect, but how would you go about dealing with the rest, the stuff that isn’t changed? And how would you get it to work cleanly?

pale yoke
#

uhhhhh

#

MultiplierManager module

#

or something

#

actually if ur referring to the gamepass then you should just learn MarketplaceService and check if the player owns said gamepass when the player joins the game, then multiply its luck stat accordingly

uneven condor
uneven condor
pale yoke
#

(its not a resource)

#

(you gotta make it urself)

#

(or you could just adapt to the system u use alr to avoid having to redo everything

uneven condor
#

But not with luck included

#

And the gamepass feature is easy

uneven condor
uneven condor
#

Like the luck stuff

uneven condor
#

@pale yoke

pale yoke
#

aw fuck its a file
im on mob rn i can't do shit

pale yoke
#

and then make a single function for all 4 possible operations that you can do for changing said luck stat

#

an updateStat function

uneven condor
uneven condor
uneven condor
uneven condor
pale yoke
#

you multiply chances based on luck

#

thats it

pale yoke
uneven condor
pale yoke
#

you'd have to multiply all of them

#

thats just how chances work

#

and luck

uneven condor
#

If I had common of 50%

#

I wouldn’t multiple it by 2?

#

Bc then it’s 100%

pale yoke
#

no no you have to multiply LUCK by 2

#

not the chances

#

if luck is just 1.56 or sumth

#

...wait

#

no wait f luck is +x0.56 (multiplier adding to base luck) then you could just mult that by 2 without too much trouble

uneven condor
uneven condor
uneven condor
# pale yoke no wait f luck is +x0.56 (multiplier adding to base luck) then you could just mu...

what about this?

local module = {}

module.items = {
    ["Celestial"] = 0.001,
    ["Divine"] = 0.01,
    ["Godly"] = 0.05,
    ["Mythic"] = 0.1,
    ["Exotic"] = 1,
    ["Legendary"] = 2.5,
    ["Epic"] = 5,
    ["Rare"] = 10,
    ["Uncommon"] = 26.4,
    ["Common"] = 54.939
}

local function chooseRarity(luck)
    luck = math.max(luck or 1, 1)

    local adjusted = {}
    local totalWeight = 0

    for rarity, chance in pairs(module.items) do
        local rarityFactor = 1 / chance
        local adjustedChance = chance * (1 + ((luck - 1) * rarityFactor * 0.001))
        adjusted[rarity] = adjustedChance
        totalWeight += adjustedChance
    end

    local roll = math.random() * totalWeight
    local cumulative = 0

    for rarity, weight in pairs(adjusted) do
        cumulative += weight
        if roll <= cumulative then
            return rarity
        end
    end

    return "Common"
end

module.chooseItem = function(luck)
    local rarity = chooseRarity(luck)
    return rarity
end

return module
cosmic root
uneven condor
uneven condor
#

A effective way to do it?

pale yoke
#

uhh

#

luck should be a player stat managed in a completely different script

#

thus, remove the luck line under the .chooseRarity() functoon opening

#

oh also whats weight for

uneven condor
uneven condor
cosmic root
#

maybe just easier to visualize the chances that way 🤷

pale yoke
uneven condor
uneven condor
uneven condor
#

@cosmic root @pale yoke this is not right..., like it works kind of, if im rolling with 100k luck i shouldnt be able to get commons, really it should be all celestial right?

#

like the luck is way to scattered for such a high luck rating

#

this is 1x in the first photo and 2x in second

#

not much luck i see

#

it actually went down for how many legendarys

pale yoke
#

...huh.

#

uhh

#

is this the same peice of code?

uneven condor
#

Same piece

#

Just displayed the values when I got it

#

But you understand what I mean? Like that scaling isn’t right

#

Or shouldn’t be in my eyes

cosmic root
#

you can calculate it trivially but .. you wouldn't hardcode it to the range of 1~100

uneven condor
#

Nothing more then 1

uneven condor
uneven condor
#

@cosmic root @pale yoke any idea how to fix the luck stuff