2020-04-04 19:07:08 +02:00
|
|
|
local Functions = require "maps.dungeons.functions"
|
2020-04-05 03:39:52 +02:00
|
|
|
local BiterRaffle = require "functions.biter_raffle"
|
2020-04-04 19:07:08 +02:00
|
|
|
|
2020-04-04 06:25:13 +02:00
|
|
|
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
|
2020-04-05 03:39:52 +02:00
|
|
|
local math_sqrt = math.sqrt
|
|
|
|
local math_floor = math.floor
|
2020-04-04 06:25:13 +02:00
|
|
|
|
2020-04-06 21:41:56 +02:00
|
|
|
local function add_enemy_units(surface, room)
|
|
|
|
for _, tile in pairs(room.room_tiles) do
|
|
|
|
if math_random(1, 2) == 1 then
|
2020-04-09 01:04:36 +02:00
|
|
|
local name = BiterRaffle.roll("biter", Functions.get_dungeon_evolution_factor() * 1.5)
|
2020-04-06 21:41:56 +02:00
|
|
|
local unit = surface.create_entity({name = name, position = tile.position, force = "enemy"})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-04-04 06:25:13 +02:00
|
|
|
local function concrete(surface, room)
|
|
|
|
for _, tile in pairs(room.path_tiles) do
|
|
|
|
surface.set_tiles({{name = "concrete", position = tile.position}}, true)
|
|
|
|
end
|
|
|
|
|
|
|
|
if not room.room_border_tiles[1] then return end
|
|
|
|
|
2020-04-05 03:39:52 +02:00
|
|
|
table_shuffle_table(room.room_tiles)
|
|
|
|
for key, tile in pairs(room.room_tiles) do
|
|
|
|
surface.set_tiles({{name = "stone-path", position = tile.position}}, true)
|
|
|
|
if math_random(1, 16) == 1 then
|
2020-04-06 21:41:56 +02:00
|
|
|
surface.create_entity({name = "iron-ore", position = tile.position, amount = Functions.get_common_resource_amount()})
|
2020-04-05 03:39:52 +02:00
|
|
|
end
|
|
|
|
if math_random(1, 128) == 1 then
|
|
|
|
Functions.crash_site_chest(surface, tile.position)
|
|
|
|
end
|
|
|
|
if key % 128 == 1 and math_random(1, 3) == 1 then
|
2020-04-06 21:41:56 +02:00
|
|
|
Functions.set_spawner_tier(surface.create_entity({name = "biter-spawner", position = tile.position, force = "enemy"}))
|
2020-04-05 03:39:52 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-04-04 06:25:13 +02:00
|
|
|
table_shuffle_table(room.room_border_tiles)
|
|
|
|
for key, tile in pairs(room.room_border_tiles) do
|
|
|
|
surface.set_tiles({{name = "refined-concrete", position = tile.position}}, true)
|
2020-04-07 10:02:32 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
for key, tile in pairs(room.room_border_tiles) do
|
2020-04-04 20:50:58 +02:00
|
|
|
if key % 8 == 1 then
|
2020-04-07 10:02:32 +02:00
|
|
|
Functions.place_border_rock(surface, tile.position)
|
2020-04-04 06:25:13 +02:00
|
|
|
else
|
2020-04-07 11:30:56 +02:00
|
|
|
surface.create_entity({name = "stone-wall", position = tile.position, force = "dungeon"})
|
2020-04-04 06:25:13 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
if room.entrance_tile then
|
|
|
|
local p = room.entrance_tile.position
|
|
|
|
local area = {{p.x - 1, p.y - 1}, {p.x + 1.5, p.y + 1.5}}
|
|
|
|
for _, entity in pairs(surface.find_entities_filtered({area = area})) do
|
|
|
|
entity.destroy()
|
|
|
|
end
|
|
|
|
end
|
2020-04-06 21:41:56 +02:00
|
|
|
|
|
|
|
add_enemy_units(surface, room)
|
2020-04-04 06:25:13 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
return concrete
|