From 1b6a2dc2c02dc3ad79b1f0d11f065bab5e854b29 Mon Sep 17 00:00:00 2001 From: hanakocz Date: Mon, 9 Dec 2024 01:32:31 +0100 Subject: [PATCH] Journey more fixes + dump_env helpers fix --- maps/journey/constants.lua | 1 + maps/journey/functions.lua | 14 ++++++------- maps/journey/main.lua | 2 +- maps/journey/unique_modifiers.lua | 34 +++++++++++++++---------------- utils/dump_env.lua | 2 +- 5 files changed, 26 insertions(+), 27 deletions(-) diff --git a/maps/journey/constants.lua b/maps/journey/constants.lua index 5592781a5..ac84c9a8f 100644 --- a/maps/journey/constants.lua +++ b/maps/journey/constants.lua @@ -105,6 +105,7 @@ Public.modifiers = { ['cliff_continuity'] = { min = 1, max = 10, base = 8, dmin = -30, dmax = -15, name = 'Cliff Continuity' }, ['cliff_frequency'] = { min = 5, max = 80, base = 60, dmin = -30, dmax = -15, name = 'Cliff Frequency' }, ['water'] = { min = 0.01, max = 10, base = 1, dmin = -20, dmax = -10, name = 'Water' }, + ['scale'] = { min = 1, max = 1, base = 1, dmin = 0, dmax = 0, name = 'Landmass scale', static = true}, ['coal'] = { min = 0.01, max = 10, base = 1, dmin = -20, dmax = -10, name = 'Coal' }, ['stone'] = { min = 0.01, max = 10, base = 1, dmin = -20, dmax = -10, name = 'Stone' }, ['iron-ore'] = { min = 0.01, max = 10, base = 1, dmin = -20, dmax = -10, name = 'Iron Ore' }, diff --git a/maps/journey/functions.lua b/maps/journey/functions.lua index 514e2b08d..fa09e524c 100644 --- a/maps/journey/functions.lua +++ b/maps/journey/functions.lua @@ -196,10 +196,11 @@ local function set_map_modifiers(journey) mgs.autoplace_controls['enemy-base'].richness = calc_modifier(journey, 'enemy_base_richness') mgs.autoplace_controls['enemy-base'].size = calc_modifier(journey, 'enemy_base_size') mgs.autoplace_controls['enemy-base'].frequency = calc_modifier(journey, 'enemy_base_frequency') + mgs.autoplace_controls['water'].size = calc_modifier(journey, 'water') + mgs.autoplace_controls['water'].frequency = calc_modifier(journey, 'scale') mgs.starting_area = calc_modifier(journey, 'starting_area') mgs.cliff_settings.cliff_elevation_interval = calc_modifier(journey, 'cliff_frequency') mgs.cliff_settings.richness = calc_modifier(journey, 'cliff_continuity') - mgs.water = calc_modifier(journey, 'water') game.map_settings.enemy_evolution['time_factor'] = calc_modifier(journey, 'time_factor') game.map_settings.enemy_evolution['destroy_factor'] = calc_modifier(journey, 'destroy_factor') game.map_settings.enemy_evolution['pollution_factor'] = calc_modifier(journey, 'pollution_factor') @@ -325,14 +326,11 @@ local function cargo_gui(name, itemname, tooltip, value, hidden) sprite.style.maximal_height = 28 sprite.style.margin = 0 sprite.style.padding = 0 - local progressbar = frame.add({ type = 'progressbar', name = name .. '_progressbar', value = 0 }) - progressbar.style = 'achievement_progressbar' - local progressbar_style = progressbar.style --[[@as LuaGuiElementStyle]] + local progressbar = frame.add({ type = 'progressbar', name = name .. '_progressbar', value = 0, style = 'achievement_progressbar' }) + local progressbar_style = progressbar.style progressbar_style.minimal_width = 100 progressbar_style.maximal_width = 100 - ---@diagnostic disable-next-line: inject-field progressbar_style.top_margin = 2 - ---@diagnostic disable-next-line: inject-field progressbar_style.right_margin = 6 progressbar_style.height = 20 end @@ -1270,8 +1268,9 @@ function Public.create_the_world(journey) local surface = game.surfaces.nauvis local mgs = surface.map_gen_settings mgs.seed = Math.random(1, 4294967295) - mgs.terrain_segmentation = Math.random(10, 20) * 0.1 + journey.world_modifiers['scale'] = Math.random(10, 20) * 0.1 mgs.peaceful_mode = false + surface.map_gen_settings = mgs local modifiers = journey.world_selectors[journey.selected_world].modifiers for _, modifier in pairs(modifiers) do @@ -1280,7 +1279,6 @@ function Public.create_the_world(journey) local extremes = { Constants.modifiers[name].min, Constants.modifiers[name].max } journey.world_modifiers[name] = math.round(math.min(extremes[2], math.max(extremes[1], journey.world_modifiers[name] * m)) * 100000, 5) / 100000 end - surface.map_gen_settings = mgs journey.world_trait = journey.world_selectors[journey.selected_world].world_trait local unique_modifier = Unique_modifiers[journey.world_trait] diff --git a/maps/journey/main.lua b/maps/journey/main.lua index f8bbc19b1..3515b1906 100644 --- a/maps/journey/main.lua +++ b/maps/journey/main.lua @@ -264,7 +264,7 @@ local function cmd_handler() end if player and not player.admin then p('You are not an admin!') - return false + return false, nil, p end return true, player or {name = 'Server'}, p end diff --git a/maps/journey/unique_modifiers.lua b/maps/journey/unique_modifiers.lua index 5bb6b82f1..e6c04b55a 100644 --- a/maps/journey/unique_modifiers.lua +++ b/maps/journey/unique_modifiers.lua @@ -220,7 +220,9 @@ Public.replicant_fauna = { return end if cause.force.index == 2 then - cause.surface.create_entity({ name = BiterRaffle.roll('mixed', game.forces.enemy.evolution_factor), position = entity.position, force = 'enemy' }) + local surface = entity.surface + local force = game.forces.enemy + surface.create_entity({ name = BiterRaffle.roll('mixed', force.get_evolution_factor(surface)), position = entity.position, force = force }) end end } @@ -279,6 +281,7 @@ Public.tarball = { Public.swamps = { set_specials = function (journey) journey.world_specials['water'] = 2 + journey.world_specials['scale'] = 0.5 end, on_chunk_generated = function (event, journey) local surface = event.surface @@ -326,7 +329,7 @@ Public.wasteland = { if math_random(1, 3) ~= 1 then return end - for _ = 1, math_random(0, 5), 1 do + for _ = 1, math_random(0, 8), 1 do local name = wrecks[math_random(1, size_of_wrecks)] local position = surface.find_non_colliding_position(name, { left_top_x + math_random(0, 31), left_top_y + math_random(0, 31) }, 16, 1) if position then @@ -342,24 +345,13 @@ Public.wasteland = { end end end, - on_world_start = function (journey) - local surface = game.surfaces.nauvis - local mgs = surface.map_gen_settings - mgs.terrain_segmentation = 2.7 - surface.map_gen_settings = mgs - surface.clear(true) - end, set_specials = function (journey) journey.world_specials['water'] = 2 + journey.world_specials['scale'] = 2.7 end } Public.oceanic = { - on_world_start = function (journey) - local surface = game.surfaces.nauvis - - surface.clear(true) - end, on_robot_built_entity = function (event) local entity = event.entity if not entity.valid then @@ -386,6 +378,8 @@ Public.oceanic = { end, set_specials = function (journey) journey.world_specials['water'] = 6 + journey.world_specials['scale'] = 0.5 + journey.world_specials['stone'] = 2 end } @@ -490,7 +484,9 @@ Public.infested = { if entity.type ~= 'simple-entity' and entity.type ~= 'tree' then return end - entity.surface.create_entity({ name = BiterRaffle.roll('mixed', game.forces.enemy.evolution_factor + 0.1), position = entity.position, force = 'enemy' }) + local surface = entity.surface + local force = game.forces.enemy + surface.create_entity({ name = BiterRaffle.roll('mixed', force.get_evolution_factor(surface) + 0.1), position = entity.position, force = force }) end, on_player_mined_entity = function (event) if math_random(1, 2) == 1 then @@ -506,7 +502,9 @@ Public.infested = { if entity.type ~= 'simple-entity' and entity.type ~= 'tree' then return end - entity.surface.create_entity({ name = BiterRaffle.roll('mixed', game.forces.enemy.evolution_factor + 0.1), position = entity.position, force = 'enemy' }) + local surface = entity.surface + local force = game.forces.enemy + surface.create_entity({ name = BiterRaffle.roll('mixed', force.get_evolution_factor(surface) + 0.1), position = entity.position, force = force }) end, on_robot_mined_entity = function (event) local entity = event.entity @@ -519,7 +517,9 @@ Public.infested = { if entity.type ~= 'simple-entity' and entity.type ~= 'tree' then return end - entity.surface.create_entity({ name = BiterRaffle.roll('mixed', game.forces.enemy.evolution_factor + 0.1), position = entity.position, force = 'enemy' }) + local surface = entity.surface + local force = game.forces.enemy + surface.create_entity({ name = BiterRaffle.roll('mixed', force.get_evolution_factor(surface) + 0.1), position = entity.position, force = force }) end } diff --git a/utils/dump_env.lua b/utils/dump_env.lua index cb5df9b07..991d1f55d 100644 --- a/utils/dump_env.lua +++ b/utils/dump_env.lua @@ -23,7 +23,7 @@ local function player_joined(event) local dump_string = inspect(_ENV, {process = filter}) if dump_string then local s = string.format('tick on join: %s\n%s', event.tick, dump_string) - game.write_file(filename, s) + helpers.write_file(filename, s) game.print('_ENV dumped into ' .. filename) else game.print('_ENV not dumped, dump_string was nil')