diff --git a/maps/biter_battles_v2/biter_battles_v2.lua b/maps/biter_battles_v2/biter_battles_v2.lua index d4f0d738..e023af0b 100644 --- a/maps/biter_battles_v2/biter_battles_v2.lua +++ b/maps/biter_battles_v2/biter_battles_v2.lua @@ -1,6 +1,6 @@ -- Biter Battles v2 -- by MewMew -require "maps.biter_battles_v2.terrain" +--require "maps.biter_battles_v2.terrain" require "maps.biter_battles_v2.mirror_terrain" local simplex_noise = require 'utils.simplex_noise' @@ -32,6 +32,7 @@ local function on_player_joined_game(event) --init_surface(event) local player = game.players[event.player_index] player.character.destructible = false + player.character.destroy() end event.add(defines.events.on_player_joined_game, on_player_joined_game) diff --git a/maps/biter_battles_v2/mirror_terrain.lua b/maps/biter_battles_v2/mirror_terrain.lua index ca1eab63..66f04b86 100644 --- a/maps/biter_battles_v2/mirror_terrain.lua +++ b/maps/biter_battles_v2/mirror_terrain.lua @@ -49,7 +49,7 @@ local function get_chunk_position(position) end local function process_entity(surface, entity) - local new_pos = {x = entity.position.x * -1, y = entity.position.y * -1} + local new_pos = {x = entity.position.x * -1, y = (entity.position.y * -1) - 1} if entity.type == "tree" then local e = surface.create_entity({name = entity.name, position = new_pos, graphics_variation = entity.graphics_variation}) --e.graphics_variation = entity.graphics_variation @@ -84,7 +84,7 @@ local function mirror_chunk(surface, chunk_area, chunk_position) surface.force_generate_chunk_requests() end for _, tile in pairs(surface.find_tiles_filtered({area = chunk_area})) do - surface.set_tiles({{name = tile.name, position = {x = tile.position.x * -1, y = tile.position.y * -1}}}, true) + surface.set_tiles({{name = tile.name, position = {x = tile.position.x * -1, y = (tile.position.y * -1) - 1}}}, true) end for _, entity in pairs(surface.find_entities_filtered({area = chunk_area})) do process_entity(surface, entity) @@ -92,7 +92,7 @@ local function mirror_chunk(surface, chunk_area, chunk_position) for _, decorative in pairs(surface.find_decoratives_filtered{area=chunk_area}) do surface.create_decoratives{ check_collision=false, - decoratives={{name = decorative.decorative.name, position = {x = decorative.position.x * -1, y = decorative.position.y * -1}, amount = decorative.amount}} + decoratives={{name = decorative.decorative.name, position = {x = decorative.position.x * -1, y = (decorative.position.y * -1) - 1}, amount = decorative.amount}} } end end @@ -103,12 +103,16 @@ local function on_chunk_generated(event) if event.area.left_top.y > 32 or event.area.left_top.x > 32 or event.area.left_top.x < -32 then for _, e in pairs(surface.find_entities_filtered({area = event.area})) do - e.destroy() + if e.valid then + e.destroy() + end end else for _, e in pairs(surface.find_entities_filtered({area = event.area})) do - if e.name ~= "player" then - e.destroy() + if e.valid then + if e.name ~= "player" then + e.destroy() + end end end end @@ -123,7 +127,7 @@ local function on_chunk_generated(event) global.on_tick_schedule[game.tick + 1][#global.on_tick_schedule[game.tick + 1] + 1] = { func = mirror_chunk, args = {surface, mirror_chunk_area, get_chunk_position({x = x, y = y})} - } + } end event.add(defines.events.on_chunk_generated, on_chunk_generated) diff --git a/maps/biter_battles_v2/terrain.lua b/maps/biter_battles_v2/terrain.lua index 980dd816..29828b71 100644 --- a/maps/biter_battles_v2/terrain.lua +++ b/maps/biter_battles_v2/terrain.lua @@ -14,6 +14,8 @@ local worms = { [7] = {"behemoth-worm-turret"} } +local spawners = {"biter-spawner", "biter-spawner", "spitter-spawner"} + local function get_noise(name, pos) local seed = game.surfaces[1].map_gen_settings.seed local noise_seed_add = 25000 @@ -21,9 +23,9 @@ local function get_noise(name, pos) local noise = {} noise[1] = simplex_noise(pos.x * 0.005, pos.y * 0.005, seed) seed = seed + noise_seed_add - noise[2] = simplex_noise(pos.x * 0.01, pos.y * 0.01, seed) + noise[2] = simplex_noise(pos.x * 0.05, pos.y * 0.05, seed) seed = seed + noise_seed_add - local noise = noise[1] + noise[2] * 0.25 + local noise = noise[1] + noise[2] * 0.2 --noise = noise * 0.5 return noise end @@ -39,8 +41,8 @@ end local function generate_biters(surface, pos, distance_to_center) if distance_to_center < biter_territory_starting_radius then return end - if distance_to_center < biter_territory_starting_radius + 64 then - if math_random(1,96) == 1 and surface.can_place_entity({name = "behemoth-worm-turret", position = pos}) then + if distance_to_center < biter_territory_starting_radius + 32 then + if math_random(1, 128) == 1 and surface.can_place_entity({name = "behemoth-worm-turret", position = pos}) then surface.create_entity({name = get_worm(distance_to_center), position = pos}) end return @@ -48,15 +50,15 @@ local function generate_biters(surface, pos, distance_to_center) local noise = get_noise(1, pos) - if noise > 0.3 or noise < -0.3 then - if math_random(1,8) == 1 and surface.can_place_entity({name = "rocket-silo", position = pos}) then - surface.create_entity({name = "biter-spawner", position = pos}) + if noise > 0.5 or noise < -0.5 then + if math_random(1,12) == 1 and surface.can_place_entity({name = "rocket-silo", position = pos}) then + surface.create_entity({name = spawners[math_random(1,3)], position = pos}) end return end - if noise < 0.1 or noise > -0.1 then - if math_random(1,64) == 1 then + if noise > 0.4 or noise < -0.4 then + if math_random(1,48) == 1 then if surface.can_place_entity({name = "behemoth-worm-turret", position = pos}) then surface.create_entity({name = get_worm(distance_to_center), position = pos}) end @@ -65,6 +67,34 @@ local function generate_biters(surface, pos, distance_to_center) end end +local function generate_horizontal_river(surface, pos, distance_to_center) + if pos.y > 32 then return end + if pos.y < -32 then return end + + local noise = get_noise(1, pos) + surface.set_tiles({{name = "water", position = pos}}) +end + +local function generate_horizontal_river(surface, pos, distance_to_center) + --local pos = {x = math.floor(pos.x), y = math.floor(pos.y)} + if pos.y < -16 then return end + + --local noise = get_noise(1, pos) + surface.set_tiles({{name = "water", position = pos}}) +end + +local function generate_circle_spawn(surface, pos, distance_to_center) + --local pos = {x = math.floor(pos.x), y = math.floor(pos.y)} + if pos.y > 16 then return end + if pos.y < -16 then return end + if pos.x > 16 then return end + if pos.x < -16 then return end + + if distance_to_center < 10 then + surface.set_tiles({{name = "concrete", position = pos}}) + end +end + local function on_chunk_generated(event) if event.area.left_top.y >= 0 then return end local surface = event.surface @@ -75,11 +105,13 @@ local function on_chunk_generated(event) local left_top_x = event.area.left_top.x local left_top_y = event.area.left_top.y - for x = 0.5, 31.5, 1 do - for y = 0.5, 31.5, 1 do + 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 distance_to_center = math.sqrt(pos.x ^ 2 + pos.y ^ 2) - generate_biters(surface, pos, distance_to_center) + generate_horizontal_river(surface, pos) + generate_circle_spawn(surface, pos, distance_to_center) + generate_biters(surface, pos, distance_to_center) end end