From 6c40863cbaf82d9b219586b4e60e21d6e9485ab9 Mon Sep 17 00:00:00 2001 From: MewMew <=> Date: Thu, 14 Feb 2019 15:44:12 +0100 Subject: [PATCH] mountain_fortress update --- commands.lua | 1 + commands/misc.lua | 40 +++ control.lua | 53 +--- maps/fish_defender.lua | 156 +++++----- maps/modules/custom_death_messages.lua | 2 +- maps/modules/explosive_biters.lua | 2 +- maps/modules/players_trample_paths.lua | 9 +- maps/modules/rocks_broken_paint_tiles.lua | 20 +- maps/modules/rocks_yield_ore.lua | 16 +- maps/modules/satellite_score.lua | 6 +- maps/modules/splice_double.lua | 23 ++ maps/mountain_fortress.lua | 161 ++++++---- maps/stoneblock.lua | 342 ++++++++++++++++++++++ 13 files changed, 635 insertions(+), 196 deletions(-) create mode 100644 commands.lua create mode 100644 commands/misc.lua create mode 100644 maps/modules/splice_double.lua create mode 100644 maps/stoneblock.lua diff --git a/commands.lua b/commands.lua new file mode 100644 index 00000000..32ebfe03 --- /dev/null +++ b/commands.lua @@ -0,0 +1 @@ +require "commands.misc" \ No newline at end of file diff --git a/commands/misc.lua b/commands/misc.lua new file mode 100644 index 00000000..af4ca931 --- /dev/null +++ b/commands/misc.lua @@ -0,0 +1,40 @@ +function generate_map(radius) + local surface = game.players[1].surface + if surface.is_chunk_generated({radius, radius}) then + game.print("Map generation done!", {r=0.22, g=0.99, b=0.99}) + return + end + surface.request_to_generate_chunks({0,0}, radius) + surface.force_generate_chunk_requests() + for _, player in pairs(game.connected_players) do + player.play_sound{path="utility/new_objective", volume_modifier=1} + end + game.print("Map generation done!", {r=0.22, g=0.99, b=0.99}) +end + +function spaghetti() + game.forces["player"].technologies["logistic-system"].enabled = false + game.forces["player"].technologies["construction-robotics"].enabled = false + game.forces["player"].technologies["logistic-robotics"].enabled = false + game.forces["player"].technologies["robotics"].enabled = false + game.forces["player"].technologies["personal-roboport-equipment"].enabled = false + game.forces["player"].technologies["personal-roboport-equipment-2"].enabled = false + game.forces["player"].technologies["character-logistic-trash-slots-1"].enabled = false + game.forces["player"].technologies["character-logistic-trash-slots-2"].enabled = false + game.forces["player"].technologies["auto-character-logistic-trash-slots"].enabled = false + game.forces["player"].technologies["worker-robots-storage-1"].enabled = false + game.forces["player"].technologies["worker-robots-storage-2"].enabled = false + game.forces["player"].technologies["worker-robots-storage-3"].enabled = false + game.forces["player"].technologies["character-logistic-slots-1"].enabled = false + game.forces["player"].technologies["character-logistic-slots-2"].enabled = false + game.forces["player"].technologies["character-logistic-slots-3"].enabled = false + game.forces["player"].technologies["character-logistic-slots-4"].enabled = false + game.forces["player"].technologies["character-logistic-slots-5"].enabled = false + game.forces["player"].technologies["character-logistic-slots-6"].enabled = false + game.forces["player"].technologies["worker-robots-speed-1"].enabled = false + game.forces["player"].technologies["worker-robots-speed-2"].enabled = false + game.forces["player"].technologies["worker-robots-speed-3"].enabled = false + game.forces["player"].technologies["worker-robots-speed-4"].enabled = false + game.forces["player"].technologies["worker-robots-speed-5"].enabled = false + game.forces["player"].technologies["worker-robots-speed-6"].enabled = false +end \ No newline at end of file diff --git a/control.lua b/control.lua index defb6f6e..6d321ae5 100644 --- a/control.lua +++ b/control.lua @@ -2,6 +2,7 @@ require "utils.utils" require "utils.corpse_util" require "bot" require "chatbot" +require "commands" require "session_tracker" require "antigrief" require "antigrief_admin_panel" @@ -9,6 +10,7 @@ require "group" require "player_list" require "poll" require "score" +require "maps.modules.custom_death_messages" ---- enable modules here ---- --require "maps.tools.map_pregen" @@ -24,7 +26,6 @@ require "score" --require "maps.modules.explosive_biters" --require "maps.modules.railgun_enhancer" --require "maps.modules.dynamic_landfill" -require "maps.modules.custom_death_messages" --require "maps.modules.players_trample_paths" --require "maps.modules.hunger_games" ----------------------------- @@ -39,8 +40,9 @@ require "maps.modules.custom_death_messages" --require "maps.tank_battles" --require "maps.spiral_troopers" --require "maps.fish_defender" ---require "maps.mountain_fortress" -require "maps.deep_jungle" +require "maps.mountain_fortress" +--require "maps.stoneblock" +--require "maps.deep_jungle" --require "maps.crossing" --require "maps.anarchy" --require "maps.railworld" @@ -50,7 +52,7 @@ require "maps.deep_jungle" --require "maps.custom_start" ----------------------------- -local Event = require 'utils.event' +local event = require 'utils.event' local function on_player_created(event) local player = game.players[event.player_index] @@ -58,45 +60,4 @@ local function on_player_created(event) player.gui.left.style = 'slot_table_spacing_vertical_flow' end -function generate_map(radius) - local surface = game.players[1].surface - if surface.is_chunk_generated({radius, radius}) then - game.print("Map is generated.") - return - end - surface.request_to_generate_chunks({0,0}, radius) - surface.force_generate_chunk_requests() - for _, player in pairs(game.connected_players) do - player.play_sound{path="utility/new_objective", volume_modifier=1} - end - game.print("Map is generated.") -end - -function spaghetti() - game.forces["player"].technologies["logistic-system"].enabled = false - game.forces["player"].technologies["construction-robotics"].enabled = false - game.forces["player"].technologies["logistic-robotics"].enabled = false - game.forces["player"].technologies["robotics"].enabled = false - game.forces["player"].technologies["personal-roboport-equipment"].enabled = false - game.forces["player"].technologies["personal-roboport-equipment-2"].enabled = false - game.forces["player"].technologies["character-logistic-trash-slots-1"].enabled = false - game.forces["player"].technologies["character-logistic-trash-slots-2"].enabled = false - game.forces["player"].technologies["auto-character-logistic-trash-slots"].enabled = false - game.forces["player"].technologies["worker-robots-storage-1"].enabled = false - game.forces["player"].technologies["worker-robots-storage-2"].enabled = false - game.forces["player"].technologies["worker-robots-storage-3"].enabled = false - game.forces["player"].technologies["character-logistic-slots-1"].enabled = false - game.forces["player"].technologies["character-logistic-slots-2"].enabled = false - game.forces["player"].technologies["character-logistic-slots-3"].enabled = false - game.forces["player"].technologies["character-logistic-slots-4"].enabled = false - game.forces["player"].technologies["character-logistic-slots-5"].enabled = false - game.forces["player"].technologies["character-logistic-slots-6"].enabled = false - game.forces["player"].technologies["worker-robots-speed-1"].enabled = false - game.forces["player"].technologies["worker-robots-speed-2"].enabled = false - game.forces["player"].technologies["worker-robots-speed-3"].enabled = false - game.forces["player"].technologies["worker-robots-speed-4"].enabled = false - game.forces["player"].technologies["worker-robots-speed-5"].enabled = false - game.forces["player"].technologies["worker-robots-speed-6"].enabled = false -end - -Event.add(defines.events.on_player_created, on_player_created) \ No newline at end of file +event.add(defines.events.on_player_created, on_player_created) \ No newline at end of file diff --git a/maps/fish_defender.lua b/maps/fish_defender.lua index 0dd23a3f..03bb7de1 100644 --- a/maps/fish_defender.lua +++ b/maps/fish_defender.lua @@ -4,20 +4,19 @@ local event = require 'utils.event' require "maps.fish_defender_map_intro" require "maps.modules.rocket_launch_always_yields_science" require "maps.modules.launch_fish_to_win" - ---require "maps.modules.explosives_are_explosive" require "maps.modules.biters_yield_coins" require "maps.modules.railgun_enhancer" require "maps.modules.dynamic_landfill" require "maps.modules.teleporting_worms" require "maps.modules.custom_death_messages" +require "maps.modules.splice_double" local map_functions = require "maps.tools.map_functions" local math_random = math.random local insert = table.insert local enable_start_grace_period = true -local wave_interval = 3600 --interval between waves in ticks -local biter_count_limit = 1600 --maximum biters on the east side of the map, next wave will be delayed if the maximum has been reached +local wave_interval = 1800 --interval between waves in ticks +local biter_count_limit = 64 --maximum biters on the east side of the map, next wave will be delayed if the maximum has been reached local boss_waves = { [50] = {{name = "big-biter", count = 3}}, [100] = {{name = "behemoth-biter", count = 1}}, @@ -346,43 +345,43 @@ local function spawn_boss_units(surface) end biter_group.set_command({ type = defines.command.compound, - structure_type = defines.compound_command.return_last, + structure_type = defines.compound_command.logical_and, commands = { { type=defines.command.attack_area, destination={x = 160, y = 0}, radius=16, - distraction=defines.distraction.by_anything + distraction=defines.distraction.by_enemy }, { type=defines.command.attack_area, destination={x = 128, y = 0}, radius=16, - distraction=defines.distraction.by_anything + distraction=defines.distraction.by_enemy }, { type=defines.command.attack_area, destination={x = 96, y = 0}, radius=16, - distraction=defines.distraction.by_anything + distraction=defines.distraction.by_enemy }, { type=defines.command.attack_area, destination={x = 64, y = 0}, radius=16, - distraction=defines.distraction.by_anything + distraction=defines.distraction.by_enemy }, { type=defines.command.attack_area, destination={x = 32, y = 0}, radius=16, - distraction=defines.distraction.by_anything + distraction=defines.distraction.by_enemy }, { type=defines.command.attack_area, destination={x = -32, y = 0}, radius=16, - distraction=defines.distraction.by_anything + distraction=defines.distraction.by_enemy }, { type=defines.command.attack, @@ -391,11 +390,48 @@ local function spawn_boss_units(surface) } } }) + biter_group.start_moving() end local function wake_up_the_biters(surface) if not global.market then return end + --if not global.wake_up_counter then global.wake_up_counter = 0 end + --global.wake_up_counter = global.wake_up_counter + 1 + --if global.wake_up_counter % 2 == 1 then return end + + --[[ + unit_group = game.player.surface.create_unit_group({position = game.player.selected.position}) + for _, biter in pairs(game.player.surface.find_enemy_units(game.player.selected.position, 96, "player")) do + unit_group.add_member(biter) + end + unit_group.set_command({ + type = defines.command.compound, + structure_type = defines.compound_command.logical_and, + commands = { + { + type=defines.command.attack_area, + destination=global.market.position, + radius=512, + distraction=defines.distraction.by_anything + } + } + }) + unit_group.start_moving() + + game.player.surface.set_multi_command({ + command={ + type=defines.command.attack, + target=global.market, + distraction=defines.distraction.none + }, + unit_count = 128, + force = "enemy", + unit_search_distance=128 + }) + + ]] + local nearest_player_unit = surface.find_nearest_enemy({position = {x = 256, y = 0}, max_distance=512, force="enemy"}) if not nearest_player_unit then return end local target_positions = {} @@ -407,11 +443,11 @@ local function wake_up_the_biters(surface) local units = surface.find_entities_filtered({type = "unit"}) units = shuffle(units) local unit_groups = {} - for i = 1, 16, 1 do + for i = 1, 2, 1 do if not units[i] then break end if not units[i].valid then break end unit_groups[i] = surface.create_unit_group({position = {x = units[i].position.x, y = units[i].position.y}}) - local biters = surface.find_enemy_units(units[i].position, 16, "player") + local biters = surface.find_enemy_units(units[i].position, 24, "player") for _, biter in pairs(biters) do unit_groups[i].add_member(biter) end @@ -422,18 +458,18 @@ local function wake_up_the_biters(surface) if #unit_groups[i].members > 0 then unit_groups[i].set_command({ type = defines.command.compound, - structure_type = defines.compound_command.return_last, + structure_type = defines.compound_command.logical_and, commands = { { type=defines.command.attack_area, - destination=target_positions[i], + destination={target_positions[i].x, target_positions[i].y}, radius=32, distraction=defines.distraction.by_anything }, { type=defines.command.attack_area, destination=global.market.position, - radius=16, + radius=32, distraction=defines.distraction.by_anything }, { @@ -442,13 +478,15 @@ local function wake_up_the_biters(surface) distraction=defines.distraction.by_enemy } } - }) + }) + unit_groups[i].start_moving() else unit_groups[i].destroy() end end end + --[[ surface.set_multi_command({ command={ type=defines.command.attack, @@ -458,7 +496,7 @@ local function wake_up_the_biters(surface) unit_count = 16, force = "enemy", unit_search_distance=64 - }) + })]] surface.set_multi_command({ command={ @@ -468,7 +506,7 @@ local function wake_up_the_biters(surface) }, unit_count = 16, force = "enemy", - unit_search_distance=16 + unit_search_distance=24 }) end @@ -480,8 +518,8 @@ local function biter_attack_wave() clear_corpses(surface) wake_up_the_biters(surface) - if surface.count_entities_filtered({type = "unit", area = {{-128,-256},{360, 256}}}) > biter_count_limit then - game.print("Biter limit reached, wave delayed.", {r = 0.7, g = 0.1, b = 0.1}) + if surface.count_entities_filtered({type = "unit"}) > biter_count_limit then + --game.print("Biter limit reached, wave delayed.", {r = 0.7, g = 0.1, b = 0.1}) return end @@ -492,13 +530,13 @@ local function biter_attack_wave() end if global.wave_count % 50 == 0 then - global.attack_wave_threat = global.wave_count * 10 + global.attack_wave_threat = global.wave_count * 6 spawn_boss_units(surface) else - global.attack_wave_threat = global.wave_count * 5 + global.attack_wave_threat = global.wave_count * 3 end - if global.attack_wave_threat > 35000 then global.attack_wave_threat = 35000 end + if global.attack_wave_threat > 20000 then global.attack_wave_threat = 20000 end local evolution = global.wave_count * 0.00125 if evolution > 1 then evolution = 1 end @@ -560,49 +598,31 @@ local function biter_attack_wave() for i = 1, #unit_groups, 1 do unit_groups[i].set_command({ type = defines.command.compound, - structure_type = defines.compound_command.return_last, + structure_type = defines.compound_command.logical_and, commands = { { type=defines.command.attack_area, destination={group_coords[i].target.x + 192, group_coords[i].target.y}, - radius=8, + radius=32, distraction=defines.distraction.by_anything - }, - { - type=defines.command.attack_area, - destination={group_coords[i].target.x + 160, group_coords[i].target.y}, - radius=8, - distraction=defines.distraction.by_anything - }, + }, { type=defines.command.attack_area, destination={group_coords[i].target.x + 128, group_coords[i].target.y}, - radius=8, + radius=32, distraction=defines.distraction.by_anything - }, - { - type=defines.command.attack_area, - destination={group_coords[i].target.x + 96, group_coords[i].target.y}, - radius=8, - distraction=defines.distraction.by_anything - }, + }, { type=defines.command.attack_area, destination={group_coords[i].target.x + 64, group_coords[i].target.y}, - radius=8, + radius=32, distraction=defines.distraction.by_anything - }, + }, { type=defines.command.attack_area, - destination={group_coords[i].target.x + 32, group_coords[i].target.y}, - radius=8, - distraction=defines.distraction.by_anything - }, - { - type=defines.command.attack_area, - destination=group_coords[i].target, - radius=8, - distraction=defines.distraction.by_anything + destination={group_coords[i].target.x, group_coords[i].target.y}, + radius=32, + distraction=defines.distraction.by_enemy }, { type=defines.command.attack, @@ -610,7 +630,8 @@ local function biter_attack_wave() distraction=defines.distraction.by_enemy } } - }) + }) + unit_groups[i].start_moving() end end @@ -805,7 +826,7 @@ local function damage_entities_in_radius(position, radius, damage) entity.damage(damage, "enemy") else entity.health = entity.health - damage - entity.surface.create_entity({name = "explosion", position = entity.position}) + --entity.surface.create_entity({name = "blood-explosion-big", position = entity.position}) if entity.health <= 0 then entity.die("enemy") end end end @@ -819,7 +840,7 @@ local function on_entity_died(event) --local worm_chance = 256 --if global.endgame_modifier then worm_chance = 96 end if event.entity.name == "medium-biter" then - event.entity.surface.create_entity({name = "explosion", position = event.entity.position}) + event.entity.surface.create_entity({name = "blood-explosion-big", position = event.entity.position}) --if math_random(1,worm_chance) == 1 then --surface.create_entity({name = "small-worm-turret", position = event.entity.position}) --end @@ -835,7 +856,7 @@ local function on_entity_died(event) end if event.entity.name == "big-biter" then - event.entity.surface.create_entity({name = "uranium-cannon-shell-explosion", position = event.entity.position}) + event.entity.surface.create_entity({name = "blood-explosion-huge", position = event.entity.position}) --if math_random(1,worm_chance) == 1 then --surface.create_entity({name = "medium-worm-turret", position = event.entity.position}) --end @@ -951,7 +972,7 @@ local function on_player_joined_game(event) game.map_settings.enemy_evolution.destroy_factor = 0 game.map_settings.enemy_evolution.time_factor = 0 game.map_settings.enemy_evolution.pollution_factor = 0 - game.map_settings.pollution.enabled = true + game.map_settings.pollution.enabled = false --game.forces["player"].technologies["flamethrower-damage-1"].enabled = false --game.forces["player"].technologies["flamethrower-damage-2"].enabled = false @@ -982,7 +1003,7 @@ local function on_player_joined_game(event) ["land-mine"] = {placed = 0, limit = 1, str = "mine", slot_price = 1} } - global.wave_grace_period = wave_interval * 21 + global.wave_grace_period = wave_interval * 31 global.fish_defense_init_done = true end @@ -1211,20 +1232,19 @@ local function on_chunk_generated(event) spawn_obstacles(left_top, surface) end + if left_top.x < 0 then return end + + for _, entity in pairs(surface.find_entities_filtered({area = area, type = "cliff"})) do + entity.destroy() + end + if left_top.x < 160 then return end - local entities = surface.find_entities_filtered({area = area, type = "tree"}) - for _, entity in pairs(entities) do + for _, entity in pairs(surface.find_entities_filtered({area = area, type = "tree"})) do entity.destroy() - end + end - local entities = surface.find_entities_filtered({area = area, type = "cliff"}) - for _, entity in pairs(entities) do - entity.destroy() - end - - local entities = surface.find_entities_filtered({area = area, type = "resource"}) - for _, entity in pairs(entities) do + for _, entity in pairs(surface.find_entities_filtered({area = area, type = "resource"})) do surface.create_entity({name = "uranium-ore", position = entity.position, amount = math_random(200, 8000)}) entity.destroy() end diff --git a/maps/modules/custom_death_messages.lua b/maps/modules/custom_death_messages.lua index e5aac763..ce39cb77 100644 --- a/maps/modules/custom_death_messages.lua +++ b/maps/modules/custom_death_messages.lua @@ -2,7 +2,7 @@ local event = require 'utils.event' local math_random = math.random -local message_color = {r=0.85, g=0.0, b=0.0} +local message_color = {r=0.9, g=0.9, b=0.9} local messages = { ["small-biter"] = {" was nibbled to death.", " should not have played with the biters.", " is biter food."}, diff --git a/maps/modules/explosive_biters.lua b/maps/modules/explosive_biters.lua index 127c768a..2602eab4 100644 --- a/maps/modules/explosive_biters.lua +++ b/maps/modules/explosive_biters.lua @@ -17,7 +17,7 @@ local function damage_entities_in_radius(surface, position, radius, damage) entity.damage(damage, "enemy") else entity.health = entity.health - damage - entity.surface.create_entity({name = "blood-explosion-big", position = entity.position}) + --entity.surface.create_entity({name = "blood-explosion-big", position = entity.position}) if entity.health <= 0 then entity.die("enemy") end end end diff --git a/maps/modules/players_trample_paths.lua b/maps/modules/players_trample_paths.lua index 37693475..204f5068 100644 --- a/maps/modules/players_trample_paths.lua +++ b/maps/modules/players_trample_paths.lua @@ -5,6 +5,9 @@ local math_random = math.random local blacklisted_tiles = { ["concrete"] = true, + ["deepwater"] = true, + ["deepwater-green"] = true, + ["dirt-1"] = true, ["hazard-concrete-left"] = true, ["hazard-concrete-right"] = true, ["lab-dark-1"] = true, @@ -14,12 +17,10 @@ local blacklisted_tiles = { ["refined-concrete"] = true, ["refined-hazard-concrete-left"] = true, ["refined-hazard-concrete-right"] = true, + ["stone-path"] = true, ["tutorial-grid"] = true, ["water"] = true, - ["deepwater"] = true, - ["water-green"] = true, - ["deepwater-green"] = true, - ["dirt-1"] = true + ["water-green"] = true } local replacement_tiles = { diff --git a/maps/modules/rocks_broken_paint_tiles.lua b/maps/modules/rocks_broken_paint_tiles.lua index e4a2ea61..c8cba64d 100644 --- a/maps/modules/rocks_broken_paint_tiles.lua +++ b/maps/modules/rocks_broken_paint_tiles.lua @@ -9,6 +9,14 @@ local valid_entities = { ["sand-rock-big"] = true } +local replacement_tiles = { + ["dirt-7"] = "dirt-6", + ["dirt-6"] = "dirt-5", + ["dirt-5"] = "dirt-4", + ["dirt-4"] = "dirt-3", + ["dirt-3"] = "dirt-2" + } + local function get_chunk_position(position) local chunk_position = {} position.x = math.floor(position.x, 0) @@ -34,21 +42,23 @@ local function regenerate_decoratives(surface, position) surface.regenerate_decorative(decorative_names, {chunk}) end -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}} +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}} local function on_player_mined_entity(event) local entity = event.entity - if valid_entities[entity.name] then + if valid_entities[entity.name] then local tiles = {} for _, p in pairs(coords) do local pos = {x = entity.position.x + p.x, y = entity.position.y + p.y} - local tile = entity.surface.get_tile(pos) + local tile = entity.surface.get_tile(pos) if not tile.collides_with("player-layer") then - insert(tiles, {name = "dirt-6", position = pos}) + if replacement_tiles[tile.name] and math_random(1,3) ~= 1 then + insert(tiles, {name = replacement_tiles[tile.name], position = pos}) + end end end if #tiles == 0 then return end entity.surface.set_tiles(tiles, true) - if math_random(1,4) == 1 then regenerate_decoratives(entity.surface, entity.position) end + -- if math_random(1,4) == 1 then regenerate_decoratives(entity.surface, entity.position) end end end diff --git a/maps/modules/rocks_yield_ore.lua b/maps/modules/rocks_yield_ore.lua index 8a6d8361..fcb4ea5c 100644 --- a/maps/modules/rocks_yield_ore.lua +++ b/maps/modules/rocks_yield_ore.lua @@ -33,7 +33,7 @@ end local function get_amount(entity) local distance_to_center = math.sqrt(entity.position.x^2 + entity.position.y^2) - local amount = 33 + (distance_to_center * 0.33) + local amount = 50 + (distance_to_center * 0.33) if amount > 150 then amount = 150 end amount = rock_yield[entity.name] * amount amount = math.random(math.ceil(amount * 0.5), math.ceil(amount * 1.5)) @@ -47,9 +47,19 @@ local function on_player_mined_entity(event) if not entity.valid then return end if rock_yield[entity.name] then event.buffer.clear() - local amount = get_amount(entity) + local ore = ore_raffle[math.random(1, #ore_raffle)] - entity.surface.spill_item_stack(entity.position,{name = ore, count = amount}, true) + + local amount = get_amount(entity) + local amount_to_spill = math.ceil(amount * 0.5) + local amount_to_insert = math.floor(amount * 0.5) + + local player = game.players[event.player_index] + local inserted_count = player.insert({name = ore, count = amount_to_insert}) + local amount_to_spill = amount_to_spill + (amount_to_insert - inserted_count) + + entity.surface.spill_item_stack(entity.position,{name = ore, count = amount_to_spill}, true) + entity.surface.create_entity({name = "flying-text", position = entity.position, text = amount .. " " .. texts[ore][1], color = texts[ore][2]}) end end diff --git a/maps/modules/satellite_score.lua b/maps/modules/satellite_score.lua index d0b77b96..b682f37a 100644 --- a/maps/modules/satellite_score.lua +++ b/maps/modules/satellite_score.lua @@ -37,9 +37,7 @@ end local function satellites_in_space_gui(player) --if global.satellites_in_space == 0 then return end - local i = get_rank() - - satellite_score_toggle_button(player) + local i = get_rank() if player.gui.left["satellites_in_space"] then player.gui.left["satellites_in_space"].destroy() end @@ -115,7 +113,7 @@ end local function on_player_joined_game(event) if not global.satellites_in_space then init() end local player = game.players[event.player_index] - satellites_in_space_gui(player) + satellite_score_toggle_button(player) end local function on_gui_click(event) diff --git a/maps/modules/splice_double.lua b/maps/modules/splice_double.lua new file mode 100644 index 00000000..026cf46a --- /dev/null +++ b/maps/modules/splice_double.lua @@ -0,0 +1,23 @@ +-- biters splice into two -- by mewmew + +local event = require 'utils.event' + +local biter_fragmentation = { + ["medium-biter"] = "small-biter", + ["big-biter"] = "medium-biter", + ["behemoth-biter"] = "big-biter" + } + +local function on_entity_died(event) + if not event.entity.valid then return end + if biter_fragmentation[event.entity.name] then + local entity = event.entity + for x = 1, 2, 1 do + local p = entity.surface.find_non_colliding_position(biter_fragmentation[entity.name] , entity.position, 3, 0.5) + if p then entity.surface.create_entity({name = biter_fragmentation[entity.name], position = p}) end + end + return + end +end + +event.add(defines.events.on_entity_died, on_entity_died) diff --git a/maps/mountain_fortress.lua b/maps/mountain_fortress.lua index a5ade572..e5978896 100644 --- a/maps/mountain_fortress.lua +++ b/maps/mountain_fortress.lua @@ -2,7 +2,6 @@ require "maps.modules.satellite_score" require "maps.modules.dynamic_landfill" -require "maps.modules.players_trample_paths" require "maps.modules.dynamic_player_spawn" require "maps.modules.backpack_research" require "maps.modules.rocks_broken_paint_tiles" @@ -11,8 +10,7 @@ require "maps.modules.rocks_yield_ore" require "maps.modules.biters_yield_coins" require "maps.modules.explosive_biters" require "maps.modules.spawners_contain_biters" -require "maps.modules.splice" -global.splice_modifier = 2 +require "maps.modules.splice_double" local event = require 'utils.event' local math_random = math.random @@ -21,6 +19,14 @@ local map_functions = require "maps.tools.map_functions" local simplex_noise = require 'utils.simplex_noise' local simplex_noise = simplex_noise.d2 +local spawn_point = {x = 0, y = 2} + +local disabled_for_deconstruction = { + ["fish"] = true, + ["rock-huge"] = true, + ["rock-big"] = true, + ["sand-rock-big"] = true, + } local worm_raffle_table = { [1] = {"small-worm-turret", "small-worm-turret", "small-worm-turret", "small-worm-turret", "small-worm-turret", "small-worm-turret"}, [2] = {"small-worm-turret", "small-worm-turret", "small-worm-turret", "small-worm-turret", "small-worm-turret", "medium-worm-turret"}, @@ -47,22 +53,25 @@ end local function secret_shop(pos, surface) local secret_market_items = { - {price = {{"coin", math_random(10,20)}}, offer = {type = 'give-item', item = 'grenade'}}, - {price = {{"coin", math_random(30,60)}}, offer = {type = 'give-item', item = 'cluster-grenade'}}, - {price = {{"coin", math_random(60,120)}}, offer = {type = 'give-item', item = 'cliff-explosives'}}, - {price = {{"coin", math_random(150,250)}}, offer = {type = 'give-item', item = 'belt-immunity-equipment'}}, - {price = {{"coin", math_random(35,70)}}, offer = {type = 'give-item', item = 'construction-robot'}}, - {price = {{"coin", math_random(100,300)}}, offer = {type = 'give-item', item = 'loader'}}, - {price = {{"coin", math_random(200,400)}}, offer = {type = 'give-item', item = 'fast-loader'}}, + {price = {{"coin", math_random(8,16)}}, offer = {type = 'give-item', item = 'grenade'}}, + {price = {{"coin", math_random(25,50)}}, offer = {type = 'give-item', item = 'cluster-grenade'}}, + {price = {{"coin", math_random(5,10)}}, offer = {type = 'give-item', item = 'defender-capsule'}}, + {price = {{"coin", math_random(25,50)}}, offer = {type = 'give-item', item = 'distractor-capsule'}}, + {price = {{"coin", math_random(35,70)}}, offer = {type = 'give-item', item = 'destroyer-capsule'}}, + --{price = {{"coin", math_random(60,120)}}, offer = {type = 'give-item', item = 'cliff-explosives'}}, + {price = {{"coin", math_random(250,350)}}, offer = {type = 'give-item', item = 'belt-immunity-equipment'}}, + {price = {{"coin", math_random(30,60)}}, offer = {type = 'give-item', item = 'construction-robot'}}, + {price = {{"coin", math_random(100,200)}}, offer = {type = 'give-item', item = 'loader'}}, + {price = {{"coin", math_random(200,300)}}, offer = {type = 'give-item', item = 'fast-loader'}}, {price = {{"coin", math_random(300,500)}}, offer = {type = 'give-item', item = 'express-loader'}}, - {price = {{"coin", math_random(150,300)}}, offer = {type = 'give-item', item = 'locomotive'}}, - {price = {{"coin", math_random(100,200)}}, offer = {type = 'give-item', item = 'cargo-wagon'}}, + {price = {{"coin", math_random(100,200)}}, offer = {type = 'give-item', item = 'locomotive'}}, + {price = {{"coin", math_random(75,150)}}, offer = {type = 'give-item', item = 'cargo-wagon'}}, {price = {{"coin", math_random(2,4)}}, offer = {type = 'give-item', item = 'rail'}}, {price = {{"coin", math_random(20,40)}}, offer = {type = 'give-item', item = 'train-stop'}}, {price = {{"coin", math_random(4,12)}}, offer = {type = 'give-item', item = 'small-lamp'}}, {price = {{"coin", math_random(80,160)}}, offer = {type = 'give-item', item = 'car'}}, - {price = {{"coin", math_random(350,550)}}, offer = {type = 'give-item', item = 'electric-furnace'}}, - {price = {{"coin", math_random(500,1000)}}, offer = {type = 'give-item', item = "assembling-machine-3"}}, + {price = {{"coin", math_random(300,600)}}, offer = {type = 'give-item', item = 'electric-furnace'}}, + {price = {{"coin", math_random(300,600)}}, offer = {type = 'give-item', item = "assembling-machine-3"}}, {price = {{"coin", math_random(5,10)}}, offer = {type = 'give-item', item = 'raw-wood', count = 50}}, {price = {{"coin", math_random(5,10)}}, offer = {type = 'give-item', item = 'iron-ore', count = 50}}, @@ -83,7 +92,7 @@ local function secret_shop(pos, surface) local market = surface.create_entity {name = "market", position = pos} market.destructible = false - for i = 1, math.random(4, 8), 1 do + for i = 1, math.random(6, 8), 1 do market.add_market_item(secret_market_items[i]) end end @@ -94,6 +103,7 @@ local function on_player_joined_game(event) if not global.surface_init_done then local map_gen_settings = {} map_gen_settings.water = "small" + map_gen_settings.height = 960 map_gen_settings.cliff_settings = {cliff_elevation_interval = 4, cliff_elevation_0 = 4} map_gen_settings.autoplace_controls = { ["coal"] = {frequency = "none", size = "none", richness = "none"}, @@ -143,10 +153,10 @@ local function on_player_joined_game(event) local surface = game.surfaces["mountain_fortress"] if player.online_time < 2 and surface.is_chunk_generated({0,0}) then - player.teleport(surface.find_non_colliding_position("player", {-48, 4}, 50, 1), "mountain_fortress") + player.teleport(surface.find_non_colliding_position("player", spawn_point, 50, 1), "mountain_fortress") else if player.online_time < 2 then - player.teleport({-48, 0}, "mountain_fortress") + player.teleport(spawn_point, "mountain_fortress") end end end @@ -154,13 +164,11 @@ end local function get_noise(name, pos) local seed = game.surfaces[1].map_gen_settings.seed local noise = {} - local noise_seed_add = 25000 - if name == "rocks" then - noise[1] = simplex_noise(pos.x * 0.002, pos.y * 0.002, seed) - seed = seed + noise_seed_add - noise[2] = simplex_noise(pos.x * 0.01, pos.y * 0.01, seed) - seed = seed + noise_seed_add - local noise = noise[1] + noise[2] * 0.2 + --local noise_seed_add = 25000 + if name == "rock_border" then + noise[1] = simplex_noise(pos.x * 0.008, pos.y * 0.008, seed) + --noise[2] = simplex_noise(pos.x * 0.04, pos.y * 0.04, seed) + local noise = noise[1]-- + noise[2] * 0.2 return noise end end @@ -171,18 +179,7 @@ local function generate_north_chunk(area, surface) for _, e in pairs(surface.find_entities_filtered({area = area, type = "tree"})) do e.destroy() - end - - if left_top.y < -480 then - local tiles_to_set = {} - for x = 0, 31, 1 do - for y = 0, 31, 1 do - insert(tiles_to_set, {name = "out-of-map", position = {x = left_top.x + x, y = left_top.y + y}}) - end - end - surface.set_tiles(tiles_to_set, true) - return - end + end local tiles_to_set = {} for x = 0, 31, 1 do @@ -242,22 +239,11 @@ local function generate_south_chunk(event, surface) for _, e in pairs(surface.find_entities_filtered({area = event.area})) do e.destroy() end - --else - -- for _, e in pairs(surface.find_entities_filtered({area = event.area, type = "cliff"})) do - -- e.destroy() - -- end - end - - if left_top.y > 480 then - local tiles_to_set = {} - for x = 0, 31, 1 do - for y = 0, 31, 1 do - insert(tiles_to_set, {name = "out-of-map", position = {x = left_top.x + x, y = left_top.y + y}}) - end + else + for _, e in pairs(surface.find_entities_filtered({area = event.area, type = "cliff"})) do + e.destroy() end - surface.set_tiles(tiles_to_set, true) - return - end + end local current_depth = math.abs(left_top.y) - 32 @@ -360,20 +346,74 @@ local function on_chunk_generated(event) if left_top.y > 0 then generate_south_chunk(event, surface) return + end + + for _, e in pairs(surface.find_entities_filtered({area = event.area, type = "cliff"})) do + e.destroy() end + local trees = {"dead-grey-trunk", "dead-grey-trunk", "dry-tree"} for x = 0, 31, 1 do - for y = 0, 5, 1 do + for y = 5, 31, 1 do local pos = {x = left_top.x + x, y = left_top.y + y} - if math_random(1,5) == 1 then - surface.create_entity({name = "tree-06", position = pos}) + if math_random(1, math.ceil(y + y) + 64) == 1 then + surface.create_entity({name = trees[math_random(1, #trees)], position = pos}) + end + end + 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} + + if math_random(1, y + 2) == 1 then + surface.create_decoratives{ + check_collision=false, + decoratives={ + {name = "rock-medium", position = pos, amount = math_random(1, 1 + math.ceil(20 - y / 2))} + } + } + end + if math_random(1, y + 2) == 1 then + surface.create_decoratives{ + check_collision=false, + decoratives={ + {name = "rock-small", position = pos, amount = math_random(1, 1 + math.ceil(20 - y / 2))} + } + } + end + if math_random(1, y + 2) == 1 then + surface.create_decoratives{ + check_collision=false, + decoratives={ + {name = "rock-tiny", position = pos, amount = math_random(1, 1 + math.ceil(20 - y / 2))} + } + } + end + + --[[ + local noise = get_noise("rock_border", {x = pos.x, y = 0}) + if math.abs(noise * 6) > y then + if math_random(1, 3) ~= 1 then surface.create_entity({name = rock_raffle[math_random(1, #rock_raffle)], position = pos}) end + surface.set_tiles({{name = "dirt-7", position = pos}}, true) + end]] + + if math_random(1, math.ceil(y + y) + 2) == 1 then + surface.create_entity({name = rock_raffle[math_random(1, #rock_raffle)], position = pos}) end end end - --for _, e in pairs(surface.find_entities_filtered({area = event.area, type = "cliff"})) do - --e.destroy() - --end + if left_top.y ~= 0 then return end + if left_top.x ~= 96 then return end + for _, e in pairs(surface.find_entities_filtered({area = {{spawn_point.x - 0.5, spawn_point.y - 0.5},{spawn_point.x + 0.5, spawn_point.y + 0.5}}})) do + if e.force.name ~= "player" then + e.destroy() + end + end + for _, e in pairs(surface.find_entities_filtered({area = {{spawn_point.x - 40, spawn_point.y - 40},{spawn_point.x + 40, spawn_point.y + 40}}, force = "enemy"})) do + e.destroy() + end end local function on_entity_damaged(event) @@ -389,13 +429,6 @@ local function on_entity_damaged(event) end end -local disabled_for_deconstruction = { - ["fish"] = true, - ["rock-huge"] = true, - ["rock-big"] = true, - ["sand-rock-big"] = true, - } - 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) diff --git a/maps/stoneblock.lua b/maps/stoneblock.lua new file mode 100644 index 00000000..e17e9c73 --- /dev/null +++ b/maps/stoneblock.lua @@ -0,0 +1,342 @@ +-- mountain digger fortress -- by mewmew -- + +require "maps.modules.satellite_score" +require "maps.modules.dynamic_landfill" +require "maps.modules.dynamic_player_spawn" +require "maps.modules.backpack_research" +require "maps.modules.rocks_broken_paint_tiles" +require "maps.modules.rocks_yield_ore_veins" +require "maps.modules.rocks_yield_ore" +require "maps.modules.biters_yield_coins" +require "maps.modules.explosive_biters" +require "maps.modules.spawners_contain_biters" +require "maps.modules.splice_double" + +local event = require 'utils.event' +local math_random = math.random +local insert = table.insert +local map_functions = require "maps.tools.map_functions" +local simplex_noise = require 'utils.simplex_noise' +local simplex_noise = simplex_noise.d2 + +local spawn_point = {x = 0, y = 2} + +local disabled_for_deconstruction = { + ["fish"] = true, + ["rock-huge"] = true, + ["rock-big"] = true, + ["sand-rock-big"] = true, + } +local worm_raffle_table = { + [1] = {"small-worm-turret", "small-worm-turret", "small-worm-turret", "small-worm-turret", "small-worm-turret", "small-worm-turret"}, + [2] = {"small-worm-turret", "small-worm-turret", "small-worm-turret", "small-worm-turret", "small-worm-turret", "medium-worm-turret"}, + [3] = {"small-worm-turret", "small-worm-turret", "small-worm-turret", "small-worm-turret", "medium-worm-turret", "medium-worm-turret"}, + [4] = {"small-worm-turret", "small-worm-turret", "small-worm-turret", "medium-worm-turret", "medium-worm-turret", "medium-worm-turret"}, + [5] = {"small-worm-turret", "small-worm-turret", "medium-worm-turret", "medium-worm-turret", "medium-worm-turret", "big-worm-turret"}, + [6] = {"small-worm-turret", "medium-worm-turret", "medium-worm-turret", "medium-worm-turret", "medium-worm-turret", "big-worm-turret"}, + [7] = {"medium-worm-turret", "medium-worm-turret", "medium-worm-turret", "medium-worm-turret", "big-worm-turret", "big-worm-turret"}, + [8] = {"medium-worm-turret", "medium-worm-turret", "medium-worm-turret", "big-worm-turret", "big-worm-turret", "big-worm-turret"}, + [9] = {"medium-worm-turret", "medium-worm-turret", "big-worm-turret", "big-worm-turret", "big-worm-turret", "big-worm-turret"}, + [10] = {"medium-worm-turret", "big-worm-turret", "big-worm-turret", "big-worm-turret", "big-worm-turret", "big-worm-turret"} + } +local rock_raffle = {"sand-rock-big","sand-rock-big","rock-big","rock-big","rock-big","rock-big","rock-big","rock-big","rock-huge"} +local nest_raffle = {"biter-spawner", "biter-spawner", "biter-spawner", "spitter-spawner"} + +local function shuffle(tbl) + local size = #tbl + for i = size, 1, -1 do + local rand = math.random(size) + tbl[i], tbl[rand] = tbl[rand], tbl[i] + end + return tbl +end + +local function secret_shop(pos, surface) + local secret_market_items = { + {price = {{"coin", math_random(8,16)}}, offer = {type = 'give-item', item = 'grenade'}}, + {price = {{"coin", math_random(25,50)}}, offer = {type = 'give-item', item = 'cluster-grenade'}}, + {price = {{"coin", math_random(5,10)}}, offer = {type = 'give-item', item = 'defender-capsule'}}, + {price = {{"coin", math_random(25,50)}}, offer = {type = 'give-item', item = 'distractor-capsule'}}, + {price = {{"coin", math_random(35,70)}}, offer = {type = 'give-item', item = 'destroyer-capsule'}}, + --{price = {{"coin", math_random(60,120)}}, offer = {type = 'give-item', item = 'cliff-explosives'}}, + {price = {{"coin", math_random(250,350)}}, offer = {type = 'give-item', item = 'belt-immunity-equipment'}}, + {price = {{"coin", math_random(30,60)}}, offer = {type = 'give-item', item = 'construction-robot'}}, + {price = {{"coin", math_random(100,200)}}, offer = {type = 'give-item', item = 'loader'}}, + {price = {{"coin", math_random(200,300)}}, offer = {type = 'give-item', item = 'fast-loader'}}, + {price = {{"coin", math_random(300,500)}}, offer = {type = 'give-item', item = 'express-loader'}}, + {price = {{"coin", math_random(100,200)}}, offer = {type = 'give-item', item = 'locomotive'}}, + {price = {{"coin", math_random(75,150)}}, offer = {type = 'give-item', item = 'cargo-wagon'}}, + {price = {{"coin", math_random(2,4)}}, offer = {type = 'give-item', item = 'rail'}}, + {price = {{"coin", math_random(20,40)}}, offer = {type = 'give-item', item = 'train-stop'}}, + {price = {{"coin", math_random(4,12)}}, offer = {type = 'give-item', item = 'small-lamp'}}, + {price = {{"coin", math_random(80,160)}}, offer = {type = 'give-item', item = 'car'}}, + {price = {{"coin", math_random(300,600)}}, offer = {type = 'give-item', item = 'electric-furnace'}}, + {price = {{"coin", math_random(300,600)}}, offer = {type = 'give-item', item = "assembling-machine-3"}}, + + {price = {{"coin", math_random(5,10)}}, offer = {type = 'give-item', item = 'raw-wood', count = 50}}, + {price = {{"coin", math_random(5,10)}}, offer = {type = 'give-item', item = 'iron-ore', count = 50}}, + {price = {{"coin", math_random(5,10)}}, offer = {type = 'give-item', item = 'copper-ore', count = 50}}, + {price = {{"coin", math_random(5,10)}}, offer = {type = 'give-item', item = 'stone', count = 50}}, + {price = {{"coin", math_random(5,10)}}, offer = {type = 'give-item', item = 'coal', count = 50}}, + {price = {{"coin", math_random(8,16)}}, offer = {type = 'give-item', item = 'uranium-ore', count = 50}}, + + {price = {{'raw-wood', math_random(10,12)}}, offer = {type = 'give-item', item = "coin"}}, + {price = {{'iron-ore', math_random(10,12)}}, offer = {type = 'give-item', item = "coin"}}, + {price = {{'copper-ore', math_random(10,12)}}, offer = {type = 'give-item', item = "coin"}}, + {price = {{'stone', math_random(10,12)}}, offer = {type = 'give-item', item = "coin"}}, + {price = {{'coal', math_random(10,12)}}, offer = {type = 'give-item', item = "coin"}}, + {price = {{'uranium-ore', math_random(8,10)}}, offer = {type = 'give-item', item = "coin"}} + } + secret_market_items = shuffle(secret_market_items) + + local market = surface.create_entity {name = "market", position = pos} + market.destructible = false + + for i = 1, math.random(6, 8), 1 do + market.add_market_item(secret_market_items[i]) + end +end + +local function on_player_joined_game(event) + local player = game.players[event.player_index] + + if not global.surface_init_done then + local map_gen_settings = {} + map_gen_settings.water = "small" + map_gen_settings.cliff_settings = {cliff_elevation_interval = 6, cliff_elevation_0 = 6} + map_gen_settings.autoplace_controls = { + ["coal"] = {frequency = "none", size = "none", richness = "none"}, + ["stone"] = {frequency = "none", size = "none", richness = "none"}, + ["copper-ore"] = {frequency = "none", size = "none", richness = "none"}, + ["iron-ore"] = {frequency = "none", size = "none", richness = "none"}, + ["uranium-ore"] = {frequency = "none", size = "none", richness = "none"}, + ["crude-oil"] = {frequency = "none", size = "none", richness = "none"}, + ["trees"] = {frequency = "normal", size = "normal", richness = "normal"}, + ["enemy-base"] = {frequency = "none", size = "none", richness = "none"}, + ["grass"] = {frequency = "none", size = "none", richness = "none"}, + ["sand"] = {frequency = "none", size = "none", richness = "none"}, + ["desert"] = {frequency = "none", size = "none", richness = "none"}, + ["dirt"] = {frequency = "normal", size = "normal", richness = "normal"} + } + game.create_surface("stoneblock", map_gen_settings) + local surface = game.surfaces["stoneblock"] + + local radius = 512 + game.forces.player.chart(surface, {{x = -1 * radius, y = -1 * radius}, {x = radius, y = radius}}) + + game.map_settings.pollution.enabled = true + game.map_settings.enemy_expansion.enabled = true + game.map_settings.enemy_evolution.destroy_factor = 0.004 + game.map_settings.enemy_evolution.time_factor = 0.00002 + game.map_settings.enemy_evolution.pollution_factor = 0.00003 + game.map_settings.enemy_expansion.max_expansion_distance = 15 + game.map_settings.enemy_expansion.settler_group_min_size = 15 + game.map_settings.enemy_expansion.settler_group_max_size = 30 + game.map_settings.enemy_expansion.min_expansion_cooldown = 1800 + game.map_settings.enemy_expansion.max_expansion_cooldown = 3600 + + surface.ticks_per_day = surface.ticks_per_day * 2 + game.forces.player.manual_mining_speed_modifier = 1.75 + + global.surface_init_done = true + end + + if player.online_time < 1 then + player.insert({name = "pistol", count = 1}) + player.insert({name = "iron-axe", count = 1}) + player.insert({name = "raw-fish", count = 3}) + player.insert({name = "raw-wood", count = 16}) + player.insert({name = "firearm-magazine", count = 16}) + player.insert({name = "iron-plate", count = 32}) + if global.show_floating_killscore then global.show_floating_killscore[player.name] = false end + end + + local surface = game.surfaces["stoneblock"] + if player.online_time < 2 and surface.is_chunk_generated({0,0}) then + player.teleport(surface.find_non_colliding_position("player", spawn_point, 50, 1), "stoneblock") + else + if player.online_time < 2 then + player.teleport(spawn_point, "stoneblock") + end + end +end + +local function get_noise(name, pos) + local seed = game.surfaces[1].map_gen_settings.seed + local noise = {} + --local noise_seed_add = 25000 + if name == "rock_border" then + noise[1] = simplex_noise(pos.x * 0.008, pos.y * 0.008, seed) + --noise[2] = simplex_noise(pos.x * 0.04, pos.y * 0.04, seed) + local noise = noise[1]-- + noise[2] * 0.2 + return noise + end +end + +local function generate_north_chunk(area, surface) + local left_top = area.left_top + local tile_positions = {} + + local tiles_to_set = {} + for x = 0, 31, 1 do + for y = 0, 31, 1 do + local pos = {x = left_top.x + x, y = left_top.y + y} + tile_positions[#tile_positions + 1] = pos + insert(tiles_to_set, {name = "dirt-7", position = pos}) + end + end + surface.set_tiles(tiles_to_set, true) + if #tile_positions == 0 then return end + + local rock_amount = math.ceil(#tile_positions * 0.75) + tile_positions = shuffle(tile_positions) + for _, pos in pairs(tile_positions) do + surface.create_entity({name = rock_raffle[math_random(1, #rock_raffle)], position = pos}) + rock_amount = rock_amount - 1 + if rock_amount < 1 then break end + end + + local waters = {"water-green", "deepwater-green"} + if math_random(1,8) == 1 then + local pos = tile_positions[math_random(1, #tile_positions)] + map_functions.draw_noise_tile_circle(pos, waters[math_random(1, #waters)], surface, math_random(2, 8)) + for x = 1, math_random(2,7), 1 do + surface.create_entity({name = "fish", position = pos}) + end + end + + if math_random(1,32) == 1 then + local pos = tile_positions[math_random(1, #tile_positions)] + local size = math_random(3, 8) + map_functions.draw_noise_tile_circle(pos, "water", surface, size - 1) + map_functions.draw_noise_tile_circle(pos, "grass-2", surface, size) + secret_shop(pos, surface) + end + + if math_random(1,26) == 1 then + map_functions.draw_noise_tile_circle(pos, "water", surface, 5) + map_functions.draw_noise_tile_circle(pos, "sand-3", surface, 6) + map_functions.draw_oil_circle(tile_positions[math_random(1, #tile_positions)], "crude-oil", surface, math_random(1, 4), math_random(100000, 500000)) + end + + local decorative_names = {} + for k,v in pairs(game.decorative_prototypes) do + if v.autoplace_specification then + decorative_names[#decorative_names+1] = k + end + end + surface.regenerate_decorative(decorative_names, {{x=math.floor(left_top.x/32),y=math.floor(left_top.y/32)}}) +end + +local function generate_south_chunk(event, surface) + local left_top = event.area.left_top + + for _, e in pairs(surface.find_entities_filtered({area = event.area, type = "cliff"})) do + e.destroy() + end + + local current_depth = math.sqrt(left_top.x^2 + left_top.y^2) * 0.05 + + local i = math.ceil(current_depth / 32) + if i > 10 then i = 10 end + if i < 1 then i = 1 end + local worm_raffle = worm_raffle_table[i] + + local worm_amount = math.ceil(current_depth / 32) + if worm_amount > 16 then worm_amount = 16 end + local nests_amount = math.ceil(current_depth / 8) + if nests_amount > 16 then nests_amount = 16 end + local ore_patch_amount = math.floor(current_depth / 96) + + local tile_positions = {} + 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 + tile_positions[#tile_positions + 1] = pos + end + end + end + if #tile_positions == 0 then return end + + tile_positions = shuffle(tile_positions) + for _, pos in pairs(tile_positions) do + if surface.can_place_entity({name = "biter-spawner", position = pos, force = "enemy"}) then + surface.create_entity({name = nest_raffle[math_random(1, #nest_raffle)], position = pos, force = "enemy"}) + nests_amount = nests_amount - 1 + if nests_amount < 1 then break end + end + end + + tile_positions = shuffle(tile_positions) + for _, pos in pairs(tile_positions) do + if surface.can_place_entity({name = "big-worm-turret", position = pos, force = "enemy"}) then + surface.create_entity({name = worm_raffle[math_random(1, #worm_raffle)], position = pos, force = "enemy"}) + worm_amount = worm_amount - 1 + if worm_amount < 1 then break end + end + end +end + +local function on_chunk_charted(event) + if not global.chunks_charted then global.chunks_charted = {} end + local surface = game.surfaces[event.surface_index] + local position = event.position + if global.chunks_charted[tostring(position.x) .. tostring(position.y)] then return end + global.chunks_charted[tostring(position.x) .. tostring(position.y)] = true + local area = { + left_top = {x = position.x * 32, y = position.y * 32}, + right_bottom = {x = position.x * 32 + 31, y = position.y * 32 + 31} + } + + local left_top = {x = position.x * 32, y = position.y * 32} + local size = 320 + if left_top.y < size and left_top.y >= size * -1 and left_top.x < size and left_top.x >= size * -1 then + return + end + + if math_random(1,3) ~= 1 then return end + local distance_to_center = math.sqrt(left_top.x^2 + left_top.y^2) + map_functions.draw_rainbow_patch({x = position.x * 32 + math_random(1,32), y = position.y * 32 + math_random(1,32)}, surface, math_random(8, 16), distance_to_center * 3) + game.forces.player.chart(surface, area) +end + +local function on_chunk_generated(event) + local surface = game.surfaces["stoneblock"] + if event.surface.name ~= surface.name then return end + local left_top = event.area.left_top + + local size = 320 + if left_top.y < size and left_top.y >= size * -1 and left_top.x < size and left_top.x >= size * -1 then + generate_north_chunk(event.area, surface) + return + else + generate_south_chunk(event, surface) + return + end +end + +local function on_entity_damaged(event) + local entity = event.entity + if not entity.valid then return end + if entity.type == "simple-entity" then + if event.force.name == "player" then + event.entity.health = event.entity.health + (event.final_damage_amount * 0.5) + if event.entity.health <= event.final_damage_amount then + event.entity.die("player") + end + end + end +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_chunk_charted, on_chunk_charted) +event.add(defines.events.on_entity_damaged, on_entity_damaged) +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_player_joined_game, on_player_joined_game) \ No newline at end of file