mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-04 00:15:45 +02:00
junkyard update
This commit is contained in:
parent
9181b2ff32
commit
02a25284d9
@ -41,8 +41,8 @@ require "on_tick_schedule"
|
||||
---- enable maps here ----
|
||||
--require "maps.biter_battles"
|
||||
--require "maps.cave_miner"
|
||||
require "maps.labyrinth"
|
||||
--require "maps.junkyard"
|
||||
--require "maps.labyrinth"
|
||||
require "maps.junkyard"
|
||||
--require "maps.spooky_forest"
|
||||
--require "maps.nightfall"
|
||||
--require "maps.atoll"
|
||||
|
@ -197,9 +197,9 @@ local function get_amount(entity)
|
||||
end
|
||||
|
||||
local function trap(entity)
|
||||
if math_random(1,512) == 1 then tick_tack_trap(entity.surface, entity.position) return end
|
||||
if math_random(1,1024) == 1 then tick_tack_trap(entity.surface, entity.position) return end
|
||||
if math_random(1,128) == 1 then unearthing_worm(entity.surface, entity.position) return end
|
||||
if math_random(1,64) == 1 then unearthing_biters(entity.surface, entity.position, math_random(4,12)) return end
|
||||
if math_random(1,128) == 1 then unearthing_biters(entity.surface, entity.position, math_random(4,12)) return end
|
||||
end
|
||||
|
||||
local function on_player_mined_entity(event)
|
||||
|
@ -6,7 +6,7 @@ require "maps.modules.mineable_wreckage_yields_scrap"
|
||||
require "maps.modules.rocks_heal_over_time"
|
||||
require "maps.modules.spawners_contain_biters"
|
||||
require "maps.modules.biters_yield_coins"
|
||||
require "maps.modules.fluids_are_explosive"
|
||||
--require "maps.modules.fluids_are_explosive"
|
||||
--require "maps.modules.explosives_are_explosive"
|
||||
require "maps.modules.dangerous_nights"
|
||||
|
||||
@ -247,19 +247,22 @@ local function place_random_scrap_entity(surface, position)
|
||||
if r < 15 then
|
||||
local e = surface.create_entity({name = scrap_buildings[math.random(1, #scrap_buildings)], position = position, force = "scrap"})
|
||||
if e.name == "nuclear-reactor" then
|
||||
create_entity_chain(surface, {name = "heat-pipe", position = position, force = "player"}, math_random(32,64), 25)
|
||||
create_entity_chain(surface, {name = "heat-pipe", position = position, force = "player"}, math_random(16,32), 25)
|
||||
end
|
||||
if e.name == "chemical-plant" or e.name == "steam-turbine" or e.name == "steam-engine" or e.name == "oil-refinery" then
|
||||
create_entity_chain(surface, {name = "pipe", position = position, force = "player"}, math_random(16,32), 25)
|
||||
end
|
||||
e.active = false
|
||||
return
|
||||
end
|
||||
if r < 25 then
|
||||
surface.create_entity({name = "substation", position = position, force = "scrap"})
|
||||
local e = surface.create_entity({name = "substation", position = position, force = "scrap"})
|
||||
e.active = false
|
||||
return
|
||||
end
|
||||
if r < 70 then
|
||||
surface.create_entity({name = "medium-electric-pole", position = position, force = "scrap"})
|
||||
local e = surface.create_entity({name = "medium-electric-pole", position = position, force = "scrap"})
|
||||
e.active = false
|
||||
return
|
||||
end
|
||||
if r < 90 then
|
||||
@ -273,21 +276,27 @@ local function place_random_scrap_entity(surface, position)
|
||||
e.fluidbox[1] = {name = fluids[math.random(1, #fluids)], amount = math.random(15000, 25000)}
|
||||
create_entity_chain(surface, {name = "pipe", position = position, force = "player"}, math_random(6,8), 1)
|
||||
create_entity_chain(surface, {name = "pipe", position = position, force = "player"}, math_random(6,8), 1)
|
||||
create_entity_chain(surface, {name = "pipe", position = position, force = "player"}, math_random(40,70), 80)
|
||||
create_entity_chain(surface, {name = "pipe", position = position, force = "player"}, math_random(20,40), 80)
|
||||
end
|
||||
|
||||
local function create_inner_content(surface, pos, noise)
|
||||
if math_random(1, 102400) == 1 then secret_shop(pos, surface) return end
|
||||
if math_random(1, 90000) == 1 then secret_shop(pos, surface) return end
|
||||
if math_random(1, 102400) == 1 then
|
||||
if noise < 0.2 or noise > -0.2 then
|
||||
create_tile_chain(surface, {name = "stone-path", position = pos}, math_random(16, 48), 50)
|
||||
create_tile_chain(surface, {name = "stone-path", position = pos}, math_random(16, 48), 50)
|
||||
create_tile_chain(surface, {name = "stone-path", position = pos}, math_random(16, 48), 50)
|
||||
create_tile_chain(surface, {name = "stone-path", position = pos}, math_random(16, 48), 50)
|
||||
create_entity_chain(surface, {name = "laser-turret", position = pos, force = "scrap_defense"}, 1, 25)
|
||||
create_entity_chain(surface, {name = "accumulator", position = pos, force = "scrap_defense"}, math_random(2, 4), 1)
|
||||
create_entity_chain(surface, {name = "substation", position = pos, force = "scrap_defense"}, math_random(6, 8), 1)
|
||||
create_entity_chain(surface, {name = "solar-panel", position = pos, force = "scrap_defense"}, math_random(16, 24), 1)
|
||||
if noise < 0.3 or noise > -0.3 then
|
||||
map_functions.draw_derpy_entity_ring(surface, pos, "laser-turret", "scrap_defense", 0, 2)
|
||||
map_functions.draw_derpy_entity_ring(surface, pos, "accumulator", "scrap_defense", 2, 3)
|
||||
map_functions.draw_derpy_entity_ring(surface, pos, "substation", "scrap_defense", 3, 4)
|
||||
map_functions.draw_derpy_entity_ring(surface, pos, "solar-panel", "scrap_defense", 4, 6)
|
||||
map_functions.draw_derpy_entity_ring(surface, pos, "stone-wall", "scrap_defense", 6, 7)
|
||||
|
||||
create_tile_chain(surface, {name = "concrete", position = pos}, math_random(16, 32), 50)
|
||||
create_tile_chain(surface, {name = "concrete", position = pos}, math_random(16, 32), 50)
|
||||
create_tile_chain(surface, {name = "stone-path", position = pos}, math_random(16, 32), 50)
|
||||
create_tile_chain(surface, {name = "stone-path", position = pos}, math_random(16, 32), 50)
|
||||
--create_entity_chain(surface, {name = "laser-turret", position = pos, force = "scrap_defense"}, 1, 25)
|
||||
--create_entity_chain(surface, {name = "accumulator", position = pos, force = "scrap_defense"}, math_random(2, 4), 1)
|
||||
--create_entity_chain(surface, {name = "substation", position = pos, force = "scrap_defense"}, math_random(6, 8), 1)
|
||||
-- create_entity_chain(surface, {name = "solar-panel", position = pos, force = "scrap_defense"}, math_random(16, 24), 1)
|
||||
end
|
||||
return
|
||||
end
|
||||
@ -360,10 +369,9 @@ local function on_chunk_generated(event)
|
||||
|
||||
if global.spawn_generated then return end
|
||||
if left_top.x < 96 then return end
|
||||
map_functions.draw_rainbow_patch({x = 0, y = 0}, surface, 12, 3000)
|
||||
map_functions.draw_rainbow_patch_v2({x = 0, y = 0}, surface, 12, 2500)
|
||||
local p = surface.find_non_colliding_position("character-corpse", {2,-2}, 32, 2)
|
||||
local e = surface.create_entity({name = "character-corpse", position = p})
|
||||
e.minable = false
|
||||
local e = surface.create_entity({name = "character-corpse", position = p})
|
||||
for _, e in pairs (surface.find_entities_filtered({area = {{-50, -50},{50, 50}}})) do
|
||||
local distance_to_center = math.sqrt(e.position.x^2 + e.position.y^2)
|
||||
if e.valid then
|
||||
@ -399,7 +407,7 @@ local function on_chunk_charted(event)
|
||||
local size = 7 + math.floor(distance_to_center * 0.0075)
|
||||
if size > 20 then size = 20 end
|
||||
local amount = 100 + distance_to_center
|
||||
map_functions.draw_rainbow_patch(pos, surface, size, amount)
|
||||
map_functions.draw_rainbow_patch_v2(pos, surface, size, amount)
|
||||
end
|
||||
|
||||
local function on_marked_for_deconstruction(event)
|
||||
@ -453,8 +461,8 @@ local function on_player_mined_entity(event)
|
||||
positions = shuffle(positions)
|
||||
for i = 1, math.ceil(entity.prototype.max_health / 32), 1 do
|
||||
if not positions[i] then return end
|
||||
if math_random(1,3) == 1 then
|
||||
unearthing_biters(entity.surface, positions[i], math_random(4,8))
|
||||
if math_random(1,3) ~= 1 then
|
||||
unearthing_biters(entity.surface, positions[i], math_random(5,10))
|
||||
else
|
||||
unearthing_worm(entity.surface, positions[i])
|
||||
end
|
||||
@ -466,7 +474,7 @@ local function on_entity_died(event)
|
||||
end
|
||||
|
||||
local function on_research_finished(event)
|
||||
event.research.force.character_inventory_slots_bonus = game.forces.player.mining_drill_productivity_bonus * 200
|
||||
event.research.force.character_inventory_slots_bonus = game.forces.player.mining_drill_productivity_bonus * 300
|
||||
end
|
||||
|
||||
event.add(defines.events.on_research_finished, on_research_finished)
|
||||
|
@ -26,24 +26,25 @@ local info = [[
|
||||
###Log End###
|
||||
]]
|
||||
|
||||
local function create_map_intro_button(player)
|
||||
if player.gui.left["map_intro_button"] then return end
|
||||
local b = player.gui.top.add({type = "sprite-button", caption = "?", name = "map_intro_button", tooltip = "Map Info"})
|
||||
b.style.font_color = {r = 0.8, g = 0.8, b = 0.8}
|
||||
b.style.font = "heading-1"
|
||||
b.style.minimal_height = 38
|
||||
b.style.minimal_width = 38
|
||||
b.style.top_padding = 2
|
||||
b.style.left_padding = 4
|
||||
b.style.right_padding = 4
|
||||
b.style.bottom_padding = 2
|
||||
end
|
||||
|
||||
local function create_map_intro(player)
|
||||
if player.gui.left["map_intro_frame"] then player.gui.left["map_intro_frame"].destroy() end
|
||||
local frame = player.gui.left.add {type = "frame", name = "map_intro_frame", direction = "vertical"}
|
||||
|
||||
local t = frame.add {type = "table", column_count = 1}
|
||||
--[[
|
||||
local tt = t.add {type = "table", column_count = 3}
|
||||
local l = tt.add {type = "label", caption = main_caption}
|
||||
l.style.font = "heading-1"
|
||||
l.style.font_color = {r=0.8, g=0.6, b=0.6}
|
||||
l.style.top_padding = 6
|
||||
l.style.bottom_padding = 6
|
||||
|
||||
local l = tt.add {type = "label", caption = sub_caption}
|
||||
l.style.font = "heading-2"
|
||||
l.style.font_color = {r=0.5, g=0.8, b=0.1}
|
||||
l.style.minimal_width = 280
|
||||
]]
|
||||
local b = frame.add {type = "button", caption = "Close", name = "close_map_intro_frame", align = "right"}
|
||||
b.style.font = "default"
|
||||
b.style.minimal_height = 30
|
||||
@ -53,19 +54,17 @@ local function create_map_intro(player)
|
||||
b.style.right_padding = 4
|
||||
b.style.bottom_padding = 2
|
||||
|
||||
--local tt = t.add {type = "table", column_count = 1}
|
||||
local frame = t.add {type = "frame"}
|
||||
local l = frame.add {type = "label", caption = info}
|
||||
l.style.single_line = false
|
||||
l.style.font = "heading-3"
|
||||
l.style.font_color = {r=0.95, g=0.95, b=0.95}
|
||||
|
||||
|
||||
l.style.font_color = {r=0.95, g=0.95, b=0.95}
|
||||
end
|
||||
|
||||
local function on_player_joined_game(event)
|
||||
local player = game.players[event.player_index]
|
||||
if player.online_time < 18000 then
|
||||
create_map_intro_button(player)
|
||||
if player.online_time == 0 then
|
||||
create_map_intro(player)
|
||||
end
|
||||
end
|
||||
@ -75,7 +74,15 @@ local function on_gui_click(event)
|
||||
if not event.element then return end
|
||||
if not event.element.valid then return end
|
||||
local player = game.players[event.element.player_index]
|
||||
if event.element.name == "close_map_intro_frame" then player.gui.left["map_intro_frame"].destroy() end
|
||||
if event.element.name == "close_map_intro_frame" then player.gui.left["map_intro_frame"].destroy() return end
|
||||
if event.element.name == "map_intro_button" then
|
||||
if player.gui.left["map_intro_frame"] then
|
||||
player.gui.left["map_intro_frame"].destroy()
|
||||
else
|
||||
create_map_intro(player)
|
||||
end
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
||||
|
@ -2,7 +2,7 @@
|
||||
require "maps.labyrinth_map_intro"
|
||||
require "maps.tools.teleporters"
|
||||
require "maps.modules.satellite_score"
|
||||
require "maps.modules.dynamic_landfill"
|
||||
require "maps.modules.landfill_reveals_nauvis"
|
||||
|
||||
local map_functions = require "maps.tools.map_functions"
|
||||
local simplex_noise = require 'utils.simplex_noise'
|
||||
@ -937,6 +937,7 @@ local function on_player_joined_game(event)
|
||||
player.insert {name = 'raw-fish', count = 3}
|
||||
player.insert {name = 'pistol', count = 1}
|
||||
player.insert {name = 'firearm-magazine', count = 32}
|
||||
player.insert {name = 'landfill', count = 10240}
|
||||
end
|
||||
create_labyrinth_difficulty_gui(player)
|
||||
end
|
||||
|
@ -8,14 +8,9 @@ local table_insert = table.insert
|
||||
local water_tile_whitelist = {
|
||||
["water"] = true,
|
||||
["deepwater"] = true,
|
||||
["water-green"] = true
|
||||
["water-green"] = true,
|
||||
["deepwater-green"] = true
|
||||
}
|
||||
|
||||
local water_tiles = {
|
||||
"water",
|
||||
"deepwater",
|
||||
"water-green"
|
||||
}
|
||||
|
||||
local function shuffle(tbl)
|
||||
local size = #tbl
|
||||
|
96
maps/modules/landfill_reveals_nauvis.lua
Normal file
96
maps/modules/landfill_reveals_nauvis.lua
Normal file
@ -0,0 +1,96 @@
|
||||
-- placing landfill in another surface will reveal nauvis -- by mewmew
|
||||
|
||||
local regenerate_decoratives = true
|
||||
|
||||
local event = require 'utils.event'
|
||||
local math_random = math.random
|
||||
local table_insert = table.insert
|
||||
local water_tile_whitelist = {
|
||||
["water"] = true,
|
||||
["deepwater"] = true,
|
||||
["water-green"] = true,
|
||||
["deepwater-green"] = true
|
||||
}
|
||||
|
||||
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 get_chunk_position(position)
|
||||
local chunk_position = {}
|
||||
position.x = math.floor(position.x, 0)
|
||||
position.y = math.floor(position.y, 0)
|
||||
for x = 0, 31, 1 do
|
||||
if (position.x - x) % 32 == 0 then chunk_position.x = (position.x - x) / 32 end
|
||||
end
|
||||
for y = 0, 31, 1 do
|
||||
if (position.y - y) % 32 == 0 then chunk_position.y = (position.y - y) / 32 end
|
||||
end
|
||||
return chunk_position
|
||||
end
|
||||
|
||||
local function regenerate_decoratives(surface, position)
|
||||
local chunk = get_chunk_position(position)
|
||||
if not chunk then return end
|
||||
surface.destroy_decoratives({area = {{chunk.x * 32, chunk.y * 32}, {chunk.x * 32 + 32, chunk.y * 32 + 32}}})
|
||||
--surface.destroy_decoratives({{chunk.x * 32, chunk.y * 32}, {chunk.x * 32 + 32, chunk.y * 32 + 32}})
|
||||
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, {chunk})
|
||||
end
|
||||
|
||||
local function place_entity(surface, e)
|
||||
if e.type == "resource" then surface.create_entity({name = e.name, position = e.position, amount = e.amount}) return end
|
||||
if e.type == "cliff" then surface.create_entity({name = e.name, position = e.position, force = e.force, cliff_orientation = e.cliff_orientation}) return end
|
||||
if e.direction then surface.create_entity({name = e.name, position = e.position, force = e.force, direction = e.direction}) return end
|
||||
surface.create_entity({name = e.name, position = e.position, force = e.force})
|
||||
end
|
||||
|
||||
local function generate_chunks(position)
|
||||
local nauvis = game.surfaces.nauvis
|
||||
local chunk = get_chunk_position(position)
|
||||
if nauvis.is_chunk_generated(chunk) then return end
|
||||
nauvis.request_to_generate_chunks(position, 1)
|
||||
nauvis.force_generate_chunk_requests()
|
||||
end
|
||||
|
||||
local function process_tile(surface, position, old_tile, player)
|
||||
local nauvis = game.surfaces.nauvis
|
||||
generate_chunks(position)
|
||||
local new_tile = nauvis.get_tile(position)
|
||||
surface.set_tiles({new_tile})
|
||||
if new_tile.name == old_tile.name then
|
||||
player.insert({name = "landfill", count = 1})
|
||||
return
|
||||
end
|
||||
for _, e in pairs(nauvis.find_entities_filtered({area = {{position.x - 0, position.y - 0}, {position.x + 0.999, position.y + 0.999}}})) do
|
||||
place_entity(surface, e)
|
||||
end
|
||||
end
|
||||
|
||||
local function on_player_built_tile(event)
|
||||
if event.item.name ~= "landfill" then return end
|
||||
local surface = game.surfaces[event.surface_index]
|
||||
local player = game.players[event.player_index]
|
||||
for _, placed_tile in pairs(event.tiles) do
|
||||
if water_tile_whitelist[placed_tile.old_tile.name] then
|
||||
process_tile(surface, placed_tile.position, placed_tile.old_tile, player)
|
||||
if regenerate_decoratives then
|
||||
if math_random(1, 4) == 1 then
|
||||
regenerate_decoratives(surface, placed_tile.position)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
event.add(defines.events.on_player_built_tile, on_player_built_tile)
|
@ -13,7 +13,7 @@ local function shuffle(tbl)
|
||||
return tbl
|
||||
end
|
||||
|
||||
f.draw_derpy_tile_circle = function(surface, position, name, radius_min, radius_max)
|
||||
f.draw_derpy_tile_ring = function(surface, position, name, radius_min, radius_max)
|
||||
local modifier_1 = math_random(2,5) * 0.01
|
||||
local seed = game.surfaces[1].map_gen_settings.seed
|
||||
local tiles = {}
|
||||
@ -31,6 +31,26 @@ f.draw_derpy_tile_circle = function(surface, position, name, radius_min, radius_
|
||||
end
|
||||
end
|
||||
|
||||
f.draw_derpy_entity_ring = function(surface, position, name, force, radius_min, radius_max)
|
||||
local modifier_1 = 0.1
|
||||
local seed = game.surfaces[1].map_gen_settings.seed
|
||||
local tiles = {}
|
||||
|
||||
for y = radius_max * -2, radius_max * 2, 1 do
|
||||
for x = radius_max * -2, radius_max * 2, 1 do
|
||||
local pos = {x = x + position.x, y = y + position.y}
|
||||
local noise = simplex_noise(pos.x * modifier_1, pos.y * modifier_1, seed)
|
||||
local distance_to_center = math.sqrt(x^2 + y^2)
|
||||
|
||||
if distance_to_center + noise * radius_max * 0.25 < radius_max and distance_to_center + noise * radius_min * 0.25 > radius_min then
|
||||
if surface.can_place_entity({name = name, position = pos}) then
|
||||
surface.create_entity({name = name, position = pos, force = force})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
f.draw_rainbow_patch = function(position, surface, radius, richness)
|
||||
if not position then return end
|
||||
if not surface then return end
|
||||
|
Loading…
Reference in New Issue
Block a user