mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-05-13 21:56:29 +02:00
update
This commit is contained in:
parent
b026865b53
commit
0cb52a6f86
@ -4,22 +4,56 @@ room.empty = function(surface, cell_left_top, direction)
|
||||
|
||||
end
|
||||
|
||||
room.single_worm = function(surface, cell_left_top, direction)
|
||||
room.worms = function(surface, cell_left_top, direction)
|
||||
local amount = math.ceil(get_biter_amount() * 0.1)
|
||||
local tile_positions = {}
|
||||
local left_top = {x = cell_left_top.x * grid_size, y = cell_left_top.y * grid_size}
|
||||
surface.create_entity({name = get_worm(), position = {x = left_top.x + grid_size * 0.5, y = left_top.y + grid_size * 0.5}, force = "enemy"})
|
||||
for x = 0.5, grid_size - 0.5, 1 do
|
||||
for y = 0.5, grid_size - 0.5, 1 do
|
||||
local pos = {left_top.x + x, left_top.y + y}
|
||||
tile_positions[#tile_positions + 1] = pos
|
||||
end
|
||||
end
|
||||
|
||||
table.shuffle_table(tile_positions)
|
||||
|
||||
for _, pos in pairs(tile_positions) do
|
||||
local worm = get_worm()
|
||||
if surface.can_place_entity({name = worm, position = pos}) and math.random(1,4) == 1 then
|
||||
surface.create_entity({name = worm, position = pos, force = "enemy"})
|
||||
amount = amount - 1
|
||||
end
|
||||
if amount < 1 then break end
|
||||
end
|
||||
end
|
||||
|
||||
room.single_nest = function(surface, cell_left_top, direction)
|
||||
room.nests = function(surface, cell_left_top, direction)
|
||||
local amount = math.ceil(get_biter_amount() * 0.1)
|
||||
local tile_positions = {}
|
||||
local left_top = {x = cell_left_top.x * grid_size, y = cell_left_top.y * grid_size}
|
||||
if math.random(1,4) == 1 then
|
||||
surface.create_entity({name = "spitter-spawner", position = {x = left_top.x + grid_size * 0.5, y = left_top.y + grid_size * 0.5}, force = "enemy"})
|
||||
else
|
||||
surface.create_entity({name = "biter-spawner", position = {x = left_top.x + grid_size * 0.5, y = left_top.y + grid_size * 0.5}, force = "enemy"})
|
||||
for x = 0.5, grid_size - 0.5, 1 do
|
||||
for y = 0.5, grid_size - 0.5, 1 do
|
||||
local pos = {left_top.x + x, left_top.y + y}
|
||||
tile_positions[#tile_positions + 1] = pos
|
||||
end
|
||||
end
|
||||
|
||||
table.shuffle_table(tile_positions)
|
||||
|
||||
for _, pos in pairs(tile_positions) do
|
||||
if surface.can_place_entity({name = "spitter-spawner", position = pos}) and math.random(1,4) == 1 then
|
||||
surface.create_entity({name = "spitter-spawner", position = pos, force = "enemy"})
|
||||
amount = amount - 1
|
||||
else
|
||||
surface.create_entity({name = "biter-spawner", position = pos, force = "enemy"})
|
||||
amount = amount - 1
|
||||
end
|
||||
if amount < 1 then break end
|
||||
end
|
||||
end
|
||||
|
||||
room.biters = function(surface, cell_left_top, direction)
|
||||
local amount = math.random(1, math.floor(1 + (global.maze_depth * 0.3)))
|
||||
local amount = get_biter_amount()
|
||||
local tile_positions = {}
|
||||
local left_top = {x = cell_left_top.x * grid_size, y = cell_left_top.y * grid_size}
|
||||
for x = 0.5, grid_size - 0.5, 1 do
|
||||
@ -39,7 +73,7 @@ room.biters = function(surface, cell_left_top, direction)
|
||||
end
|
||||
|
||||
room.spitters = function(surface, cell_left_top, direction)
|
||||
local amount = math.random(1, math.floor(1 + (global.maze_depth * 0.3)))
|
||||
local amount = get_biter_amount()
|
||||
local tile_positions = {}
|
||||
local left_top = {x = cell_left_top.x * grid_size, y = cell_left_top.y * grid_size}
|
||||
for x = 0.5, grid_size - 0.5, 1 do
|
||||
@ -58,6 +92,30 @@ room.spitters = function(surface, cell_left_top, direction)
|
||||
end
|
||||
end
|
||||
|
||||
room.spitters_and_biters = function(surface, cell_left_top, direction)
|
||||
local amount = get_biter_amount()
|
||||
local tile_positions = {}
|
||||
local left_top = {x = cell_left_top.x * grid_size, y = cell_left_top.y * grid_size}
|
||||
for x = 0.5, grid_size - 0.5, 1 do
|
||||
for y = 0.5, grid_size - 0.5, 1 do
|
||||
local pos = {left_top.x + x, left_top.y + y}
|
||||
tile_positions[#tile_positions + 1] = pos
|
||||
end
|
||||
end
|
||||
|
||||
table.shuffle_table(tile_positions)
|
||||
|
||||
for _, pos in pairs(tile_positions) do
|
||||
local enemy = get_biter()
|
||||
if math.random(1,3) == 1 then enemy = get_spitter() end
|
||||
if surface.can_place_entity({name = enemy, position = pos, force = "enemy"}) then
|
||||
surface.create_entity({name = enemy, position = pos, force = "enemy"})
|
||||
amount = amount - 1
|
||||
end
|
||||
if amount < 1 then break end
|
||||
end
|
||||
end
|
||||
|
||||
room.checkerboard_ore = function(surface, cell_left_top, direction)
|
||||
local ores = {"coal", "iron-ore", "copper-ore", "stone"}
|
||||
table.shuffle_table(ores)
|
||||
@ -76,22 +134,46 @@ room.checkerboard_ore = function(surface, cell_left_top, direction)
|
||||
end
|
||||
end
|
||||
|
||||
room.single_oil = function(surface, cell_left_top, direction)
|
||||
local left_top = {x = cell_left_top.x * grid_size, y = cell_left_top.y * grid_size}
|
||||
surface.create_entity({name = "crude-oil", position = {left_top.x + grid_size * 0.5, left_top.y + grid_size * 0.5}, amount = 100000 + global.maze_depth * 1000})
|
||||
room.spitters(surface, cell_left_top, direction)
|
||||
room.biters(surface, cell_left_top, direction)
|
||||
end
|
||||
|
||||
room.tree_ring = function(surface, cell_left_top, direction)
|
||||
local left_top = {x = cell_left_top.x * grid_size, y = cell_left_top.y * grid_size}
|
||||
local tree = tree_raffle[math.random(1, #tree_raffle)]
|
||||
map_functions.draw_noise_entity_ring(surface, {x = left_top.x + grid_size * 0.5, y = left_top.y + grid_size * 0.5}, tree, "neutral", grid_size * 0.25, grid_size * 0.33)
|
||||
surface.spill_item_stack({x = left_top.x + grid_size * 0.5, y = left_top.y + grid_size * 0.5}, get_loot_item_stack(), true, nil, true)
|
||||
room.spitters(surface, cell_left_top, direction)
|
||||
end
|
||||
|
||||
room.tons_of_trees = function(surface, cell_left_top, direction)
|
||||
local tree = tree_raffle[math.random(1, #tree_raffle)]
|
||||
local left_top = {x = cell_left_top.x * grid_size, y = cell_left_top.y * grid_size}
|
||||
for x = 0.5, grid_size - 0.5, 1 do
|
||||
for y = 0.5, grid_size - 0.5, 1 do
|
||||
local pos = {left_top.x + x, left_top.y + y}
|
||||
if math.random(1,2) ~= 1 then
|
||||
if math.random(1,3) == 1 then
|
||||
surface.create_entity({name = tree, position = pos, force = "neutral"})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
room.loot_crate = function(surface, cell_left_top, direction)
|
||||
local left_top = {x = cell_left_top.x * grid_size, y = cell_left_top.y * grid_size}
|
||||
local chest = surface.create_entity({name = "wooden-chest", position = {left_top.x + grid_size * 0.5, left_top.y + grid_size * 0.5}, force = "neutral"})
|
||||
chest.destructible = false
|
||||
chest.insert(get_loot_item_stack())
|
||||
if math.random(1,2) == 1 then chest.insert(get_loot_item_stack()) end
|
||||
room.spitters_and_biters(surface, cell_left_top, direction)
|
||||
end
|
||||
|
||||
room.single_rock = function(surface, cell_left_top, direction)
|
||||
local left_top = {x = cell_left_top.x * grid_size, y = cell_left_top.y * grid_size}
|
||||
surface.create_entity({name = rock_raffle[math.random(1, #rock_raffle)], position = {left_top.x + grid_size * 0.5, left_top.y + grid_size * 0.5}, force = "neutral"})
|
||||
surface.create_entity({name = rock_raffle[math.random(1, #rock_raffle)], position = {left_top.x + grid_size * 0.5, left_top.y + grid_size * 0.5}, force = "neutral"})
|
||||
end
|
||||
|
||||
room.three_rocks = function(surface, cell_left_top, direction)
|
||||
@ -99,6 +181,7 @@ room.three_rocks = function(surface, cell_left_top, direction)
|
||||
surface.create_entity({name = rock_raffle[math.random(1, #rock_raffle)], position = {left_top.x + grid_size * 0.2, left_top.y + grid_size * 0.8}, force = "neutral"})
|
||||
surface.create_entity({name = rock_raffle[math.random(1, #rock_raffle)], position = {left_top.x + grid_size * 0.8, left_top.y + grid_size * 0.8}, force = "neutral"})
|
||||
surface.create_entity({name = rock_raffle[math.random(1, #rock_raffle)], position = {left_top.x + grid_size * 0.5, left_top.y + grid_size * 0.2}, force = "neutral"})
|
||||
room.biters(surface, cell_left_top, direction)
|
||||
end
|
||||
|
||||
room.quad_rocks = function(surface, cell_left_top, direction)
|
||||
@ -107,6 +190,7 @@ room.quad_rocks = function(surface, cell_left_top, direction)
|
||||
surface.create_entity({name = rock_raffle[math.random(1, #rock_raffle)], position = {left_top.x + grid_size * 0.15, left_top.y + grid_size * 0.85}, force = "neutral"})
|
||||
surface.create_entity({name = rock_raffle[math.random(1, #rock_raffle)], position = {left_top.x + grid_size * 0.85, left_top.y + grid_size * 0.15}, force = "neutral"})
|
||||
surface.create_entity({name = rock_raffle[math.random(1, #rock_raffle)], position = {left_top.x + grid_size * 0.85, left_top.y + grid_size * 0.85}, force = "neutral"})
|
||||
room.spitters_and_biters(surface, cell_left_top, direction)
|
||||
end
|
||||
|
||||
room.tons_of_rocks = function(surface, cell_left_top, direction)
|
||||
@ -143,6 +227,7 @@ room.some_scrap = function(surface, cell_left_top, direction)
|
||||
end
|
||||
end
|
||||
end
|
||||
room.worms(surface, cell_left_top, direction)
|
||||
end
|
||||
|
||||
room.lots_of_scrap = function(surface, cell_left_top, direction)
|
||||
@ -171,19 +256,22 @@ end
|
||||
|
||||
room.pond = function(surface, cell_left_top, direction)
|
||||
local left_top = {x = cell_left_top.x * grid_size, y = cell_left_top.y * grid_size}
|
||||
for x = math.floor(grid_size * 0.25), math.floor(grid_size * 0.75) - 1, 1 do
|
||||
for y = math.floor(grid_size * 0.25), math.floor(grid_size * 0.75) - 1, 1 do
|
||||
map_functions.draw_noise_tile_circle({x = left_top.x + grid_size * 0.5, y = left_top.y + grid_size * 0.5}, "water", surface, grid_size * 0.3)
|
||||
for x = 0.5, grid_size - 0.5, 1 do
|
||||
for y = 0.5, grid_size - 0.5, 1 do
|
||||
local pos = {left_top.x + x, left_top.y + y}
|
||||
surface.set_tiles({{name = "water", position = pos}}, true)
|
||||
if math.random(1,16) == 1 then
|
||||
if surface.can_place_entity({name = "fish", position = pos, force = "neutral"}) then
|
||||
surface.create_entity({name = "fish", position = pos, force = "neutral"})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local room_weights = {
|
||||
{func = room.biters, weight = 25},
|
||||
{func = room.spitters, weight = 15},
|
||||
{func = room.single_worm, weight = 15},
|
||||
{func = room.single_nest, weight = 8},
|
||||
{func = room.worms, weight = 15},
|
||||
{func = room.nests, weight = 8},
|
||||
|
||||
{func = room.tons_of_trees, weight = 15},
|
||||
|
||||
@ -194,12 +282,17 @@ local room_weights = {
|
||||
{func = room.single_rock, weight = 10},
|
||||
|
||||
{func = room.checkerboard_ore, weight = 5},
|
||||
{func = room.single_oil, weight = 5},
|
||||
--{func = room.some_scrap, weight = 10},
|
||||
{func = room.lots_of_scrap, weight = 5},
|
||||
--{func = room.tons_of_scrap, weight = 2},
|
||||
{func = room.empty, weight = 1},
|
||||
|
||||
{func = room.pond, weight = 10}
|
||||
{func = room.pond, weight = 10},
|
||||
|
||||
{func = room.loot_crate, weight = 10},
|
||||
{func = room.tree_ring, weight = 10}
|
||||
|
||||
}
|
||||
|
||||
local room_shuffle = {}
|
||||
@ -209,5 +302,4 @@ for _, r in pairs(room_weights) do
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
return room_shuffle
|
||||
return room_shuffle
|
@ -12,6 +12,17 @@ room.stone_block = function(surface, cell_left_top, direction)
|
||||
if math.random(1,6) ~= 1 then surface.create_entity({name = rock_raffle[math.random(1, #rock_raffle)], position = pos, force = "neutral"}) end
|
||||
end
|
||||
end
|
||||
|
||||
for a = 1, math.random(1, 2), 1 do
|
||||
local chest = surface.create_entity({
|
||||
name = "steel-chest",
|
||||
position = {left_top.x + math.random(math.floor(grid_size * 0.5), math.floor(grid_size * 1.5)), left_top.y + math.random(math.floor(grid_size * 0.5), math.floor(grid_size * 1.5))},
|
||||
force = "neutral",
|
||||
})
|
||||
for a = 1, math.random(1, 3), 1 do
|
||||
chest.insert(get_loot_item_stack())
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
room.scrapyard = function(surface, cell_left_top, direction)
|
||||
@ -19,7 +30,7 @@ room.scrapyard = function(surface, cell_left_top, direction)
|
||||
for x = 2.5, grid_size * 2 - 2.5, 1 do
|
||||
for y = 2.5, grid_size * 2 - 2.5, 1 do
|
||||
local pos = {left_top.x + x, left_top.y + y}
|
||||
if math.random(1,4) ~= 1 then surface.create_entity({name = "mineable-wreckage", position = pos, force = "neutral"}) end
|
||||
if math.random(1,3) == 1 then surface.create_entity({name = "mineable-wreckage", position = pos, force = "neutral"}) end
|
||||
end
|
||||
end
|
||||
local e = surface.create_entity({name = "storage-tank", position = {left_top.x + grid_size, left_top.y + grid_size}, force = "neutral", direction = math.random(0, 3)})
|
||||
@ -41,6 +52,11 @@ room.circle_pond_with_trees = function(surface, cell_left_top, direction)
|
||||
if math.random(1,5) == 1 and distance_to_center < grid_size * 0.85 then
|
||||
if surface.can_place_entity({name = tree, position = pos, force = "neutral"}) then surface.create_entity({name = tree, position = pos, force = "neutral"}) end
|
||||
end
|
||||
if math.random(1,16) == 1 then
|
||||
if surface.can_place_entity({name = "fish", position = pos, force = "neutral"}) then
|
||||
surface.create_entity({name = "fish", position = pos, force = "neutral"})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -50,17 +66,26 @@ room.checkerboard_ore = function(surface, cell_left_top, direction)
|
||||
table.shuffle_table(ores)
|
||||
|
||||
local left_top = {x = cell_left_top.x * grid_size, y = cell_left_top.y * grid_size}
|
||||
for x = 2, grid_size * 2 - 3, 1 do
|
||||
for y = 2, grid_size * 2 - 3, 1 do
|
||||
for x = 4, grid_size * 2 - 5, 1 do
|
||||
for y = 4, grid_size * 2 - 5, 1 do
|
||||
local pos = {left_top.x + x, left_top.y + y}
|
||||
if x % 2 == y % 2 then
|
||||
surface.create_entity({name = ores[1], position = pos, force = "neutral", amount = 256 + global.maze_depth * 4})
|
||||
surface.create_entity({name = ores[1], position = pos, force = "neutral", amount = get_ore_amount()})
|
||||
else
|
||||
surface.create_entity({name = ores[2], position = pos, force = "neutral", amount = 256 + global.maze_depth * 4})
|
||||
surface.create_entity({name = ores[2], position = pos, force = "neutral", amount = get_ore_amount()})
|
||||
end
|
||||
surface.set_tiles({{name = "grass-2", position = pos}}, true)
|
||||
end
|
||||
end
|
||||
|
||||
for x = 1, grid_size * 2 - 2, 1 do
|
||||
for y = 1, grid_size * 2 - 2, 1 do
|
||||
local pos = {left_top.x + x, left_top.y + y}
|
||||
if x <= 3 or x >= grid_size * 2 - 3 or y <= 3 or y >= grid_size * 2 - 3 then
|
||||
if math.random(1,2) == 1 then surface.create_entity({name = rock_raffle[math.random(1, #rock_raffle)], position = pos, force = "neutral"}) end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
room.minefield_chest = function(surface, cell_left_top, direction)
|
||||
@ -71,7 +96,13 @@ room.minefield_chest = function(surface, cell_left_top, direction)
|
||||
position = {left_top.x + grid_size + (direction[1] * grid_size * 0.5), left_top.y + grid_size + (direction[2] * grid_size * 0.5)},
|
||||
force = "neutral",
|
||||
})
|
||||
chest.insert({name = "grenade", count = "1"})
|
||||
|
||||
chest.insert(get_loot_item_stack())
|
||||
chest.insert(get_loot_item_stack())
|
||||
chest.insert(get_loot_item_stack())
|
||||
chest.insert(get_loot_item_stack())
|
||||
chest.insert(get_loot_item_stack())
|
||||
chest.insert(get_loot_item_stack())
|
||||
|
||||
for x = 0, grid_size * 2 - 1, 1 do
|
||||
for y = 0, grid_size * 2 - 1, 1 do
|
||||
@ -96,8 +127,7 @@ local room_weights = {
|
||||
{func = room.scrapyard, weight = 10},
|
||||
{func = room.stone_block, weight = 25},
|
||||
{func = room.minefield_chest, weight = 5},
|
||||
{func = room.checkerboard_ore, weight = 10},
|
||||
{func = room.empty, weight = 1},
|
||||
{func = room.checkerboard_ore, weight = 10}
|
||||
}
|
||||
|
||||
local room_shuffle = {}
|
||||
|
@ -4,6 +4,103 @@ room.empty = function(surface, cell_left_top, direction)
|
||||
|
||||
end
|
||||
|
||||
room.biters = function(surface, cell_left_top, direction)
|
||||
local amount = get_biter_amount() * 2
|
||||
local tile_positions = {}
|
||||
local left_top = {x = cell_left_top.x * grid_size, y = cell_left_top.y * grid_size}
|
||||
for x = 0.5, grid_size * 3 - 0.5, 1 do
|
||||
for y = 0.5, grid_size * 3 - 0.5, 1 do
|
||||
local pos = {left_top.x + x, left_top.y + y}
|
||||
tile_positions[#tile_positions + 1] = pos
|
||||
end
|
||||
end
|
||||
|
||||
table.shuffle_table(tile_positions)
|
||||
|
||||
for _, pos in pairs(tile_positions) do
|
||||
local enemy = get_biter()
|
||||
if surface.can_place_entity({name = enemy, position = pos}) then
|
||||
surface.create_entity({name = enemy, position = pos, force = "enemy"})
|
||||
amount = amount - 1
|
||||
end
|
||||
if amount < 1 then break end
|
||||
end
|
||||
end
|
||||
|
||||
room.spitters = function(surface, cell_left_top, direction)
|
||||
local amount = get_biter_amount() * 2
|
||||
local tile_positions = {}
|
||||
local left_top = {x = cell_left_top.x * grid_size, y = cell_left_top.y * grid_size}
|
||||
for x = 0.5, grid_size * 3 - 0.5, 1 do
|
||||
for y = 0.5, grid_size * 3 - 0.5, 1 do
|
||||
local pos = {left_top.x + x, left_top.y + y}
|
||||
tile_positions[#tile_positions + 1] = pos
|
||||
end
|
||||
end
|
||||
|
||||
table.shuffle_table(tile_positions)
|
||||
|
||||
for _, pos in pairs(tile_positions) do
|
||||
local enemy = get_spitter()
|
||||
if surface.can_place_entity({name = enemy, position = pos}) then
|
||||
surface.create_entity({name = enemy, position = pos, force = "enemy"})
|
||||
amount = amount - 1
|
||||
end
|
||||
if amount < 1 then break end
|
||||
end
|
||||
end
|
||||
|
||||
room.nests = function(surface, cell_left_top, direction)
|
||||
local amount = math.ceil(get_biter_amount() * 0.1)
|
||||
local tile_positions = {}
|
||||
local left_top = {x = cell_left_top.x * grid_size, y = cell_left_top.y * grid_size}
|
||||
for x = 0.5, grid_size * 3 - 0.5, 1 do
|
||||
for y = 0.5, grid_size * 3 - 0.5, 1 do
|
||||
local pos = {left_top.x + x, left_top.y + y}
|
||||
tile_positions[#tile_positions + 1] = pos
|
||||
end
|
||||
end
|
||||
|
||||
table.shuffle_table(tile_positions)
|
||||
|
||||
for _, pos in pairs(tile_positions) do
|
||||
if surface.can_place_entity({name = "spitter-spawner", position = pos}) and math.random(1,4) == 1 then
|
||||
surface.create_entity({name = "spitter-spawner", position = pos, force = "enemy"})
|
||||
amount = amount - 1
|
||||
else
|
||||
surface.create_entity({name = "biter-spawner", position = pos, force = "enemy"})
|
||||
amount = amount - 1
|
||||
end
|
||||
if amount < 1 then break end
|
||||
end
|
||||
end
|
||||
|
||||
room.uranium_wasteland = function(surface, cell_left_top, direction)
|
||||
|
||||
local left_top = {x = cell_left_top.x * grid_size, y = cell_left_top.y * grid_size}
|
||||
local center_pos = {x = left_top.x + grid_size * 1.5, y = left_top.y + grid_size * 1.5}
|
||||
|
||||
map_functions.draw_noise_tile_circle(center_pos, "water-green", surface, grid_size * 0.65)
|
||||
map_functions.draw_smoothed_out_ore_circle(center_pos, "uranium-ore", surface, grid_size * 1.3, get_ore_amount())
|
||||
|
||||
for x = math.floor(grid_size * 3 * 0.1), math.floor(grid_size * 3 * 0.9), 1 do
|
||||
for y = math.floor(grid_size * 3 * 0.1), math.floor(grid_size * 3 * 0.9), 1 do
|
||||
local pos = {x = left_top.x + x, y = left_top.y + y}
|
||||
local distance_to_center = math.sqrt((center_pos.x - pos.x) ^ 2 + (center_pos.y - pos.y) ^ 2)
|
||||
if math.random(1,128) == 1 and distance_to_center < grid_size * 1.4 then
|
||||
spawn_enemy_gun_turret(surface, pos)
|
||||
end
|
||||
if math.random(1,10) == 1 and distance_to_center < grid_size * 1.4 then
|
||||
if surface.can_place_entity({name = "mineable-wreckage", position = pos, force = "neutral"}) then
|
||||
surface.create_entity({name = "mineable-wreckage", position = pos, force = "neutral"})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
room.biters(surface, cell_left_top, direction)
|
||||
end
|
||||
|
||||
room.stone_block = function(surface, cell_left_top, direction)
|
||||
local left_top = {x = cell_left_top.x * grid_size, y = cell_left_top.y * grid_size}
|
||||
for x = 3.5, grid_size * 3 - 3.5, 1 do
|
||||
@ -12,9 +109,20 @@ room.stone_block = function(surface, cell_left_top, direction)
|
||||
if math.random(1,5) ~= 1 then surface.create_entity({name = rock_raffle[math.random(1, #rock_raffle)], position = pos, force = "neutral"}) end
|
||||
end
|
||||
end
|
||||
|
||||
for a = 1, math.random(1, 3), 1 do
|
||||
local chest = surface.create_entity({
|
||||
name = "steel-chest",
|
||||
position = {left_top.x + math.random(math.floor(grid_size * 0.5), math.floor(grid_size * 2.5)), left_top.y + math.random(math.floor(grid_size * 0.5), math.floor(grid_size * 2.5))},
|
||||
force = "neutral",
|
||||
})
|
||||
for a = 1, math.random(1, 4), 1 do
|
||||
chest.insert(get_loot_item_stack())
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
room.nine_nests = function(surface, cell_left_top, direction)
|
||||
room.tree_square_nests = function(surface, cell_left_top, direction)
|
||||
local left_top = {x = cell_left_top.x * grid_size, y = cell_left_top.y * grid_size}
|
||||
|
||||
local tree = tree_raffle[math.random(1, #tree_raffle)]
|
||||
@ -26,27 +134,16 @@ room.nine_nests = function(surface, cell_left_top, direction)
|
||||
surface.create_entity({name = tree, position = pos, force = "neutral"})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if global.maze_depth < 50 then
|
||||
surface.create_entity({name = "biter-spawner", position = {left_top.x + grid_size * 3 * 0.5, left_top.y + grid_size * 3 * 0.5}, force = "enemy"})
|
||||
return
|
||||
end
|
||||
surface.create_entity({name = "biter-spawner", position = {left_top.x + grid_size * 3 * 0.25, left_top.y + grid_size * 3 * 0.25}, force = "enemy"})
|
||||
surface.create_entity({name = "biter-spawner", position = {left_top.x + grid_size * 3 * 0.5, left_top.y + grid_size * 3 * 0.25}, force = "enemy"})
|
||||
surface.create_entity({name = "biter-spawner", position = {left_top.x + grid_size * 3 * 0.75, left_top.y + grid_size * 3 * 0.25}, force = "enemy"})
|
||||
surface.create_entity({name = "biter-spawner", position = {left_top.x + grid_size * 3 * 0.25, left_top.y + grid_size * 3 * 0.5}, force = "enemy"})
|
||||
surface.create_entity({name = "spitter-spawner", position = {left_top.x + grid_size * 3 * 0.5, left_top.y + grid_size * 3 * 0.5}, force = "enemy"})
|
||||
surface.create_entity({name = "biter-spawner", position = {left_top.x + grid_size * 3 * 0.75, left_top.y + grid_size * 3 * 0.5}, force = "enemy"})
|
||||
surface.create_entity({name = "biter-spawner", position = {left_top.x + grid_size * 3 * 0.25, left_top.y + grid_size * 3 * 0.75}, force = "enemy"})
|
||||
surface.create_entity({name = "biter-spawner", position = {left_top.x + grid_size * 3 * 0.5, left_top.y + grid_size * 3 * 0.75}, force = "enemy"})
|
||||
surface.create_entity({name = "biter-spawner", position = {left_top.x + grid_size * 3 * 0.75, left_top.y + grid_size * 3 * 0.75}, force = "enemy"})
|
||||
end
|
||||
room.nests(surface, cell_left_top, direction)
|
||||
room.spitters(surface, cell_left_top, direction)
|
||||
room.biters(surface, cell_left_top, direction)
|
||||
end
|
||||
|
||||
local room_weights = {
|
||||
{func = room.stone_block, weight = 25},
|
||||
{func = room.nine_nests, weight = 15},
|
||||
{func = room.empty, weight = 1}
|
||||
{func = room.uranium_wasteland, weight = 1},
|
||||
{func = room.stone_block, weight = 2},
|
||||
{func = room.tree_square_nests, weight = 2}
|
||||
}
|
||||
|
||||
local room_shuffle = {}
|
||||
|
@ -50,7 +50,173 @@ function get_ammo()
|
||||
end
|
||||
end
|
||||
|
||||
function ore_market(surface, position)
|
||||
function spawn_enemy_gun_turret(surface, position)
|
||||
if not surface.can_place_entity({name = "gun-turret", position = position}) then return end
|
||||
local e = surface.create_entity({name = "gun-turret", position = position, force = "enemy"})
|
||||
e.insert({name = get_ammo(), count = math.random(16, 64)})
|
||||
end
|
||||
|
||||
function get_biter_amount()
|
||||
local average = math.ceil(1 + (global.maze_depth * 0.3))
|
||||
return math.random(math.ceil(average * 0.7), math.ceil(average * 1.3))
|
||||
end
|
||||
|
||||
function get_ore_amount()
|
||||
return 256 + global.maze_depth * 4
|
||||
end
|
||||
|
||||
function get_loot_item_stack()
|
||||
local math_random = math.random
|
||||
local chest_raffle = {}
|
||||
local chest_loot = {
|
||||
{{name = "submachine-gun", count = math_random(1,3)}, weight = 3, evolution_min = 0.0, evolution_max = 0.1},
|
||||
{{name = "slowdown-capsule", count = math_random(4,8)}, weight = 1, evolution_min = 0.0, evolution_max = 1},
|
||||
{{name = "poison-capsule", count = math_random(4,8)}, weight = 3, evolution_min = 0.3, evolution_max = 1},
|
||||
{{name = "uranium-cannon-shell", count = math_random(16,32)}, weight = 5, evolution_min = 0.6, evolution_max = 1},
|
||||
{{name = "cannon-shell", count = math_random(16,32)}, weight = 5, evolution_min = 0.4, evolution_max = 0.7},
|
||||
{{name = "explosive-uranium-cannon-shell", count = math_random(16,32)}, weight = 5, evolution_min = 0.6, evolution_max = 1},
|
||||
{{name = "explosive-cannon-shell", count = math_random(16,32)}, weight = 5, evolution_min = 0.4, evolution_max = 0.8},
|
||||
{{name = "shotgun", count = 1}, weight = 2, evolution_min = 0.0, evolution_max = 0.2},
|
||||
{{name = "shotgun-shell", count = math_random(16,32)}, weight = 5, evolution_min = 0.0, evolution_max = 0.2},
|
||||
{{name = "combat-shotgun", count = 1}, weight = 10, evolution_min = 0.3, evolution_max = 0.8},
|
||||
{{name = "piercing-shotgun-shell", count = math_random(16,32)}, weight = 10, evolution_min = 0.2, evolution_max = 1},
|
||||
{{name = "flamethrower", count = 1}, weight = 3, evolution_min = 0.3, evolution_max = 0.6},
|
||||
{{name = "flamethrower-ammo", count = math_random(16,32)}, weight = 5, evolution_min = 0.3, evolution_max = 1},
|
||||
{{name = "rocket-launcher", count = 1}, weight = 5, evolution_min = 0.2, evolution_max = 0.6},
|
||||
{{name = "rocket", count = math_random(16,32)}, weight = 10, evolution_min = 0.2, evolution_max = 0.7},
|
||||
{{name = "explosive-rocket", count = math_random(16,32)}, weight = 10, evolution_min = 0.3, evolution_max = 1},
|
||||
{{name = "land-mine", count = math_random(8,16)}, weight = 10, evolution_min = 0.2, evolution_max = 0.7},
|
||||
{{name = "grenade", count = math_random(8,16)}, weight = 10, evolution_min = 0.0, evolution_max = 0.5},
|
||||
{{name = "cluster-grenade", count = math_random(8,16)}, weight = 5, evolution_min = 0.4, evolution_max = 1},
|
||||
{{name = "firearm-magazine", count = math_random(32,128)}, weight = 10, evolution_min = 0, evolution_max = 0.3},
|
||||
{{name = "piercing-rounds-magazine", count = math_random(32,128)}, weight = 10, evolution_min = 0.1, evolution_max = 0.8},
|
||||
{{name = "uranium-rounds-magazine", count = math_random(32,128)}, weight = 10, evolution_min = 0.5, evolution_max = 1},
|
||||
{{name = "railgun", count = 1}, weight = 1, evolution_min = 0.2, evolution_max = 1},
|
||||
{{name = "railgun-dart", count = math_random(16,32)}, weight = 3, evolution_min = 0.2, evolution_max = 0.7},
|
||||
{{name = "defender-capsule", count = math_random(8,16)}, weight = 10, evolution_min = 0.0, evolution_max = 0.7},
|
||||
{{name = "distractor-capsule", count = math_random(8,16)}, weight = 10, evolution_min = 0.2, evolution_max = 1},
|
||||
{{name = "destroyer-capsule", count = math_random(8,16)}, weight = 10, evolution_min = 0.3, evolution_max = 1},
|
||||
{{name = "atomic-bomb", count = math_random(8,16)}, weight = 1, evolution_min = 0.3, evolution_max = 1},
|
||||
{{name = "light-armor", count = 1}, weight = 3, evolution_min = 0, evolution_max = 0.1},
|
||||
{{name = "heavy-armor", count = 1}, weight = 3, evolution_min = 0.1, evolution_max = 0.3},
|
||||
{{name = "modular-armor", count = 1}, weight = 2, evolution_min = 0.2, evolution_max = 0.6},
|
||||
{{name = "power-armor", count = 1}, weight = 2, evolution_min = 0.4, evolution_max = 1},
|
||||
{{name = "power-armor-mk2", count = 1}, weight = 1, evolution_min = 0.8, evolution_max = 1},
|
||||
{{name = "battery-equipment", count = 1}, weight = 2, evolution_min = 0.3, evolution_max = 0.7},
|
||||
{{name = "battery-mk2-equipment", count = 1}, weight = 2, evolution_min = 0.6, evolution_max = 1},
|
||||
{{name = "belt-immunity-equipment", count = 1}, weight = 1, evolution_min = 0.3, evolution_max = 1},
|
||||
{{name = "solar-panel-equipment", count = math_random(1,4)}, weight = 5, evolution_min = 0.3, evolution_max = 0.8},
|
||||
{{name = "discharge-defense-equipment", count = 1}, weight = 1, evolution_min = 0.5, evolution_max = 0.8},
|
||||
{{name = "energy-shield-equipment", count = math_random(1,2)}, weight = 2, evolution_min = 0.3, evolution_max = 0.8},
|
||||
{{name = "energy-shield-mk2-equipment", count = 1}, weight = 2, evolution_min = 0.7, evolution_max = 1},
|
||||
{{name = "exoskeleton-equipment", count = 1}, weight = 1, evolution_min = 0.3, evolution_max = 1},
|
||||
{{name = "fusion-reactor-equipment", count = 1}, weight = 1, evolution_min = 0.5, evolution_max = 1},
|
||||
{{name = "night-vision-equipment", count = 1}, weight = 1, evolution_min = 0.3, evolution_max = 0.8},
|
||||
{{name = "personal-laser-defense-equipment", count = 1}, weight = 2, evolution_min = 0.4, evolution_max = 1},
|
||||
{{name = "exoskeleton-equipment", count = 1}, weight = 1, evolution_min = 0.3, evolution_max = 1},
|
||||
|
||||
|
||||
{{name = "iron-gear-wheel", count = math_random(80,100)}, weight = 3, evolution_min = 0.0, evolution_max = 0.3},
|
||||
{{name = "copper-cable", count = math_random(100,200)}, weight = 3, evolution_min = 0.0, evolution_max = 0.3},
|
||||
{{name = "engine-unit", count = math_random(16,32)}, weight = 2, evolution_min = 0.1, evolution_max = 0.5},
|
||||
{{name = "electric-engine-unit", count = math_random(16,32)}, weight = 2, evolution_min = 0.4, evolution_max = 0.8},
|
||||
{{name = "battery", count = math_random(100,200)}, weight = 2, evolution_min = 0.3, evolution_max = 0.8},
|
||||
{{name = "advanced-circuit", count = math_random(100,200)}, weight = 3, evolution_min = 0.4, evolution_max = 1},
|
||||
{{name = "electronic-circuit", count = math_random(100,200)}, weight = 3, evolution_min = 0.0, evolution_max = 0.4},
|
||||
{{name = "processing-unit", count = math_random(100,200)}, weight = 3, evolution_min = 0.7, evolution_max = 1},
|
||||
{{name = "explosives", count = math_random(25,50)}, weight = 1, evolution_min = 0.2, evolution_max = 0.6},
|
||||
{{name = "lubricant-barrel", count = math_random(4,10)}, weight = 1, evolution_min = 0.3, evolution_max = 0.5},
|
||||
{{name = "rocket-fuel", count = math_random(4,10)}, weight = 2, evolution_min = 0.3, evolution_max = 0.7},
|
||||
{{name = "computer", count = 1}, weight = 1, evolution_min = 0.2, evolution_max = 1},
|
||||
{{name = "steel-plate", count = math_random(50,100)}, weight = 2, evolution_min = 0.1, evolution_max = 0.3},
|
||||
{{name = "nuclear-fuel", count = 1}, weight = 2, evolution_min = 0.7, evolution_max = 1},
|
||||
|
||||
{{name = "burner-inserter", count = math_random(8,16)}, weight = 3, evolution_min = 0.0, evolution_max = 0.1},
|
||||
{{name = "inserter", count = math_random(8,16)}, weight = 3, evolution_min = 0.0, evolution_max = 0.4},
|
||||
{{name = "long-handed-inserter", count = math_random(8,16)}, weight = 3, evolution_min = 0.0, evolution_max = 0.4},
|
||||
{{name = "fast-inserter", count = math_random(8,16)}, weight = 3, evolution_min = 0.1, evolution_max = 1},
|
||||
{{name = "filter-inserter", count = math_random(8,16)}, weight = 1, evolution_min = 0.2, evolution_max = 1},
|
||||
{{name = "stack-filter-inserter", count = math_random(4,8)}, weight = 1, evolution_min = 0.4, evolution_max = 1},
|
||||
{{name = "stack-inserter", count = math_random(4,8)}, weight = 3, evolution_min = 0.3, evolution_max = 1},
|
||||
{{name = "small-electric-pole", count = math_random(16,32)}, weight = 3, evolution_min = 0.0, evolution_max = 0.3},
|
||||
{{name = "medium-electric-pole", count = math_random(8,16)}, weight = 3, evolution_min = 0.2, evolution_max = 1},
|
||||
{{name = "big-electric-pole", count = math_random(8,16)}, weight = 3, evolution_min = 0.3, evolution_max = 1},
|
||||
{{name = "substation", count = math_random(2,4)}, weight = 3, evolution_min = 0.5, evolution_max = 1},
|
||||
{{name = "wooden-chest", count = math_random(25,50)}, weight = 3, evolution_min = 0.0, evolution_max = 0.2},
|
||||
{{name = "iron-chest", count = math_random(4,8)}, weight = 3, evolution_min = 0.1, evolution_max = 0.4},
|
||||
{{name = "steel-chest", count = math_random(4,8)}, weight = 3, evolution_min = 0.3, evolution_max = 1},
|
||||
{{name = "small-lamp", count = math_random(8,16)}, weight = 3, evolution_min = 0.1, evolution_max = 0.3},
|
||||
{{name = "rail", count = math_random(50,75)}, weight = 3, evolution_min = 0.1, evolution_max = 0.6},
|
||||
{{name = "assembling-machine-1", count = math_random(2,4)}, weight = 3, evolution_min = 0.0, evolution_max = 0.3},
|
||||
{{name = "assembling-machine-2", count = math_random(2,4)}, weight = 3, evolution_min = 0.2, evolution_max = 0.8},
|
||||
{{name = "assembling-machine-3", count = math_random(2,4)}, weight = 3, evolution_min = 0.5, evolution_max = 1},
|
||||
{{name = "accumulator", count = math_random(4,8)}, weight = 3, evolution_min = 0.4, evolution_max = 1},
|
||||
{{name = "offshore-pump", count = math_random(1,2)}, weight = 2, evolution_min = 0.0, evolution_max = 0.1},
|
||||
{{name = "beacon", count = math_random(1,2)}, weight = 3, evolution_min = 0.7, evolution_max = 1},
|
||||
{{name = "boiler", count = math_random(2,4)}, weight = 3, evolution_min = 0.0, evolution_max = 0.3},
|
||||
{{name = "steam-engine", count = math_random(2,4)}, weight = 3, evolution_min = 0.0, evolution_max = 0.5},
|
||||
{{name = "steam-turbine", count = math_random(1,2)}, weight = 2, evolution_min = 0.5, evolution_max = 1},
|
||||
--{{name = "nuclear-reactor", count = 1}, weight = 2, evolution_min = 0.5, evolution_max = 1},
|
||||
{{name = "centrifuge", count = math_random(1,2)}, weight = 2, evolution_min = 0.5, evolution_max = 1},
|
||||
{{name = "heat-pipe", count = math_random(8,12)}, weight = 2, evolution_min = 0.5, evolution_max = 1},
|
||||
{{name = "heat-exchanger", count = math_random(2,4)}, weight = 2, evolution_min = 0.5, evolution_max = 1},
|
||||
{{name = "arithmetic-combinator", count = math_random(8,16)}, weight = 1, evolution_min = 0.1, evolution_max = 1},
|
||||
{{name = "constant-combinator", count = math_random(8,16)}, weight = 1, evolution_min = 0.1, evolution_max = 1},
|
||||
{{name = "decider-combinator", count = math_random(8,16)}, weight = 1, evolution_min = 0.1, evolution_max = 1},
|
||||
{{name = "power-switch", count = math_random(2,4)}, weight = 1, evolution_min = 0.1, evolution_max = 1},
|
||||
{{name = "programmable-speaker", count = math_random(2,4)}, weight = 1, evolution_min = 0.1, evolution_max = 1},
|
||||
{{name = "green-wire", count = math_random(50,100)}, weight = 1, evolution_min = 0.1, evolution_max = 1},
|
||||
{{name = "red-wire", count = math_random(50,100)}, weight = 1, evolution_min = 0.1, evolution_max = 1},
|
||||
{{name = "chemical-plant", count = math_random(2,4)}, weight = 3, evolution_min = 0.3, evolution_max = 1},
|
||||
{{name = "burner-mining-drill", count = math_random(4,8)}, weight = 3, evolution_min = 0.0, evolution_max = 0.2},
|
||||
{{name = "electric-mining-drill", count = math_random(4,8)}, weight = 3, evolution_min = 0.2, evolution_max = 0.6},
|
||||
{{name = "express-transport-belt", count = math_random(25,75)}, weight = 3, evolution_min = 0.5, evolution_max = 1},
|
||||
{{name = "express-underground-belt", count = math_random(4,8)}, weight = 3, evolution_min = 0.5, evolution_max = 1},
|
||||
{{name = "express-splitter", count = math_random(2,4)}, weight = 3, evolution_min = 0.5, evolution_max = 1},
|
||||
{{name = "fast-transport-belt", count = math_random(25,75)}, weight = 3, evolution_min = 0.2, evolution_max = 0.7},
|
||||
{{name = "fast-underground-belt", count = math_random(4,8)}, weight = 3, evolution_min = 0.2, evolution_max = 0.7},
|
||||
{{name = "fast-splitter", count = math_random(2,4)}, weight = 3, evolution_min = 0.2, evolution_max = 0.3},
|
||||
{{name = "transport-belt", count = math_random(25,75)}, weight = 3, evolution_min = 0, evolution_max = 0.3},
|
||||
{{name = "underground-belt", count = math_random(4,8)}, weight = 3, evolution_min = 0, evolution_max = 0.3},
|
||||
{{name = "splitter", count = math_random(2,4)}, weight = 3, evolution_min = 0, evolution_max = 0.3},
|
||||
{{name = "oil-refinery", count = math_random(1,2)}, weight = 2, evolution_min = 0.3, evolution_max = 1},
|
||||
{{name = "pipe", count = math_random(40,50)}, weight = 3, evolution_min = 0.0, evolution_max = 0.3},
|
||||
{{name = "pipe-to-ground", count = math_random(8,16)}, weight = 1, evolution_min = 0.2, evolution_max = 0.5},
|
||||
{{name = "pumpjack", count = math_random(1,2)}, weight = 1, evolution_min = 0.3, evolution_max = 0.8},
|
||||
{{name = "pump", count = math_random(1,4)}, weight = 1, evolution_min = 0.3, evolution_max = 0.8},
|
||||
{{name = "solar-panel", count = math_random(4,8)}, weight = 3, evolution_min = 0.4, evolution_max = 0.9},
|
||||
{{name = "electric-furnace", count = math_random(2,4)}, weight = 3, evolution_min = 0.5, evolution_max = 1},
|
||||
{{name = "steel-furnace", count = math_random(4,8)}, weight = 3, evolution_min = 0.2, evolution_max = 0.7},
|
||||
{{name = "stone-furnace", count = math_random(8,16)}, weight = 3, evolution_min = 0.0, evolution_max = 0.1},
|
||||
{{name = "radar", count = math_random(1,2)}, weight = 1, evolution_min = 0.1, evolution_max = 0.3},
|
||||
{{name = "rail-signal", count = math_random(8,16)}, weight = 2, evolution_min = 0.2, evolution_max = 0.8},
|
||||
{{name = "rail-chain-signal", count = math_random(8,16)}, weight = 2, evolution_min = 0.2, evolution_max = 0.8},
|
||||
{{name = "stone-wall", count = math_random(25,75)}, weight = 1, evolution_min = 0.1, evolution_max = 0.5},
|
||||
{{name = "gate", count = math_random(4,8)}, weight = 1, evolution_min = 0.1, evolution_max = 0.5},
|
||||
{{name = "storage-tank", count = math_random(2,4)}, weight = 3, evolution_min = 0.3, evolution_max = 0.6},
|
||||
{{name = "train-stop", count = math_random(1,2)}, weight = 1, evolution_min = 0.2, evolution_max = 0.7},
|
||||
{{name = "express-loader", count = math_random(1,2)}, weight = 1, evolution_min = 0.5, evolution_max = 1},
|
||||
{{name = "fast-loader", count = math_random(1,2)}, weight = 1, evolution_min = 0.2, evolution_max = 0.7},
|
||||
{{name = "loader", count = math_random(1,2)}, weight = 1, evolution_min = 0.0, evolution_max = 0.5},
|
||||
{{name = "lab", count = math_random(2,4)}, weight = 2, evolution_min = 0.0, evolution_max = 0.1},
|
||||
|
||||
--{{name = "roboport", count = math_random(2,4)}, weight = 2, evolution_min = 0.6, evolution_max = 1},
|
||||
--{{name = "flamethrower-turret", count = math_random(4,8)}, weight = 3, evolution_min = 0.5, evolution_max = 1},
|
||||
--{{name = "laser-turret", count = math_random(4,8)}, weight = 3, evolution_min = 0.5, evolution_max = 1},
|
||||
{{name = "gun-turret", count = math_random(2,4)}, weight = 3, evolution_min = 0.2, evolution_max = 0.9}
|
||||
}
|
||||
for _, t in pairs (chest_loot) do
|
||||
for x = 1, t.weight, 1 do
|
||||
if t.evolution_min <= game.forces.enemy.evolution_factor and t.evolution_max >= game.forces.enemy.evolution_factor then
|
||||
table.insert(chest_raffle, t[1])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return chest_raffle[math_random(1,#chest_raffle)]
|
||||
end
|
||||
|
||||
function spawn_market(surface, position)
|
||||
local market = surface.create_entity({name = "market", position = position, force = "neutral"})
|
||||
market.destructible = false
|
||||
market.add_market_item({price = {{"coin", 5}}, offer = {type = 'give-item', item = 'iron-ore', count = 50}})
|
||||
@ -62,5 +228,12 @@ function ore_market(surface, position)
|
||||
market.add_market_item({price = {{'copper-ore', 50}}, offer = {type = 'give-item', item = "coin", count = 5}})
|
||||
market.add_market_item({price = {{'stone', 50}}, offer = {type = 'give-item', item = "coin", count = 5}})
|
||||
market.add_market_item({price = {{'coal', 50}}, offer = {type = 'give-item', item = "coin", count = 5}})
|
||||
market.add_market_item({price = {{'uranium-ore', 25}}, offer = {type = 'give-item', item = "coin", count = 5}})
|
||||
market.add_market_item({price = {{"uranium-ore", 25}}, offer = {type = 'give-item', item = 'coin', count = 5}})
|
||||
|
||||
market.add_market_item({price = {{'coin', 1}}, offer = {type = 'give-item', item = "wood", count = 50}})
|
||||
market.add_market_item({price = {{'coin', 1}}, offer = {type = 'give-item', item = "raw-fish", count = 1}})
|
||||
market.add_market_item({price = {{'coin', 8}}, offer = {type = 'give-item', item = "grenade", count = 1}})
|
||||
market.add_market_item({price = {{'coin', 1}}, offer = {type = 'give-item', item = "firearm-magazine", count = 1}})
|
||||
market.add_market_item({price = {{'coin', 16}}, offer = {type = 'give-item', item = "submachine-gun", count = 1}})
|
||||
market.add_market_item({price = {{'coin', 32}}, offer = {type = 'give-item', item = "car", count = 1}})
|
||||
end
|
@ -23,12 +23,15 @@ multirooms["2x2"] = require 'maps.stone_maze.2x2_rooms'
|
||||
multirooms["3x3"] = require 'maps.stone_maze.3x3_rooms'
|
||||
|
||||
map_functions = require "tools.map_functions"
|
||||
grid_size = 24
|
||||
grid_size = 16
|
||||
manual_mining_speed_modifier = 2
|
||||
main_ground_tile = "dirt-3"
|
||||
rock_raffle = {"rock-huge", "rock-big", "rock-big", "rock-big"}
|
||||
tree_raffle = {"tree-01", "tree-02", "tree-03", "tree-04", "tree-05", "tree-06", "tree-07", "tree-08", "tree-09", "tree-02-red", "tree-06-brown", "tree-08-brown", "tree-08-red","tree-09-brown","tree-09-red","dead-dry-hairy-tree","dry-hairy-tree","dry-tree","dead-tree-desert","dead-grey-trunk"}
|
||||
|
||||
|
||||
local visited_tile_translation = {
|
||||
--["dirt-7"] = "grass-2",
|
||||
["dirt-3"] = "dirt-7",
|
||||
["dirt-5"] = "dirt-7",
|
||||
["grass-2"] = "grass-1"
|
||||
@ -110,6 +113,32 @@ local function init_cell(cell_position)
|
||||
global.maze_cells[coord_to_string(cell_position)].occupied = false
|
||||
end
|
||||
|
||||
local function get_chunk_position(position)
|
||||
local chunk_position = {}
|
||||
position.x = math.floor(position.x, 0)
|
||||
position.y = math.floor(position.y, 0)
|
||||
for x = 0, 31, 1 do
|
||||
if (position.x - x) % 32 == 0 then chunk_position.x = (position.x - x) / 32 end
|
||||
end
|
||||
for y = 0, 31, 1 do
|
||||
if (position.y - y) % 32 == 0 then chunk_position.y = (position.y - y) / 32 end
|
||||
end
|
||||
return chunk_position
|
||||
end
|
||||
|
||||
local function regenerate_decoratives(surface, position)
|
||||
local chunk = get_chunk_position(position)
|
||||
if not chunk then return end
|
||||
surface.destroy_decoratives({area = {{chunk.x * 32, chunk.y * 32}, {chunk.x * 32 + 32, chunk.y * 32 + 32}}})
|
||||
local decorative_names = {}
|
||||
for k,v in pairs(game.decorative_prototypes) do
|
||||
if v.autoplace_specification then
|
||||
decorative_names[#decorative_names+1] = k
|
||||
end
|
||||
end
|
||||
surface.regenerate_decorative(decorative_names, {chunk})
|
||||
end
|
||||
|
||||
local function set_cell_tiles(surface, cell_position, tile_name)
|
||||
local left_top = {x = cell_position.x * grid_size, y = cell_position.y * grid_size}
|
||||
for x = 0, grid_size - 1, 1 do
|
||||
@ -118,6 +147,7 @@ local function set_cell_tiles(surface, cell_position, tile_name)
|
||||
surface.set_tiles({{name = tile_name, position = pos}}, true)
|
||||
end
|
||||
end
|
||||
regenerate_decoratives(surface, left_top)
|
||||
end
|
||||
|
||||
local function set_visted_cell_tiles(surface, cell_position)
|
||||
@ -125,7 +155,7 @@ local function set_visted_cell_tiles(surface, cell_position)
|
||||
|
||||
local remnants = {}
|
||||
for _, e in pairs(surface.find_entities_filtered({type = "corpse", area = {{left_top.x, left_top.y},{left_top.x + grid_size, left_top.y + grid_size}}})) do
|
||||
remnants[#remnants] = {name = e.name, position = e.position, direction = e.direction}
|
||||
remnants[#remnants + 1] = {name = e.name, position = e.position, direction = e.direction}
|
||||
end
|
||||
|
||||
for x = 0, grid_size - 1, 1 do
|
||||
@ -141,6 +171,8 @@ local function set_visted_cell_tiles(surface, cell_position)
|
||||
for _, e in pairs(remnants) do
|
||||
surface.create_entity({name = e.name, position = e.position, direction = e.direction})
|
||||
end
|
||||
|
||||
regenerate_decoratives(surface, left_top)
|
||||
end
|
||||
|
||||
local function can_multicell_expand(cell_position, direction, cell_type)
|
||||
@ -197,7 +229,7 @@ local function set_cell(surface, cell_position, direction)
|
||||
for x = 0, cells[multi_cell_type].size_x - 1, 1 do
|
||||
for y = 0, cells[multi_cell_type].size_y - 1, 1 do
|
||||
local p = {x = cell_left_top.x + x, y = cell_left_top.y + y}
|
||||
set_cell_tiles(surface, p, "dirt-3")
|
||||
set_cell_tiles(surface, p, main_ground_tile)
|
||||
|
||||
init_cell(p)
|
||||
global.maze_cells[coord_to_string(p)].occupied = true
|
||||
@ -216,7 +248,7 @@ local function set_cell(surface, cell_position, direction)
|
||||
if cells_to_open == 0 then return end
|
||||
cells_to_open = cells_to_open - 1
|
||||
|
||||
set_cell_tiles(surface, cell_position, "dirt-3")
|
||||
set_cell_tiles(surface, cell_position, main_ground_tile)
|
||||
rooms_1x1[math_random(1,#rooms_1x1)](surface, cell_position, direction)
|
||||
|
||||
init_cell(cell_position)
|
||||
@ -271,7 +303,7 @@ local function on_chunk_generated(event)
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
local tile_name = "out-of-map"
|
||||
if x < grid_size and y < grid_size then tile_name = "dirt-7" end
|
||||
if x < grid_size and y < grid_size then tile_name = "stone-path" end
|
||||
local p = {x = left_top.x + x, y = left_top.y + y}
|
||||
surface.set_tiles({{name = tile_name, position = p}}, true)
|
||||
end
|
||||
@ -279,7 +311,7 @@ local function on_chunk_generated(event)
|
||||
for _, e in pairs(surface.find_entities_filtered({force = "neutral"})) do
|
||||
e.destroy()
|
||||
end
|
||||
ore_market(surface, {x = grid_size * 0.4, y = grid_size * 0.4})
|
||||
spawn_market(surface, {x = math.random(4, grid_size - 4), y = math.random(4, grid_size - 4)})
|
||||
init_cell({0,0})
|
||||
global.maze_cells[coord_to_string({0,0})].occupied = true
|
||||
return
|
||||
@ -304,6 +336,11 @@ local function on_player_joined_game(event)
|
||||
end
|
||||
end
|
||||
|
||||
local function on_research_finished(event)
|
||||
if not event.research.force.technologies["steel-axe"].researched then return end
|
||||
event.research.force.manual_mining_speed_modifier = manual_mining_speed_modifier + 2
|
||||
end
|
||||
|
||||
local function on_init(event)
|
||||
global.maze_cells = {}
|
||||
global.maze_depth = 0
|
||||
@ -314,10 +351,16 @@ local function on_init(event)
|
||||
{biter = "behemoth-biter", spitter = "behemoth-spitter", worm = "behemoth-worm-turret", ammo = "uranium-rounds-magazine", chance = 0}
|
||||
}
|
||||
|
||||
game.forces["player"].set_spawn_position({x = grid_size * 0.5, y = grid_size * 0.75}, game.surfaces.nauvis)
|
||||
game.forces["player"].set_spawn_position({x = 2, y = 2}, game.surfaces.nauvis)
|
||||
game.forces["player"].manual_mining_speed_modifier = manual_mining_speed_modifier
|
||||
|
||||
game.map_settings.enemy_evolution.time_factor = 0
|
||||
game.map_settings.enemy_evolution.destroy_factor = 0
|
||||
game.map_settings.enemy_evolution.pollution_factor = 0
|
||||
end
|
||||
|
||||
event.on_init(on_init)
|
||||
event.add(defines.events.on_player_changed_position, on_player_changed_position)
|
||||
event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
event.add(defines.events.on_chunk_generated, on_chunk_generated)
|
||||
event.add(defines.events.on_chunk_generated, on_chunk_generated)
|
||||
event.add(defines.events.on_research_finished, on_research_finished)
|
Loading…
x
Reference in New Issue
Block a user