mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-22 03:38:48 +02:00
58 lines
1.8 KiB
Lua
58 lines
1.8 KiB
Lua
local Functions = require "maps.dungeons.functions"
|
|
local BiterRaffle = require "functions.biter_raffle"
|
|
local Get_noise = require "utils.get_noise"
|
|
|
|
local table_shuffle_table = table.shuffle_table
|
|
local table_insert = table.insert
|
|
local table_remove = table.remove
|
|
local math_random = math.random
|
|
local math_abs = math.abs
|
|
local math_sqrt = math.sqrt
|
|
local math_floor = math.floor
|
|
|
|
local rainbow_tiles = {
|
|
"cyan-refined-concrete", "purple-refined-concrete",
|
|
}
|
|
|
|
local ores = {
|
|
"copper-ore", "iron-ore", "iron-ore", "iron-ore", "coal", "stone"
|
|
}
|
|
|
|
local function treasure(surface, room)
|
|
local tiles = {}
|
|
for _, tile in pairs(room.path_tiles) do table_insert(tiles, tile) end
|
|
for _, tile in pairs(room.room_border_tiles) do table_insert(tiles, tile) end
|
|
for _, tile in pairs(room.room_tiles) do table_insert(tiles, tile) end
|
|
|
|
local seed = game.surfaces[surface.index].map_gen_settings.seed + math_random(1, 1000000)
|
|
for _, tile in pairs(tiles) do
|
|
surface.set_tiles({{name = rainbow_tiles[math_random(1, 2)], position = tile.position}}, true)
|
|
|
|
if math_random(1, 3) == 1 then
|
|
surface.create_entity({name = ores[math_random(1, 6)], position = tile.position, amount = Functions.get_common_resource_amount(surface.index) * 5})
|
|
end
|
|
end
|
|
|
|
if not room.room_border_tiles[1] then return end
|
|
|
|
table_shuffle_table(room.room_tiles)
|
|
for key, tile in pairs(room.room_tiles) do
|
|
if math_random(1, 256) == 1 or key == 1 then
|
|
Functions.epic_loot_crate(surface, tile.position, true)
|
|
else
|
|
if math_random(1, 128) == 1 then
|
|
Functions.rare_loot_crate(surface, tile.position, true)
|
|
end
|
|
end
|
|
end
|
|
|
|
table_shuffle_table(room.room_border_tiles)
|
|
for key, tile in pairs(room.room_border_tiles) do
|
|
if key % 8 == 1 then
|
|
Functions.place_border_rock(surface, tile.position)
|
|
end
|
|
end
|
|
end
|
|
|
|
return treasure
|