I was reading through this post and was struggeling to get it work really as intended. For example, if players depth is 99, then it only has 7 ores appear
GENERATING ▼ {
[1] = “Uranium Ore”,
[2] = “Opal Ore”,
[3] = “Amethyst Ore”,
[4] = “Platinum Ore”,
[5] = “Emerald Ore”,
[6] = “Diamond Ore”,
[7] = “Sapphire Ore”
} - Edit
Which means Uranium/Opal have the same odds as the other ores. These ores however should still be quite rare. And thus, players are currently able to find these ores really easily if they just get down to the 90s depth
local function GetDepthScore(ore, depth)
if depth > ore.MaxDepth or depth < ore.MinDepth then
return 0 -- Can't spawn
elseif depth < ore.DepthApex then -- Below apex (higher up)
return (depth - (ore.MinDepth - 1)) / (ore.DepthApex - (ore.MinDepth - 1))
elseif depth == ore.DepthApex then -- At apex
return 1
elseif depth > ore.DepthApex then -- Above apex (deeper down)
return ((ore.MaxDepth + 1) - depth) / (ore.MaxDepth + 1)
end
end
local MineData = require(game.ReplicatedStorage.MineData)
local Depth = 99
local OreOdds = {}
for ore, oreData in pairs(MineData) do
local DepthScore = GetDepthScore(oreData, Depth)
if DepthScore <= 0 then continue end -- No ore at this depth
local Percent = DepthScore * 100
-- Add to OreOdds
for i = 1, Percent do
table.insert(OreOdds, ore)
end
end
if #OreOdds > 0 then -- Spawn an ore
local RandomOre = OreOdds[math.random(1, #OreOdds)]
print("GENERATING", OreOdds)
end
return {
["Coal Ore"] = {
DepthApex = 14,
MinDepth = 7,
MaxDepth = 65,
},
["Copper Ore"] = {
DepthApex = 22,
MinDepth = 10,
MaxDepth = 70,
},
["Silver Ore"] = {
DepthApex = 26,
MinDepth = 10,
MaxDepth = 75,
},
["Iron Ore"] = {
DepthApex = 32,
MinDepth = 10,
MaxDepth = 80,
},
["Gold Ore"] = {
DepthApex = 42,
MinDepth = 20,
MaxDepth = 85,
},
["Ruby Ore"] = {
DepthApex = 49,
MinDepth = 20,
MaxDepth = 90,
},
["Quartz Ore"] = {
DepthApex = 56,
MinDepth = 30,
MaxDepth = 95,
},
["Sapphire Ore"] = {
DepthApex = 62,
MinDepth = 40,
MaxDepth = 100,
},
["Diamond Ore"] = {
DepthApex = 69,
MinDepth = 50,
MaxDepth = 100,
},
["Emerald Ore"] = {
DepthApex = 76,
MinDepth = 60,
MaxDepth = 100,
},
["Amethyst Ore"] = {
DepthApex = 82,
MinDepth = 70,
MaxDepth = 100,
},
["Platinum Ore"] = {
DepthApex = 86,
MinDepth = 80,
MaxDepth = 100,
},
["Opal Ore"] = {
DepthApex = 93,
MinDepth = 90,
MaxDepth = 100,
},
["Uranium Ore"] = {
DepthApex = 96,
MinDepth = 90,
MaxDepth = 100,
},
}