From fb2ef3b9014b5ecce53f7734f6e328b77204b5dc Mon Sep 17 00:00:00 2001 From: Gerkiz Date: Wed, 4 Oct 2023 20:12:26 +0200 Subject: [PATCH] Towny and Mtn fortress changes --- maps/mountain_fortress_v3/entities.lua | 24 +++++------- .../icw/linked_chests.lua | 9 +++++ maps/scrap_towny_ffa/main.lua | 11 +++++- maps/scrap_towny_ffa/nauvis.lua | 38 +++++++++++-------- .../scrap_towny_ffa_layout.lua | 32 ++++++---------- maps/scrap_towny_ffa/table.lua | 4 +- maps/scrap_towny_ffa/team.lua | 6 +-- 7 files changed, 66 insertions(+), 58 deletions(-) diff --git a/maps/mountain_fortress_v3/entities.lua b/maps/mountain_fortress_v3/entities.lua index c57dd8aa5..af6405178 100644 --- a/maps/mountain_fortress_v3/entities.lua +++ b/maps/mountain_fortress_v3/entities.lua @@ -1237,48 +1237,42 @@ local function show_mvps(player) field1 = { text1 = 'Time played:', text2 = time_played, - inline = 'true' + inline = 'false' }, field2 = { text1 = 'Highest wave:', - text2 = format_number(wave, true), - inline = 'true' + text2 = wave, + inline = 'false' }, field3 = { text1 = 'Total connected players:', text2 = total_players, - inline = 'true', - emptyField = 'true', - emptyInline = 'true' + inline = 'false' }, field4 = { text1 = 'Threat:', text2 = format_number(threat, true), - inline = 'true' + inline = 'false' }, field5 = { text1 = 'Pickaxe Upgrade:', text2 = pick_tier .. ' (' .. upgrades.pickaxe_tier .. ')', - inline = 'true', - emptyField = 'true', - emptyInline = 'true' + inline = 'false' }, field6 = { text1 = 'Collapse Speed:', text2 = collapse_speed, - inline = 'true' + inline = 'false' }, field7 = { text1 = 'Collapse Amount:', text2 = collapse_amount, - inline = 'true' + inline = 'false' }, field8 = { text1 = 'Connected players:', text2 = total_connected_players, - inline = 'true', - emptyField = 'true', - emptyInline = 'true' + inline = 'false' } } if server_name_matches then diff --git a/maps/mountain_fortress_v3/icw/linked_chests.lua b/maps/mountain_fortress_v3/icw/linked_chests.lua index 7247c8c85..194b6f5b0 100644 --- a/maps/mountain_fortress_v3/icw/linked_chests.lua +++ b/maps/mountain_fortress_v3/icw/linked_chests.lua @@ -1304,6 +1304,15 @@ function Public.clear_linked_frames() end function Public.reset() + if this.main_containers and next(this.main_containers) then + for _, container in pairs(this.main_containers) do + local chest = container.chest + if chest and chest.valid then + chest.get_inventory(defines.inventory.chest).clear() + end + end + end + this.main_containers = {} this.linked_gui = {} this.valid_chests = { diff --git a/maps/scrap_towny_ffa/main.lua b/maps/scrap_towny_ffa/main.lua index a7d4ca91f..4cb224046 100644 --- a/maps/scrap_towny_ffa/main.lua +++ b/maps/scrap_towny_ffa/main.lua @@ -244,7 +244,16 @@ Event.on_init(on_init) Event.on_nth_tick(60, on_nth_tick) -- once every second Event.on_nth_tick(60 * 30, ui_smell_evolution) Event.on_nth_tick(60, update_score) -Event.add(Server.events.on_changes_detected, handle_changes) + +Server.on_scenario_changed( + 'Towny', + function(data) + local scenario = data.scenario + if scenario == 'Towny' then + handle_changes() + end + end +) --Disable the comfy main gui since we got too many goodies there. Event.add( diff --git a/maps/scrap_towny_ffa/nauvis.lua b/maps/scrap_towny_ffa/nauvis.lua index 2235aa8a0..afb76f2d5 100644 --- a/maps/scrap_towny_ffa/nauvis.lua +++ b/maps/scrap_towny_ffa/nauvis.lua @@ -1,19 +1,19 @@ local Event = require 'utils.event' local ScenarioTable = require 'maps.scrap_towny_ffa.table' local SoftReset = require 'functions.soft_reset' -local Server = require 'utils.server' -local Token = require 'utils.token' +-- local Server = require 'utils.server' +-- local Token = require 'utils.token' local math_random = math.random local table_shuffle = table.shuffle_table -local dataset = 'scenario_settings' -local dataset_key = 'scrap_towny_ffa' +-- local dataset = 'scenario_settings' +-- local dataset_key = 'scrap_towny_ffa' local Public = {} local map_width = 3840 local map_height = 3840 - +--[[ local set_victory_length_token = Token.register( function(data) @@ -42,8 +42,7 @@ local set_victory_length_token = Server.set_data(dataset, dataset_key, settings) end -) - +) ]] function Public.nuke(position) local this = ScenarioTable.get_table() local map_surface = game.get_surface(this.active_surface_index) @@ -132,6 +131,17 @@ function Public.initialize() ['sand-rock-small'] = {frequency = 10, size = 'normal', richness = 'normal'}, ['sand-rock-medium'] = {frequency = 5, size = 'normal', richness = 'normal'} } + }, + tile = { + settings = { + ['deepwater'] = {frequency = 1, size = 0, richness = 1}, + ['deepwater-green'] = {frequency = 1, size = 0, richness = 1}, + ['water'] = {frequency = 1, size = 0, richness = 1}, + ['water-green'] = {frequency = 1, size = 0, richness = 1}, + ['water-mud'] = {frequency = 1, size = 0, richness = 1}, + ['water-shallow'] = {frequency = 1, size = 0, richness = 1} + }, + treat_missing_as_default = true } } mgs.cliff_settings = { @@ -140,10 +150,10 @@ function Public.initialize() cliff_elevation_interval = 10, richness = 0.4 } - mgs.water = 0.5 + mgs.water = 0 mgs.peaceful_mode = false mgs.starting_area = 'none' - mgs.terrain_segmentation = 3.5 + mgs.terrain_segmentation = 8 -- terrain size is 64 x 64 chunks, water size is 80 x 80 mgs.width = map_width mgs.height = map_height @@ -158,11 +168,7 @@ function Public.initialize() -- adjust this value to set how many nests spawn per tile ['enemy-base-frequency'] = 0.4, -- this will make and average base radius around 12 tiles - ['enemy-base-radius'] = 12, - ['control-setting:aux:bias'] = '-0.300000', - ['control-setting:aux:frequency:multiplier'] = '1.333333', - ['control-setting:moisture:bias'] = '-0.200000', - ['control-setting:moisture:frequency:multiplier'] = '1.333333' + ['enemy-base-radius'] = 12 } mgs.seed = math_random(100000, 9999999) @@ -177,13 +183,13 @@ function Public.initialize() return end - Server.try_get_data(dataset, dataset_key, set_victory_length_token) + -- Server.try_get_data(dataset, dataset_key, set_victory_length_token) surface.map_gen_settings = mgs surface.peaceful_mode = false surface.always_day = false surface.freeze_daytime = false - surface.map_gen_settings.water = 0.5 + -- surface.map_gen_settings.water = 0.5 surface.clear(true) surface.regenerate_entity({'rock-huge', 'rock-big', 'sand-rock-big'}) surface.regenerate_decorative() diff --git a/maps/scrap_towny_ffa/scrap_towny_ffa_layout.lua b/maps/scrap_towny_ffa/scrap_towny_ffa_layout.lua index b2e0a060f..0d252c2ce 100644 --- a/maps/scrap_towny_ffa/scrap_towny_ffa_layout.lua +++ b/maps/scrap_towny_ffa/scrap_towny_ffa_layout.lua @@ -2,26 +2,12 @@ local Event = require 'utils.event' local get_noise = require 'utils.get_noise' local ScenarioTable = require 'maps.scrap_towny_ffa.table' local Scrap = require 'maps.scrap_towny_ffa.scrap' +local get_perlin = require 'utils.get_perlin' local table_insert = table.insert local math_random = math.random local math_floor = math.floor -local start_ground_tiles = { - 'grass-1', - 'grass-1', - 'grass-2', - 'sand-2', - 'grass-1', - 'grass-4', - 'sand-2', - 'grass-3', - 'grass-4', - 'grass-2', - 'sand-3', - 'grass-4' -} - local scrap_entities = { -- simple entity with owner {name = 'crash-site-spaceship-wreck-small-1'}, -- these do not have mining animation @@ -298,12 +284,16 @@ 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 math_random(1, 3) > 1 then - local tile = surface.get_tile(position) - if not tile.collides_with('water-tile') then - noise = get_noise('dungeon_sewer', position, seed) - local index = math_floor(noise * 32) % 11 + 1 - surface.set_tiles({{name = start_ground_tiles[index], position = position}}, true) + local cave_ponds = get_perlin('cave_ponds', position, seed + seed) + + if cave_ponds > 0.02 and cave_ponds < 0.3 then + if cave_ponds > 0.2 then + surface.set_tiles({{name = 'water-shallow', position = position}}, true) + else + surface.set_tiles({{name = 'water', position = position}}, true) + end + if math_random(1, 48) == 1 then + surface.create_entity({name = 'fish', position = position, force = 'neutral'}) end end if math_random(1, 3) > 1 then diff --git a/maps/scrap_towny_ffa/table.lua b/maps/scrap_towny_ffa/table.lua index aabbd2789..b2e915d77 100644 --- a/maps/scrap_towny_ffa/table.lua +++ b/maps/scrap_towny_ffa/table.lua @@ -37,8 +37,8 @@ function Public.reset_table() this.mining_target = {} this.spaceships = {} this.suicides = {} - this.required_time_to_win = 168 - this.required_time_to_win_in_ticks = 36288000 + this.required_time_to_win = 72 + this.required_time_to_win_in_ticks = 15552000 this.shuffle_random_victory_time = false this.announced_message = nil this.soft_reset = true diff --git a/maps/scrap_towny_ffa/team.lua b/maps/scrap_towny_ffa/team.lua index d896f4f5d..aeea418ad 100644 --- a/maps/scrap_towny_ffa/team.lua +++ b/maps/scrap_towny_ffa/team.lua @@ -786,13 +786,13 @@ local function kill_force(force_name, cause) end for _, e in pairs(surface.find_entities_filtered({force = force_name})) do if e.valid then - if destroy_military_types[e.type] == true then + if destroy_military_types[e.type] then surface.create_entity({name = 'big-artillery-explosion', position = position}) e.die() - elseif destroy_robot_types[e.type] == true then + elseif destroy_robot_types[e.type] then surface.create_entity({name = 'explosion', position = position}) e.die() - elseif destroy_wall_types[e.type] == true then + elseif destroy_wall_types[e.type] then e.die() elseif storage_types[e.type] ~= true then -- spare chests local random = math_random()