1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-04 00:15:45 +02:00

lost_desert update

This commit is contained in:
MewMew 2018-10-17 02:27:24 +02:00
parent 7ac8546e15
commit 79d013e9b1
5 changed files with 116 additions and 119 deletions

View File

@ -12,9 +12,9 @@ require "score"
---- enable maps here ----
--require "maps.biter_battles"
require "maps.cave_miner"
--require "maps.cave_miner"
--require "maps.deep_jungle"
--require "maps.lost_desert"
require "maps.lost_desert"
--require "maps.labyrinth"
--require "maps.spaghettorio"
--require "maps.spiral_troopers"

View File

@ -1,36 +1,27 @@
--lost desert-- mewmew made this --
local chunk_loader = require "maps.tools.lazy_chunk_loader"
local simplex_noise = require 'utils.simplex_noise'
simplex_noise = simplex_noise.d2
local event = require 'utils.event'
local event = require 'utils.event'
local map_functions = require "maps.tools.map_functions"
local math_random = math.random
require "maps.tools.map_pregen"
local function shipwreck(position, surface)
local wrecks = {"big-ship-wreck-1", "big-ship-wreck-2", "big-ship-wreck-3"}
local wreck = wrecks[math.random(1,#wrecks)]
local p = game.surfaces[1].find_non_colliding_position(wreck,position, 2,0.5)
if not p then return end
local wreck_raffle_table = {}
local wreck_loot_weights = {}
table.insert(wreck_loot_weights, {{name = 'iron-gear-wheel', count = math.random(16,48)},5})
table.insert(wreck_loot_weights, {{name = 'burner-inserter', count = math.random(16,32)},2})
table.insert(wreck_loot_weights, {{name = 'engine-unit', count = math.random(1,16)},3})
table.insert(wreck_loot_weights, {{name = 'rocket-fuel', count = math.random(1,5)},3})
table.insert(wreck_loot_weights, {{name = 'lubricant-barrel', count = math.random(1,10)},3})
table.insert(wreck_loot_weights, {{name = 'crude-oil-barrel', count = math.random(1,10)},3})
local wreck_loot_weights = {}
table.insert(wreck_loot_weights, {{name = "firearm-magazine", count = math.random(64,128)},8})
table.insert(wreck_loot_weights, {{name = 'grenade', count = math.random(16,32)},5})
table.insert(wreck_loot_weights, {{name = 'land-mine', count = math.random(16,32)},5})
table.insert(wreck_loot_weights, {{name = 'light-armor', count = 1},1})
table.insert(wreck_loot_weights, {{name = 'heavy-armor', count = 1},2})
table.insert(wreck_loot_weights, {{name = 'pipe', count = math.random(10,100)},3})
table.insert(wreck_loot_weights, {{name = 'rail', count = math.random(32,100)},4})
table.insert(wreck_loot_weights, {{name = 'assembling-machine-1', count = math.random(1,4)},2})
table.insert(wreck_loot_weights, {{name = 'assembling-machine-2', count = math.random(1,3)},2})
table.insert(wreck_loot_weights, {{name = 'assembling-machine-3', count = math.random(1,2)},1})
table.insert(wreck_loot_weights, {{name = 'combat-shotgun', count = 1},4})
table.insert(wreck_loot_weights, {{name = 'combat-shotgun', count = 1},3})
table.insert(wreck_loot_weights, {{name = 'piercing-shotgun-shell', count = math.random(16,48)},5})
table.insert(wreck_loot_weights, {{name = 'flamethrower', count = 1},4})
table.insert(wreck_loot_weights, {{name = 'flamethrower', count = 1},3})
table.insert(wreck_loot_weights, {{name = 'rocket-launcher', count = 1},4})
table.insert(wreck_loot_weights, {{name = 'flamethrower-ammo', count = math.random(16,48)},5})
table.insert(wreck_loot_weights, {{name = 'rocket', count = math.random(16,48)},5})
@ -51,7 +42,7 @@ local function shipwreck(position, surface)
table.insert(wreck_raffle_table, t[1])
end
end
local e = surface.create_entity {name=wreck, position=p, force="player"}
local e = surface.create_entity {name=wreck, position=position, force="player"}
e.minable = false
local i = e.get_inventory(defines.inventory.chest)
for x = 1, math.random(2,3), 1 do
@ -69,46 +60,21 @@ local function shuffle(tbl)
return tbl
end
local function create_cluster(name, pos, size, surface, spread, resource_amount)
local p = {x = pos.x, y = pos.y}
local math_random = math.random
for z = 1, size, 1 do
for x = 1, 8, 1 do
local y = 1
if spread then y = math_random(1, spread) end
local modifier_raffle = {{0,y*-1},{y*-1,0},{y,0},{0,y},{y*-1,y*-1},{y,y},{y,y*-1},{y*-1,y}}
modifier_raffle = shuffle(modifier_raffle)
local m = modifier_raffle[x]
local pos = {x = p.x + m[1], y = p.y + m[2]}
if resource_amount then
surface.create_entity {name=name, position=pos, amount=resource_amount}
p = {x = pos.x, y = pos.y}
break
else
if surface.can_place_entity({name=name, position=pos}) then
surface.create_entity {name=name, position=pos}
p = {x = pos.x, y = pos.y}
break
end
end
end
end
end
local function get_noise(name, pos)
local seed = game.surfaces[1].map_gen_settings.seed
local noise = {}
local noise_seed_add = 25000
seed = seed + noise_seed_add
if name == 1 then
noise[1] = simplex_noise(pos.x * 0.001, pos.y * 0.001, seed)
if name == 1 then
local m = 2
noise[1] = simplex_noise(pos.x * 0.001 * m, pos.y * 0.001 * m, seed)
seed = seed + noise_seed_add
noise[2] = simplex_noise(pos.x * 0.01, pos.y * 0.01, seed)
noise[2] = simplex_noise(pos.x * 0.01 * m, pos.y * 0.01 * m, seed)
seed = seed + noise_seed_add
noise[3] = simplex_noise(pos.x * 0.05, pos.y * 0.05, seed)
noise[3] = simplex_noise(pos.x * 0.05 * m, pos.y * 0.05 * m, seed)
seed = seed + noise_seed_add
noise[4] = simplex_noise(pos.x * 0.1, pos.y * 0.1, seed)
local noise = noise[1] + noise[2] * 0.15 + noise[3] * 0.02 + noise[4] * 0.001
noise[4] = simplex_noise(pos.x * 0.1 * m, pos.y * 0.1 * m, seed)
local noise = noise[1] + noise[2] * 0.05 + noise[3] * 0.02 + noise[4] * 0.001
return noise
end
seed = seed + noise_seed_add
@ -151,15 +117,14 @@ local worm_raffle = {"small-worm-turret", "small-worm-turret", "small-worm-turre
local rock_raffle = {"sand-rock-big","sand-rock-big","rock-big","rock-big","rock-big","rock-big","rock-huge"}
local ore_spawn_raffle = {"iron-ore","iron-ore","iron-ore","copper-ore","copper-ore","copper-ore","coal","coal","stone","stone","uranium-ore","crude-oil"}
chunk_loader.add(function(chunk_piece)
local surface = game.surfaces["lost_desert"]
if chunk_piece[2] ~= surface.index then return end
local chunk_piece_position = chunk_piece[1]
local chunk_pos_x = chunk_piece_position.x
local chunk_pos_y = chunk_piece_position.y
local function on_chunk_generated(event)
local surface = game.surfaces["lost_desert"]
if event.surface.name ~= surface.name then return end
local chunk_pos_x = event.area.left_top.x
local chunk_pos_y = event.area.left_top.y
local area = {
left_top = {x = chunk_piece_position.x, y = chunk_piece_position.y},
right_bottom = {x = chunk_piece_position.x + 8, y = chunk_piece_position.y + 8}
left_top = {x = chunk_pos_x, y = chunk_pos_y},
right_bottom = {x = chunk_pos_x + 31, y = chunk_pos_y + 31}
}
local tiles = {}
local entities_to_place = {
@ -170,18 +135,21 @@ chunk_loader.add(function(chunk_piece)
fish = {},
shipwrecks = {}
}
local decoratives = {}
local math_random = math.random
surface.destroy_decoratives(area)
local decoratives = {}
local entities = surface.find_entities(area)
for _, e in pairs(entities) do
if e.type == "tree" or e.force.name == "enemy" then
--e.destroy()
e.destroy()
end
end
end
local sands = {"sand-1", "sand-2", "sand-3"}
local tile_to_insert = false
for x = 0, 7, 1 do
for y = 0, 7, 1 do
for x = 0, 31, 1 do
for y = 0, 31, 1 do
local pos_x = chunk_pos_x + x
local pos_y = chunk_pos_y + y
local pos = {x = pos_x, y = pos_y}
@ -189,10 +157,10 @@ chunk_loader.add(function(chunk_piece)
tile_to_insert = false
local noise_1 = get_noise(1, pos)
if tile_distance_to_center > 10000 then
if noise_1 <= -0.9 then
if noise_1 <= -0.80 then
if math_random(1,250) == 1 then table.insert(entities_to_place.shipwrecks, pos) end
end
if noise_1 <= -0.85 then
if noise_1 <= -0.75 then
if math_random(1,16) == 1 then table.insert(entities_to_place.worms, pos) end
if math_random(1,16) == 1 then table.insert(entities_to_place.enemy_buildings, pos) end
end
@ -201,7 +169,18 @@ chunk_loader.add(function(chunk_piece)
if noise_1 > -0.4 then tile_to_insert = "sand-1" end
if noise_1 > 0.4 then tile_to_insert = "sand-3" end
if noise_1 > 0.72 and noise_1 < 0.8 then if math_random(1,3) == 1 then table.insert(decoratives, {name = "garballo", position = pos, amount = math_random(1,3)}) end end
if noise_1 > 0.75 then if math_random(1,5) == 1 then table.insert(entities_to_place.trees, {"tree-05", pos}) end end
if noise_1 > 0.75 then
if math_random(1,5) == 1 then table.insert(entities_to_place.trees, {"tree-05", pos}) end
if math_random(1,400) == 1 then
if surface.count_entities_filtered({name = "market", area = {{pos.x - 50, pos.y - 50}, {pos.x + 50, pos.y + 50}}, limit = 1}) < 1 then
if surface.can_place_entity {name = "market", position = pos} then
local market = surface.create_entity {name = "market", position = pos}
market.destructible = false
market.add_market_item({price = {{"raw-wood", math.random(2,10)}}, offer = {type = 'give-item', item = 'raw-fish'}})
end
end
end
end
if noise_1 > 0.8 then
tile_to_insert = "water"
if math_random(1,32) == 1 then table.insert(entities_to_place.fish, pos) end
@ -209,17 +188,14 @@ chunk_loader.add(function(chunk_piece)
if noise_1 > 0.9 then tile_to_insert = "deepwater" end
if tile_to_insert ~= "deepwater" and tile_to_insert ~= "water" and noise_1 < 0.7 then
if math_random(1,20000) == 1 and noise_1 < 0.65 then
local spread = 1
local amount = math_random(400,600)
local size = math.ceil(math.sqrt(tile_distance_to_center),0)
if math_random(1, 15000) == 1 and noise_1 < 0.65 then
local ore = ore_spawn_raffle[math_random(1,#ore_spawn_raffle)]
if ore == "crude-oil" then
spread = 10
amount = 100000 + math_random(tile_distance_to_center,tile_distance_to_center*2)
size = math_random(4,16)
end
create_cluster(ore, pos, size, surface, spread, amount)
map_functions.draw_oil_circle(pos, ore, surface, math_random(4,12), amount)
else
map_functions.draw_crazy_smoothed_out_ore_circle(pos, ore, surface, math_random(10,70), math_random(300,400) + math.sqrt(tile_distance_to_center))
end
end
local noise_dead_trees = get_noise("dead_trees", pos)
local noise_rocks_1 = get_noise("rocks_1", pos)
@ -234,7 +210,7 @@ chunk_loader.add(function(chunk_piece)
if noise_rocks_1 > 0.55 then
if math_random(1,6) == 1 then table.insert(entities_to_place.rocks, pos) end
end
tile_to_insert = "dirt-1"
--tile_to_insert = "dirt-1"
end
if noise_deco_1 > 0.75 then
if math_random(1,7) == 1 then table.insert(decoratives, {name = "brown-fluff-dry", position = pos, amount = math_random(1,3)}) end
@ -261,11 +237,12 @@ chunk_loader.add(function(chunk_piece)
if tile_to_insert == false then
--table.insert(tiles, {name = "sand-4", position = {pos_x,pos_y}}) tree-06
else
table.insert(tiles, {name = tile_to_insert, position = {pos_x,pos_y}})
table.insert(tiles, {name = tile_to_insert, position = pos})
end
end
end
surface.set_tiles(tiles,true)
surface.create_decoratives{check_collision=false, decoratives=decoratives}
for _, p in pairs(entities_to_place.shipwrecks) do
@ -292,9 +269,17 @@ chunk_loader.add(function(chunk_piece)
for _, p in pairs(entities_to_place.fish) do
surface.create_entity {name="fish",position=p}
end
return true
if not global.lost_desert_spawn_ores then
if chunk_pos_x > 96 then
map_functions.draw_smoothed_out_ore_circle({x=0, y=20}, "stone", surface , 14, 500)
map_functions.draw_smoothed_out_ore_circle({x=0, y=-20}, "coal", surface , 14, 500)
map_functions.draw_smoothed_out_ore_circle({x=-20, y=0}, "iron-ore", surface , 14, 500)
map_functions.draw_smoothed_out_ore_circle({x=20, y=0}, "copper-ore", surface , 14, 500)
global.lost_desert_spawn_ores = true
end
end
end
)
local function on_player_joined_game(event)
local player = game.players[event.player_index]
@ -303,27 +288,25 @@ local function on_player_joined_game(event)
map_gen_settings.water = "none"
map_gen_settings.cliff_settings = {cliff_elevation_interval = 20, cliff_elevation_0 = 20}
map_gen_settings.autoplace_controls = {
["coal"] = {frequency = "very-low", size = "normal", richness = "normal"},
["stone"] = {frequency = "very-low", size = "normal", richness = "normal"},
["copper-ore"] = {frequency = "very-low", size = "normal", richness = "normal"},
["iron-ore"] = {frequency = "very-low", size = "normal", richness = "normal"},
["crude-oil"] = {frequency = "very-low", size = "normal", richness = "normal"},
["coal"] = {frequency = "none", size = "none", richness = "none"},
["stone"] = {frequency = "none", size = "none", richness = "none"},
["copper-ore"] = {frequency = "none", size = "none", richness = "none"},
["uranium-ore"] = {frequency = "none", size = "none", richness = "none"},
["iron-ore"] = {frequency = "none", size = "none", richness = "none"},
["crude-oil"] = {frequency = "none", size = "none", richness = "none"},
["trees"] = {frequency = "none", size = "none", richness = "none"},
["enemy-base"] = {frequency = "very-low", size = "small", richness = "none"},
["enemy-base"] = {frequency = "none", size = "none", richness = "none"},
["grass"] = {frequency = "none", size = "none", richness = "none"},
["sand"] = {frequency = "none", size = "none", richness = "none"},
["desert"] = {frequency = "none", size = "none", richness = "none"},
["dirt"] = {frequency = "none", size = "none", richness = "none"}
["dirt"] = {frequency = "normal", size = "normal", richness = "normal"}
}
game.map_settings.pollution.pollution_restored_per_tree_damage = 0
game.create_surface("lost_desert", map_gen_settings)
game.forces["player"].set_spawn_position({0,0},game.surfaces["lost_desert"])
local surface = game.surfaces["lost_desert"]
create_cluster("stone", {x=-30,y=30}, 1500, surface, 1, math.random(400,600))
create_cluster("copper-ore", {x=30,y=30}, 1500, surface, 1, math.random(400,600))
create_cluster("coal", {x=30,y=-30}, 1500, surface, 1, math.random(400,600))
create_cluster("iron-ore", {x=-30,y=-30}, 1500, surface, 1, math.random(400,600))
create_cluster("crude-oil", {x=0,y=0}, 5, surface, 10, math.random(300000,400000))
--create_cluster("crude-oil", {x=0,y=0}, 5, surface, 10, math.random(300000,400000))
global.map_init_done = true
end
local surface = game.surfaces["lost_desert"]
@ -340,26 +323,7 @@ local function on_player_joined_game(event)
player.insert {name = 'light-armor', count = 1}
end
end
function cheat_mode()
local cheat_mode_enabed = false
if cheat_mode_enabed == true then
local surface = game.surfaces["lost_desert"]
game.player.cheat_mode=true
game.players[1].insert({name="power-armor-mk2"})
game.players[1].insert({name="fusion-reactor-equipment", count=4})
game.players[1].insert({name="personal-laser-defense-equipment", count=8})
game.players[1].insert({name="rocket-launcher"})
game.players[1].insert({name="explosive-rocket", count=200})
game.speed = 2
surface.daytime = 1
game.player.force.research_all_technologies()
game.forces["enemy"].evolution_factor = 0.2
local chart = 300
local surface = game.surfaces["lost_desert"]
game.forces["player"].chart(surface, {lefttop = {x = chart*-1, y = chart*-1}, rightbottom = {x = chart, y = chart}})
end
end
event.add(defines.events.on_chunk_generated, on_chunk_generated)
event.add(defines.events.on_marked_for_deconstruction, on_marked_for_deconstruction)
event.add(defines.events.on_player_joined_game, on_player_joined_game)

View File

@ -319,7 +319,7 @@ local function grow_level()
local pos = {x = reward_chunk.x * 32 + x, y = reward_chunk.y * 32 + y}
if x == 16 and y == 16 then
local ore = ore_rotation[current_growth_direction]
if global.spiral_troopers_level % 11 == 0 then ore = "uranium-ore" end
if global.spiral_troopers_level % 12 == 0 then ore = "uranium-ore" end
map_functions.draw_smoothed_out_ore_circle(pos, ore, surface, 14, 400 * global.spiral_troopers_level)
local unlocker = surface.create_entity({name = "burner-inserter", position = pos, force = "player"})
unlocker.destructible = false

View File

@ -44,9 +44,9 @@ f.draw_smoothed_out_ore_circle = function(position, name, surface, radius, richn
for y = radius*-1, radius, 1 do
for x = radius*-1, radius, 1 do
local pos = {x = x + position.x, y = y + position.y}
local noise_1 = simplex_noise(pos.x * 0.05, pos.y * 0.05, seed)
local noise_1 = simplex_noise(pos.x * 0.08, pos.y * 0.08, seed)
seed = seed + noise_seed_add
local noise_2 = simplex_noise(pos.x * 0.1, pos.y * 0.1, seed)
local noise_2 = simplex_noise(pos.x * 0.15, pos.y * 0.15, seed)
local noise = noise_1 + noise_2 * 0.2
local distance_to_center = math.sqrt(x^2 + y^2)
local a = richness - richness_part * distance_to_center
@ -59,6 +59,34 @@ f.draw_smoothed_out_ore_circle = function(position, name, surface, radius, richn
end
end
f.draw_crazy_smoothed_out_ore_circle = function(position, name, surface, radius, richness)
if not position then return end
if not name then return end
if not surface then return end
if not radius then return end
if not richness then return end
local math_random = math.random
local noise_seed_add = 25000
local richness_part = richness / radius
for y = radius*-1, radius, 1 do
for x = radius*-1, radius, 1 do
local pos = {x = x + position.x, y = y + position.y}
local seed = game.surfaces[1].map_gen_settings.seed
local noise_1 = simplex_noise(pos.x * 0.02, pos.y * 0.02, seed)
seed = seed + noise_seed_add
local noise_2 = simplex_noise(pos.x * 0.2, pos.y * 0.2, seed)
local noise = noise_1 + noise_2 * 0.2
local distance_to_center = math.sqrt(x^2 + y^2)
local a = richness - richness_part * distance_to_center
if distance_to_center < radius * noise and a > 1 then
if surface.can_place_entity({name = name, position = pos, amount = a}) then
surface.create_entity{name = name, position = pos, amount = a}
end
end
end
end
end
f.create_cluster = function(name, pos, size, surface, spread, resource_amount)
local p = {x = pos.x, y = pos.y}
local math_random = math.random

View File

@ -4,11 +4,11 @@ local function on_tick(event)
if global.map_pregeneration_is_active then
if game.tick % 600 == 0 then
local r = 1
for x = 1,40,1 do
for x = 1, global.chunk_radius, 1 do
if game.forces.map_pregen.is_chunk_charted(game.players[1].surface, {x,x}) then r = x end
end
game.print("Map chunks are generating... current radius " .. r, { r=0.22, g=0.99, b=0.99})
if game.forces.map_pregen.is_chunk_charted(game.players[1].surface, {40,40}) then
if game.forces.map_pregen.is_chunk_charted(game.players[1].surface, {global.chunk_radius, global.chunk_radius}) then
game.print("Map generation done!", {r=0.22, g=0.99, b=0.99})
game.players[1].force = game.forces["player"]
@ -18,8 +18,13 @@ local function on_tick(event)
end
end
function map_pregen()
local radius = 1280
function map_pregen(chunk_radius)
if chunk_radius then
global.chunk_radius = chunk_radius
else
global.chunk_radius = 32
end
local radius = global.chunk_radius * 32
if not game.forces.map_pregen then game.create_force("map_pregen") end
game.players[1].force = game.forces["map_pregen"]
game.forces.map_pregen.chart(game.players[1].surface,{{x = -1 * radius, y = -1 * radius}, {x = radius, y = radius}})