mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-16 02:47:48 +02:00
port layer names
This commit is contained in:
parent
c3d3ab6f97
commit
7be16f4b92
@ -140,7 +140,7 @@ function Public.biters_landfill(entity)
|
||||
local surface = entity.surface
|
||||
for _, vector in pairs(landfill_biters_vectors) do
|
||||
local tile = surface.get_tile({ position.x + vector[1], position.y + vector[2] })
|
||||
if tile.collides_with('resource-layer') then
|
||||
if tile.collides_with('resource') then
|
||||
surface.set_tiles({ { name = 'landfill', position = tile.position } })
|
||||
local particle_pos = { tile.position.x + 0.5, tile.position.y + 0.5 }
|
||||
for i = 1, 50, 1 do
|
||||
|
@ -13,13 +13,13 @@ local math_sqrt = math.sqrt
|
||||
local GetNoise = require 'utils.get_noise'
|
||||
local simplex_noise = require 'utils.simplex_noise'.d2
|
||||
local spawn_circle_size = 39
|
||||
local ores = {'copper-ore', 'iron-ore', 'stone', 'coal'}
|
||||
local rocks = {'sand-rock-big', 'sand-rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-huge'}
|
||||
local ores = { 'copper-ore', 'iron-ore', 'stone', 'coal' }
|
||||
local rocks = { 'sand-rock-big', 'sand-rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-huge' }
|
||||
|
||||
local chunk_tile_vectors = {}
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
chunk_tile_vectors[#chunk_tile_vectors + 1] = {x, y}
|
||||
chunk_tile_vectors[#chunk_tile_vectors + 1] = { x, y }
|
||||
end
|
||||
end
|
||||
local size_of_chunk_tile_vectors = #chunk_tile_vectors
|
||||
@ -103,17 +103,17 @@ local function create_mirrored_tile_chain(surface, tile, count, straightness)
|
||||
return
|
||||
end
|
||||
|
||||
local position = {x = tile.position.x, y = tile.position.y}
|
||||
local position = { x = tile.position.x, y = tile.position.y }
|
||||
|
||||
local modifiers = {
|
||||
{x = 0, y = -1},
|
||||
{x = -1, y = 0},
|
||||
{x = 1, y = 0},
|
||||
{x = 0, y = 1},
|
||||
{x = -1, y = 1},
|
||||
{x = 1, y = -1},
|
||||
{x = 1, y = 1},
|
||||
{x = -1, y = -1}
|
||||
{ x = 0, y = -1 },
|
||||
{ x = -1, y = 0 },
|
||||
{ x = 1, y = 0 },
|
||||
{ x = 0, y = 1 },
|
||||
{ x = -1, y = 1 },
|
||||
{ x = 1, y = -1 },
|
||||
{ x = 1, y = 1 },
|
||||
{ x = -1, y = -1 }
|
||||
}
|
||||
modifiers = shuffle(modifiers)
|
||||
|
||||
@ -124,31 +124,31 @@ local function create_mirrored_tile_chain(surface, tile, count, straightness)
|
||||
modifiers = shuffle(modifiers)
|
||||
end
|
||||
for b = 1, 4, 1 do
|
||||
local pos = {x = position.x + modifiers[b].x, y = position.y + modifiers[b].y}
|
||||
local pos = { x = position.x + modifiers[b].x, y = position.y + modifiers[b].y }
|
||||
if surface.get_tile(pos).name ~= tile.name then
|
||||
surface.set_tiles({{name = 'landfill', position = pos}}, true)
|
||||
surface.set_tiles({{name = tile.name, position = pos}}, true)
|
||||
surface.set_tiles({ { name = 'landfill', position = pos } }, true)
|
||||
surface.set_tiles({ { name = tile.name, position = pos } }, true)
|
||||
--surface.set_tiles({{name = "landfill", position = {pos.x * -1, (pos.y * -1) - 1}}}, true)
|
||||
--surface.set_tiles({{name = tile.name, position = {pos.x * -1, (pos.y * -1) - 1}}}, true)
|
||||
position = {x = pos.x, y = pos.y}
|
||||
position = { x = pos.x, y = pos.y }
|
||||
tile_placed = true
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if not tile_placed then
|
||||
position = {x = position.x + modifiers[1].x, y = position.y + modifiers[1].y}
|
||||
position = { x = position.x + modifiers[1].x, y = position.y + modifiers[1].y }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function get_replacement_tile(surface, position)
|
||||
for i = 1, 128, 1 do
|
||||
local vectors = {{0, i}, {0, i * -1}, {i, 0}, {i * -1, 0}}
|
||||
local vectors = { { 0, i }, { 0, i * -1 }, { i, 0 }, { i * -1, 0 } }
|
||||
table.shuffle_table(vectors)
|
||||
for k, v in pairs(vectors) do
|
||||
local tile = surface.get_tile(position.x + v[1], position.y + v[2])
|
||||
if not tile.collides_with('resource-layer') then
|
||||
if not tile.collides_with('resource') then
|
||||
if tile.name ~= 'stone-path' then
|
||||
return tile.name
|
||||
end
|
||||
@ -179,16 +179,16 @@ local function draw_noise_ore_patch(position, name, surface, radius, richness)
|
||||
local richness_part = richness / radius
|
||||
for y = radius * -3, radius * 3, 1 do
|
||||
for x = radius * -3, radius * 3, 1 do
|
||||
local pos = {x = x + position.x + 0.5, y = y + position.y + 0.5}
|
||||
local pos = { x = x + position.x + 0.5, y = y + position.y + 0.5 }
|
||||
local noise_1 = simplex_noise(pos.x * 0.0125, pos.y * 0.0125, seed)
|
||||
local noise_2 = simplex_noise(pos.x * 0.1, pos.y * 0.1, seed + 25000)
|
||||
local noise = noise_1 + noise_2 * 0.12
|
||||
local distance_to_center = math_sqrt(x ^ 2 + y ^ 2)
|
||||
local a = richness - richness_part * distance_to_center
|
||||
if distance_to_center < radius - math_abs(noise * radius * 0.85) and a > 1 then
|
||||
if surface.can_place_entity({name = name, position = pos, amount = a}) then
|
||||
surface.create_entity {name = name, position = pos, amount = a}
|
||||
for _, e in pairs(surface.find_entities_filtered({position = pos, name = {'wooden-chest', 'stone-wall', 'gun-turret'}})) do
|
||||
if surface.can_place_entity({ name = name, position = pos, amount = a }) then
|
||||
surface.create_entity { name = name, position = pos, amount = a }
|
||||
for _, e in pairs(surface.find_entities_filtered({ position = pos, name = { 'wooden-chest', 'stone-wall', 'gun-turret' } })) do
|
||||
e.destroy()
|
||||
end
|
||||
end
|
||||
@ -255,7 +255,7 @@ local function generate_starting_area(pos, distance_to_center, surface)
|
||||
|
||||
if distance_from_spawn_wall < 0 then
|
||||
if math_random(1, 100) > 23 then
|
||||
for _, tree in pairs(surface.find_entities_filtered({type = 'tree', area = {{pos.x, pos.y}, {pos.x + 1, pos.y + 1}}})) do
|
||||
for _, tree in pairs(surface.find_entities_filtered({ type = 'tree', area = { { pos.x, pos.y }, { pos.x + 1, pos.y + 1 } } })) do
|
||||
tree.destroy()
|
||||
end
|
||||
end
|
||||
@ -264,22 +264,22 @@ local function generate_starting_area(pos, distance_to_center, surface)
|
||||
if distance_from_spawn_wall < -10 and not is_horizontal_border_river(pos) then
|
||||
local tile_name = surface.get_tile(pos).name
|
||||
if tile_name == 'water' or tile_name == 'deepwater' then
|
||||
surface.set_tiles({{name = get_replacement_tile(surface, pos), position = pos}}, true)
|
||||
surface.set_tiles({ { name = get_replacement_tile(surface, pos), position = pos } }, true)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if surface.can_place_entity({name = 'wooden-chest', position = pos}) and surface.can_place_entity({name = 'coal', position = pos}) then
|
||||
if surface.can_place_entity({ name = 'wooden-chest', position = pos }) and surface.can_place_entity({ name = 'coal', position = pos }) then
|
||||
local noise_2 = get_noise(3, pos)
|
||||
if noise_2 < 0.40 then
|
||||
if noise_2 > -0.40 then
|
||||
if distance_from_spawn_wall > -1.75 and distance_from_spawn_wall < 0 then
|
||||
local e = surface.create_entity({name = 'stone-wall', position = pos, force = 'neutral'})
|
||||
local e = surface.create_entity({ name = 'stone-wall', position = pos, force = 'neutral' })
|
||||
e.active = false
|
||||
end
|
||||
else
|
||||
if distance_from_spawn_wall > -1.95 and distance_from_spawn_wall < 0 then
|
||||
local e = surface.create_entity({name = 'stone-wall', position = pos, force = 'neutral'})
|
||||
local e = surface.create_entity({ name = 'stone-wall', position = pos, force = 'neutral' })
|
||||
e.active = false
|
||||
elseif distance_from_spawn_wall > 0 and distance_from_spawn_wall < 4.5 then
|
||||
local name = 'wooden-chest'
|
||||
@ -288,20 +288,20 @@ local function generate_starting_area(pos, distance_to_center, surface)
|
||||
name = name .. '-remnants'
|
||||
end
|
||||
if math_random(1, r_max) == 1 then
|
||||
local e = surface.create_entity({name = name, position = pos, force = 'neutral'})
|
||||
local e = surface.create_entity({ name = name, position = pos, force = 'neutral' })
|
||||
e.active = false
|
||||
end
|
||||
elseif distance_from_spawn_wall > -6 and distance_from_spawn_wall < -3 then
|
||||
if math_random(1, 16) == 1 then
|
||||
if surface.can_place_entity({name = 'gun-turret', position = pos}) then
|
||||
local e = surface.create_entity({name = 'gun-turret', position = pos, force = 'neutral'})
|
||||
e.insert({name = 'firearm-magazine', count = math_random(6, 12)})
|
||||
if surface.can_place_entity({ name = 'gun-turret', position = pos }) then
|
||||
local e = surface.create_entity({ name = 'gun-turret', position = pos, force = 'neutral' })
|
||||
e.insert({ name = 'firearm-magazine', count = math_random(6, 12) })
|
||||
e.active = false
|
||||
end
|
||||
else
|
||||
if math_random(1, 24) == 1 and not is_horizontal_border_river(pos) then
|
||||
if surface.can_place_entity({name = 'gun-turret', position = pos}) then
|
||||
surface.create_entity({name = 'gun-turret-remnants', position = pos, force = 'neutral'})
|
||||
if surface.can_place_entity({ name = 'gun-turret', position = pos }) then
|
||||
surface.create_entity({ name = 'gun-turret-remnants', position = pos, force = 'neutral' })
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -317,12 +317,12 @@ local function generate_river(surface, left_top_x, left_top_y)
|
||||
end
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
local pos = {x = left_top_x + x, y = left_top_y + y}
|
||||
local pos = { x = left_top_x + x, y = left_top_y + y }
|
||||
local distance_to_center = math_sqrt(pos.x ^ 2 + pos.y ^ 2)
|
||||
if is_horizontal_border_river(pos) and distance_to_center > spawn_circle_size - 2 then
|
||||
surface.set_tiles({{name = 'deepwater', position = pos}})
|
||||
surface.set_tiles({ { name = 'deepwater', position = pos } })
|
||||
if math_random(1, 64) == 1 then
|
||||
local e = surface.create_entity({name = 'fish', position = pos})
|
||||
local e = surface.create_entity({ name = 'fish', position = pos })
|
||||
e.active = false
|
||||
end
|
||||
end
|
||||
@ -334,7 +334,7 @@ local scrap_vectors = {}
|
||||
for x = -8, 8, 1 do
|
||||
for y = -8, 8, 1 do
|
||||
if math_sqrt(x ^ 2 + y ^ 2) <= 8 then
|
||||
scrap_vectors[#scrap_vectors + 1] = {x, y}
|
||||
scrap_vectors[#scrap_vectors + 1] = { x, y }
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -363,19 +363,19 @@ local function generate_extra_worm_turrets(surface, left_top)
|
||||
for _ = 1, floor_amount, 1 do
|
||||
local worm_turret_name = BiterRaffle.roll('worm', chunk_distance_to_center * 0.00015)
|
||||
local v = chunk_tile_vectors[math_random(1, size_of_chunk_tile_vectors)]
|
||||
local position = surface.find_non_colliding_position(worm_turret_name, {left_top.x + v[1], left_top.y + v[2]}, 8, 1)
|
||||
local position = surface.find_non_colliding_position(worm_turret_name, { left_top.x + v[1], left_top.y + v[2] }, 8, 1)
|
||||
if position then
|
||||
local worm = surface.create_entity({name = worm_turret_name, position = position, force = 'enemy'})
|
||||
local worm = surface.create_entity({ name = worm_turret_name, position = position, force = 'enemy' })
|
||||
worm.active = false
|
||||
|
||||
-- add some scrap
|
||||
for c = 1, math_random(0, 4), 1 do
|
||||
local vector = scrap_vectors[math_random(1, size_of_scrap_vectors)]
|
||||
local position = {worm.position.x + vector[1], worm.position.y + vector[2]}
|
||||
local position = { worm.position.x + vector[1], worm.position.y + vector[2] }
|
||||
local name = wrecks[math_random(1, size_of_wrecks)]
|
||||
position = surface.find_non_colliding_position(name, position, 16, 1)
|
||||
if position then
|
||||
local e = surface.create_entity({name = name, position = position, force = 'neutral'})
|
||||
local e = surface.create_entity({ name = name, position = position, force = 'neutral' })
|
||||
e.active = false
|
||||
end
|
||||
end
|
||||
@ -401,7 +401,7 @@ local function is_biter_area(position)
|
||||
end
|
||||
|
||||
local function draw_biter_area(surface, left_top_x, left_top_y)
|
||||
if not is_biter_area({x = left_top_x, y = left_top_y - 96}) then
|
||||
if not is_biter_area({ x = left_top_x, y = left_top_y - 96 }) then
|
||||
return
|
||||
end
|
||||
|
||||
@ -413,11 +413,11 @@ local function draw_biter_area(surface, left_top_x, left_top_y)
|
||||
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
local position = {x = left_top_x + x, y = left_top_y + y}
|
||||
local position = { x = left_top_x + x, y = left_top_y + y }
|
||||
if is_biter_area(position) then
|
||||
local index = math_floor(GetNoise('bb_biterland', position, seed) * 48) % 7 + 1
|
||||
out_of_map[i] = {name = 'out-of-map', position = position}
|
||||
tiles[i] = {name = 'dirt-' .. index, position = position}
|
||||
out_of_map[i] = { name = 'out-of-map', position = position }
|
||||
tiles[i] = { name = 'dirt-' .. index, position = position }
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
@ -428,13 +428,13 @@ local function draw_biter_area(surface, left_top_x, left_top_y)
|
||||
|
||||
for _ = 1, 4, 1 do
|
||||
local v = chunk_tile_vectors[math_random(1, size_of_chunk_tile_vectors)]
|
||||
local position = {x = left_top_x + v[1], y = left_top_y + v[2]}
|
||||
if is_biter_area(position) and surface.can_place_entity({name = 'spitter-spawner', position = position}) then
|
||||
local position = { x = left_top_x + v[1], y = left_top_y + v[2] }
|
||||
if is_biter_area(position) and surface.can_place_entity({ name = 'spitter-spawner', position = position }) then
|
||||
if math_random(1, 4) == 1 then
|
||||
local e = surface.create_entity({name = 'spitter-spawner', position = position, force = 'enemy'})
|
||||
local e = surface.create_entity({ name = 'spitter-spawner', position = position, force = 'enemy' })
|
||||
e.active = false
|
||||
else
|
||||
local e = surface.create_entity({name = 'biter-spawner', position = position, force = 'enemy'})
|
||||
local e = surface.create_entity({ name = 'biter-spawner', position = position, force = 'enemy' })
|
||||
e.active = false
|
||||
end
|
||||
end
|
||||
@ -443,10 +443,10 @@ local function draw_biter_area(surface, left_top_x, left_top_y)
|
||||
local e = (math_abs(left_top_y) - bb_config.bitera_area_distance) * 0.0015
|
||||
for _ = 1, math_random(5, 10), 1 do
|
||||
local v = chunk_tile_vectors[math_random(1, size_of_chunk_tile_vectors)]
|
||||
local position = {x = left_top_x + v[1], y = left_top_y + v[2]}
|
||||
local position = { x = left_top_x + v[1], y = left_top_y + v[2] }
|
||||
local worm_turret_name = BiterRaffle.roll('worm', e)
|
||||
if is_biter_area(position) and surface.can_place_entity({name = worm_turret_name, position = position}) then
|
||||
surface.create_entity({name = worm_turret_name, position = position, force = 'enemy'})
|
||||
if is_biter_area(position) and surface.can_place_entity({ name = worm_turret_name, position = position }) then
|
||||
surface.create_entity({ name = worm_turret_name, position = position, force = 'enemy' })
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -454,7 +454,7 @@ end
|
||||
local function mixed_ore(surface, left_top_x, left_top_y)
|
||||
local seed = game.surfaces['bb_source'].map_gen_settings.seed
|
||||
|
||||
local noise = GetNoise('bb_ore', {x = left_top_x + 16, y = left_top_y + 16}, seed)
|
||||
local noise = GetNoise('bb_ore', { x = left_top_x + 16, y = left_top_y + 16 }, seed)
|
||||
|
||||
--Draw noise text values to determine which chunks are valid for mixed ore.
|
||||
--rendering.draw_text{text = noise, surface = game.surfaces.biter_battles, target = {x = left_top_x + 16, y = left_top_y + 16}, color = {255, 255, 255}, scale = 2, font = "default-game"}
|
||||
@ -467,20 +467,20 @@ local function mixed_ore(surface, left_top_x, left_top_y)
|
||||
--Draw the mixed ore patches.
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
local pos = {x = left_top_x + x, y = left_top_y + y}
|
||||
if surface.can_place_entity({name = 'iron-ore', position = pos}) then
|
||||
local pos = { x = left_top_x + x, y = left_top_y + y }
|
||||
if surface.can_place_entity({ name = 'iron-ore', position = pos }) then
|
||||
local noise = GetNoise('bb_ore', pos, seed)
|
||||
if noise > 0.72 then
|
||||
local amount = math_random(800, 1000) + math_sqrt(pos.x ^ 2 + pos.y ^ 2) * 3
|
||||
local i = math_floor(noise * 25 + math_abs(pos.x) * 0.05) % 4 + 1
|
||||
surface.create_entity({name = ores[i], position = pos, amount = amount})
|
||||
surface.create_entity({ name = ores[i], position = pos, amount = amount })
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if left_top_y == -32 and math_abs(left_top_x) <= 32 then
|
||||
for _, e in pairs(surface.find_entities_filtered({area = {{-12, -12}, {12, 12}}})) do
|
||||
for _, e in pairs(surface.find_entities_filtered({ area = { { -12, -12 }, { 12, 12 } } })) do
|
||||
e.destroy()
|
||||
end
|
||||
end
|
||||
@ -496,7 +496,7 @@ function Public.generate(event)
|
||||
local tiles = {}
|
||||
if math_abs(left_top_x) > 64 or math_abs(left_top_y) > 64 then
|
||||
for k, v in pairs(loading_chunk_vectors) do
|
||||
tiles[k] = {name = 'out-of-map', position = {left_top_x + v[1], left_top_y + v[2]}}
|
||||
tiles[k] = { name = 'out-of-map', position = { left_top_x + v[1], left_top_y + v[2] } }
|
||||
end
|
||||
end
|
||||
surface.set_tiles(tiles, false)
|
||||
@ -513,7 +513,7 @@ function Public.generate(event)
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
i = i + 1
|
||||
tiles[i] = {name = 'out-of-map', position = {left_top_x + x, left_top_y + y}}
|
||||
tiles[i] = { name = 'out-of-map', position = { left_top_x + x, left_top_y + y } }
|
||||
end
|
||||
end
|
||||
surface.set_tiles(tiles, false)
|
||||
@ -534,25 +534,25 @@ function Public.draw_spawn_circle(surface)
|
||||
local tiles = {}
|
||||
for x = spawn_circle_size * -1, -1, 1 do
|
||||
for y = spawn_circle_size * -1, -1, 1 do
|
||||
local pos = {x = x, y = y}
|
||||
local pos = { x = x, y = y }
|
||||
local distance_to_center = math_sqrt(pos.x ^ 2 + pos.y ^ 2)
|
||||
if distance_to_center <= spawn_circle_size then
|
||||
table_insert(tiles, {name = 'deepwater', position = pos})
|
||||
table_insert(tiles, { name = 'deepwater', position = pos })
|
||||
|
||||
if distance_to_center < 9.5 then
|
||||
table_insert(tiles, {name = 'refined-concrete', position = pos})
|
||||
table_insert(tiles, { name = 'refined-concrete', position = pos })
|
||||
if distance_to_center < 7 then
|
||||
table_insert(tiles, {name = 'sand-1', position = pos})
|
||||
table_insert(tiles, { name = 'sand-1', position = pos })
|
||||
end
|
||||
-- else
|
||||
--
|
||||
-- else
|
||||
--
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for i = 1, #tiles, 1 do
|
||||
table_insert(tiles, {name = tiles[i].name, position = {tiles[i].position.x * -1 - 1, tiles[i].position.y}})
|
||||
table_insert(tiles, { name = tiles[i].name, position = { tiles[i].position.x * -1 - 1, tiles[i].position.y } })
|
||||
end
|
||||
|
||||
surface.set_tiles(tiles, true)
|
||||
@ -560,7 +560,7 @@ function Public.draw_spawn_circle(surface)
|
||||
for i = 1, #tiles, 1 do
|
||||
if tiles[i].name == 'deepwater' then
|
||||
if math_random(1, 48) == 1 then
|
||||
local e = surface.create_entity({name = 'fish', position = tiles[i].position})
|
||||
local e = surface.create_entity({ name = 'fish', position = tiles[i].position })
|
||||
e.active = false
|
||||
end
|
||||
end
|
||||
@ -573,12 +573,12 @@ function Public.fill_water_tiles(surface)
|
||||
|
||||
for x = r * -1, r, 1 do
|
||||
for y = r * -1, -4, 1 do
|
||||
local pos = {x = x, y = y}
|
||||
local pos = { x = x, y = y }
|
||||
local distance_to_center = math_sqrt(pos.x ^ 2 + pos.y ^ 2)
|
||||
if distance_to_center < 550 and not is_horizontal_border_river(pos) then
|
||||
local tile_name = surface.get_tile(pos).name
|
||||
if tile_name == 'water' or tile_name == 'deepwater' then
|
||||
surface.set_tiles({{name = get_replacement_tile(surface, pos), position = pos}}, true)
|
||||
surface.set_tiles({ { name = get_replacement_tile(surface, pos), position = pos } }, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -591,7 +591,7 @@ function Public.draw_spawn_area(surface)
|
||||
|
||||
for x = r * -1, r, 1 do
|
||||
for y = r * -1, -4, 1 do
|
||||
local pos = {x = x, y = y}
|
||||
local pos = { x = x, y = y }
|
||||
local distance_to_center = math_sqrt(pos.x ^ 2 + pos.y ^ 2)
|
||||
generate_starting_area(pos, distance_to_center, surface)
|
||||
end
|
||||
@ -603,18 +603,18 @@ end
|
||||
|
||||
function Public.generate_additional_spawn_ore(surface)
|
||||
local r = 130
|
||||
local area = {{r * -1, r * -1}, {r, 0}}
|
||||
local area = { { r * -1, r * -1 }, { r, 0 } }
|
||||
local ores = {}
|
||||
ores['iron-ore'] = surface.count_entities_filtered({name = 'iron-ore', area = area})
|
||||
ores['copper-ore'] = surface.count_entities_filtered({name = 'copper-ore', area = area})
|
||||
ores['coal'] = surface.count_entities_filtered({name = 'coal', area = area})
|
||||
ores['stone'] = surface.count_entities_filtered({name = 'stone', area = area})
|
||||
ores['iron-ore'] = surface.count_entities_filtered({ name = 'iron-ore', area = area })
|
||||
ores['copper-ore'] = surface.count_entities_filtered({ name = 'copper-ore', area = area })
|
||||
ores['coal'] = surface.count_entities_filtered({ name = 'coal', area = area })
|
||||
ores['stone'] = surface.count_entities_filtered({ name = 'stone', area = area })
|
||||
for ore, ore_count in pairs(ores) do
|
||||
if ore_count < 1000 or ore_count == nil then
|
||||
local pos = {}
|
||||
for a = 1, 32, 1 do
|
||||
pos = {x = -96 + math_random(0, 192), y = -20 - math_random(0, 96)}
|
||||
if surface.can_place_entity({name = 'coal', position = pos, amount = 1}) then
|
||||
pos = { x = -96 + math_random(0, 192), y = -20 - math_random(0, 96) }
|
||||
if surface.can_place_entity({ name = 'coal', position = pos, amount = 1 }) then
|
||||
break
|
||||
end
|
||||
end
|
||||
@ -625,62 +625,63 @@ end
|
||||
|
||||
function Public.generate_additional_rocks(surface)
|
||||
local r = 130
|
||||
if surface.count_entities_filtered({type = 'simple-entity', area = {{r * -1, r * -1}, {r, 0}}}) >= 12 then
|
||||
if surface.count_entities_filtered({ type = 'simple-entity', area = { { r * -1, r * -1 }, { r, 0 } } }) >= 12 then
|
||||
return
|
||||
end
|
||||
local position = {x = -96 + math_random(0, 192), y = -40 - math_random(0, 96)}
|
||||
local rocks = {'rock-huge', 'rock-big', 'rock-big', 'rock-big', 'sand-rock-big'}
|
||||
local position = { x = -96 + math_random(0, 192), y = -40 - math_random(0, 96) }
|
||||
local rocks = { 'rock-huge', 'rock-big', 'rock-big', 'rock-big', 'sand-rock-big' }
|
||||
for _ = 1, math_random(6, 10) do
|
||||
local name = rocks[math_random(1, 5)]
|
||||
local p = surface.find_non_colliding_position(name, {position.x + (-10 + math_random(0, 20)), position.y + (-10 + math_random(0, 20))}, 16, 1)
|
||||
local p = surface.find_non_colliding_position(name, { position.x + (-10 + math_random(0, 20)), position.y + (-10 + math_random(0, 20)) }, 16, 1)
|
||||
if p and p.y < -16 then
|
||||
surface.create_entity({name = name, position = p})
|
||||
surface.create_entity({ name = name, position = p })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function Public.generate_silo(surface)
|
||||
local pos = {x = -32 + math_random(0, 64), y = -72}
|
||||
local mirror_position = {x = pos.x * -1, y = pos.y * -1}
|
||||
local pos = { x = -32 + math_random(0, 64), y = -72 }
|
||||
local mirror_position = { x = pos.x * -1, y = pos.y * -1 }
|
||||
|
||||
for _, t in pairs(surface.find_tiles_filtered({area = {{pos.x - 6, pos.y - 6}, {pos.x + 6, pos.y + 6}}, name = {'water', 'deepwater'}})) do
|
||||
surface.set_tiles({{name = get_replacement_tile(surface, t.position), position = t.position}})
|
||||
for _, t in pairs(surface.find_tiles_filtered({ area = { { pos.x - 6, pos.y - 6 }, { pos.x + 6, pos.y + 6 } }, name = { 'water', 'deepwater' } })) do
|
||||
surface.set_tiles({ { name = get_replacement_tile(surface, t.position), position = t.position } })
|
||||
end
|
||||
for _, t in pairs(surface.find_tiles_filtered({area = {{mirror_position.x - 6, mirror_position.y - 6}, {mirror_position.x + 6, mirror_position.y + 6}}, name = {'water', 'deepwater'}})) do
|
||||
surface.set_tiles({{name = get_replacement_tile(surface, t.position), position = t.position}})
|
||||
for _, t in pairs(surface.find_tiles_filtered({ area = { { mirror_position.x - 6, mirror_position.y - 6 }, { mirror_position.x + 6, mirror_position.y + 6 } }, name = { 'water', 'deepwater' } })) do
|
||||
surface.set_tiles({ { name = get_replacement_tile(surface, t.position), position = t.position } })
|
||||
end
|
||||
|
||||
local silo =
|
||||
surface.create_entity(
|
||||
{
|
||||
name = 'rocket-silo',
|
||||
position = pos,
|
||||
force = 'neutral'
|
||||
}
|
||||
)
|
||||
{
|
||||
name = 'rocket-silo',
|
||||
position = pos,
|
||||
force = 'neutral'
|
||||
}
|
||||
)
|
||||
silo.minable = false
|
||||
silo.active = false
|
||||
|
||||
for i = 1, 32, 1 do
|
||||
create_mirrored_tile_chain(surface, {name = 'stone-path', position = silo.position}, 32, 10)
|
||||
create_mirrored_tile_chain(surface, { name = 'stone-path', position = silo.position }, 32, 10)
|
||||
end
|
||||
|
||||
local p = silo.position
|
||||
for _, entity in pairs(surface.find_entities({{p.x - 4, p.y - 4}, {p.x + 4, p.y + 4}})) do
|
||||
for _, entity in pairs(surface.find_entities({ { p.x - 4, p.y - 4 }, { p.x + 4, p.y + 4 } })) do
|
||||
if entity.type == 'simple-entity' or entity.type == 'tree' or entity.type == 'resource' then
|
||||
entity.destroy()
|
||||
end
|
||||
end
|
||||
|
||||
if bb_config.spawn_turrets_at_silo then
|
||||
local turret1 = surface.create_entity({name = 'gun-turret', position = {x = pos.x, y = pos.y - 5}, force = 'neutral'})
|
||||
turret1.insert({name = 'firearm-magazine', count = 10})
|
||||
local turret1 = surface.create_entity({ name = 'gun-turret', position = { x = pos.x, y = pos.y - 5 }, force = 'neutral' })
|
||||
turret1.insert({ name = 'firearm-magazine', count = 10 })
|
||||
turret1.active = false
|
||||
local turret2 = surface.create_entity({name = 'gun-turret', position = {x = pos.x + 2, y = pos.y - 5}, force = 'neutral'})
|
||||
turret2.insert({name = 'firearm-magazine', count = 10})
|
||||
local turret2 = surface.create_entity({ name = 'gun-turret', position = { x = pos.x + 2, y = pos.y - 5 }, force = 'neutral' })
|
||||
turret2.insert({ name = 'firearm-magazine', count = 10 })
|
||||
turret2.active = false
|
||||
end
|
||||
end
|
||||
|
||||
--[[
|
||||
function Public.generate_spawn_goodies(surface)
|
||||
local tiles = surface.find_tiles_filtered({name = "stone-path"})
|
||||
@ -742,18 +743,18 @@ function Public.minable_wrecks(event)
|
||||
local amount = stack.count
|
||||
local name = stack.name
|
||||
|
||||
local inserted_count = player.insert({name = name, count = amount})
|
||||
local inserted_count = player.insert({ name = name, count = amount })
|
||||
if inserted_count ~= amount then
|
||||
local amount_to_spill = amount - inserted_count
|
||||
surface.spill_item_stack(entity.position, {name = name, count = amount_to_spill}, true)
|
||||
surface.spill_item_stack(entity.position, { name = name, count = amount_to_spill }, true)
|
||||
end
|
||||
|
||||
surface.create_entity(
|
||||
{
|
||||
name = 'flying-text',
|
||||
position = {entity.position.x, entity.position.y - 0.5 * k},
|
||||
position = { entity.position.x, entity.position.y - 0.5 * k },
|
||||
text = '+' .. amount .. ' [img=item/' .. name .. ']',
|
||||
color = {r = 0.98, g = 0.66, b = 0.22}
|
||||
color = { r = 0.98, g = 0.66, b = 0.22 }
|
||||
}
|
||||
)
|
||||
end
|
||||
@ -765,23 +766,23 @@ function Public.restrict_landfill(surface, inventory, tiles)
|
||||
local distance_to_center = math_sqrt(t.position.x ^ 2 + t.position.y ^ 2)
|
||||
local check_position = t.position
|
||||
if check_position.y > 0 then
|
||||
check_position = {x = check_position.x * -1, y = (check_position.y * -1) - 1}
|
||||
check_position = { x = check_position.x * -1, y = (check_position.y * -1) - 1 }
|
||||
end
|
||||
if is_horizontal_border_river(check_position) or distance_to_center < spawn_circle_size then
|
||||
surface.set_tiles({{name = t.old_tile.name, position = t.position}}, true)
|
||||
inventory.insert({name = 'landfill', count = 1})
|
||||
surface.set_tiles({ { name = t.old_tile.name, position = t.position } }, true)
|
||||
inventory.insert({ name = 'landfill', count = 1 })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--Construction Robot Restriction
|
||||
local robot_build_restriction = {
|
||||
['north'] = function(y)
|
||||
['north'] = function (y)
|
||||
if y >= -10 then
|
||||
return true
|
||||
end
|
||||
end,
|
||||
['south'] = function(y)
|
||||
['south'] = function (y)
|
||||
if y <= 10 then
|
||||
return true
|
||||
end
|
||||
@ -796,9 +797,9 @@ function Public.deny_construction_bots(event)
|
||||
return
|
||||
end
|
||||
local inventory = event.robot.get_inventory(defines.inventory.robot_cargo)
|
||||
inventory.insert({name = event.created_entity.name, count = 1})
|
||||
event.robot.surface.create_entity({name = 'explosion', position = event.created_entity.position})
|
||||
game.print('Team ' .. event.robot.force.name .. "'s construction drone had an accident.", {r = 200, g = 50, b = 100})
|
||||
inventory.insert({ name = event.created_entity.name, count = 1 })
|
||||
event.robot.surface.create_entity({ name = 'explosion', position = event.created_entity.position })
|
||||
game.print('Team ' .. event.robot.force.name .. "'s construction drone had an accident.", { r = 200, g = 50, b = 100 })
|
||||
event.created_entity.destroy()
|
||||
end
|
||||
|
||||
|
@ -12,7 +12,7 @@ local function get_replacement_tile(surface, position)
|
||||
table.shuffle_table(vectors)
|
||||
for _, v in pairs(vectors) do
|
||||
local tile = surface.get_tile(position.x + v[1], position.y + v[2])
|
||||
if not tile.collides_with('resource-layer') then
|
||||
if not tile.collides_with('resource') then
|
||||
return tile.name
|
||||
end
|
||||
end
|
||||
|
@ -276,7 +276,7 @@ local function process_entity(e)
|
||||
end
|
||||
|
||||
local function process_tile(surface, pos, tile, seed)
|
||||
if tile.collides_with('player-layer') then
|
||||
if tile.collides_with('player') then
|
||||
return
|
||||
end
|
||||
if not surface.can_place_entity({ name = 'tree-01', position = pos }) then
|
||||
|
@ -133,7 +133,7 @@ local function process_entity(e)
|
||||
end
|
||||
|
||||
local function process_tile(surface, pos, tile, seed)
|
||||
if tile.collides_with('player-layer') then
|
||||
if tile.collides_with('player') then
|
||||
return
|
||||
end
|
||||
if not surface.can_place_entity({ name = 'tree-01', position = pos }) then
|
||||
|
@ -144,7 +144,7 @@ end
|
||||
-- local nightmare_trees = {"tree-08-brown","tree-01","tree-04","tree-02-red"} // unused?
|
||||
|
||||
local function process_tile(surface, pos, tile, entities, seed)
|
||||
if tile.collides_with('player-layer') then
|
||||
if tile.collides_with('player') then
|
||||
return
|
||||
end
|
||||
if not surface.can_place_entity({ name = 'tree-01', position = pos }) then
|
||||
|
@ -70,7 +70,7 @@ local function get_replacement_tile(surface, position)
|
||||
table.shuffle_table(vectors)
|
||||
for k, v in pairs(vectors) do
|
||||
local tile = surface.get_tile(position.x + v[1], position.y + v[2])
|
||||
if not tile.collides_with('resource-layer') then
|
||||
if not tile.collides_with('resource') then
|
||||
return tile.name
|
||||
end
|
||||
end
|
||||
@ -98,7 +98,7 @@ function Public.replace_water(surface, left_top)
|
||||
local tile = surface.get_tile(p)
|
||||
if tile.hidden_tile then
|
||||
surface.set_hidden_tile(p, get_replacement_tile(surface, p).name)
|
||||
elseif tile.collides_with('resource-layer') then
|
||||
elseif tile.collides_with('resource') then
|
||||
tiles[#tiles + 1] = { name = get_replacement_tile(surface, p), position = p }
|
||||
end
|
||||
end
|
||||
@ -166,9 +166,9 @@ local modifiers = {
|
||||
{ x = 0, y = 1 }
|
||||
}
|
||||
local modifiers_diagonal = {
|
||||
{ diagonal = { x = -1, y = 1 }, connection_1 = { x = -1, y = 0 }, connection_2 = { x = 0, y = 1 } },
|
||||
{ diagonal = { x = 1, y = -1 }, connection_1 = { x = 1, y = 0 }, connection_2 = { x = 0, y = -1 } },
|
||||
{ diagonal = { x = 1, y = 1 }, connection_1 = { x = 1, y = 0 }, connection_2 = { x = 0, y = 1 } },
|
||||
{ diagonal = { x = -1, y = 1 }, connection_1 = { x = -1, y = 0 }, connection_2 = { x = 0, y = 1 } },
|
||||
{ diagonal = { x = 1, y = -1 }, connection_1 = { x = 1, y = 0 }, connection_2 = { x = 0, y = -1 } },
|
||||
{ diagonal = { x = 1, y = 1 }, connection_1 = { x = 1, y = 0 }, connection_2 = { x = 0, y = 1 } },
|
||||
{ diagonal = { x = -1, y = -1 }, connection_1 = { x = -1, y = 0 }, connection_2 = { x = 0, y = -1 } }
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ local function get_replacement_tile(surface, position)
|
||||
shuffle(vectors)
|
||||
for k, v in pairs(vectors) do
|
||||
local tile = surface.get_tile(position.x + v[1], position.y + v[2])
|
||||
if not tile.collides_with('resource-layer') then
|
||||
if not tile.collides_with('resource') then
|
||||
return tile.name
|
||||
end
|
||||
end
|
||||
|
@ -53,12 +53,12 @@ local function process_tile(surface, pos)
|
||||
end
|
||||
|
||||
local tile = surface.get_tile(pos)
|
||||
if tile.collides_with('player-layer') then
|
||||
if tile.collides_with('player') then
|
||||
return
|
||||
end
|
||||
|
||||
if surface.can_place_entity({name = 'wooden-chest', position = pos, force = 'neutral'}) then
|
||||
local e = surface.create_entity({name = 'wooden-chest', position = pos, force = 'neutral'})
|
||||
if surface.can_place_entity({ name = 'wooden-chest', position = pos, force = 'neutral' }) then
|
||||
local e = surface.create_entity({ name = 'wooden-chest', position = pos, force = 'neutral' })
|
||||
|
||||
if math_abs(noise_2) > 0.76 or math_random(1, 32) == 1 then
|
||||
local budget = math_sqrt(pos.x ^ 2 + pos.y ^ 2) + 1
|
||||
@ -73,7 +73,7 @@ end
|
||||
local function get_spawn_position()
|
||||
for y = 0, 1024, 1 do
|
||||
for x = 0, 1024, 1 do
|
||||
local pos = {x = x, y = y}
|
||||
local pos = { x = x, y = y }
|
||||
local noise = get_noise(1, pos)
|
||||
if noise < 0.08 and noise > -0.08 then
|
||||
return pos
|
||||
@ -87,7 +87,7 @@ local function on_chunk_generated(event)
|
||||
local left_top = event.area.left_top
|
||||
for x = 0.5, 31.5, 1 do
|
||||
for y = 0.5, 31.5, 1 do
|
||||
local pos = {x = left_top.x + x, y = left_top.y + y}
|
||||
local pos = { x = left_top.x + x, y = left_top.y + y }
|
||||
process_tile(surface, pos)
|
||||
end
|
||||
end
|
||||
@ -96,11 +96,11 @@ end
|
||||
local function on_player_joined_game(event)
|
||||
local player = game.players[event.player_index]
|
||||
if player.online_time == 0 then
|
||||
player.insert {name = 'pistol', count = 1}
|
||||
player.insert {name = 'firearm-magazine', count = 16}
|
||||
player.insert {name = 'iron-plate', count = 100}
|
||||
player.insert {name = 'copper-plate', count = 50}
|
||||
player.insert {name = 'car', count = 1}
|
||||
player.insert { name = 'pistol', count = 1 }
|
||||
player.insert { name = 'firearm-magazine', count = 16 }
|
||||
player.insert { name = 'iron-plate', count = 100 }
|
||||
player.insert { name = 'copper-plate', count = 50 }
|
||||
player.insert { name = 'car', count = 1 }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -14,58 +14,58 @@ end
|
||||
|
||||
local function secret_shop(pos, surface)
|
||||
local secret_market_items = {
|
||||
{price = {{'coin', random(300, 600)}}, offer = {type = 'give-item', item = 'combat-shotgun'}},
|
||||
{price = {{'coin', random(200, 400)}}, offer = {type = 'give-item', item = 'rocket-launcher'}},
|
||||
{price = {{'coin', random(5, 10)}}, offer = {type = 'give-item', item = 'piercing-rounds-magazine'}},
|
||||
{ price = { { 'coin', random(300, 600) } }, offer = { type = 'give-item', item = 'combat-shotgun' } },
|
||||
{ price = { { 'coin', random(200, 400) } }, offer = { type = 'give-item', item = 'rocket-launcher' } },
|
||||
{ price = { { 'coin', random(5, 10) } }, offer = { type = 'give-item', item = 'piercing-rounds-magazine' } },
|
||||
--{price = {{"coin", random(150,250)}}, offer = {type = 'give-item', item = 'uranium-rounds-magazine'}},
|
||||
{price = {{'coin', random(15, 30)}}, offer = {type = 'give-item', item = 'piercing-shotgun-shell'}},
|
||||
{price = {{'coin', random(10, 20)}}, offer = {type = 'give-item', item = 'rocket'}},
|
||||
{price = {{'coin', random(20, 30)}}, offer = {type = 'give-item', item = 'explosive-rocket'}},
|
||||
{price = {{'coin', random(30, 60)}}, offer = {type = 'give-item', item = 'cluster-grenade'}},
|
||||
{price = {{'coin', random(8, 16)}}, offer = {type = 'give-item', item = 'land-mine'}},
|
||||
{price = {{'coin', random(200, 300)}}, offer = {type = 'give-item', item = 'heavy-armor'}},
|
||||
{price = {{'coin', random(400, 800)}}, offer = {type = 'give-item', item = 'modular-armor'}},
|
||||
{price = {{'coin', random(1000, 2000)}}, offer = {type = 'give-item', item = 'power-armor'}},
|
||||
{price = {{'coin', random(2500, 5000)}}, offer = {type = 'give-item', item = 'fusion-reactor-equipment'}},
|
||||
{price = {{'coin', random(200, 400)}}, offer = {type = 'give-item', item = 'battery-equipment'}},
|
||||
{price = {{'coin', random(150, 250)}}, offer = {type = 'give-item', item = 'belt-immunity-equipment'}},
|
||||
{price = {{'coin', random(100, 200)}}, offer = {type = 'give-item', item = 'night-vision-equipment'}},
|
||||
{price = {{'coin', random(400, 800)}}, offer = {type = 'give-item', item = 'exoskeleton-equipment'}},
|
||||
{price = {{'coin', random(200, 300)}}, offer = {type = 'give-item', item = 'personal-roboport-equipment'}},
|
||||
{price = {{'coin', random(25, 50)}}, offer = {type = 'give-item', item = 'construction-robot'}},
|
||||
{ price = { { 'coin', random(15, 30) } }, offer = { type = 'give-item', item = 'piercing-shotgun-shell' } },
|
||||
{ price = { { 'coin', random(10, 20) } }, offer = { type = 'give-item', item = 'rocket' } },
|
||||
{ price = { { 'coin', random(20, 30) } }, offer = { type = 'give-item', item = 'explosive-rocket' } },
|
||||
{ price = { { 'coin', random(30, 60) } }, offer = { type = 'give-item', item = 'cluster-grenade' } },
|
||||
{ price = { { 'coin', random(8, 16) } }, offer = { type = 'give-item', item = 'land-mine' } },
|
||||
{ price = { { 'coin', random(200, 300) } }, offer = { type = 'give-item', item = 'heavy-armor' } },
|
||||
{ price = { { 'coin', random(400, 800) } }, offer = { type = 'give-item', item = 'modular-armor' } },
|
||||
{ price = { { 'coin', random(1000, 2000) } }, offer = { type = 'give-item', item = 'power-armor' } },
|
||||
{ price = { { 'coin', random(2500, 5000) } }, offer = { type = 'give-item', item = 'fusion-reactor-equipment' } },
|
||||
{ price = { { 'coin', random(200, 400) } }, offer = { type = 'give-item', item = 'battery-equipment' } },
|
||||
{ price = { { 'coin', random(150, 250) } }, offer = { type = 'give-item', item = 'belt-immunity-equipment' } },
|
||||
{ price = { { 'coin', random(100, 200) } }, offer = { type = 'give-item', item = 'night-vision-equipment' } },
|
||||
{ price = { { 'coin', random(400, 800) } }, offer = { type = 'give-item', item = 'exoskeleton-equipment' } },
|
||||
{ price = { { 'coin', random(200, 300) } }, offer = { type = 'give-item', item = 'personal-roboport-equipment' } },
|
||||
{ price = { { 'coin', random(25, 50) } }, offer = { type = 'give-item', item = 'construction-robot' } },
|
||||
-- {price = {{"coin", random(10000,20000)}}, offer = {type = 'give-item', item = 'energy-shield-equipment'}},
|
||||
-- {price = {{"coin", random(5000,15000)}}, offer = {type = 'give-item', item = 'personal-laser-defense-equipment'}},
|
||||
{price = {{'coin', random(100, 300)}}, offer = {type = 'give-item', item = 'loader'}},
|
||||
{price = {{'coin', random(200, 400)}}, offer = {type = 'give-item', item = 'fast-loader'}},
|
||||
{price = {{'coin', random(300, 500)}}, offer = {type = 'give-item', item = 'express-loader'}},
|
||||
{price = {{'coin', random(150, 300)}}, offer = {type = 'give-item', item = 'locomotive'}},
|
||||
{price = {{'coin', random(100, 200)}}, offer = {type = 'give-item', item = 'cargo-wagon'}},
|
||||
{price = {{'coin', random(5, 15)}}, offer = {type = 'give-item', item = 'grenade'}},
|
||||
{price = {{'coin', random(80, 160)}}, offer = {type = 'give-item', item = 'cliff-explosives'}},
|
||||
{price = {{'coin', random(10, 20)}}, offer = {type = 'give-item', item = 'explosives', count = 50}},
|
||||
{price = {{'coin', random(4, 8)}}, offer = {type = 'give-item', item = 'rail', count = 4}},
|
||||
{price = {{'coin', random(20, 30)}}, offer = {type = 'give-item', item = 'train-stop'}},
|
||||
{price = {{'coin', random(4, 12)}}, offer = {type = 'give-item', item = 'small-lamp'}},
|
||||
{price = {{'coin', random(1, 4)}}, offer = {type = 'give-item', item = 'firearm-magazine'}},
|
||||
{price = {{'coin', random(60, 150)}}, offer = {type = 'give-item', item = 'car', count = 1}},
|
||||
{price = {{'coin', random(75, 150)}}, offer = {type = 'give-item', item = 'gun-turret', count = 1}},
|
||||
{price = {{'coin', random(500, 750)}}, offer = {type = 'give-item', item = 'laser-turret', count = 1}},
|
||||
{price = {{'coin', random(1000, 2000)}}, offer = {type = 'give-item', item = 'artillery-turret', count = 1}},
|
||||
{price = {{'coin', random(100, 200)}}, offer = {type = 'give-item', item = 'artillery-shell', count = 1}},
|
||||
{price = {{'coin', random(50, 150)}}, offer = {type = 'give-item', item = 'artillery-targeting-remote', count = 1}},
|
||||
{price = {{'coin', random(5, 15)}}, offer = {type = 'give-item', item = 'shotgun-shell', count = 1}},
|
||||
{price = {{'coin', random(8000, 16000)}}, offer = {type = 'give-item', item = 'power-armor-mk2', count = 1}},
|
||||
{price = {{'coin', random(80, 160)}}, offer = {type = 'give-item', item = 'solar-panel-equipment', count = 1}},
|
||||
{price = {{'coin', random(4, 8)}}, offer = {type = 'give-item', item = 'wood', count = 50}},
|
||||
{price = {{'coin', random(4, 8)}}, offer = {type = 'give-item', item = 'iron-ore', count = 50}},
|
||||
{price = {{'coin', random(4, 8)}}, offer = {type = 'give-item', item = 'copper-ore', count = 50}},
|
||||
{price = {{'coin', random(4, 8)}}, offer = {type = 'give-item', item = 'stone', count = 50}},
|
||||
{price = {{'coin', random(4, 8)}}, offer = {type = 'give-item', item = 'coal', count = 50}}
|
||||
{ price = { { 'coin', random(100, 300) } }, offer = { type = 'give-item', item = 'loader' } },
|
||||
{ price = { { 'coin', random(200, 400) } }, offer = { type = 'give-item', item = 'fast-loader' } },
|
||||
{ price = { { 'coin', random(300, 500) } }, offer = { type = 'give-item', item = 'express-loader' } },
|
||||
{ price = { { 'coin', random(150, 300) } }, offer = { type = 'give-item', item = 'locomotive' } },
|
||||
{ price = { { 'coin', random(100, 200) } }, offer = { type = 'give-item', item = 'cargo-wagon' } },
|
||||
{ price = { { 'coin', random(5, 15) } }, offer = { type = 'give-item', item = 'grenade' } },
|
||||
{ price = { { 'coin', random(80, 160) } }, offer = { type = 'give-item', item = 'cliff-explosives' } },
|
||||
{ price = { { 'coin', random(10, 20) } }, offer = { type = 'give-item', item = 'explosives', count = 50 } },
|
||||
{ price = { { 'coin', random(4, 8) } }, offer = { type = 'give-item', item = 'rail', count = 4 } },
|
||||
{ price = { { 'coin', random(20, 30) } }, offer = { type = 'give-item', item = 'train-stop' } },
|
||||
{ price = { { 'coin', random(4, 12) } }, offer = { type = 'give-item', item = 'small-lamp' } },
|
||||
{ price = { { 'coin', random(1, 4) } }, offer = { type = 'give-item', item = 'firearm-magazine' } },
|
||||
{ price = { { 'coin', random(60, 150) } }, offer = { type = 'give-item', item = 'car', count = 1 } },
|
||||
{ price = { { 'coin', random(75, 150) } }, offer = { type = 'give-item', item = 'gun-turret', count = 1 } },
|
||||
{ price = { { 'coin', random(500, 750) } }, offer = { type = 'give-item', item = 'laser-turret', count = 1 } },
|
||||
{ price = { { 'coin', random(1000, 2000) } }, offer = { type = 'give-item', item = 'artillery-turret', count = 1 } },
|
||||
{ price = { { 'coin', random(100, 200) } }, offer = { type = 'give-item', item = 'artillery-shell', count = 1 } },
|
||||
{ price = { { 'coin', random(50, 150) } }, offer = { type = 'give-item', item = 'artillery-targeting-remote', count = 1 } },
|
||||
{ price = { { 'coin', random(5, 15) } }, offer = { type = 'give-item', item = 'shotgun-shell', count = 1 } },
|
||||
{ price = { { 'coin', random(8000, 16000) } }, offer = { type = 'give-item', item = 'power-armor-mk2', count = 1 } },
|
||||
{ price = { { 'coin', random(80, 160) } }, offer = { type = 'give-item', item = 'solar-panel-equipment', count = 1 } },
|
||||
{ price = { { 'coin', random(4, 8) } }, offer = { type = 'give-item', item = 'wood', count = 50 } },
|
||||
{ price = { { 'coin', random(4, 8) } }, offer = { type = 'give-item', item = 'iron-ore', count = 50 } },
|
||||
{ price = { { 'coin', random(4, 8) } }, offer = { type = 'give-item', item = 'copper-ore', count = 50 } },
|
||||
{ price = { { 'coin', random(4, 8) } }, offer = { type = 'give-item', item = 'stone', count = 50 } },
|
||||
{ price = { { 'coin', random(4, 8) } }, offer = { type = 'give-item', item = 'coal', count = 50 } }
|
||||
--{price = {{"coin", random(4,8)}}, offer = {type = 'give-item', item = 'uranium-ore', count = 50}}
|
||||
}
|
||||
secret_market_items = shuffle(secret_market_items)
|
||||
|
||||
local market = surface.create_entity {name = 'market', position = pos}
|
||||
local market = surface.create_entity { name = 'market', position = pos }
|
||||
market.destructible = false
|
||||
|
||||
for i = 1, math.random(6, 10), 1 do
|
||||
@ -74,44 +74,44 @@ local function secret_shop(pos, surface)
|
||||
end
|
||||
|
||||
local function treasure_chest(position)
|
||||
if not game.surfaces['deep_jungle'].can_place_entity({name = 'steel-chest', position = position, force = 'player'}) then
|
||||
if not game.surfaces['deep_jungle'].can_place_entity({ name = 'steel-chest', position = position, force = 'player' }) then
|
||||
return
|
||||
end
|
||||
local treasure_chest_raffle_table = {}
|
||||
local treasure_chest_loot_weights = {}
|
||||
table.insert(treasure_chest_loot_weights, {{name = 'landfill', count = random(8, 16)}, 16})
|
||||
table.insert(treasure_chest_loot_weights, {{name = 'iron-gear-wheel', count = random(16, 48)}, 8})
|
||||
table.insert(treasure_chest_loot_weights, {{name = 'coal', count = random(16, 48)}, 2})
|
||||
table.insert(treasure_chest_loot_weights, {{name = 'copper-cable', count = random(64, 128)}, 8})
|
||||
table.insert(treasure_chest_loot_weights, {{name = 'inserter', count = random(4, 8)}, 4})
|
||||
table.insert(treasure_chest_loot_weights, {{name = 'fast-inserter', count = random(4, 8)}, 3})
|
||||
table.insert(treasure_chest_loot_weights, {{name = 'burner-inserter', count = random(4, 8)}, 6})
|
||||
table.insert(treasure_chest_loot_weights, {{name = 'rocket-fuel', count = random(1, 5)}, 3})
|
||||
table.insert(treasure_chest_loot_weights, {{name = 'small-electric-pole', count = random(4, 8)}, 7})
|
||||
table.insert(treasure_chest_loot_weights, {{name = 'firearm-magazine', count = random(16, 48)}, 8})
|
||||
table.insert(treasure_chest_loot_weights, {{name = 'submachine-gun', count = 1}, 4})
|
||||
table.insert(treasure_chest_loot_weights, {{name = 'grenade', count = random(6, 12)}, 5})
|
||||
table.insert(treasure_chest_loot_weights, {{name = 'land-mine', count = random(8, 16)}, 5})
|
||||
table.insert(treasure_chest_loot_weights, {{name = 'light-armor', count = 1}, 1})
|
||||
table.insert(treasure_chest_loot_weights, {{name = 'heavy-armor', count = 1}, 2})
|
||||
table.insert(treasure_chest_loot_weights, {{name = 'pipe', count = random(10, 100)}, 6})
|
||||
table.insert(treasure_chest_loot_weights, {{name = 'explosives', count = random(40, 50)}, 6})
|
||||
table.insert(treasure_chest_loot_weights, {{name = 'shotgun', count = 1}, 3})
|
||||
table.insert(treasure_chest_loot_weights, {{name = 'shotgun-shell', count = random(8, 16)}, 3})
|
||||
table.insert(treasure_chest_loot_weights, {{name = 'stone-brick', count = random(80, 100)}, 4})
|
||||
table.insert(treasure_chest_loot_weights, {{name = 'small-lamp', count = random(2, 4)}, 2})
|
||||
table.insert(treasure_chest_loot_weights, {{name = 'rail', count = random(16, 48)}, 3})
|
||||
table.insert(treasure_chest_loot_weights, {{name = 'coin', count = random(32, 320)}, 1})
|
||||
table.insert(treasure_chest_loot_weights, {{name = 'assembling-machine-1', count = random(1, 3)}, 3})
|
||||
table.insert(treasure_chest_loot_weights, {{name = 'assembling-machine-2', count = random(1, 3)}, 2})
|
||||
table.insert(treasure_chest_loot_weights, {{name = 'assembling-machine-3', count = random(1, 2)}, 1})
|
||||
table.insert(treasure_chest_loot_weights, { { name = 'landfill', count = random(8, 16) }, 16 })
|
||||
table.insert(treasure_chest_loot_weights, { { name = 'iron-gear-wheel', count = random(16, 48) }, 8 })
|
||||
table.insert(treasure_chest_loot_weights, { { name = 'coal', count = random(16, 48) }, 2 })
|
||||
table.insert(treasure_chest_loot_weights, { { name = 'copper-cable', count = random(64, 128) }, 8 })
|
||||
table.insert(treasure_chest_loot_weights, { { name = 'inserter', count = random(4, 8) }, 4 })
|
||||
table.insert(treasure_chest_loot_weights, { { name = 'fast-inserter', count = random(4, 8) }, 3 })
|
||||
table.insert(treasure_chest_loot_weights, { { name = 'burner-inserter', count = random(4, 8) }, 6 })
|
||||
table.insert(treasure_chest_loot_weights, { { name = 'rocket-fuel', count = random(1, 5) }, 3 })
|
||||
table.insert(treasure_chest_loot_weights, { { name = 'small-electric-pole', count = random(4, 8) }, 7 })
|
||||
table.insert(treasure_chest_loot_weights, { { name = 'firearm-magazine', count = random(16, 48) }, 8 })
|
||||
table.insert(treasure_chest_loot_weights, { { name = 'submachine-gun', count = 1 }, 4 })
|
||||
table.insert(treasure_chest_loot_weights, { { name = 'grenade', count = random(6, 12) }, 5 })
|
||||
table.insert(treasure_chest_loot_weights, { { name = 'land-mine', count = random(8, 16) }, 5 })
|
||||
table.insert(treasure_chest_loot_weights, { { name = 'light-armor', count = 1 }, 1 })
|
||||
table.insert(treasure_chest_loot_weights, { { name = 'heavy-armor', count = 1 }, 2 })
|
||||
table.insert(treasure_chest_loot_weights, { { name = 'pipe', count = random(10, 100) }, 6 })
|
||||
table.insert(treasure_chest_loot_weights, { { name = 'explosives', count = random(40, 50) }, 6 })
|
||||
table.insert(treasure_chest_loot_weights, { { name = 'shotgun', count = 1 }, 3 })
|
||||
table.insert(treasure_chest_loot_weights, { { name = 'shotgun-shell', count = random(8, 16) }, 3 })
|
||||
table.insert(treasure_chest_loot_weights, { { name = 'stone-brick', count = random(80, 100) }, 4 })
|
||||
table.insert(treasure_chest_loot_weights, { { name = 'small-lamp', count = random(2, 4) }, 2 })
|
||||
table.insert(treasure_chest_loot_weights, { { name = 'rail', count = random(16, 48) }, 3 })
|
||||
table.insert(treasure_chest_loot_weights, { { name = 'coin', count = random(32, 320) }, 1 })
|
||||
table.insert(treasure_chest_loot_weights, { { name = 'assembling-machine-1', count = random(1, 3) }, 3 })
|
||||
table.insert(treasure_chest_loot_weights, { { name = 'assembling-machine-2', count = random(1, 3) }, 2 })
|
||||
table.insert(treasure_chest_loot_weights, { { name = 'assembling-machine-3', count = random(1, 2) }, 1 })
|
||||
for _, t in pairs(treasure_chest_loot_weights) do
|
||||
for _ = 1, t[2], 1 do
|
||||
table.insert(treasure_chest_raffle_table, t[1])
|
||||
end
|
||||
end
|
||||
|
||||
local e = game.surfaces['deep_jungle'].create_entity {name = 'wooden-chest', position = position, force = 'player'}
|
||||
local e = game.surfaces['deep_jungle'].create_entity { name = 'wooden-chest', position = position, force = 'player' }
|
||||
e.minable = false
|
||||
local i = e.get_inventory(defines.inventory.chest)
|
||||
for _ = 1, random(3, 7), 1 do
|
||||
@ -121,28 +121,28 @@ local function treasure_chest(position)
|
||||
end
|
||||
|
||||
local function rare_treasure_chest(position)
|
||||
if not game.surfaces['deep_jungle'].can_place_entity({name = 'steel-chest', position = position, force = 'player'}) then
|
||||
if not game.surfaces['deep_jungle'].can_place_entity({ name = 'steel-chest', position = position, force = 'player' }) then
|
||||
return
|
||||
end
|
||||
local rare_treasure_chest_raffle_table = {}
|
||||
local rare_treasure_chest_loot_weights = {}
|
||||
table.insert(rare_treasure_chest_loot_weights, {{name = 'combat-shotgun', count = 1}, 5})
|
||||
table.insert(rare_treasure_chest_loot_weights, {{name = 'piercing-shotgun-shell', count = random(8, 16)}, 5})
|
||||
table.insert(rare_treasure_chest_loot_weights, {{name = 'rocket-launcher', count = 1}, 5})
|
||||
table.insert(rare_treasure_chest_loot_weights, {{name = 'rocket', count = random(4, 8)}, 5})
|
||||
table.insert(rare_treasure_chest_loot_weights, {{name = 'explosive-rocket', count = random(4, 8)}, 5})
|
||||
table.insert(rare_treasure_chest_loot_weights, {{name = 'modular-armor', count = 1}, 3})
|
||||
table.insert(rare_treasure_chest_loot_weights, {{name = 'piercing-rounds-magazine', count = random(32, 64)}, 3})
|
||||
table.insert(rare_treasure_chest_loot_weights, {{name = 'defender-capsule', count = random(4, 8)}, 5})
|
||||
table.insert(rare_treasure_chest_loot_weights, {{name = 'distractor-capsule', count = random(3, 5)}, 4})
|
||||
table.insert(rare_treasure_chest_loot_weights, {{name = 'destroyer-capsule', count = random(2, 3)}, 3})
|
||||
table.insert(rare_treasure_chest_loot_weights, { { name = 'combat-shotgun', count = 1 }, 5 })
|
||||
table.insert(rare_treasure_chest_loot_weights, { { name = 'piercing-shotgun-shell', count = random(8, 16) }, 5 })
|
||||
table.insert(rare_treasure_chest_loot_weights, { { name = 'rocket-launcher', count = 1 }, 5 })
|
||||
table.insert(rare_treasure_chest_loot_weights, { { name = 'rocket', count = random(4, 8) }, 5 })
|
||||
table.insert(rare_treasure_chest_loot_weights, { { name = 'explosive-rocket', count = random(4, 8) }, 5 })
|
||||
table.insert(rare_treasure_chest_loot_weights, { { name = 'modular-armor', count = 1 }, 3 })
|
||||
table.insert(rare_treasure_chest_loot_weights, { { name = 'piercing-rounds-magazine', count = random(32, 64) }, 3 })
|
||||
table.insert(rare_treasure_chest_loot_weights, { { name = 'defender-capsule', count = random(4, 8) }, 5 })
|
||||
table.insert(rare_treasure_chest_loot_weights, { { name = 'distractor-capsule', count = random(3, 5) }, 4 })
|
||||
table.insert(rare_treasure_chest_loot_weights, { { name = 'destroyer-capsule', count = random(2, 3) }, 3 })
|
||||
for _, t in pairs(rare_treasure_chest_loot_weights) do
|
||||
for _ = 1, t[2], 1 do
|
||||
table.insert(rare_treasure_chest_raffle_table, t[1])
|
||||
end
|
||||
end
|
||||
|
||||
local e = game.surfaces['deep_jungle'].create_entity {name = 'steel-chest', position = position, force = 'player'}
|
||||
local e = game.surfaces['deep_jungle'].create_entity { name = 'steel-chest', position = position, force = 'player' }
|
||||
e.minable = false
|
||||
local i = e.get_inventory(defines.inventory.chest)
|
||||
for _ = 1, random(2, 3), 1 do
|
||||
@ -189,8 +189,8 @@ local function get_noise(name, pos)
|
||||
end
|
||||
end
|
||||
|
||||
local rock_raffle = {'sand-rock-big', 'sand-rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-huge'}
|
||||
local tree_raffle = {'tree-04', 'tree-07', 'tree-09', 'tree-06', 'tree-04', 'tree-07', 'tree-09', 'tree-04'}
|
||||
local rock_raffle = { 'sand-rock-big', 'sand-rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-huge' }
|
||||
local tree_raffle = { 'tree-04', 'tree-07', 'tree-09', 'tree-06', 'tree-04', 'tree-07', 'tree-09', 'tree-04' }
|
||||
|
||||
local function process_tile(pos)
|
||||
local noise_1 = get_noise(1, pos)
|
||||
@ -237,13 +237,13 @@ local function process_bits(data)
|
||||
|
||||
local tile_to_insert, entity_to_place = process_tile(pos)
|
||||
if entity_to_place then
|
||||
entities[#entities + 1] = {name = entity_to_place, position = pos, force = 'player'}
|
||||
entities[#entities + 1] = { name = entity_to_place, position = pos, force = 'player' }
|
||||
end
|
||||
|
||||
if tile_to_insert then
|
||||
tiles[#tiles + 1] = {name = tile_to_insert, position = pos}
|
||||
tiles[#tiles + 1] = { name = tile_to_insert, position = pos }
|
||||
if random(1, 40) == 1 and tile_to_insert == 'deepwater' then
|
||||
entities[#entities + 1] = {name = 'fish', position = pos}
|
||||
entities[#entities + 1] = { name = 'fish', position = pos }
|
||||
end
|
||||
end
|
||||
|
||||
@ -264,9 +264,9 @@ local function process_bits(data)
|
||||
rare_treasure_chest(v)
|
||||
end
|
||||
for _, v in pairs(secret_shops) do
|
||||
if not surface.get_tile(v).collides_with('player-layer') then
|
||||
local area = {{v.x - 128, v.y - 128}, {v.x + 128, v.y + 128}}
|
||||
if surface.count_entities_filtered({name = 'market', area = area}) == 0 then
|
||||
if not surface.get_tile(v).collides_with('player') then
|
||||
local area = { { v.x - 128, v.y - 128 }, { v.x + 128, v.y + 128 } }
|
||||
if surface.count_entities_filtered({ name = 'market', area = area }) == 0 then
|
||||
secret_shop(v, surface)
|
||||
end
|
||||
end
|
||||
|
@ -8,16 +8,16 @@ local math_abs = math.abs
|
||||
|
||||
local function horizontal_water_barrier(surface, room)
|
||||
local a = room.radius * 2
|
||||
local left_top = {x = room.center.x - room.radius, y = room.center.y - room.radius}
|
||||
local left_top = { x = room.center.x - room.radius, y = room.center.y - room.radius }
|
||||
local center_position = room.center
|
||||
|
||||
for x = 0, a, 1 do
|
||||
for y = 0, a, 1 do
|
||||
local p = {x = left_top.x + x, y = left_top.y + y}
|
||||
local p = { x = left_top.x + x, y = left_top.y + y }
|
||||
if math_abs(p.y - center_position.y) < room.radius * 0.4 then
|
||||
surface.set_tiles({{name = 'water', position = p}})
|
||||
surface.set_tiles({ { name = 'water', position = p } })
|
||||
if math_random(1, 16) == 1 then
|
||||
surface.create_entity({name = 'fish', position = p})
|
||||
surface.create_entity({ name = 'fish', position = p })
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -26,16 +26,16 @@ end
|
||||
|
||||
local function vertical_water_barrier(surface, room)
|
||||
local a = room.radius * 2
|
||||
local left_top = {x = room.center.x - room.radius, y = room.center.y - room.radius}
|
||||
local left_top = { x = room.center.x - room.radius, y = room.center.y - room.radius }
|
||||
local center_position = room.center
|
||||
|
||||
for x = 0, a, 1 do
|
||||
for y = 0, a, 1 do
|
||||
local p = {x = left_top.x + x, y = left_top.y + y}
|
||||
local p = { x = left_top.x + x, y = left_top.y + y }
|
||||
if math_abs(p.x - center_position.x) < room.radius * 0.4 then
|
||||
surface.set_tiles({{name = 'water', position = p}})
|
||||
surface.set_tiles({ { name = 'water', position = p } })
|
||||
if math_random(1, 16) == 1 then
|
||||
surface.create_entity({name = 'fish', position = p})
|
||||
surface.create_entity({ name = 'fish', position = p })
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -44,16 +44,16 @@ end
|
||||
|
||||
local function vertical_bridge(surface, room)
|
||||
local a = room.radius * 2
|
||||
local left_top = {x = room.center.x - room.radius, y = room.center.y - room.radius}
|
||||
local left_top = { x = room.center.x - room.radius, y = room.center.y - room.radius }
|
||||
local center_position = room.center
|
||||
|
||||
for x = 0, a, 1 do
|
||||
for y = 0, a, 1 do
|
||||
local p = {x = left_top.x + x, y = left_top.y + y}
|
||||
local p = { x = left_top.x + x, y = left_top.y + y }
|
||||
if math_abs(p.x - center_position.x) > room.radius * 0.4 then
|
||||
surface.set_tiles({{name = 'water', position = p}})
|
||||
surface.set_tiles({ { name = 'water', position = p } })
|
||||
if math_random(1, 16) == 1 then
|
||||
surface.create_entity({name = 'fish', position = p})
|
||||
surface.create_entity({ name = 'fish', position = p })
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -62,16 +62,16 @@ end
|
||||
|
||||
local function horizontal_bridge(surface, room)
|
||||
local a = room.radius * 2
|
||||
local left_top = {x = room.center.x - room.radius, y = room.center.y - room.radius}
|
||||
local left_top = { x = room.center.x - room.radius, y = room.center.y - room.radius }
|
||||
local center_position = room.center
|
||||
|
||||
for x = 0, a, 1 do
|
||||
for y = 0, a, 1 do
|
||||
local p = {x = left_top.x + x, y = left_top.y + y}
|
||||
local p = { x = left_top.x + x, y = left_top.y + y }
|
||||
if math_abs(p.y - center_position.y) > room.radius * 0.4 then
|
||||
surface.set_tiles({{name = 'water', position = p}})
|
||||
surface.set_tiles({ { name = 'water', position = p } })
|
||||
if math_random(1, 16) == 1 then
|
||||
surface.create_entity({name = 'fish', position = p})
|
||||
surface.create_entity({ name = 'fish', position = p })
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -80,18 +80,18 @@ end
|
||||
|
||||
local function island(surface, room)
|
||||
local a = room.radius * 2
|
||||
local left_top = {x = room.center.x - room.radius, y = room.center.y - room.radius}
|
||||
local left_top = { x = room.center.x - room.radius, y = room.center.y - room.radius }
|
||||
local center_position = room.center
|
||||
|
||||
for x = 0, a, 1 do
|
||||
for y = 0, a, 1 do
|
||||
local p = {x = left_top.x + x, y = left_top.y + y}
|
||||
local inside_x = math_abs(p.x - center_position.x) < room.radius * 0.6
|
||||
local inside_y = math_abs(p.y - center_position.y) < room.radius * 0.6
|
||||
local p = { x = left_top.x + x, y = left_top.y + y }
|
||||
local inside_x = math_abs(p.x - center_position.x) < room.radius * 0.6
|
||||
local inside_y = math_abs(p.y - center_position.y) < room.radius * 0.6
|
||||
if not inside_x and not inside_y then
|
||||
surface.set_tiles({{name = 'water', position = p}})
|
||||
surface.set_tiles({ { name = 'water', position = p } })
|
||||
if math_random(1, 16) == 1 then
|
||||
surface.create_entity({name = 'fish', position = p})
|
||||
surface.create_entity({ name = 'fish', position = p })
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -100,18 +100,18 @@ end
|
||||
|
||||
local function cross(surface, room)
|
||||
local a = room.radius * 2
|
||||
local left_top = {x = room.center.x - room.radius, y = room.center.y - room.radius}
|
||||
local left_top = { x = room.center.x - room.radius, y = room.center.y - room.radius }
|
||||
local center_position = room.center
|
||||
|
||||
for x = 0, a, 1 do
|
||||
for y = 0, a, 1 do
|
||||
local p = {x = left_top.x + x, y = left_top.y + y}
|
||||
local ok_x = math_abs(p.x - center_position.x) > (room.radius * 0.33)
|
||||
local ok_y = math_abs(p.y - center_position.y) > (room.radius * 0.33)
|
||||
local p = { x = left_top.x + x, y = left_top.y + y }
|
||||
local ok_x = math_abs(p.x - center_position.x) > (room.radius * 0.33)
|
||||
local ok_y = math_abs(p.y - center_position.y) > (room.radius * 0.33)
|
||||
if ok_x and ok_y then
|
||||
surface.set_tiles({{name = 'water', position = p}})
|
||||
surface.set_tiles({ { name = 'water', position = p } })
|
||||
if math_random(1, 16) == 1 then
|
||||
surface.create_entity({name = 'fish', position = p})
|
||||
surface.create_entity({ name = 'fish', position = p })
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -120,18 +120,18 @@ end
|
||||
|
||||
local function cross_inverted(surface, room)
|
||||
local a = room.radius * 2
|
||||
local left_top = {x = room.center.x - room.radius, y = room.center.y - room.radius}
|
||||
local left_top = { x = room.center.x - room.radius, y = room.center.y - room.radius }
|
||||
local center_position = room.center
|
||||
|
||||
for x = 0, a, 1 do
|
||||
for y = 0, a, 1 do
|
||||
local p = {x = left_top.x + x, y = left_top.y + y}
|
||||
local outside_x = math_abs(p.x - center_position.x) > room.radius * 0.33
|
||||
local outside_y = math_abs(p.y - center_position.y) > room.radius * 0.33
|
||||
local p = { x = left_top.x + x, y = left_top.y + y }
|
||||
local outside_x = math_abs(p.x - center_position.x) > room.radius * 0.33
|
||||
local outside_y = math_abs(p.y - center_position.y) > room.radius * 0.33
|
||||
if not outside_x and outside_y then
|
||||
surface.set_tiles({{name = 'water', position = p}})
|
||||
surface.set_tiles({ { name = 'water', position = p } })
|
||||
if math_random(1, 16) == 1 then
|
||||
surface.create_entity({name = 'fish', position = p})
|
||||
surface.create_entity({ name = 'fish', position = p })
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -157,15 +157,15 @@ local function squares(surface, room)
|
||||
local square_left_top = tiles[math_random(1, #tiles)].position
|
||||
for x = 0, a, 1 do
|
||||
for y = 0, b, 1 do
|
||||
local p = {x = square_left_top.x + x, y = square_left_top.y + y}
|
||||
local p = { x = square_left_top.x + x, y = square_left_top.y + y }
|
||||
if p.x - center_position.x < room.radius and p.y - center_position.y < room.radius then
|
||||
if math_random(1, 2) == 1 then
|
||||
surface.set_tiles({{name = 'water', position = p}})
|
||||
surface.set_tiles({ { name = 'water', position = p } })
|
||||
else
|
||||
surface.set_tiles({{name = 'deepwater', position = p}})
|
||||
surface.set_tiles({ { name = 'deepwater', position = p } })
|
||||
end
|
||||
if math_random(1, 16) == 1 then
|
||||
surface.create_entity({name = 'fish', position = p})
|
||||
surface.create_entity({ name = 'fish', position = p })
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -189,7 +189,7 @@ end
|
||||
local function biome(surface, room)
|
||||
local dungeontable = DungeonsTable.get_dungeontable()
|
||||
for _, tile in pairs(room.path_tiles) do
|
||||
surface.set_tiles({{name = 'concrete', position = tile.position}}, true)
|
||||
surface.set_tiles({ { name = 'concrete', position = tile.position } }, true)
|
||||
end
|
||||
|
||||
if not room.room_border_tiles[1] then
|
||||
@ -198,12 +198,12 @@ local function biome(surface, room)
|
||||
|
||||
table_shuffle_table(room.room_tiles)
|
||||
for key, tile in pairs(room.room_tiles) do
|
||||
surface.set_tiles({{name = 'blue-refined-concrete', position = tile.position}}, true)
|
||||
surface.set_tiles({ { name = 'blue-refined-concrete', position = tile.position } }, true)
|
||||
end
|
||||
|
||||
table_shuffle_table(room.room_border_tiles)
|
||||
for key, tile in pairs(room.room_border_tiles) do
|
||||
surface.set_tiles({{name = 'cyan-refined-concrete', position = tile.position}}, true)
|
||||
surface.set_tiles({ { name = 'cyan-refined-concrete', position = tile.position } }, true)
|
||||
end
|
||||
|
||||
local choice = math_random(1, #water_shapes)
|
||||
@ -211,21 +211,21 @@ local function biome(surface, room)
|
||||
water_shapes[choice](surface, room)
|
||||
for key, tile in pairs(room.room_tiles) do
|
||||
tile = surface.get_tile(tile.position)
|
||||
if not tile.collides_with('resource-layer') then
|
||||
if not tile.collides_with('resource') then
|
||||
if math_random(1, 10) == 1 then
|
||||
surface.create_entity({name = 'stone', position = tile.position, amount = Functions.get_common_resource_amount(surface.index)})
|
||||
surface.create_entity({ name = 'stone', position = tile.position, amount = Functions.get_common_resource_amount(surface.index) })
|
||||
end
|
||||
if math_random(1, 320) == 1 then
|
||||
Functions.crash_site_chest(surface, tile.position)
|
||||
end
|
||||
if key % 64 == 1 and math_random(1, 2) == 1 then
|
||||
Functions.set_spawner_tier(
|
||||
surface.create_entity({name = Functions.roll_spawner_name(), position = tile.position, force = dungeontable.enemy_forces[surface.index]}),
|
||||
surface.create_entity({ name = Functions.roll_spawner_name(), position = tile.position, force = dungeontable.enemy_forces[surface.index] }),
|
||||
surface.index
|
||||
)
|
||||
end
|
||||
if math_random(1, 64) == 1 then
|
||||
surface.create_entity({name = Functions.roll_worm_name(surface.index), position = tile.position, force = dungeontable.enemy_forces[surface.index]})
|
||||
surface.create_entity({ name = Functions.roll_worm_name(surface.index), position = tile.position, force = dungeontable.enemy_forces[surface.index] })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -241,7 +241,7 @@ local function container_opened(event)
|
||||
game.print({ 'expanse.tile_unlock', colored_player_name, { 'expanse.gps', math.floor(expansion_position.x), math.floor(expansion_position.y), 'expanse' } })
|
||||
expanse.size = (expanse.size or 1) + 1
|
||||
if math.random(1, 4) == 1 then
|
||||
if surface.count_tiles_filtered({ position = expansion_position, radius = 6, collision_mask = 'water-tile' }) > 40 then
|
||||
if surface.count_tiles_filtered({ position = expansion_position, radius = 6, collision_mask = 'water_tile' }) > 40 then
|
||||
return
|
||||
end
|
||||
local render = rendering.draw_sprite {
|
||||
|
@ -28,7 +28,7 @@ local function get_replacement_tile(surface, position)
|
||||
table.shuffle_table(vectors)
|
||||
for k, v in pairs(vectors) do
|
||||
local tile = surface.get_tile(position.x + v[1], position.y + v[2])
|
||||
if not tile.collides_with('resource-layer') then
|
||||
if not tile.collides_with('resource') then
|
||||
return tile.name
|
||||
end
|
||||
end
|
||||
|
@ -1308,7 +1308,7 @@ local function spawn_obstacles(left_top, surface)
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
local pos = { x = left_top.x + x, y = left_top.y + y }
|
||||
if not surface.get_tile(pos).collides_with('player-layer') then
|
||||
if not surface.get_tile(pos).collides_with('player') then
|
||||
tile_positions[#tile_positions + 1] = pos
|
||||
end
|
||||
end
|
||||
|
@ -101,7 +101,7 @@ function Public.get_replacement_tile(surface, position)
|
||||
shuffle(vectors)
|
||||
for k, v in pairs(vectors) do
|
||||
local tile = surface.get_tile(position.x + v[1], position.y + v[2])
|
||||
if tile and tile.valid and not tile.collides_with('resource-layer') then
|
||||
if tile and tile.valid and not tile.collides_with('resource') then
|
||||
return tile.name
|
||||
end
|
||||
end
|
||||
|
@ -75,7 +75,7 @@ local function drift_corpses_toward_beach()
|
||||
local surface = game.surfaces[1]
|
||||
for _, corpse in pairs(surface.find_entities_filtered({ name = 'character-corpse' })) do
|
||||
if corpse.position.y < 0 then
|
||||
if surface.get_tile(corpse.position).collides_with('resource-layer') then
|
||||
if surface.get_tile(corpse.position).collides_with('resource') then
|
||||
corpse.clone {
|
||||
position = { corpse.position.x, corpse.position.y + (math.random(50, 250) * 0.01) },
|
||||
surface = surface,
|
||||
|
@ -386,7 +386,7 @@ local function on_chunk_generated(event)
|
||||
table_insert(tiles, { name = tile_replacements[tile.name], position = pos })
|
||||
end
|
||||
|
||||
if not tile.collides_with('player-layer') then
|
||||
if not tile.collides_with('player') then
|
||||
local noise = get_noise(1, pos)
|
||||
if noise > 0.43 or noise < -0.43 then
|
||||
if math_random(1, 3) ~= 1 then
|
||||
|
@ -90,7 +90,7 @@ function Public.create_mirror_surface()
|
||||
local p = { x = cargo_wagon_position.x + x, y = cargo_wagon_position.y + y }
|
||||
if math.sqrt(x ^ 2 + y ^ 2) < r then
|
||||
local tile = surface.get_tile(p)
|
||||
if tile.collides_with('resource-layer') then
|
||||
if tile.collides_with('resource') then
|
||||
surface.set_tiles({ { name = 'landfill', position = p } }, true)
|
||||
end
|
||||
end
|
||||
|
@ -285,7 +285,7 @@ local function generate_south_chunk(event, surface)
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
local pos = { x = left_top.x + x, y = left_top.y + y }
|
||||
if not surface.get_tile(pos).collides_with('player-layer') then
|
||||
if not surface.get_tile(pos).collides_with('player') then
|
||||
tile_positions[#tile_positions + 1] = pos
|
||||
end
|
||||
end
|
||||
|
@ -50,7 +50,7 @@ local function get_replacement_tile(surface, position)
|
||||
table.shuffle_table(vectors)
|
||||
for k, v in pairs(vectors) do
|
||||
local tile = surface.get_tile(position.x + v[1], position.y + v[2])
|
||||
if tile.valid and not tile.collides_with('resource-layer') then
|
||||
if tile.valid and not tile.collides_with('resource') then
|
||||
return tile.name
|
||||
end
|
||||
end
|
||||
@ -75,7 +75,7 @@ local function place_wagon(surface, left_top)
|
||||
end
|
||||
|
||||
for k, tile in pairs(tiles) do
|
||||
if tile.collides_with('resource-layer') then
|
||||
if tile.collides_with('resource') then
|
||||
surface.set_tiles({ { name = 'landfill', position = tile.position } }, true)
|
||||
end
|
||||
for _, e in pairs(surface.find_entities_filtered({ position = tile.position, force = { 'neutral', 'enemy' } })) do
|
||||
@ -1103,7 +1103,7 @@ local function replace_water(surface, left_top)
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
local p = { x = left_top.x + x, y = left_top.y + y }
|
||||
if surface.get_tile(p).collides_with('resource-layer') then
|
||||
if surface.get_tile(p).collides_with('resource') then
|
||||
surface.set_tiles({ { name = get_replacement_tile(surface, p), position = p } }, true)
|
||||
end
|
||||
end
|
||||
|
@ -5,15 +5,15 @@ local Immersive_cargo_wagons = require 'modules.immersive_cargo_wagons.main'
|
||||
local GetNoise = require 'utils.get_noise'
|
||||
local LootRaffle = require 'utils.functions.loot_raffle'
|
||||
|
||||
local wagon_raffle = {'cargo-wagon', 'cargo-wagon', 'cargo-wagon', 'locomotive', 'fluid-wagon'}
|
||||
local rock_raffle = {'sand-rock-big', 'sand-rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-huge'}
|
||||
local wagon_raffle = { 'cargo-wagon', 'cargo-wagon', 'cargo-wagon', 'locomotive', 'fluid-wagon' }
|
||||
local rock_raffle = { 'sand-rock-big', 'sand-rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-big', 'rock-huge' }
|
||||
|
||||
local function draw_border(surface, left_x, height)
|
||||
local tiles = {}
|
||||
local i = 1
|
||||
for x = left_x, left_x + 31, 1 do
|
||||
for y = height * -1, height - 1, 1 do
|
||||
tiles[i] = {name = 'out-of-map', position = {x = x, y = y}}
|
||||
tiles[i] = { name = 'out-of-map', position = { x = x, y = y } }
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
@ -25,11 +25,11 @@ function Public.clone_south_to_north(mountain_race)
|
||||
return
|
||||
end
|
||||
local surface = game.surfaces.nauvis
|
||||
if not surface.is_chunk_generated({mountain_race.clone_x + 2, 0}) then
|
||||
if not surface.is_chunk_generated({ mountain_race.clone_x + 2, 0 }) then
|
||||
return
|
||||
end
|
||||
|
||||
local area = {{mountain_race.clone_x * 32, 0}, {mountain_race.clone_x * 32 + 32, mountain_race.playfield_height}}
|
||||
local area = { { mountain_race.clone_x * 32, 0 }, { mountain_race.clone_x * 32 + 32, mountain_race.playfield_height } }
|
||||
local offset = mountain_race.playfield_height + mountain_race.border_half_width
|
||||
|
||||
draw_border(surface, mountain_race.clone_x * 32, mountain_race.border_half_width)
|
||||
@ -37,7 +37,7 @@ function Public.clone_south_to_north(mountain_race)
|
||||
surface.clone_area(
|
||||
{
|
||||
source_area = area,
|
||||
destination_area = {{area[1][1], area[1][2] - offset}, {area[2][1], area[2][2] - offset}},
|
||||
destination_area = { { area[1][1], area[1][2] - offset }, { area[2][1], area[2][2] - offset } },
|
||||
destination_surface = surface,
|
||||
--destination_force = …,
|
||||
clone_tiles = true,
|
||||
@ -54,7 +54,7 @@ end
|
||||
|
||||
local function common_loot_crate(surface, position)
|
||||
local item_stacks = LootRaffle.roll(math.abs(position.x), 16)
|
||||
local container = surface.create_entity({name = 'wooden-chest', position = position, force = 'neutral'})
|
||||
local container = surface.create_entity({ name = 'wooden-chest', position = position, force = 'neutral' })
|
||||
for _, item_stack in pairs(item_stacks) do
|
||||
container.insert(item_stack)
|
||||
end
|
||||
@ -68,11 +68,11 @@ function Public.draw_terrain(surface, left_top)
|
||||
local seed = surface.map_gen_settings.seed
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
local position = {x = left_top.x + x, y = left_top.y + y}
|
||||
local position = { x = left_top.x + x, y = left_top.y + y }
|
||||
local tile = surface.get_tile(position)
|
||||
if not tile.collides_with('resource-layer') then
|
||||
if math_random(1, 3) > 1 and surface.can_place_entity({name = 'coal', position = position, amount = 1}) and GetNoise('decoratives', position, seed) > 0.2 then
|
||||
surface.create_entity({name = rock_raffle[math_random(1, #rock_raffle)], position = position})
|
||||
if not tile.collides_with('resource') then
|
||||
if math_random(1, 3) > 1 and surface.can_place_entity({ name = 'coal', position = position, amount = 1 }) and GetNoise('decoratives', position, seed) > 0.2 then
|
||||
surface.create_entity({ name = rock_raffle[math_random(1, #rock_raffle)], position = position })
|
||||
end
|
||||
if math_random(1, 756) == 1 then
|
||||
common_loot_crate(surface, position)
|
||||
@ -87,7 +87,7 @@ function Public.draw_out_of_map_chunk(surface, left_top)
|
||||
local i = 1
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
tiles[i] = {name = 'out-of-map', position = {x = left_top.x + x, y = left_top.y + y}}
|
||||
tiles[i] = { name = 'out-of-map', position = { x = left_top.x + x, y = left_top.y + y } }
|
||||
i = i + 1
|
||||
end
|
||||
end
|
||||
@ -99,22 +99,22 @@ function Public.generate_spawn(mountain_race, force_name)
|
||||
local surface = game.surfaces.nauvis
|
||||
local p = force.get_spawn_position(surface)
|
||||
|
||||
local v = {{0, 0}, {1, 0}, {0, 1}, {1, 1}}
|
||||
local v = { { 0, 0 }, { 1, 0 }, { 0, 1 }, { 1, 1 } }
|
||||
local teams = {
|
||||
['north'] = {75, 75, 255},
|
||||
['south'] = {255, 65, 65}
|
||||
['north'] = { 75, 75, 255 },
|
||||
['south'] = { 255, 65, 65 }
|
||||
}
|
||||
|
||||
for x = 0, 48, 2 do
|
||||
surface.create_entity({name = 'straight-rail', position = {p.x + x, p.y}, direction = 2, force = force_name})
|
||||
for k, tile in pairs(surface.find_tiles_filtered({area = {{p.x + x, p.y}, {p.x + x + 2, p.y + 2}}})) do
|
||||
if tile.collides_with('resource-layer') then
|
||||
surface.set_tiles({{name = 'landfill', position = tile.position}}, true)
|
||||
surface.create_entity({ name = 'straight-rail', position = { p.x + x, p.y }, direction = 2, force = force_name })
|
||||
for k, tile in pairs(surface.find_tiles_filtered({ area = { { p.x + x, p.y }, { p.x + x + 2, p.y + 2 } } })) do
|
||||
if tile.collides_with('resource') then
|
||||
surface.set_tiles({ { name = 'landfill', position = tile.position } }, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local entity = surface.create_entity({name = 'locomotive', position = {p.x + 6, p.y}, force = force_name, direction = 2})
|
||||
local entity = surface.create_entity({ name = 'locomotive', position = { p.x + 6, p.y }, force = force_name, direction = 2 })
|
||||
entity.minable = false
|
||||
entity.color = teams[force_name]
|
||||
|
||||
@ -123,7 +123,7 @@ function Public.generate_spawn(mountain_race, force_name)
|
||||
text = string.upper(force_name),
|
||||
surface = surface,
|
||||
target = entity,
|
||||
target_offset = {0, -3},
|
||||
target_offset = { 0, -3 },
|
||||
color = teams[force_name],
|
||||
scale = 2,
|
||||
font = 'default-game',
|
||||
@ -143,8 +143,8 @@ function Public.generate_chunks(mountain_race)
|
||||
return
|
||||
end
|
||||
local surface = game.surfaces.nauvis
|
||||
surface.request_to_generate_chunks({0, 0}, 10)
|
||||
if not surface.is_chunk_generated({9, 0}) then
|
||||
surface.request_to_generate_chunks({ 0, 0 }, 10)
|
||||
if not surface.is_chunk_generated({ 9, 0 }) then
|
||||
return
|
||||
end
|
||||
game.print('preparing terrain..')
|
||||
@ -163,7 +163,7 @@ function Public.reroll_terrain(mountain_race)
|
||||
end
|
||||
end
|
||||
player.character = nil
|
||||
player.set_controller({type = defines.controllers.god})
|
||||
player.set_controller({ type = defines.controllers.god })
|
||||
end
|
||||
|
||||
local surface = game.surfaces.nauvis
|
||||
@ -172,21 +172,21 @@ function Public.reroll_terrain(mountain_race)
|
||||
mgs.water = 0.5
|
||||
mgs.starting_area = 1
|
||||
mgs.terrain_segmentation = 12
|
||||
mgs.cliff_settings = {cliff_elevation_interval = 0, cliff_elevation_0 = 0}
|
||||
mgs.cliff_settings = { cliff_elevation_interval = 0, cliff_elevation_0 = 0 }
|
||||
mgs.autoplace_controls = {
|
||||
['coal'] = {frequency = 16, size = 1, richness = 0.5},
|
||||
['stone'] = {frequency = 16, size = 1, richness = 0.5},
|
||||
['copper-ore'] = {frequency = 16, size = 1, richness = 0.75},
|
||||
['iron-ore'] = {frequency = 16, size = 1, richness = 1},
|
||||
['uranium-ore'] = {frequency = 8, size = 0.5, richness = 0.5},
|
||||
['crude-oil'] = {frequency = 32, size = 1, richness = 1},
|
||||
['trees'] = {frequency = math.random(4, 32) * 0.1, size = math.random(4, 16) * 0.1, richness = math.random(1, 10) * 0.1},
|
||||
['enemy-base'] = {frequency = 16, size = 1, richness = 1}
|
||||
['coal'] = { frequency = 16, size = 1, richness = 0.5 },
|
||||
['stone'] = { frequency = 16, size = 1, richness = 0.5 },
|
||||
['copper-ore'] = { frequency = 16, size = 1, richness = 0.75 },
|
||||
['iron-ore'] = { frequency = 16, size = 1, richness = 1 },
|
||||
['uranium-ore'] = { frequency = 8, size = 0.5, richness = 0.5 },
|
||||
['crude-oil'] = { frequency = 32, size = 1, richness = 1 },
|
||||
['trees'] = { frequency = math.random(4, 32) * 0.1, size = math.random(4, 16) * 0.1, richness = math.random(1, 10) * 0.1 },
|
||||
['enemy-base'] = { frequency = 16, size = 1, richness = 1 }
|
||||
}
|
||||
surface.map_gen_settings = mgs
|
||||
surface.clear(false)
|
||||
for chunk in surface.get_chunks() do
|
||||
surface.delete_chunk({chunk.x, chunk.y})
|
||||
surface.delete_chunk({ chunk.x, chunk.y })
|
||||
end
|
||||
|
||||
game.print('generating chunks..')
|
||||
|
@ -17,7 +17,7 @@ local function get_replacement_tile(surface, position)
|
||||
table.shuffle_table(vectors)
|
||||
for k, v in pairs(vectors) do
|
||||
local tile = surface.get_tile(position.x + v[1], position.y + v[2])
|
||||
if not tile.collides_with('resource-layer') then
|
||||
if not tile.collides_with('resource') then
|
||||
return tile.name
|
||||
end
|
||||
end
|
||||
|
@ -1849,7 +1849,7 @@ end
|
||||
|
||||
function Public.replace_unwalkable_tiles(surface, position, width, height)
|
||||
local area = { left_top = { position.x - width / 2, position.y - height / 2 }, right_bottom = { position.x + width / 2 + 0.5, position.y + height / 2 + 0.5 } }
|
||||
local existing = surface.find_tiles_filtered { area = area, collision_mask = 'water-tile' }
|
||||
local existing = surface.find_tiles_filtered { area = area, collision_mask = 'water_tile' }
|
||||
if not existing then
|
||||
return
|
||||
end
|
||||
|
@ -617,7 +617,7 @@ function Public.collision_infront(boat)
|
||||
for _, relative_area in pairs(Public[boat.type].Data.areas_infront) do
|
||||
for _, p in pairs(Common.central_positions_within_area(relative_area, boat.position)) do
|
||||
local tile = surface.get_tile(p)
|
||||
if tile and tile.valid and not tile.collides_with('resource-layer') then
|
||||
if tile and tile.valid and not tile.collides_with('resource') then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
@ -38,7 +38,7 @@ local random = math.random
|
||||
|
||||
Global.register(
|
||||
this,
|
||||
function(tbl)
|
||||
function (tbl)
|
||||
this = tbl
|
||||
end
|
||||
)
|
||||
@ -139,7 +139,7 @@ local function assign_perks(player)
|
||||
return this.perks[player.name]
|
||||
end
|
||||
|
||||
local assign_camouflage = function(ent, common)
|
||||
local assign_camouflage = function (ent, common)
|
||||
local shade = common.rand_range(20, 200)
|
||||
ent.color = {
|
||||
r = shade,
|
||||
@ -151,41 +151,41 @@ end
|
||||
|
||||
local set_noise_hostile_hook =
|
||||
Token.register(
|
||||
function(data)
|
||||
local ent = data
|
||||
if not ent or not ent.valid then
|
||||
return
|
||||
end
|
||||
ent.force = 'enemy'
|
||||
if ent.name == 'character' then
|
||||
assign_camouflage(ent, CommonFunctions)
|
||||
|
||||
if CommonFunctions.rand_range(1, 5) == 1 then
|
||||
ent.insert({name = 'shotgun', count = 1})
|
||||
ent.insert({name = 'shotgun-shell', count = 20})
|
||||
else
|
||||
ent.insert({name = 'pistol', count = 1})
|
||||
ent.insert({name = 'firearm-magazine', count = 20})
|
||||
function (data)
|
||||
local ent = data
|
||||
if not ent or not ent.valid then
|
||||
return
|
||||
end
|
||||
ent.force = 'enemy'
|
||||
if ent.name == 'character' then
|
||||
assign_camouflage(ent, CommonFunctions)
|
||||
|
||||
if CommonFunctions.rand_range(1, 5) == 1 then
|
||||
ent.insert({ name = 'shotgun', count = 1 })
|
||||
ent.insert({ name = 'shotgun-shell', count = 20 })
|
||||
else
|
||||
ent.insert({ name = 'pistol', count = 1 })
|
||||
ent.insert({ name = 'firearm-magazine', count = 20 })
|
||||
end
|
||||
else
|
||||
ent.insert({ name = 'firearm-magazine', count = 200 })
|
||||
end
|
||||
else
|
||||
ent.insert({name = 'firearm-magazine', count = 200})
|
||||
end
|
||||
end
|
||||
)
|
||||
)
|
||||
|
||||
local set_neutral_to_entity =
|
||||
Token.register(
|
||||
function(entity)
|
||||
entity.force = 'neutral'
|
||||
end
|
||||
)
|
||||
function (entity)
|
||||
entity.force = 'neutral'
|
||||
end
|
||||
)
|
||||
|
||||
local fetch_common =
|
||||
Token.register(
|
||||
function()
|
||||
return CommonFunctions
|
||||
end
|
||||
)
|
||||
function ()
|
||||
return CommonFunctions
|
||||
end
|
||||
)
|
||||
|
||||
local industrial_zone_layers = {
|
||||
{
|
||||
@ -466,17 +466,17 @@ end
|
||||
|
||||
local init_player_ship_bp =
|
||||
Token.register(
|
||||
function(data)
|
||||
local player = data.player
|
||||
local entity = data.entity
|
||||
entity.force = player.force
|
||||
if entity.name == 'crash-site-chest-1' then
|
||||
for _, stack in pairs(MapConfig.player_ship_loot) do
|
||||
entity.insert(stack)
|
||||
function (data)
|
||||
local player = data.player
|
||||
local entity = data.entity
|
||||
entity.force = player.force
|
||||
if entity.name == 'crash-site-chest-1' then
|
||||
for _, stack in pairs(MapConfig.player_ship_loot) do
|
||||
entity.insert(stack)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
||||
)
|
||||
|
||||
this.events = {
|
||||
merchant = {
|
||||
@ -484,27 +484,27 @@ this.events = {
|
||||
moving = false,
|
||||
spawn_tick = 0,
|
||||
embark_tick = 0,
|
||||
position = {x = 0, y = 0},
|
||||
position = { x = 0, y = 0 },
|
||||
offer = MapConfig.merchant_offer
|
||||
}
|
||||
}
|
||||
|
||||
local init_merchant_bp =
|
||||
Token.register(
|
||||
function(data)
|
||||
local entity = data.entity
|
||||
entity.force = 'merchant'
|
||||
entity.rotatable = false
|
||||
entity.minable = false
|
||||
if entity.name ~= 'market' then
|
||||
entity.operable = false
|
||||
else
|
||||
for _, entry in pairs(this.events.merchant.offer) do
|
||||
entity.add_market_item(entry)
|
||||
function (data)
|
||||
local entity = data.entity
|
||||
entity.force = 'merchant'
|
||||
entity.rotatable = false
|
||||
entity.minable = false
|
||||
if entity.name ~= 'market' then
|
||||
entity.operable = false
|
||||
else
|
||||
for _, entry in pairs(this.events.merchant.offer) do
|
||||
entity.add_market_item(entry)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
)
|
||||
)
|
||||
|
||||
local function create_orbit_group()
|
||||
local orbit = game.permissions.create_group('orbit')
|
||||
@ -550,7 +550,7 @@ local function init_game()
|
||||
game.difficulty_settings.technology_price_multiplier = 0.3
|
||||
game.difficulty_settings.research_queue_setting = 'always'
|
||||
|
||||
LayersFunctions.set_collision_mask({'water-tile'})
|
||||
LayersFunctions.set_collision_mask({ 'water_tile' })
|
||||
|
||||
for _, layer in pairs(preset) do
|
||||
LayersFunctions.add_noise_layer(layer.type, layer.name, layer.objects, layer.elevation, layer.resolution)
|
||||
@ -581,53 +581,53 @@ end
|
||||
|
||||
local explode_ship_update =
|
||||
Token.register(
|
||||
function(data)
|
||||
local id = data.id
|
||||
local time_left = data.time_left
|
||||
local ship = data.ship
|
||||
local time = CommonFunctions.get_time(time_left)
|
||||
for _, ent in pairs(ship.entities) do
|
||||
if not ent.valid then
|
||||
return false
|
||||
function (data)
|
||||
local id = data.id
|
||||
local time_left = data.time_left
|
||||
local ship = data.ship
|
||||
local time = CommonFunctions.get_time(time_left)
|
||||
for _, ent in pairs(ship.entities) do
|
||||
if not ent.valid then
|
||||
return false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
rendering.set_text(id, time)
|
||||
return true
|
||||
end
|
||||
)
|
||||
rendering.set_text(id, time)
|
||||
return true
|
||||
end
|
||||
)
|
||||
|
||||
local explode_ship =
|
||||
Token.register(
|
||||
function(data)
|
||||
local ship = data.ship
|
||||
local id = data.id
|
||||
local active_surface = data.active_surface
|
||||
local surface = game.get_surface(active_surface)
|
||||
if not surface or not surface.valid then
|
||||
return
|
||||
end
|
||||
|
||||
for _, ent in pairs(Blueprints.reference_get_entities(ship)) do
|
||||
if not ent.valid then
|
||||
goto continue
|
||||
function (data)
|
||||
local ship = data.ship
|
||||
local id = data.id
|
||||
local active_surface = data.active_surface
|
||||
local surface = game.get_surface(active_surface)
|
||||
if not surface or not surface.valid then
|
||||
return
|
||||
end
|
||||
|
||||
local explosion = {
|
||||
name = 'massive-explosion',
|
||||
position = ent.position
|
||||
}
|
||||
surface.create_entity(explosion)
|
||||
for _, ent in pairs(Blueprints.reference_get_entities(ship)) do
|
||||
if not ent.valid then
|
||||
goto continue
|
||||
end
|
||||
|
||||
::continue::
|
||||
local explosion = {
|
||||
name = 'massive-explosion',
|
||||
position = ent.position
|
||||
}
|
||||
surface.create_entity(explosion)
|
||||
|
||||
::continue::
|
||||
end
|
||||
|
||||
local bb = Blueprints.reference_get_bounding_box(ship)
|
||||
LayersFunctions.remove_excluding_bounding_box(bb)
|
||||
Blueprints.destroy_reference(surface, ship)
|
||||
rendering.get_object_by_id(id).destroy()
|
||||
end
|
||||
|
||||
local bb = Blueprints.reference_get_bounding_box(ship)
|
||||
LayersFunctions.remove_excluding_bounding_box(bb)
|
||||
Blueprints.destroy_reference(surface, ship)
|
||||
rendering.get_object_by_id(id).destroy()
|
||||
end
|
||||
)
|
||||
)
|
||||
|
||||
local function do_spawn_point(player)
|
||||
local point = {
|
||||
@ -654,7 +654,7 @@ local function do_spawn_point(player)
|
||||
}
|
||||
|
||||
local id = rendering.draw_text(object)
|
||||
local data = {id = id, time_left = time_left, ship = instance, active_surface = player.surface.index}
|
||||
local data = { id = id, time_left = time_left, ship = instance, active_surface = player.surface.index }
|
||||
|
||||
local timer = Timers.set_timer(time_left, explode_ship)
|
||||
Timers.set_timer_on_update(timer, explode_ship_update)
|
||||
@ -685,7 +685,7 @@ local function get_non_obstructed_position(s, radius)
|
||||
search_info = {
|
||||
position = chunk,
|
||||
radius = radius,
|
||||
force = {'neutral', 'enemy'},
|
||||
force = { 'neutral', 'enemy' },
|
||||
invert = true
|
||||
}
|
||||
local ents = s.find_entities_filtered(search_info)
|
||||
@ -897,7 +897,7 @@ local function on_gui_click(e)
|
||||
end
|
||||
|
||||
local function init_player(p)
|
||||
p.teleport({0, 0}, 'arena')
|
||||
p.teleport({ 0, 0 }, 'arena')
|
||||
local s = p.surface
|
||||
local position = get_non_obstructed_position(s, 10)
|
||||
|
||||
@ -926,7 +926,7 @@ local function init_player(p)
|
||||
end
|
||||
|
||||
if not p.character or not p.character.valid then
|
||||
p.set_controller({type = defines.controllers.god})
|
||||
p.set_controller({ type = defines.controllers.god })
|
||||
p.create_character()
|
||||
end
|
||||
|
||||
@ -1241,7 +1241,7 @@ local function remove_offline_players()
|
||||
game.merge_forces(player.name, 'neutral')
|
||||
end
|
||||
Session.clear_player(player)
|
||||
game.remove_offline_players({player})
|
||||
game.remove_offline_players({ player })
|
||||
offline_players.players[i] = nil
|
||||
end
|
||||
end
|
||||
@ -1453,7 +1453,7 @@ local function on_player_died(e)
|
||||
return
|
||||
end
|
||||
Session.clear_player(p)
|
||||
game.remove_offline_players({p})
|
||||
game.remove_offline_players({ p })
|
||||
end
|
||||
|
||||
local function on_player_respawned(e)
|
||||
@ -1471,12 +1471,12 @@ local function on_player_dropped_item(e)
|
||||
if ent.stack.name == 'raw-fish' then
|
||||
local ent_list =
|
||||
p.surface.find_entities_filtered(
|
||||
{
|
||||
name = 'character',
|
||||
position = ent.position,
|
||||
radius = 2
|
||||
}
|
||||
)
|
||||
{
|
||||
name = 'character',
|
||||
position = ent.position,
|
||||
radius = 2
|
||||
}
|
||||
)
|
||||
if not ent_list then
|
||||
return
|
||||
end
|
||||
@ -1516,12 +1516,12 @@ local function on_player_dropped_item(e)
|
||||
elseif ent.stack.name == 'coal' then
|
||||
local ent_list =
|
||||
p.surface.find_entities_filtered(
|
||||
{
|
||||
name = 'character',
|
||||
position = ent.position,
|
||||
radius = 2
|
||||
}
|
||||
)
|
||||
{
|
||||
name = 'character',
|
||||
position = ent.position,
|
||||
radius = 2
|
||||
}
|
||||
)
|
||||
if not ent_list then
|
||||
return
|
||||
end
|
||||
@ -1647,7 +1647,7 @@ local function hostile_death(e)
|
||||
return false
|
||||
end
|
||||
|
||||
loot.insert({name = 'coin', count = random(30, 70)})
|
||||
loot.insert({ name = 'coin', count = random(30, 70) })
|
||||
|
||||
return true
|
||||
end
|
||||
|
@ -84,7 +84,7 @@ end
|
||||
|
||||
local function process_tile(surface, pos)
|
||||
local tile = surface.get_tile(pos)
|
||||
if tile.collides_with('player-layer') then
|
||||
if tile.collides_with('player') then
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -9,32 +9,32 @@ local math_floor = math.floor
|
||||
local math_abs = math.abs
|
||||
local math_sqrt = math.sqrt
|
||||
|
||||
local loot_containers = {'crash-site-chest-1', 'crash-site-chest-2', 'big-ship-wreck-1', 'big-ship-wreck-2', 'big-ship-wreck-3'}
|
||||
local loot_containers = { 'crash-site-chest-1', 'crash-site-chest-2', 'big-ship-wreck-1', 'big-ship-wreck-2', 'big-ship-wreck-3' }
|
||||
local size_of_loot_containers = #loot_containers
|
||||
|
||||
local function init_surface()
|
||||
local map_gen_settings = {}
|
||||
map_gen_settings.water = '0.5'
|
||||
map_gen_settings.starting_area = '1'
|
||||
map_gen_settings.cliff_settings = {cliff_elevation_interval = 0, cliff_elevation_0 = 0}
|
||||
map_gen_settings.cliff_settings = { cliff_elevation_interval = 0, cliff_elevation_0 = 0 }
|
||||
map_gen_settings.autoplace_controls = {
|
||||
['coal'] = {frequency = '0.55', size = '1', richness = '0.25'},
|
||||
['stone'] = {frequency = '0.55', size = '1', richness = '0.25'},
|
||||
['iron-ore'] = {frequency = '0.55', size = '1', richness = '0.25'},
|
||||
['copper-ore'] = {frequency = '0.55', size = '1', richness = '0.25'},
|
||||
['uranium-ore'] = {frequency = '0.55', size = '1', richness = '0.25'},
|
||||
['crude-oil'] = {frequency = '0.75', size = '1', richness = '1'},
|
||||
['trees'] = {frequency = '1', size = '0.5', richness = '1'},
|
||||
['enemy-base'] = {frequency = '3', size = '2', richness = '1'}
|
||||
['coal'] = { frequency = '0.55', size = '1', richness = '0.25' },
|
||||
['stone'] = { frequency = '0.55', size = '1', richness = '0.25' },
|
||||
['iron-ore'] = { frequency = '0.55', size = '1', richness = '0.25' },
|
||||
['copper-ore'] = { frequency = '0.55', size = '1', richness = '0.25' },
|
||||
['uranium-ore'] = { frequency = '0.55', size = '1', richness = '0.25' },
|
||||
['crude-oil'] = { frequency = '0.75', size = '1', richness = '1' },
|
||||
['trees'] = { frequency = '1', size = '0.5', richness = '1' },
|
||||
['enemy-base'] = { frequency = '3', size = '2', richness = '1' }
|
||||
}
|
||||
|
||||
local surface = game.create_surface('scrap_railworld', map_gen_settings)
|
||||
surface.request_to_generate_chunks({x = 0, y = 0}, 2)
|
||||
surface.request_to_generate_chunks({ x = 0, y = 0 }, 2)
|
||||
surface.force_generate_chunk_requests()
|
||||
surface.daytime = 0.7
|
||||
surface.ticks_per_day = surface.ticks_per_day * 2
|
||||
|
||||
game.forces['player'].set_spawn_position({0, 0}, surface)
|
||||
game.forces['player'].set_spawn_position({ 0, 0 }, surface)
|
||||
end
|
||||
|
||||
local function on_player_joined_game(event)
|
||||
@ -42,22 +42,22 @@ local function on_player_joined_game(event)
|
||||
local player = game.players[event.player_index]
|
||||
|
||||
if player.online_time == 0 then
|
||||
player.teleport(surface.find_non_colliding_position('character', {0, 0}, 2, 1), surface)
|
||||
player.teleport(surface.find_non_colliding_position('character', { 0, 0 }, 2, 1), surface)
|
||||
end
|
||||
end
|
||||
|
||||
local function place_scrap(surface, position)
|
||||
if math_random(1, 1024) == 1 then
|
||||
if position.x ^ 2 + position.x ^ 2 > 4096 then
|
||||
local e = surface.create_entity({name = 'gun-turret', position = position, force = 'enemy'})
|
||||
e.insert({name = 'piercing-rounds-magazine', count = 100})
|
||||
local e = surface.create_entity({ name = 'gun-turret', position = position, force = 'enemy' })
|
||||
e.insert({ name = 'piercing-rounds-magazine', count = 100 })
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
if math_random(1, 196) == 1 then
|
||||
local item_stacks = LootRaffle.roll(math_sqrt(position.x ^ 2 + position.y ^ 2) * 2 + 1, 3)
|
||||
local container = surface.create_entity({name = loot_containers[math_random(1, size_of_loot_containers)], position = position, force = 'neutral'})
|
||||
local container = surface.create_entity({ name = loot_containers[math_random(1, size_of_loot_containers)], position = position, force = 'neutral' })
|
||||
local inventory = container.get_inventory(defines.inventory.chest)
|
||||
for _, item_stack in pairs(item_stacks) do
|
||||
inventory.insert(item_stack)
|
||||
@ -70,14 +70,14 @@ local function place_scrap(surface, position)
|
||||
return
|
||||
end
|
||||
|
||||
surface.create_entity({name = 'mineable-wreckage', position = position, force = 'neutral'})
|
||||
surface.create_entity({ name = 'mineable-wreckage', position = position, force = 'neutral' })
|
||||
end
|
||||
|
||||
local function move_away_biteys(surface, area)
|
||||
for _, e in pairs(surface.find_entities_filtered({type = {'unit-spawner', 'turret', 'unit'}, area = area})) do
|
||||
for _, e in pairs(surface.find_entities_filtered({ type = { 'unit-spawner', 'turret', 'unit' }, area = area })) do
|
||||
local position = surface.find_non_colliding_position(e.name, e.position, 96, 4)
|
||||
if position then
|
||||
surface.create_entity({name = e.name, position = position, force = 'enemy'})
|
||||
surface.create_entity({ name = e.name, position = position, force = 'enemy' })
|
||||
e.destroy()
|
||||
end
|
||||
end
|
||||
@ -97,19 +97,19 @@ local function on_chunk_generated(event)
|
||||
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
local position = {x = left_top_x + x, y = left_top_y + y}
|
||||
local position = { x = left_top_x + x, y = left_top_y + y }
|
||||
local noise_1 = Get_noise('n3', position, seed)
|
||||
if not surface.get_tile(position).collides_with('resource-layer') and math_abs(noise_1) > 0.3 then
|
||||
if not surface.get_tile(position).collides_with('resource') and math_abs(noise_1) > 0.3 then
|
||||
local noise_2 = Get_noise('scrapyard', position, seed)
|
||||
if math_floor(noise_2 * 16) % 5 > 1 then
|
||||
surface.set_tiles({{name = 'dirt-' .. math_floor(math_abs(noise_2) * 3) % 3 + 5, position = position}}, true)
|
||||
surface.set_tiles({ { name = 'dirt-' .. math_floor(math_abs(noise_2) * 3) % 3 + 5, position = position } }, true)
|
||||
place_scrap(surface, position)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for _, e in pairs(surface.find_entities_filtered({type = {'tree'}, area = area})) do
|
||||
for _, e in pairs(surface.find_entities_filtered({ type = { 'tree' }, area = area })) do
|
||||
local noise_1 = Get_noise('n3', e.position, seed)
|
||||
if math_abs(noise_1) > 0.3 then
|
||||
e.destroy()
|
||||
@ -119,7 +119,7 @@ local function on_chunk_generated(event)
|
||||
move_away_biteys(surface, area)
|
||||
end
|
||||
|
||||
local vectors = {{0, 0}, {1, 0}, {-1, 0}, {0, 1}, {0, -1}}
|
||||
local vectors = { { 0, 0 }, { 1, 0 }, { -1, 0 }, { 0, 1 }, { 0, -1 } }
|
||||
local function on_player_mined_entity(event)
|
||||
local entity = event.entity
|
||||
if not entity.valid then
|
||||
@ -130,9 +130,9 @@ local function on_player_mined_entity(event)
|
||||
end
|
||||
local surface = entity.surface
|
||||
for _, v in pairs(vectors) do
|
||||
local position = {entity.position.x + v[1], entity.position.y + v[2]}
|
||||
if not surface.get_tile(position).collides_with('resource-layer') then
|
||||
surface.set_tiles({{name = 'landfill', position = position}}, true)
|
||||
local position = { entity.position.x + v[1], entity.position.y + v[2] }
|
||||
if not surface.get_tile(position).collides_with('resource') then
|
||||
surface.set_tiles({ { name = 'landfill', position = position } }, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -33,13 +33,13 @@ local function get_area(position, w, h)
|
||||
local x2 = w - x1
|
||||
local y1 = math_floor(h / 2)
|
||||
local y2 = h - y1
|
||||
return {{position.x - x1, position.y - y1}, {position.x + x2, position.y + y2}}
|
||||
return { { position.x - x1, position.y - y1 }, { position.x + x2, position.y + y2 } }
|
||||
end
|
||||
|
||||
local function clear_spawn(position, surface, w, h)
|
||||
--log("clear_spawn {" .. position.x .. "," .. position.y .. "}")
|
||||
local area = get_area(position, w, h)
|
||||
for _, e in pairs(surface.find_entities_filtered({area = area})) do
|
||||
for _, e in pairs(surface.find_entities_filtered({ area = area })) do
|
||||
if e.type ~= 'character' then
|
||||
e.destroy()
|
||||
end
|
||||
@ -102,17 +102,17 @@ local function is_empty(position, surface)
|
||||
end
|
||||
local entity_radius = 3
|
||||
local tile_radius = 2
|
||||
local entities = surface.find_entities_filtered({position = position, radius = entity_radius})
|
||||
local entities = surface.find_entities_filtered({ position = position, radius = entity_radius })
|
||||
--log("entities = " .. #entities)
|
||||
if #entities > 0 then
|
||||
return false
|
||||
end
|
||||
local tiles = surface.count_tiles_filtered({position = position, radius = tile_radius, collision_mask = 'water-tile'})
|
||||
--log("water-tiles = " .. tiles)
|
||||
local tiles = surface.count_tiles_filtered({ position = position, radius = tile_radius, collision_mask = 'water_tile' })
|
||||
--log("water_tiles = " .. tiles)
|
||||
if tiles > 0 then
|
||||
return false
|
||||
end
|
||||
local result = surface.can_place_entity({name = 'character', position = position})
|
||||
local result = surface.can_place_entity({ name = 'character', position = position })
|
||||
--log("is_empty = " .. tostring(result))
|
||||
return result
|
||||
end
|
||||
@ -122,7 +122,7 @@ local function find_valid_spawn_point(player, force_name, surface)
|
||||
local this = ScenarioTable.get_table()
|
||||
|
||||
-- check center of map first if valid
|
||||
local position = {x = 0, y = 0}
|
||||
local position = { x = 0, y = 0 }
|
||||
--log("testing {" .. position.x .. "," .. position.y .. "}")
|
||||
force_load(position, surface, 1)
|
||||
|
||||
@ -140,8 +140,8 @@ local function find_valid_spawn_point(player, force_name, surface)
|
||||
-- is the point near any other players
|
||||
local r = 55
|
||||
local area = {
|
||||
left_top = {x = player.position.x - r, y = player.position.y - r},
|
||||
right_bottom = {x = player.position.x + r, y = player.position.y + r}
|
||||
left_top = { x = player.position.x - r, y = player.position.y - r },
|
||||
right_bottom = { x = player.position.x + r, y = player.position.y + r }
|
||||
}
|
||||
|
||||
if not is_position_near(area) then
|
||||
@ -162,7 +162,7 @@ local function find_valid_spawn_point(player, force_name, surface)
|
||||
if town_center ~= nil then
|
||||
position = town_center.market.position
|
||||
end
|
||||
--log("town center is {" .. position.x .. "," .. position.y .. "}")
|
||||
--log("town center is {" .. position.x .. "," .. position.y .. "}")
|
||||
end
|
||||
-- and start checking around it for a suitable spawn position
|
||||
local tries = 0
|
||||
@ -176,7 +176,7 @@ local function find_valid_spawn_point(player, force_name, surface)
|
||||
local t = math_rad(angle)
|
||||
local x = math_floor(position.x + math_cos(t) * radius)
|
||||
local y = math_floor(position.y + math_sin(t) * radius)
|
||||
local target = {x = x, y = y}
|
||||
local target = { x = x, y = y }
|
||||
--log("testing {" .. target.x .. "," .. target.y .. "}")
|
||||
force_load(position, surface, 1)
|
||||
if in_use(target) == false then
|
||||
@ -195,13 +195,13 @@ local function find_valid_spawn_point(player, force_name, surface)
|
||||
radius = radius + math_random(1, spawn_point_incremental_distance)
|
||||
tries = tries + 1
|
||||
end
|
||||
return {x = 0, y = 0}
|
||||
return { x = 0, y = 0 }
|
||||
end
|
||||
|
||||
function Public.get_new_spawn_point(player, surface)
|
||||
local this = ScenarioTable.get_table()
|
||||
-- get a new spawn point
|
||||
local position = {0, 0}
|
||||
local position = { 0, 0 }
|
||||
if player ~= nil then
|
||||
local force = player.force
|
||||
if force ~= nil then
|
||||
@ -222,7 +222,7 @@ function Public.get_spawn_point(player, surface)
|
||||
-- if there is a spawn point and less than three strikes
|
||||
if position ~= nil and this.strikes[player.name] < 3 then
|
||||
-- check that the spawn point is not blocked
|
||||
if surface.can_place_entity({name = 'character', position = position}) then
|
||||
if surface.can_place_entity({ name = 'character', position = position }) then
|
||||
--log("player " .. player.name .. "using existing spawn point at {" .. position.x .. "," .. position.y .. "}")
|
||||
return position
|
||||
else
|
||||
@ -235,7 +235,7 @@ function Public.get_spawn_point(player, surface)
|
||||
end
|
||||
|
||||
function Public.clear_spawn_point(position, surface)
|
||||
Enemy.clear_worms(position, surface, spawn_point_safety) -- behemoth worms can attack from a range of 48, clear first time only
|
||||
Enemy.clear_worms(position, surface, spawn_point_safety) -- behemoth worms can attack from a range of 48, clear first time only
|
||||
Enemy.clear_enemies(position, surface, spawn_point_safety) -- behemoth worms can attack from a range of 48
|
||||
clear_spawn(position, surface, 7, 9)
|
||||
end
|
||||
|
@ -16,7 +16,7 @@ local scrap_entities = {
|
||||
{ name = 'crash-site-spaceship-wreck-small-3' }, -- these do not have mining animation
|
||||
{ name = 'crash-site-spaceship-wreck-small-4' }, -- these do not have mining animation
|
||||
{ name = 'crash-site-spaceship-wreck-small-5' }, -- these do not have mining animation
|
||||
{ name = 'crash-site-spaceship-wreck-small-6' } -- these do not have mining animation
|
||||
{ name = 'crash-site-spaceship-wreck-small-6' } -- these do not have mining animation
|
||||
}
|
||||
|
||||
local scrap_entities_index = table.size(scrap_entities)
|
||||
@ -51,7 +51,7 @@ local scrap_containers = {
|
||||
{ name = 'crash-site-spaceship-wreck-big-1', size = 2 }, -- these do not have mining animation
|
||||
{ name = 'crash-site-spaceship-wreck-big-2', size = 2 }, -- these do not have mining animation
|
||||
{ name = 'crash-site-spaceship-wreck-big-2', size = 2 }, -- these do not have mining animation
|
||||
{ name = 'crash-site-spaceship-wreck-big-2', size = 2 } -- these do not have mining animation
|
||||
{ name = 'crash-site-spaceship-wreck-big-2', size = 2 } -- these do not have mining animation
|
||||
}
|
||||
local scrap_containers_index = table.size(scrap_containers)
|
||||
|
||||
@ -233,7 +233,7 @@ local function landfill_under(entity)
|
||||
local surface = entity.surface
|
||||
for _, v in pairs(vectors) do
|
||||
local position = { entity.position.x + v[1], entity.position.y + v[2] }
|
||||
if not surface.get_tile(position).collides_with('resource-layer') then
|
||||
if not surface.get_tile(position).collides_with('resource') then
|
||||
surface.set_tiles({ { name = 'landfill', position = position } }, true)
|
||||
end
|
||||
end
|
||||
@ -298,7 +298,7 @@ local function on_chunk_generated(event)
|
||||
end
|
||||
end
|
||||
if math_random(1, 3) > 1 then
|
||||
if not surface.get_tile(position).collides_with('resource-layer') then
|
||||
if not surface.get_tile(position).collides_with('resource') then
|
||||
noise = get_noise('scrap_towny_ffa', position, seed)
|
||||
if is_scrap_area(noise) then
|
||||
place_scrap(surface, position)
|
||||
@ -312,7 +312,7 @@ local function on_chunk_generated(event)
|
||||
for y = 0, 31, 1 do
|
||||
position = { x = left_top_x + x, y = left_top_y + y }
|
||||
if math_random(1, 3) > 1 then
|
||||
if not surface.get_tile(position).collides_with('resource-layer') then
|
||||
if not surface.get_tile(position).collides_with('resource') then
|
||||
noise = get_noise('scrap_towny_ffa', position, seed)
|
||||
if is_scrap_area(noise) then
|
||||
place_scrap(surface, position)
|
||||
|
@ -272,7 +272,7 @@ local function generate_south_chunk(event, surface)
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
local pos = { x = left_top.x + x, y = left_top.y + y }
|
||||
if not surface.get_tile(pos).collides_with('player-layer') then
|
||||
if not surface.get_tile(pos).collides_with('player') then
|
||||
tile_positions[#tile_positions + 1] = pos
|
||||
end
|
||||
end
|
||||
|
@ -83,7 +83,7 @@ local function init(surface, left_top)
|
||||
|
||||
game.forces[i].set_spawn_position({ x = position.x, y = position.y + 8 }, surface)
|
||||
|
||||
--rendering.draw_sprite({sprite = "file/maps/wave_of_death/WoD.png", target = {x = -140 + 160*(i - 1), y = 0}, surface = surface, orientation = 0, x_scale = 2, y_scale = 2, render_layer = "ground-tile"})
|
||||
--rendering.draw_sprite({sprite = "file/maps/wave_of_death/WoD.png", target = {x = -140 + 160*(i - 1), y = 0}, surface = surface, orientation = 0, x_scale = 2, y_scale = 2, render_layer = "ground_tile"})
|
||||
end
|
||||
|
||||
local center_position = { x = 32, y = 0 }
|
||||
|
@ -74,7 +74,7 @@ local function drift_corpses_toward_beach()
|
||||
local surface = game.surfaces[1]
|
||||
for _, corpse in pairs(surface.find_entities_filtered({ name = 'character-corpse' })) do
|
||||
if corpse.position.y < 0 then
|
||||
if surface.get_tile(corpse.position).collides_with('resource-layer') then
|
||||
if surface.get_tile(corpse.position).collides_with('resource') then
|
||||
corpse.clone {
|
||||
position = { corpse.position.x, corpse.position.y + (math.random(50, 250) * 0.01) },
|
||||
surface = surface,
|
||||
|
@ -30,7 +30,7 @@ end
|
||||
local function get_replacement_tile(surface, position)
|
||||
for _, vector in pairs(vectors) do
|
||||
local tile = surface.get_tile({ position.x + vector[1], position.y + vector[2] })
|
||||
if not tile.collides_with('resource-layer') then
|
||||
if not tile.collides_with('resource') then
|
||||
return tile.name
|
||||
end
|
||||
end
|
||||
|
@ -73,7 +73,7 @@ end
|
||||
local function place_fitting_tile(position, surface, tiles_placed)
|
||||
for _, coord in pairs(spiral_coords) do
|
||||
local tile = surface.get_tile({ position.x + coord.x, position.y + coord.y })
|
||||
if not tile.collides_with('player-layer') then
|
||||
if not tile.collides_with('player') then
|
||||
local valid_source_tile = is_this_a_valid_source_tile(tile.position, tiles_placed)
|
||||
if tile.name == 'out-of-map' then
|
||||
valid_source_tile = false
|
||||
|
@ -17,19 +17,19 @@ local replacement_tiles = {
|
||||
}
|
||||
|
||||
local coords = {
|
||||
{x = 0, y = 0},
|
||||
{x = -1, y = -1},
|
||||
{x = 1, y = -1},
|
||||
{x = 0, y = -1},
|
||||
{x = -1, y = 0},
|
||||
{x = -1, y = 1},
|
||||
{x = 0, y = 1},
|
||||
{x = 1, y = 1},
|
||||
{x = 1, y = 0},
|
||||
{x = 2, y = 0},
|
||||
{x = -2, y = 0},
|
||||
{x = 0, y = 2},
|
||||
{x = 0, y = -2}
|
||||
{ x = 0, y = 0 },
|
||||
{ x = -1, y = -1 },
|
||||
{ x = 1, y = -1 },
|
||||
{ x = 0, y = -1 },
|
||||
{ x = -1, y = 0 },
|
||||
{ x = -1, y = 1 },
|
||||
{ x = 0, y = 1 },
|
||||
{ x = 1, y = 1 },
|
||||
{ x = 1, y = 0 },
|
||||
{ x = 2, y = 0 },
|
||||
{ x = -2, y = 0 },
|
||||
{ x = 0, y = 2 },
|
||||
{ x = 0, y = -2 }
|
||||
}
|
||||
|
||||
local function on_pre_player_mined_item(event)
|
||||
@ -42,11 +42,11 @@ local function on_pre_player_mined_item(event)
|
||||
for i = 1, #coords do
|
||||
local p = coords[i]
|
||||
|
||||
local pos = {x = entity.position.x + p.x, y = entity.position.y + p.y}
|
||||
local pos = { x = entity.position.x + p.x, y = entity.position.y + p.y }
|
||||
local tile = entity.surface.get_tile(pos)
|
||||
if not tile.collides_with('player-layer') then
|
||||
if not tile.collides_with('player') then
|
||||
if replacement_tiles[tile.name] and math.random(1, 2) == 1 then
|
||||
table.insert(tiles, {name = replacement_tiles[tile.name], position = pos})
|
||||
table.insert(tiles, { name = replacement_tiles[tile.name], position = pos })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -5,24 +5,24 @@ local math_floor = math.floor
|
||||
local table_insert = table.insert
|
||||
|
||||
local vectors = {}
|
||||
table_insert(vectors, {0, 0})
|
||||
table_insert(vectors, { 0, 0 })
|
||||
for r = 1, 64, 1 do
|
||||
table_insert(vectors, {0, r})
|
||||
table_insert(vectors, {0, r * -1})
|
||||
table_insert(vectors, {r, 0})
|
||||
table_insert(vectors, {r * -1, 0})
|
||||
table_insert(vectors, { 0, r })
|
||||
table_insert(vectors, { 0, r * -1 })
|
||||
table_insert(vectors, { r, 0 })
|
||||
table_insert(vectors, { r * -1, 0 })
|
||||
end
|
||||
|
||||
local vectors_2 = {{0, -1}, {0, 1}, {-1, 0}, {1, 0}}
|
||||
local vectors_2 = { { 0, -1 }, { 0, 1 }, { -1, 0 }, { 1, 0 } }
|
||||
|
||||
local function is_position_sticky(surface, position)
|
||||
local tile = surface.get_tile(position)
|
||||
if not tile.collides_with('resource-layer') then
|
||||
if not tile.collides_with('resource') then
|
||||
return
|
||||
end
|
||||
for _, v in pairs(vectors_2) do
|
||||
tile = surface.get_tile({position.x + v[1], position.y + v[2]})
|
||||
if not tile.collides_with('resource-layer') then
|
||||
tile = surface.get_tile({ position.x + v[1], position.y + v[2] })
|
||||
if not tile.collides_with('resource') then
|
||||
return true
|
||||
end
|
||||
end
|
||||
@ -30,9 +30,9 @@ end
|
||||
|
||||
local function move_tile(surface, tile_name, position)
|
||||
for key, v in pairs(vectors) do
|
||||
local p = {x = position.x + v[1], y = position.y + v[2]}
|
||||
local p = { x = position.x + v[1], y = position.y + v[2] }
|
||||
if is_position_sticky(surface, p) then
|
||||
surface.set_tiles({{name = tile_name, position = p}}, true)
|
||||
surface.set_tiles({ { name = tile_name, position = p } }, true)
|
||||
return
|
||||
end
|
||||
end
|
||||
@ -40,13 +40,13 @@ end
|
||||
|
||||
local function safe_players_from_drowning(surface, tiles)
|
||||
local a = math_floor(math_sqrt(#tiles)) + 2
|
||||
local left_top = {x = tiles[1].position.x - 1, y = tiles[1].position.y - 1}
|
||||
local area = {{left_top.x, left_top.y}, {left_top.x + a + 2, left_top.y + a + 2}}
|
||||
local left_top = { x = tiles[1].position.x - 1, y = tiles[1].position.y - 1 }
|
||||
local area = { { left_top.x, left_top.y }, { left_top.x + a + 2, left_top.y + a + 2 } }
|
||||
local players = {}
|
||||
for _, character in pairs(surface.find_entities_filtered({area = area, name = 'character'})) do
|
||||
for _, character in pairs(surface.find_entities_filtered({ area = area, name = 'character' })) do
|
||||
if character.player then
|
||||
table_insert(players, {character.player, {character.player.position.x, character.player.position.y}})
|
||||
character.player.teleport({0, 0}, surface)
|
||||
table_insert(players, { character.player, { character.player.position.x, character.player.position.y } })
|
||||
character.player.teleport({ 0, 0 }, surface)
|
||||
end
|
||||
end
|
||||
return players
|
||||
@ -58,13 +58,13 @@ local function sticky(surface, tiles, tile_name)
|
||||
local i = 1
|
||||
local i2 = 1
|
||||
for _, placed_tile in pairs(tiles) do
|
||||
revert_tiles[i] = {name = placed_tile.old_tile.name, position = placed_tile.position}
|
||||
revert_tiles[i] = { name = placed_tile.old_tile.name, position = placed_tile.position }
|
||||
local resources =
|
||||
surface.find_entities_filtered(
|
||||
{type = 'resource', area = {{placed_tile.position.x - 1, placed_tile.position.y - 1}, {placed_tile.position.x + 1, placed_tile.position.y + 1}}}
|
||||
)
|
||||
{ type = 'resource', area = { { placed_tile.position.x - 1, placed_tile.position.y - 1 }, { placed_tile.position.x + 1, placed_tile.position.y + 1 } } }
|
||||
)
|
||||
for _, resource in pairs(resources) do
|
||||
revert_entities[i2] = {name = resource.name, position = resource.position, amount = resource.amount}
|
||||
revert_entities[i2] = { name = resource.name, position = resource.position, amount = resource.amount }
|
||||
resource.destroy()
|
||||
i2 = i2 + 1
|
||||
end
|
||||
|
@ -989,7 +989,7 @@ local function command_to_main_target(group, bypass)
|
||||
end
|
||||
|
||||
local tile = group.surface.get_tile(group.position)
|
||||
if tile.valid and tile.collides_with('player-layer') then
|
||||
if tile.valid and tile.collides_with('player') then
|
||||
group = reform_group(group)
|
||||
end
|
||||
if not valid(group) then
|
||||
@ -1033,7 +1033,7 @@ local function command_to_side_target(group)
|
||||
end
|
||||
|
||||
local tile = group.surface.get_tile(group.position)
|
||||
if tile.valid and tile.collides_with('player-layer') then
|
||||
if tile.valid and tile.collides_with('player') then
|
||||
group = reform_group(group)
|
||||
end
|
||||
|
||||
|
@ -12,32 +12,32 @@ local function build_room_rect(surface, position, vector, room_center_position,
|
||||
|
||||
--local a = room_radius - 1
|
||||
local room_area = {
|
||||
left_top = {x = room_center_position.x - room_size.x + 1, y = room_center_position.y - room_size.y + 1},
|
||||
right_bottom = {x = room_center_position.x + room_size.x, y = room_center_position.y + room_size.y}
|
||||
left_top = { x = room_center_position.x - room_size.x + 1, y = room_center_position.y - room_size.y + 1 },
|
||||
right_bottom = { x = room_center_position.x + room_size.x, y = room_center_position.y + room_size.y }
|
||||
}
|
||||
room.room_tiles = surface.find_tiles_filtered({area = room_area})
|
||||
room.room_tiles = surface.find_tiles_filtered({ area = room_area })
|
||||
|
||||
room.path_tiles = {}
|
||||
for d = 1, room_spacing, 1 do
|
||||
local p = {position.x + vector[1] * d + offset.x, position.y + vector[2] * d + offset.y}
|
||||
local p = { position.x + vector[1] * d + offset.x, position.y + vector[2] * d + offset.y }
|
||||
local tile = surface.get_tile(p)
|
||||
table_insert(room.path_tiles, tile)
|
||||
end
|
||||
|
||||
room.entrance_tile = surface.get_tile({position.x + offset.x + vector[1] * (room_spacing + 1), position.y + offset.y + vector[2] * (room_spacing + 1)})
|
||||
room.entrance_tile = surface.get_tile({ position.x + offset.x + vector[1] * (room_spacing + 1), position.y + offset.y + vector[2] * (room_spacing + 1) })
|
||||
|
||||
room.room_border_tiles = {}
|
||||
local left_top = {x = room_area.left_top.x - 1, y = room_area.left_top.y - 1}
|
||||
local right_bottom = {x = room_area.right_bottom.x, y = room_area.right_bottom.y}
|
||||
local left_top = { x = room_area.left_top.x - 1, y = room_area.left_top.y - 1 }
|
||||
local right_bottom = { x = room_area.right_bottom.x, y = room_area.right_bottom.y }
|
||||
local t = room.room_border_tiles
|
||||
for d = 0, room_size.x * 2, 1 do
|
||||
table_insert(t, surface.get_tile({left_top.x + d, left_top.y}))
|
||||
table_insert(t, surface.get_tile({left_top.x + d, right_bottom.y}))
|
||||
table_insert(t, surface.get_tile({ left_top.x + d, left_top.y }))
|
||||
table_insert(t, surface.get_tile({ left_top.x + d, right_bottom.y }))
|
||||
end
|
||||
|
||||
for d = 1, room_size.y * 2 - 1, 1 do
|
||||
table_insert(t, surface.get_tile({left_top.x, left_top.y + d}))
|
||||
table_insert(t, surface.get_tile({right_bottom.x, left_top.y + d}))
|
||||
table_insert(t, surface.get_tile({ left_top.x, left_top.y + d }))
|
||||
table_insert(t, surface.get_tile({ right_bottom.x, left_top.y + d }))
|
||||
end
|
||||
|
||||
room.center = room_center_position
|
||||
@ -48,9 +48,9 @@ local function build_room_rect(surface, position, vector, room_center_position,
|
||||
end
|
||||
|
||||
local function scan_area_empty(surface, search_area)
|
||||
local tiles = surface.find_tiles_filtered({area = search_area})
|
||||
local tiles = surface.find_tiles_filtered({ area = search_area })
|
||||
for _, tile in pairs(tiles) do
|
||||
if not tile.collides_with('resource-layer') then
|
||||
if not tile.collides_with('resource') then
|
||||
return false
|
||||
end
|
||||
end
|
||||
@ -59,9 +59,9 @@ end
|
||||
|
||||
local function scan_strip_empty(surface, position, vector, length)
|
||||
for d = 0, length, 1 do
|
||||
local p = {position.x + vector[1] * d, position.y + vector[2] * d}
|
||||
local p = { position.x + vector[1] * d, position.y + vector[2] * d }
|
||||
local tile = surface.get_tile(p)
|
||||
if not tile.collides_with('resource-layer') then
|
||||
if not tile.collides_with('resource') then
|
||||
return false
|
||||
end
|
||||
end
|
||||
@ -70,20 +70,20 @@ end
|
||||
|
||||
--Scans the X and Y independantly for best size
|
||||
local function scan_direction_full(surface, position, vector, room_max, room_min)
|
||||
local best = {x = room_min, y = room_min}
|
||||
local best = { x = room_min, y = room_min }
|
||||
|
||||
-- make the center of the room a steps in the direction of vector.
|
||||
-- +2 because with only +1 the calculation would end up overlapping quite often with the current position
|
||||
local a = room_min + room_spacing + 2
|
||||
local room_center_pos = {x = position.x + vector[1] * a, y = position.y + vector[2] * a}
|
||||
local room_center_pos = { x = position.x + vector[1] * a, y = position.y + vector[2] * a }
|
||||
|
||||
local search_area = {
|
||||
{x = room_center_pos.x - best.x - room_spacing, y = room_center_pos.y - best.y - room_spacing},
|
||||
{x = room_center_pos.x + best.x + room_spacing + 1, y = room_center_pos.y + best.y + room_spacing + 1}
|
||||
{ x = room_center_pos.x - best.x - room_spacing, y = room_center_pos.y - best.y - room_spacing },
|
||||
{ x = room_center_pos.x + best.x + room_spacing + 1, y = room_center_pos.y + best.y + room_spacing + 1 }
|
||||
}
|
||||
|
||||
if not scan_area_empty(surface, search_area) then
|
||||
return {x = 0, y = 0}
|
||||
return { x = 0, y = 0 }
|
||||
end
|
||||
|
||||
local x_end = false
|
||||
@ -94,9 +94,9 @@ local function scan_direction_full(surface, position, vector, room_max, room_min
|
||||
repeat
|
||||
if not x_end then
|
||||
if
|
||||
not scan_strip_empty(surface, {x = position.x + best.x + room_spacing + 1, y = yy}, vector, best.y * 2 + room_spacing2) or
|
||||
not scan_strip_empty(surface, {x = position.x - best.x - room_spacing - 1, y = yy}, vector, best.y * 2 + room_spacing2)
|
||||
then
|
||||
not scan_strip_empty(surface, { x = position.x + best.x + room_spacing + 1, y = yy }, vector, best.y * 2 + room_spacing2) or
|
||||
not scan_strip_empty(surface, { x = position.x - best.x - room_spacing - 1, y = yy }, vector, best.y * 2 + room_spacing2)
|
||||
then
|
||||
x_end = true
|
||||
else
|
||||
best.x = best.x + 1
|
||||
@ -108,9 +108,9 @@ local function scan_direction_full(surface, position, vector, room_max, room_min
|
||||
if not y_end then
|
||||
local xx = position.x - best.x - room_spacing - 1
|
||||
if
|
||||
not scan_strip_empty(surface, {x = xx, y = position.y + vector[2] * (best.y * 2 + room_spacing2 + 1)}, {1, 0}, best.x * 2 + room_spacing2) or
|
||||
not scan_strip_empty(surface, {x = xx, y = position.y + vector[2] * (best.y * 2 + room_spacing2 + 2)}, {1, 0}, best.x * 2 + room_spacing2)
|
||||
then
|
||||
not scan_strip_empty(surface, { x = xx, y = position.y + vector[2] * (best.y * 2 + room_spacing2 + 1) }, { 1, 0 }, best.x * 2 + room_spacing2) or
|
||||
not scan_strip_empty(surface, { x = xx, y = position.y + vector[2] * (best.y * 2 + room_spacing2 + 2) }, { 1, 0 }, best.x * 2 + room_spacing2)
|
||||
then
|
||||
y_end = true
|
||||
else
|
||||
best.y = best.y + 1
|
||||
@ -125,9 +125,9 @@ local function scan_direction_full(surface, position, vector, room_max, room_min
|
||||
repeat
|
||||
if not y_end then
|
||||
if
|
||||
not scan_strip_empty(surface, {x = xx, y = position.y + best.y + room_spacing + 1}, vector, best.x * 2 + room_spacing2) or
|
||||
not scan_strip_empty(surface, {x = xx, y = position.y - best.y - room_spacing - 1}, vector, best.x * 2 + room_spacing2)
|
||||
then
|
||||
not scan_strip_empty(surface, { x = xx, y = position.y + best.y + room_spacing + 1 }, vector, best.x * 2 + room_spacing2) or
|
||||
not scan_strip_empty(surface, { x = xx, y = position.y - best.y - room_spacing - 1 }, vector, best.x * 2 + room_spacing2)
|
||||
then
|
||||
y_end = true
|
||||
else
|
||||
best.y = best.y + 1
|
||||
@ -139,9 +139,9 @@ local function scan_direction_full(surface, position, vector, room_max, room_min
|
||||
if not x_end then
|
||||
local yy = position.y - best.y - room_spacing - 1
|
||||
if
|
||||
not scan_strip_empty(surface, {x = position.x + vector[1] * (best.x * 2 + room_spacing2 + 1), y = yy}, {0, 1}, best.y * 2 + room_spacing2) or
|
||||
not scan_strip_empty(surface, {x = position.x + vector[1] * (best.x * 2 + room_spacing2 + 2), y = yy}, {0, 1}, best.y * 2 + room_spacing2)
|
||||
then
|
||||
not scan_strip_empty(surface, { x = position.x + vector[1] * (best.x * 2 + room_spacing2 + 1), y = yy }, { 0, 1 }, best.y * 2 + room_spacing2) or
|
||||
not scan_strip_empty(surface, { x = position.x + vector[1] * (best.x * 2 + room_spacing2 + 2), y = yy }, { 0, 1 }, best.y * 2 + room_spacing2)
|
||||
then
|
||||
x_end = true
|
||||
else
|
||||
best.x = best.x + 1
|
||||
@ -158,10 +158,10 @@ end
|
||||
|
||||
--get room tiles and build a room with best fit and add a chance for offset
|
||||
local function get_room_tiles_wiggle(surface, position, size, shape)
|
||||
local vectors = {{0, -1}, {0, 1}, {1, 0}, {-1, 0}}
|
||||
local vectors = { { 0, -1 }, { 0, 1 }, { 1, 0 }, { -1, 0 } }
|
||||
table_shuffle_table(vectors)
|
||||
|
||||
local room_max = {x = size, y = size}
|
||||
local room_max = { x = size, y = size }
|
||||
|
||||
if shape == 'wide' then
|
||||
room_max.x = room_max.x + 4
|
||||
@ -178,7 +178,7 @@ local function get_room_tiles_wiggle(surface, position, size, shape)
|
||||
if full.x > 0 then
|
||||
local new_pos = position
|
||||
|
||||
local offset = {x = 0, y = 0}
|
||||
local offset = { x = 0, y = 0 }
|
||||
|
||||
if v[1] == 0 then
|
||||
if full.x > 6 then
|
||||
@ -213,7 +213,7 @@ local function get_room_tiles_wiggle(surface, position, size, shape)
|
||||
end
|
||||
end
|
||||
|
||||
local room_center_position = {x = new_pos.x + v[1] * (full.x + room_spacing + 1), y = new_pos.y + v[2] * (full.y + room_spacing + 1)}
|
||||
local room_center_position = { x = new_pos.x + v[1] * (full.x + room_spacing + 1), y = new_pos.y + v[2] * (full.y + room_spacing + 1) }
|
||||
return build_room_rect(surface, new_pos, v, room_center_position, full, offset)
|
||||
end
|
||||
end
|
||||
@ -234,7 +234,7 @@ local function expand_path_tiles_width(surface, room)
|
||||
--if max_expansion_count == 0 then return end
|
||||
|
||||
local path_tiles = room.path_tiles
|
||||
local vectors = {{0, -1}, {0, 1}, {1, 0}, {-1, 0}}
|
||||
local vectors = { { 0, -1 }, { 0, 1 }, { 1, 0 }, { -1, 0 } }
|
||||
|
||||
local entrance_tile
|
||||
local exit_tile
|
||||
@ -242,14 +242,14 @@ local function expand_path_tiles_width(surface, room)
|
||||
local position = path_tiles[1].position
|
||||
local expansion_vectors = {}
|
||||
for _, v in pairs(vectors) do
|
||||
local tile = surface.get_tile({position.x + v[1], position.y + v[2]})
|
||||
if not tile.collides_with('resource-layer') then
|
||||
local tile = surface.get_tile({ position.x + v[1], position.y + v[2] })
|
||||
if not tile.collides_with('resource') then
|
||||
entrance_tile = tile
|
||||
exit_tile = surface.get_tile({path_tiles[#path_tiles].position.x + v[1] * -1, path_tiles[#path_tiles].position.y + v[2] * -1})
|
||||
exit_tile = surface.get_tile({ path_tiles[#path_tiles].position.x + v[1] * -1, path_tiles[#path_tiles].position.y + v[2] * -1 })
|
||||
if v[1] == 0 then
|
||||
expansion_vectors = {{1, 0}, {-1, 0}}
|
||||
expansion_vectors = { { 1, 0 }, { -1, 0 } }
|
||||
else
|
||||
expansion_vectors = {{0, 1}, {0, -1}}
|
||||
expansion_vectors = { { 0, 1 }, { 0, -1 } }
|
||||
end
|
||||
break
|
||||
end
|
||||
@ -260,8 +260,8 @@ local function expand_path_tiles_width(surface, room)
|
||||
end
|
||||
local ent_tile_pos = entrance_tile.position
|
||||
for k, v in pairs(expansion_vectors) do
|
||||
local tile = surface.get_tile({ent_tile_pos.x + v[1], ent_tile_pos.y + v[2]})
|
||||
if tile.collides_with('resource-layer') then
|
||||
local tile = surface.get_tile({ ent_tile_pos.x + v[1], ent_tile_pos.y + v[2] })
|
||||
if tile.collides_with('resource') then
|
||||
table_remove(expansion_vectors, k)
|
||||
end
|
||||
end
|
||||
@ -269,11 +269,11 @@ local function expand_path_tiles_width(surface, room)
|
||||
return
|
||||
end
|
||||
|
||||
if not exit_tile.collides_with('resource-layer') then
|
||||
if not exit_tile.collides_with('resource') then
|
||||
local exit_tile_pos = exit_tile.position
|
||||
for k, v in pairs(expansion_vectors) do
|
||||
local tile = surface.get_tile({exit_tile_pos.x + v[1], exit_tile_pos.y + v[2]})
|
||||
if tile.collides_with('resource-layer') then
|
||||
local tile = surface.get_tile({ exit_tile_pos.x + v[1], exit_tile_pos.y + v[2] })
|
||||
if tile.collides_with('resource') then
|
||||
table_remove(expansion_vectors, k)
|
||||
end
|
||||
end
|
||||
@ -291,8 +291,8 @@ local function expand_path_tiles_width(surface, room)
|
||||
break
|
||||
end
|
||||
for _, path_tile in pairs(path_tiles) do
|
||||
local tile = surface.get_tile({path_tile.position.x + v[1], path_tile.position.y + v[2]})
|
||||
if tile.collides_with('resource-layer') then
|
||||
local tile = surface.get_tile({ path_tile.position.x + v[1], path_tile.position.y + v[2] })
|
||||
if tile.collides_with('resource') then
|
||||
table_insert(tiles, tile)
|
||||
end
|
||||
end
|
||||
@ -307,16 +307,16 @@ local function is_bridge_valid(surface, vector, room)
|
||||
local bridge_tiles = room.path_tiles
|
||||
local scan_vector
|
||||
if vector[1] == 0 then
|
||||
scan_vector = {1, 0}
|
||||
scan_vector = { 1, 0 }
|
||||
else
|
||||
scan_vector = {0, 1}
|
||||
scan_vector = { 0, 1 }
|
||||
end
|
||||
|
||||
for _, tile in pairs(bridge_tiles) do
|
||||
for d = -5, 5, 1 do
|
||||
local p = {tile.position.x + scan_vector[1] * d, tile.position.y + scan_vector[2] * d}
|
||||
local p = { tile.position.x + scan_vector[1] * d, tile.position.y + scan_vector[2] * d }
|
||||
tile = surface.get_tile(p)
|
||||
if not tile.collides_with('resource-layer') then
|
||||
if not tile.collides_with('resource') then
|
||||
return
|
||||
end
|
||||
end
|
||||
@ -330,7 +330,7 @@ local function build_bridge(surface, position)
|
||||
return
|
||||
end
|
||||
|
||||
local vectors = {{0, -1}, {0, 1}, {1, 0}, {-1, 0}}
|
||||
local vectors = { { 0, -1 }, { 0, 1 }, { 1, 0 }, { -1, 0 } }
|
||||
table_shuffle_table(vectors)
|
||||
|
||||
local room = {}
|
||||
@ -342,9 +342,9 @@ local function build_bridge(surface, position)
|
||||
|
||||
for _, v in pairs(vectors) do
|
||||
for d = 1, a, 1 do
|
||||
local p = {position.x + v[1] * d, position.y + v[2] * d}
|
||||
local p = { position.x + v[1] * d, position.y + v[2] * d }
|
||||
local tile = surface.get_tile(p)
|
||||
if not tile.collides_with('resource-layer') then
|
||||
if not tile.collides_with('resource') then
|
||||
break
|
||||
end
|
||||
table_insert(room.path_tiles, tile)
|
||||
@ -393,18 +393,18 @@ function Public.draw_random_room(surface, position, shape)
|
||||
end
|
||||
|
||||
for _, tile in pairs(room.path_tiles) do
|
||||
surface.set_tiles({{name = 'dirt-3', position = tile.position}}, true)
|
||||
surface.set_tiles({ { name = 'dirt-3', position = tile.position } }, true)
|
||||
end
|
||||
|
||||
for _, tile in pairs(room.room_border_tiles) do
|
||||
surface.set_tiles({{name = 'dirt-7', position = tile.position}}, true)
|
||||
surface.set_tiles({ { name = 'dirt-7', position = tile.position } }, true)
|
||||
if math_random(1, 2) == 1 then
|
||||
surface.create_entity({name = 'rock-big', position = tile.position})
|
||||
surface.create_entity({ name = 'rock-big', position = tile.position })
|
||||
end
|
||||
end
|
||||
|
||||
for _, tile in pairs(room.room_tiles) do
|
||||
surface.set_tiles({{name = 'dirt-5', position = tile.position}}, true)
|
||||
surface.set_tiles({ { name = 'dirt-5', position = tile.position } }, true)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -74,7 +74,7 @@ local function on_player_mined_entity(event)
|
||||
local surface = entity.surface
|
||||
for _, v in pairs(vectors) do
|
||||
local position = { entity.position.x + v[1], entity.position.y + v[2] }
|
||||
if not surface.get_tile(position).collides_with('resource-layer') then
|
||||
if not surface.get_tile(position).collides_with('resource') then
|
||||
surface.set_tiles({ { name = 'landfill', position = position } }, true)
|
||||
end
|
||||
end
|
||||
@ -102,7 +102,7 @@ local function on_chunk_generated(event)
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
position = { x = left_top_x + x, y = left_top_y + y }
|
||||
if not get_tile(position).collides_with('resource-layer') then
|
||||
if not get_tile(position).collides_with('resource') then
|
||||
noise = get_noise('scrapyard', position, seed)
|
||||
if is_scrap_area(noise) then
|
||||
set_tiles({ { name = 'dirt-' .. math_floor(math_abs(noise) * 12) % 4 + 3, position = position } }, true)
|
||||
|
@ -199,7 +199,7 @@ local function on_player_mined_entity(event)
|
||||
local surface = entity.surface
|
||||
for _, v in pairs(vectors) do
|
||||
local position = { entity.position.x + v[1], entity.position.y + v[2] }
|
||||
if not surface.get_tile(position).collides_with('resource-layer') then
|
||||
if not surface.get_tile(position).collides_with('resource') then
|
||||
surface.set_tiles({ { name = 'landfill', position = position } }, true)
|
||||
end
|
||||
end
|
||||
@ -223,7 +223,7 @@ local function on_chunk_generated(event)
|
||||
for y = 0, 31, 1 do
|
||||
if math_random(1, 3) > 1 then
|
||||
position = { x = left_top_x + x, y = left_top_y + y }
|
||||
if not surface.get_tile(position).collides_with('resource-layer') then
|
||||
if not surface.get_tile(position).collides_with('resource') then
|
||||
noise = get_noise('scrapyard', position, seed)
|
||||
if is_scrap_area(noise) then
|
||||
surface.set_tiles({ { name = 'dirt-' .. math_floor(math_abs(noise) * 6) % 6 + 2, position = position } }, true)
|
||||
|
@ -215,7 +215,7 @@ local function replace_ground(entity)
|
||||
local surface = entity.surface
|
||||
for _, v in pairs(vectors) do
|
||||
local position = { entity.position.x + v[1], entity.position.y + v[2] }
|
||||
if not surface.get_tile(position).collides_with('resource-layer') then
|
||||
if not surface.get_tile(position).collides_with('resource') then
|
||||
surface.set_tiles({ { name = 'landfill', position = position } }, true)
|
||||
end
|
||||
end
|
||||
@ -279,7 +279,7 @@ local function on_chunk_generated(event)
|
||||
for y = 0, 31, 1 do
|
||||
if math_random(1, 3) > 1 then
|
||||
position = { x = left_top_x + x, y = left_top_y + y }
|
||||
if not surface.get_tile(position).collides_with('resource-layer') then
|
||||
if not surface.get_tile(position).collides_with('resource') then
|
||||
noise = get_noise('scrapyard', position, seed)
|
||||
if is_scrap_area(noise) then
|
||||
surface.set_tiles({ { name = 'dirt-' .. math_floor(math_abs(noise) * 6) % 6 + 2, position = position } }, true)
|
||||
|
@ -55,7 +55,7 @@ local function on_chunk_generated(event)
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
position = { x = left_top_x + x, y = left_top_y + y }
|
||||
if not get_tile(position).collides_with('resource-layer') then
|
||||
if not get_tile(position).collides_with('resource') then
|
||||
noise = get_noise('watery_world', position, seed)
|
||||
if is_water(position, noise, seed) then
|
||||
set_tiles({ { name = waters[math_floor(noise * 10 % 2 + 1)], position = position } }, true)
|
||||
|
Loading…
Reference in New Issue
Block a user