1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-03-17 20:58:13 +02:00

wip update

This commit is contained in:
MewMew 2020-04-04 04:55:05 +02:00
parent 325c865b97
commit 379cbd3750
6 changed files with 263 additions and 80 deletions

View File

@ -105,7 +105,7 @@ require "modules.autostash"
--require "maps.spiral_troopers"
--require "maps.refactor-io"
--require "maps.desert_oasis"
--require "maps.dungeons"
--require "maps.dungeons.main"
--require "maps.lost_desert"
--require "maps.stoneblock"
--require "maps.wave_defense"

View File

@ -150,7 +150,7 @@ end
function Public.get_room(surface, position)
local room_sizes = {}
for i = 1, 9, 1 do
for i = 1, 11, 1 do
room_sizes[i] = i + 1
end
table_shuffle_table(room_sizes)

View File

@ -0,0 +1,78 @@
local table_shuffle_table = table.shuffle_table
local table_insert = table.insert
local table_remove = table.remove
local math_random = math.random
local math_abs = math.abs
local ores = {"iron-ore", "iron-ore", "iron-ore", "iron-ore", "copper-ore", "copper-ore", "copper-ore","coal", "coal","stone", "stone","uranium-ore"}
local trees = {"dead-dry-hairy-tree", "dead-grey-trunk", "dead-tree-desert", "dry-hairy-tree", "dry-tree"}
local size_of_trees = #trees
local worms = {}
for _ = 1, 64, 1 do table_insert(worms, "small") end
for _ = 1, 8, 1 do table_insert(worms, "medium") end
for _ = 1, 4, 1 do table_insert(worms, "big") end
for _ = 1, 1, 1 do table_insert(worms, "behemoth") end
local size_of_worms = #worms
local function dirtlands(surface, room)
local path_tile = "dirt-" .. math_random(1, 3)
for _, tile in pairs(room.path_tiles) do
surface.set_tiles({{name = path_tile, position = tile.position}}, true)
end
if #room.room_border_tiles > 1 then table_shuffle_table(room.room_border_tiles) end
for key, tile in pairs(room.room_border_tiles) do
surface.set_tiles({{name = "dirt-4", position = tile.position}}, true)
if key < 6 then
surface.create_entity({name = "rock-big", position = tile.position})
end
end
if #room.room_tiles > 1 then table_shuffle_table(room.room_tiles) end
for key, tile in pairs(room.room_tiles) do
surface.set_tiles({{name = "dirt-7", position = tile.position}}, true)
if math_random(1, 64) == 1 then
surface.create_entity({name = ores[math_random(1, #ores)], position = tile.position, amount = math_random(100, 20000)})
else
if math_random(1, 128) == 1 then
surface.create_entity({name = trees[math_random(1, size_of_trees)], position = tile.position})
end
end
if key % 128 == 0 and math_random(1, 2) == 1 then
surface.create_entity({name = "biter-spawner", position = tile.position})
end
if math_random(1, 256) == 1 then
local turret_name = worms[math_random(1, size_of_worms)] .. "-worm-turret"
surface.create_entity({name = turret_name, position = tile.position})
end
if math_random(1, 512) == 1 then
surface.create_entity({name = "mineable-wreckage", position = tile.position})
end
if math_random(1, 256) == 1 then
surface.create_entity({name = "rock-huge", position = tile.position})
end
end
if room.center then
if math_random(1, 16) == 1 then
for x = -1, 1, 1 do
for y = -1, 1, 1 do
local p = {room.center.x + x, room.center.y + y}
surface.set_tiles({{name = "water", position = p}})
if math_random(1, 4) == 1 then
surface.create_entity({name = "fish", position = p})
end
end
end
else
if math_random(1, 16) == 1 then
surface.create_entity({name = "crude-oil", position = room.center, amount = math_random(200000, 400000)})
end
if math_random(1, 2) == 1 then
surface.create_entity({name = "biter-spawner", position = room.center})
end
end
end
end
return dirtlands

View File

@ -0,0 +1,70 @@
local table_shuffle_table = table.shuffle_table
local table_insert = table.insert
local table_remove = table.remove
local math_random = math.random
local math_abs = math.abs
local ores = {"iron-ore", "iron-ore", "iron-ore", "iron-ore", "copper-ore", "copper-ore", "copper-ore","coal", "coal", "stone", "stone","uranium-ore"}
local worms = {}
for _ = 1, 64, 1 do table_insert(worms, "small") end
for _ = 1, 8, 1 do table_insert(worms, "medium") end
for _ = 1, 4, 1 do table_insert(worms, "big") end
for _ = 1, 1, 1 do table_insert(worms, "behemoth") end
local size_of_worms = #worms
local function grasslands(surface, room)
for _, tile in pairs(room.path_tiles) do
surface.set_tiles({{name = "lab-white", position = tile.position}}, true)
end
if not room.room_border_tiles[1] then return end
table_shuffle_table(room.room_border_tiles)
for key, tile in pairs(room.room_border_tiles) do
surface.set_tiles({{name = "lab-dark-2", position = tile.position}}, true)
if key < 7 then
surface.create_entity({name = "rock-big", position = tile.position})
end
end
table_shuffle_table(room.room_tiles)
for key, tile in pairs(room.room_tiles) do
surface.set_tiles({{name = "lab-dark-1", position = tile.position}}, true)
if math_random(1, 8) == 1 then
surface.create_entity({name = ores[math_random(1, #ores)], position = tile.position, amount = math_random(100, 20000)})
end
if key % 32 == 0 and math_random(1, 2) == 1 then
surface.create_entity({name = "biter-spawner", position = tile.position})
end
if math_random(1, 64) == 1 then
local turret_name = worms[math_random(1, size_of_worms)] .. "-worm-turret"
surface.create_entity({name = turret_name, position = tile.position})
end
if math_random(1, 2048) == 1 then
surface.create_entity({name = "rock-huge", position = tile.position})
end
end
if room.center then
if math_random(1, 16) == 1 then
for x = -1, 1, 1 do
for y = -1, 1, 1 do
local p = {room.center.x + x, room.center.y + y}
surface.set_tiles({{name = "water", position = p}})
if math_random(1, 4) == 1 then
surface.create_entity({name = "fish", position = p})
end
end
end
else
if math_random(1, 8) == 1 then
surface.create_entity({name = "crude-oil", position = room.center, amount = math_random(200000, 400000)})
end
if math_random(1, 2) == 1 then
surface.create_entity({name = "biter-spawner", position = room.center})
end
end
end
end
return grasslands

View File

@ -0,0 +1,74 @@
local table_shuffle_table = table.shuffle_table
local table_insert = table.insert
local table_remove = table.remove
local math_random = math.random
local math_abs = math.abs
local math_sqrt = math.sqrt
local ores = {"iron-ore", "iron-ore", "iron-ore", "iron-ore", "copper-ore", "copper-ore", "copper-ore","coal", "coal", "stone", "stone"}
local trees = {"tree-01", "tree-02", "tree-03", "tree-04", "tree-05"}
local size_of_trees = #trees
local worms = {}
for _ = 1, 64, 1 do table_insert(worms, "small") end
for _ = 1, 8, 1 do table_insert(worms, "medium") end
for _ = 1, 4, 1 do table_insert(worms, "big") end
for _ = 1, 1, 1 do table_insert(worms, "behemoth") end
local size_of_worms = #worms
local function grasslands(surface, room)
for _, tile in pairs(room.path_tiles) do
surface.set_tiles({{name = "grass-1", position = tile.position}}, true)
end
if #room.room_border_tiles > 1 then table_shuffle_table(room.room_border_tiles) end
for key, tile in pairs(room.room_border_tiles) do
surface.set_tiles({{name = "grass-3", position = tile.position}}, true)
if key < 9 then
surface.create_entity({name = "rock-big", position = tile.position})
else
if math_random(1, 8) == 1 then
surface.create_entity({name = trees[math_random(1, size_of_trees)], position = tile.position})
end
end
end
if #room.room_tiles > 1 then table_shuffle_table(room.room_tiles) end
for key, tile in pairs(room.room_tiles) do
surface.set_tiles({{name = "grass-2", position = tile.position}}, true)
if math_random(1, 64) == 1 then
surface.create_entity({name = ores[math_random(1, #ores)], position = tile.position, amount = math_random(100, 20000)})
else
if math_random(1, 24) == 1 then
surface.create_entity({name = trees[math_random(1, size_of_trees)], position = tile.position})
end
end
if math_random(1, 320) == 1 then
local turret_name = worms[math_random(1, size_of_worms)] .. "-worm-turret"
surface.create_entity({name = turret_name, position = tile.position})
end
if math_random(1, 1024) == 1 then
surface.create_entity({name = "rock-huge", position = tile.position})
end
end
if room.center then
if math_random(1, 7) == 1 then
local r = math_floor(math_sqrt(#room.room_tiles)) + 1
for x = r * -1, r, 1 do
for y = r * -1, r, 1 do
local p = {room.center.x + x, room.center.y + y}
surface.set_tiles({{name = "water", position = p}})
if math_random(1, 4) == 1 then
surface.create_entity({name = "fish", position = p})
end
end
end
else
if math_random(1, 2) == 1 then
surface.create_entity({name = "biter-spawner", position = room.center})
end
end
end
end
return grasslands

View File

@ -1,33 +1,28 @@
--lost-- mewmew made this --
-- Deep dark dungeons by mewmew --
local Rooms = require "functions.random_room"
require "modules.mineable_wreckage_yields_scrap"
local Room_generator = require "functions.room_generator"
local Biomes = {}
Biomes.dirtlands = require "maps.dungeons.biome_dirtlands"
Biomes.grasslands = require "maps.dungeons.biome_grasslands"
Biomes.glitch = require "maps.dungeons.biome_glitch"
local Get_noise = require "utils.get_noise"
local table_shuffle_table = table.shuffle_table
local table_insert = table.insert
local table_remove = table.remove
local math_random = math.random
local math_abs = math.abs
local ores = {"iron-ore", "iron-ore", "iron-ore", "iron-ore", "copper-ore", "copper-ore", "copper-ore","coal", "coal","stone", "stone","uranium-ore"}
local trees = {"dead-dry-hairy-tree", "dead-grey-trunk", "dead-tree-desert", "dry-hairy-tree", "dry-tree"}
local size_of_trees = #trees
local tile_sets = {
{"dirt-3", "dirt-7", "dirt-5"},
{"dirt-3", "dirt-7", "dirt-5"},
{"dirt-3", "dirt-7", "dirt-5"},
{"dirt-3", "dirt-7", "dirt-5"},
{"dirt-3", "dirt-7", "dirt-5"},
{"dirt-3", "dirt-7", "dirt-5"},
{"dirt-3", "dirt-7", "dirt-5"},
{"lab-white", "lab-dark-2", "lab-dark-1"},
{"red-desert-1", "red-desert-3", "red-desert-2"},
{"grass-1", "grass-3", "grass-2"},
{"sand-2", "sand-1", "sand-3"},
{"concrete", "refined-concrete", "stone-path"},
}
local size_of_tile_sets = #tile_sets
local disabled_for_deconstruction = {
["fish"] = true,
@ -37,60 +32,24 @@ local disabled_for_deconstruction = {
["mineable-wreckage"] = true
}
local function expand(surface, room)
local tile_set = tile_sets[math_random(1, size_of_tile_sets)]
local function get_biome(position)
local seed = game.surfaces[1].map_gen_settings.seed
local seed_addition = 100000
for _, tile in pairs(room.path_tiles) do
surface.set_tiles({{name = tile_set[1], position = tile.position}}, true)
end
if Get_noise("cave_ponds", position, seed + seed_addition) > 0.25 then return "grasslands" end
if Get_noise("cave_ponds", position, seed + seed_addition * 2) > 0.5 then return "glitch" end
if #room.room_border_tiles > 1 then table_shuffle_table(room.room_border_tiles) end
for key, tile in pairs(room.room_border_tiles) do
surface.set_tiles({{name = tile_set[2], position = tile.position}}, true)
if key < 5 then
surface.create_entity({name = "rock-big", position = tile.position})
end
end
return "dirtlands"
end
local function expand(surface, position)
local room = Room_generator.get_room(surface, position)
if not room then return end
local name = get_biome(position)
Biomes[name](surface, room)
if #room.room_tiles > 1 then table_shuffle_table(room.room_tiles) end
for key, tile in pairs(room.room_tiles) do
surface.set_tiles({{name = tile_set[3], position = tile.position}}, true)
if math_random(1, 64) == 1 then
surface.create_entity({name = ores[math_random(1, #ores)], position = tile.position, amount = math_random(100, 20000)})
else
if math_random(1, 128) == 1 then
surface.create_entity({name = trees[math_random(1, size_of_trees)], position = tile.position})
end
end
if key % 128 == 1 and math_random(1, 2) == 1 then
surface.create_entity({name = "biter-spawner", position = tile.position})
end
if key % 128 == 1 and math_random(1, 3) == 1 then
surface.create_entity({name = "small-worm-turret", position = tile.position})
end
if math_random(1, 64) == 1 then
surface.create_entity({name = "mineable-wreckage", position = tile.position})
end
if math_random(1, 256) == 1 then
surface.create_entity({name = "rock-huge", position = tile.position})
end
end
if room.center then
if math_random(1, 16) == 1 then
for x = -1, 1, 1 do
for y = -1, 1, 1 do
local p = {room.center.x + x, room.center.y + y}
surface.set_tiles({{name = "water", position = p}})
surface.create_entity({name = "fish", position = p})
end
end
else
if math_random(1, 16) == 1 then
surface.create_entity({name = "crude-oil", position = room.center, amount = math_random(200000, 400000)})
end
end
end
if not room.room_tiles[1] then return end
global.dungeons.depth = global.dungeons.depth + 1
end
local function on_chunk_generated(event)
@ -105,6 +64,14 @@ local function on_chunk_generated(event)
if math_abs(position.x) > 2 or math_abs(position.y) > 2 then
tiles[i] = {name = "out-of-map", position = position}
i = i + 1
else
if math_abs(position.x) > 1 or math_abs(position.y) > 1 then
tiles[i] = {name = "black-refined-concrete", position = position}
i = i + 1
else
tiles[i] = {name = "purple-refined-concrete", position = position}
i = i + 1
end
end
end
end
@ -129,16 +96,9 @@ end
local function on_player_mined_entity(event)
local entity = event.entity
if not entity.valid then return end
if not entity.valid then return end
if entity.name ~= "rock-big" then return end
local surface = entity.surface
local room = Rooms.get_room(surface, entity.position)
if room then
expand(surface, room)
end
expand(entity.surface, entity.position)
end
local function on_marked_for_deconstruction(event)
@ -173,9 +133,10 @@ local function on_init()
surface.delete_chunk({chunk.x, chunk.y})
end
--game.forces.player.manual_mining_speed_modifier = 10
game.forces.player.manual_mining_speed_modifier = 20
global.terrain_work = {}
global.dungeons = {}
global.dungeons.depth = 0
end
local Event = require 'utils.event'