Skip to content

Commit

Permalink
Journey more fixes + dump_env helpers fix
Browse files Browse the repository at this point in the history
  • Loading branch information
hanakocz committed Dec 9, 2024
1 parent d939797 commit 1b6a2dc
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 27 deletions.
1 change: 1 addition & 0 deletions maps/journey/constants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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' },
Expand Down
14 changes: 6 additions & 8 deletions maps/journey/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion maps/journey/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
34 changes: 17 additions & 17 deletions maps/journey/unique_modifiers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
}

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion utils/dump_env.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 1b6a2dc

Please sign in to comment.