1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-02-13 13:49:33 +02:00
This commit is contained in:
MewMew 2019-07-26 21:47:59 +02:00
parent 22dfdb39e7
commit f96463922f
3 changed files with 36 additions and 20 deletions

View File

@ -94,7 +94,7 @@ local function get_random_close_spawner(surface, biter_force_name)
if not spawners[1] then return false end
local spawner = spawners[math_random(1,#spawners)]
for i = 1, 7, 1 do
for i = 1, 4, 1 do
local spawner_2 = spawners[math_random(1,#spawners)]
if spawner_2.position.x ^ 2 + spawner_2.position.y ^ 2 < spawner.position.x ^ 2 + spawner.position.y ^ 2 then spawner = spawner_2 end
end
@ -162,21 +162,23 @@ end
local function get_unit_group_position(surface, nearest_player_unit, spawner)
local spawner_chunk_position = {x = math.floor(spawner.position.x / 32), y = math.floor(spawner.position.y / 32)}
local valid_chunks = {}
for x = -2, 2, 1 do
for y = -2, 2, 1 do
local chunk = {x = spawner_chunk_position.x + x, y = spawner_chunk_position.y + y}
local area = {{chunk.x * 32, chunk.y * 32},{chunk.x * 32 + 32, chunk.y * 32 + 32}}
if is_chunk_empty(surface, area) then
valid_chunks[#valid_chunks + 1] = chunk
if math_random(1,3) ~= 1 then
local spawner_chunk_position = {x = math.floor(spawner.position.x / 32), y = math.floor(spawner.position.y / 32)}
local valid_chunks = {}
for x = -2, 2, 1 do
for y = -2, 2, 1 do
local chunk = {x = spawner_chunk_position.x + x, y = spawner_chunk_position.y + y}
local area = {{chunk.x * 32, chunk.y * 32},{chunk.x * 32 + 32, chunk.y * 32 + 32}}
if is_chunk_empty(surface, area) then
valid_chunks[#valid_chunks + 1] = chunk
end
end
end
end
if #valid_chunks > 0 then
local chunk = valid_chunks[math_random(1, #valid_chunks)]
return {x = chunk.x * 32 + 16, y = chunk.y * 32 + 16}
if #valid_chunks > 0 then
local chunk = valid_chunks[math_random(1, #valid_chunks)]
return {x = chunk.x * 32 + 16, y = chunk.y * 32 + 16}
end
end
local unit_group_position = {x = (spawner.position.x + nearest_player_unit.position.x) * 0.5, y = (spawner.position.y + nearest_player_unit.position.y) * 0.5}

View File

@ -19,7 +19,7 @@ end
local function spy_fish(player)
if not player.character then return end
local duration_per_unit = 1800
local duration_per_unit = 2700
local i2 = player.get_inventory(defines.inventory.character_main)
if not i2 then return end
local owned_fishes = i2.get_item_count("raw-fish")

View File

@ -91,6 +91,7 @@ local function generate_circle_spawn(event)
--if bb_config.builders_area then
-- if event.area.left_top.x > 32 then return end
--end
local r = 101
local surface = event.surface
local left_top_x = event.area.left_top.x
@ -99,6 +100,7 @@ local function generate_circle_spawn(event)
for y = 0, 31, 1 do
local pos = {x = left_top_x + x, y = left_top_y + y}
local distance_to_center = math.sqrt(pos.x ^ 2 + pos.y ^ 2)
local noise = get_noise(2, pos) * 15
local tile = false
if distance_to_center < spawn_circle_size then
@ -106,12 +108,24 @@ local function generate_circle_spawn(event)
if math_random(1, 48) == 1 then surface.create_entity({name = "fish", position = pos}) end
end
if distance_to_center < 9.5 then tile = "refined-concrete" end
if distance_to_center < 7 then tile = "sand-1" end
if distance_to_center < 7 then tile = "sand-1" end
if distance_to_center + noise < r - 24 and distance_to_center > spawn_circle_size and not is_horizontal_border_river(surface, pos) then
local tile_name = surface.get_tile(pos).name
if tile_name == "water" or tile_name == "deepwater" then
surface.set_tiles({{name = "grass-2", position = pos}}, true)
surface.set_tiles({{name = "stone-path", position = pos}}, true)
--if math_random(1,256) == 1 then
-- local wrecks = {"big-ship-wreck-1", "big-ship-wreck-2", "big-ship-wreck-3"}
-- surface.create_entity({name = wrecks[math_random(1, #wrecks)], position = pos, force = "north"})
--end
if bb_config.random_scrap and math_random(1,64) == 1 then
surface.create_entity({name = "mineable-wreckage", position = pos})
end
end
end
if tile then surface.set_tiles({{name = tile, position = pos}}, true) end
if surface.can_place_entity({name = "coal", position = pos}) then
local noise = get_noise(2, pos) * 15
local r = 101
if surface.can_place_entity({name = "coal", position = pos}) then
if distance_to_center + noise < r and distance_to_center + noise > r - 1.75 then
surface.create_entity({name = "stone-wall", position = pos, force = "north"})
@ -151,7 +165,7 @@ local function generate_silos(event)
end
if event.area.left_top.y > -128 then return end
local surface = event.surface
local surface = event.surface
local pos = surface.find_non_colliding_position("rocket-silo", {0,-64}, 32, 1)
if not pos then pos = {x = 0, y = -64} end
global.rocket_silo["north"] = surface.create_entity({