#Rarity System

9 messages · Page 1 of 1 (latest)

spring escarp
#

Do you have the code?

rose agate
#

Yeah

#

Can't send doe

#

too much

#

Ima send in small sections ig

#

This is the module script

#
local rarities = {
    ["Common"] = {
        ["Fire"] = 10,
        ["Water"] = 10
    },
    ["Rare"] = {
        ["Earth"] = 25,
        ["Air"] = 25
    },
    ["Epic"] = {
        ["Lightning"] = 50,
        ["Ice"] = 50
    },
    ["Legendary"] = {
        ["Darkness"] = 100,
        ["Nature"] = 100
    },
    ["Mythical"] = {
        ["Light"] = 200,
        ["Shadow"] = 200
    }
}

-- Declare a function to choose a random bloodline
function chooseBloodline()
    -- Choose a random rarity
    local rarity = math.random(5)
    local chosenRarity
    if rarity == 1 then
        chosenRarity = "Common"
    elseif rarity == 2 then
        chosenRarity = "Rare"
    elseif rarity == 3 then
        chosenRarity = "Epic"
    elseif rarity == 4 then
        chosenRarity = "Legendary"
    else
        chosenRarity = "Mythical"
    end

    -- Get the total probability of all bloodlines in the chosen rarity
    local totalProbability = 0
    for _, probability in pairs(rarities[chosenRarity]) do
        totalProbability = totalProbability + probability
    end

    -- Choose a random number between 1 and the total probability
    local randomNumber = math.random(totalProbability)

    -- Loop through the bloodlines and find the chosen one
    local chosenBloodline = ""
    local probabilitySum = 0
    for bloodline, probability in pairs(rarities[chosenRarity]) do
        probabilitySum = probabilitySum + probability
        if randomNumber <= probabilitySum then
            chosenBloodline = bloodline
            break
        end
    end

    -- Return the chosen bloodline and rarity
    return chosenBloodline, chosenRarity
end
#

first 63 lines

#

then these