From 32ebb877b72a40527b7341353ccaffaf0dacd9a6 Mon Sep 17 00:00:00 2001 From: MewMew Date: Fri, 24 May 2019 02:26:29 +0200 Subject: [PATCH] update --- maps/blue_beach.lua | 120 +++++++++++++++++++++++++------- modules/surrounded_by_worms.lua | 5 +- 2 files changed, 96 insertions(+), 29 deletions(-) diff --git a/maps/blue_beach.lua b/maps/blue_beach.lua index ec5e316a..4019fdff 100644 --- a/maps/blue_beach.lua +++ b/maps/blue_beach.lua @@ -4,11 +4,34 @@ require "modules.spawners_contain_biters" require "modules.splice_double" require "modules.landfill_reveals_nauvis" require "modules.biter_evasion_hp_increaser" +require "modules.dynamic_player_spawn" local event = require 'utils.event' local math_random = math.random local simplex_noise = require 'utils.simplex_noise'.d2 +local function get_noise(name, pos) + local seed = game.surfaces[1].map_gen_settings.seed + local noise_seed_add = 25000 + seed = seed + noise_seed_add + if name == "sands" then + local noise = {} + noise[1] = simplex_noise(pos.x * 0.016, pos.y * 0.012, seed) + seed = seed + noise_seed_add + noise[2] = simplex_noise(pos.x * 0.064, pos.y * 0.048, seed) + local noise = noise[1] + noise[2] * 0.1 + return noise + end +end + +local disabled_for_deconstruction = { + ["fish"] = true, + ["rock-huge"] = true, + ["rock-big"] = true, + ["sand-rock-big"] = true, + ["mineable-wreckage"] = true + } + local landfill_drops = { ["small-biter"] = 1, ["small-spitter"] = 1, @@ -26,6 +49,13 @@ local landfill_drops = { ["behemoth-worm-turret"] = 64 } +local turrets = { + [1] = "small-worm-turret", + [2] = "medium-worm-turret", + [3] = "big-worm-turret", + [4] = "behemoth-worm-turret" +} + local tile_coords = {} for x = 0, 31, 1 do for y = 0, 31, 1 do @@ -66,14 +96,21 @@ local function south_side(surface, left_top) crate.insert({name = "firearm-magazine", count = math_random(32, 96)}) end else - if left_top.x > 160 or left_top.x < -160 then - if math_random(1, 256) == 1 then - surface.create_entity({name = "small-worm-turret", position = pos, force = "enemy"}) - end - end + --if left_top.x > 160 or left_top.x < -160 then + -- if math_random(1, 192) == 1 then + -- local name = "small-worm-turret" + -- local r = 1 + math.floor(math.abs(left_top.x) * 0.0025) + -- if r > 4 then r = 4 end + -- surface.create_entity({name = turrets[math_random(1, r)], position = pos, force = "enemy"}) + -- end + --end if math_random(1, 256) == 1 then - surface.create_entity({name = "tree-02", position = pos, force = "neutral"}) - end + surface.create_entity({name = "tree-02", position = pos}) + else + if math_random(1, 512) == 1 then + surface.create_entity({name = "rock-huge", position = pos}) + end + end end end end @@ -82,8 +119,13 @@ local function south_side(surface, 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} - surface.set_tiles({{name = "water", position = pos}}) - if math_random(1, 256) == 1 then surface.create_entity({name = "fish", position = pos, force = "neutral"}) end + --local noise = get_noise("sands", pos) + --if noise < 0.1 and noise > -0.1 then + -- surface.set_tiles({{name = "sand-1", position = pos}}) + --else + surface.set_tiles({{name = "water", position = pos}}) + if math_random(1, 256) == 1 then surface.create_entity({name = "fish", position = pos}) end + --end end end end @@ -100,7 +142,7 @@ local function on_chunk_generated(event) local left_top = event.area.left_top - surface.destroy_decoratives({area = area}) + surface.destroy_decoratives({area = event.area}) if left_top.y < 0 then north_side(surface, left_top) return end south_side(surface, left_top) @@ -111,7 +153,7 @@ local function init_surface() local map_gen_settings = {} map_gen_settings.water = "0" - map_gen_settings.starting_area = "0" + map_gen_settings.starting_area = "1" map_gen_settings.cliff_settings = {cliff_elevation_interval = 40, cliff_elevation_0 = 40} map_gen_settings.autoplace_controls = { ["coal"] = {frequency = "0", size = "0", richness = "0"}, @@ -139,9 +181,11 @@ local function init_surface() surface.ticks_per_day = surface.ticks_per_day * 1.5 surface.min_brightness = 0.1 - game.forces["player"].set_spawn_position({0,0},game.surfaces["blue_beach"]) + game.forces["player"].set_spawn_position({0,16},game.surfaces["blue_beach"]) game.forces["player"].technologies["landfill"].enabled = false + global.average_worm_amount_per_chunk = 4 + return surface end @@ -149,8 +193,9 @@ local function on_player_joined_game(event) local surface = init_surface() 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), "blue_beach") + if player.online_time == 0 then + local spawn = game.forces["player"].get_spawn_position(game.surfaces["blue_beach"]) + player.teleport(surface.find_non_colliding_position("character", spawn, 3, 0.5), "blue_beach") player.insert({name = "raw-fish", count = 3}) player.insert({name = "iron-plate", count = 128}) player.insert({name = "iron-gear-wheel", count = 64}) @@ -164,19 +209,29 @@ local function on_player_joined_game(event) end end +local sand_coords = { + {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 = 2}, + {x = -2, y = 0}, + {x = 2, y = 0}, + {x = 0, y = -2} +} + local function make_sand(surface, position) - if math_random(1,5) ~= 1 then return end - local water_tiles = {} - for x = -1, 1, 1 do - for y = -1, 1, 1 do - local pos = {position.x + x, position.y + y} - if surface.get_tile(pos).name == "water" then - water_tiles[#water_tiles + 1] = pos - end + for _, coord_modifier in pairs(sand_coords) do + local pos = {position.x + coord_modifier.x, position.y + coord_modifier.y} + if surface.get_tile(pos).name == "water" then + surface.set_tiles({{name = "sand-1", position = pos}}, true) + return end end - if not water_tiles[2] then return end - surface.set_tiles({{name = "sand-1", position = water_tiles[math_random(1, #water_tiles)]}}) end local function on_entity_died(event) @@ -225,8 +280,9 @@ local function send_wave() if not biters[1] then return end local amount = math.floor(game.tick * 0.001) if amount > 128 then amount = 128 end - local group_position = surface.find_non_colliding_position("rocket-silo", spawner.position, 128, 1) - if not group_position then return end + local group_position = {x = spawner.position.x, y = -48} + --local group_position = surface.find_non_colliding_position("rocket-silo", spawner.position, 1024, 1) + --if not group_position then return end local nearest_player_unit = surface.find_nearest_enemy({position = spawner.position, max_distance = 2048, force = "enemy"}) if not nearest_player_unit then return end local unit_group = surface.create_unit_group({position = group_position, force = "enemy"}) @@ -273,7 +329,17 @@ local function on_tick(event) draw_evolution_gui() end +local function on_marked_for_deconstruction(event) + if disabled_for_deconstruction[event.entity.name] then + event.entity.cancel_deconstruction(game.players[event.player_index].force.name) + end +end + event.add(defines.events.on_tick, on_tick) +event.add(defines.events.on_marked_for_deconstruction, on_marked_for_deconstruction) event.add(defines.events.on_chunk_generated, on_chunk_generated) event.add(defines.events.on_entity_died, on_entity_died) -event.add(defines.events.on_player_joined_game, on_player_joined_game) \ No newline at end of file +event.add(defines.events.on_player_joined_game, on_player_joined_game) + +require "modules.ores_are_mixed" +require "modules.surrounded_by_worms" \ No newline at end of file diff --git a/modules/surrounded_by_worms.lua b/modules/surrounded_by_worms.lua index 10366407..cf778202 100644 --- a/modules/surrounded_by_worms.lua +++ b/modules/surrounded_by_worms.lua @@ -31,8 +31,9 @@ local function on_chunk_generated(event) local coord_modifier = tile_coords[math_random(1, #tile_coords)] local pos = {left_top.x + coord_modifier[1], left_top.y + coord_modifier[2]} local name = turrets[math_random(1, highest_worm_tier)] - if surface.can_place_entity({name = name, position = pos}) then - surface.create_entity({name = name, position = pos, force = "enemy"}) + local position = surface.find_non_colliding_position("big-worm-turret", pos, 8, 1) + if position then + surface.create_entity({name = name, position = position, force = "enemy"}) end end end