mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-03-07 15:11:02 +02:00
New Map Spaghettorio
This commit is contained in:
parent
ee2fbf8288
commit
29a33e578f
@ -14,8 +14,10 @@ require "score"
|
||||
--require "maps.cave_miner"
|
||||
--require "maps.deep_jungle"
|
||||
--require "maps.lost_desert"
|
||||
require "maps.labyrinth"
|
||||
--require "maps.labyrinth"
|
||||
require "maps.spaghettorio"
|
||||
-----------------------------
|
||||
--require "maps.tools.cheat_mode"
|
||||
|
||||
local Event = require 'utils.event'
|
||||
|
||||
|
@ -99,7 +99,7 @@ worm_raffle[7] = {"medium-worm-turret", "medium-worm-turret", "medium-worm-turre
|
||||
worm_raffle[8] = {"medium-worm-turret", "medium-worm-turret", "medium-worm-turret", "medium-worm-turret", "big-worm-turret", "big-worm-turret"}
|
||||
worm_raffle[9] = {"medium-worm-turret", "medium-worm-turret", "medium-worm-turret", "big-worm-turret", "big-worm-turret", "big-worm-turret"}
|
||||
worm_raffle[10] = {"medium-worm-turret", "medium-worm-turret", "medium-worm-turret", "big-worm-turret", "big-worm-turret", "big-worm-turret"}
|
||||
local rock_raffle = {"sand-rock-big","sand-rock-big","sand-rock-big","rock-big","rock-big","rock-big","rock-big","rock-big","rock-big","rock-big","rock-big","rock-huge"}
|
||||
local rock_raffle = {"sand-rock-big","sand-rock-big","sand-rock-big","rock-big","rock-big","rock-big","rock-big","rock-big","rock-big","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"}
|
||||
local room_layouts = {"quad_rocks", "single_center_rock", "three_horizontal_rocks", "three_vertical_rocks", "tree_and_lake", "forest", "forest_fence"}
|
||||
local biter_raffle = {
|
||||
@ -215,7 +215,7 @@ local function grow_cell(chunk_position, surface)
|
||||
local enemies = room_enemies[math_random(1,#room_enemies)]
|
||||
|
||||
local unique_room = true
|
||||
if global.labyrinth_size > 12 and math_random(1,44) == 1 then
|
||||
if global.labyrinth_size > 12 and math_random(1,50) == 1 then
|
||||
layout = nil
|
||||
enemies = nil
|
||||
unique_room = unique_room_raffle[math_random(1,#unique_room_raffle)]
|
||||
@ -1020,33 +1020,7 @@ function dump_layout()
|
||||
str = str .. t.name
|
||||
str = str .. '"},'
|
||||
game.write_file("layout.lua", str .. '\n' , true)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function cheat_mode()
|
||||
local cheat_mode_enabed = false
|
||||
if cheat_mode_enabed == true then
|
||||
local surface = game.surfaces["labyrinth"]
|
||||
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.players[1].insert({name="loader"})
|
||||
game.players[1].insert({name="fast-loader"})
|
||||
game.players[1].insert({name="express-loader"})
|
||||
game.players[1].insert({name="infinity-chest"})
|
||||
game.speed = 3
|
||||
surface.daytime = 1
|
||||
surface.freeze_daytime = 1
|
||||
game.player.force.research_all_technologies()
|
||||
--game.forces["enemy"].evolution_factor = 0.2
|
||||
local chart = 500
|
||||
local surface = game.surfaces["labyrinth"]
|
||||
game.forces["player"].chart(surface, {lefttop = {x = chart*-1, y = chart*-1}, rightbottom = {x = chart, y = chart}})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
event.add(defines.events.on_robot_built_entity, on_robot_built_entity)
|
||||
|
@ -1,104 +1,173 @@
|
||||
--spaghettorio-- mewmew made this -- inspired by redlabel
|
||||
|
||||
require "maps.spaghettorio_map_intro"
|
||||
local simplex_noise = require 'utils.simplex_noise'
|
||||
simplex_noise = simplex_noise.d2
|
||||
local event = require 'utils.event'
|
||||
require "maps.tools.map_pregen"
|
||||
|
||||
local function disable_recipes()
|
||||
game.forces.player.recipes["splitter"].enabled = false
|
||||
game.forces.player.recipes["fast-splitter"].enabled = false
|
||||
game.forces.player.recipes["express-splitter"].enabled = false
|
||||
game.forces.player.recipes["steam-engine"].enabled = false
|
||||
game.forces.player.recipes["boiler"].enabled = false
|
||||
game.forces.player.recipes["assembling-machine-1"].enabled = false
|
||||
game.forces.player.recipes["assembling-machine-2"].enabled = false
|
||||
game.forces.player.recipes["assembling-machine-3"].enabled = false
|
||||
game.forces.player.recipes["steel-furnace"].enabled = false
|
||||
game.forces.player.recipes["chemical-plant"].enabled = false
|
||||
game.forces.player.recipes["centrifuge"].enabled = false
|
||||
game.forces.player.recipes["heat-exchanger"].enabled = false
|
||||
game.forces.player.recipes["steam-turbine"].enabled = false
|
||||
game.forces.player.recipes["oil-refinery"].enabled = false
|
||||
game.forces.player.recipes["lab"].enabled = false
|
||||
end
|
||||
|
||||
local function on_player_joined_game(event)
|
||||
local player = game.players[event.player_index]
|
||||
if not global.map_init_done then
|
||||
local map_gen_settings = {}
|
||||
map_gen_settings.water = "none"
|
||||
map_gen_settings.cliff_settings = {cliff_elevation_interval = 50, cliff_elevation_0 = 50}
|
||||
map_gen_settings.autoplace_controls = {
|
||||
["coal"] = {frequency = "none", size = "none", richness = "none"},
|
||||
["stone"] = {frequency = "none", size = "none", richness = "none"},
|
||||
["copper-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 = "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"}
|
||||
}
|
||||
game.map_settings.pollution.pollution_restored_per_tree_damage = 0
|
||||
map_gen_settings.water = "none"
|
||||
game.create_surface("spaghettorio", map_gen_settings)
|
||||
game.forces["player"].set_spawn_position({16,16},game.surfaces["spaghettorio"])
|
||||
local surface = game.surfaces["spaghettorio"]
|
||||
|
||||
if not global.spaghettorio_size then global.spaghettorio_size = 1 end
|
||||
game.forces["player"].set_spawn_position({0,0},game.surfaces["spaghettorio"])
|
||||
game.forces["player"].technologies["logistic-system"].enabled = false
|
||||
global.map_init_done = true
|
||||
end
|
||||
local surface = game.surfaces["spaghettorio"]
|
||||
if player.online_time < 5 and surface.is_chunk_generated({0,0}) then
|
||||
player.teleport(surface.find_non_colliding_position("player", {16,16}, 2, 1), "spaghettorio")
|
||||
player.teleport(surface.find_non_colliding_position("player", {0,0}, 2, 1), "spaghettorio")
|
||||
else
|
||||
if player.online_time < 5 then
|
||||
player.teleport({16,16}, "spaghettorio")
|
||||
player.teleport({0,0}, "spaghettorio")
|
||||
end
|
||||
end
|
||||
if player.online_time < 10 then
|
||||
player.insert {name = 'raw-fish', count = 3}
|
||||
player.insert {name = 'iron-axe', count = 1}
|
||||
player.insert {name = 'pistol', count = 1}
|
||||
player.insert {name = 'firearm-magazine', count = 32}
|
||||
end
|
||||
player.insert {name = 'iron-axe', count = 1}
|
||||
end
|
||||
disable_recipes()
|
||||
end
|
||||
|
||||
local function get_noise(name, pos)
|
||||
local seed = game.surfaces[1].map_gen_settings.seed
|
||||
local noise = {}
|
||||
local noise_seed_add = 25000
|
||||
if name == "water" then
|
||||
noise[1] = simplex_noise(pos.x * 0.002, pos.y * 0.002, seed)
|
||||
seed = seed + noise_seed_add
|
||||
noise[2] = simplex_noise(pos.x * 0.01, pos.y * 0.01, seed)
|
||||
seed = seed + noise_seed_add
|
||||
local noise = noise[1] + noise[2] * 0.2
|
||||
return noise
|
||||
end
|
||||
seed = seed + noise_seed_add
|
||||
if name == "assembly" then
|
||||
noise[1] = simplex_noise(pos.x * 0.004, pos.y * 0.004, seed)
|
||||
seed = seed + noise_seed_add
|
||||
local noise = noise[1]
|
||||
return noise
|
||||
end
|
||||
end
|
||||
|
||||
local splitter_raffle = {"splitter", "splitter", "splitter", "fast-splitter", "fast-splitter", "express-splitter"}
|
||||
local assembly_raffle = {"assembling-machine-1", "assembling-machine-2", "assembling-machine-1", "assembling-machine-2", "assembling-machine-3", "assembling-machine-1", "assembling-machine-2", "assembling-machine-1", "assembling-machine-2", "assembling-machine-3","chemical-plant", "chemical-plant", "chemical-plant", "oil-refinery", "lab"}
|
||||
local smelting_raffle = {"steel-furnace", "stone-furnace"}
|
||||
local steampower_raffle = {"steam-engine", "steam-engine", "boiler"}
|
||||
local nuclearpower_raffle = {"steam-turbine", "steam-turbine", "steam-turbine", "heat-exchanger", "heat-exchanger", "centrifuge"}
|
||||
local direction_raffle = {0,2,4,6}
|
||||
|
||||
local function on_chunk_generated(event)
|
||||
local surface = game.surfaces[1]
|
||||
if event.surface.name ~= surface then return end
|
||||
local surface = game.surfaces["spaghettorio"]
|
||||
if event.surface.name ~= surface.name then return end
|
||||
local entities = {}
|
||||
local tiles = {}
|
||||
local math_random = math.random
|
||||
|
||||
|
||||
end
|
||||
|
||||
---kyte
|
||||
local function on_player_rotated_entity(event)
|
||||
if event.entity.type ~= "loader" then return end
|
||||
local surface = game.surfaces[1]
|
||||
local tiles = {}
|
||||
if not global.trainpath_1 then
|
||||
if event.entity.position.x == 448.5 and event.entity.position.y == -191 then
|
||||
game.print("Trainpath to rewards of level 1 unlocked!")
|
||||
global.trainpath_1 = true
|
||||
for x = -11, 21, 1 do
|
||||
for y = -4, 0, 1 do
|
||||
table.insert(tiles, {name = "dirt-6", position = {x = event.entity.position.x + x, y = event.entity.position.y + y}})
|
||||
for x = 0, 31, 1 do
|
||||
for y = 0, 31, 1 do
|
||||
local pos = {x = event.area.left_top.x + x, y = event.area.left_top.y + y}
|
||||
local noise_water = get_noise("water", pos)
|
||||
local noise_assembly = get_noise("assembly", pos)
|
||||
while true do
|
||||
if noise_water > 0.8 or noise_water < -0.8 then
|
||||
table.insert(tiles, {name = "water", position = pos})
|
||||
break
|
||||
end
|
||||
end
|
||||
surface.set_tiles(tiles, true)
|
||||
if noise_water > 0.7 then
|
||||
if math_random(1,50) == 1 then
|
||||
local a = {
|
||||
left_top = {x = pos.x - 75, y = pos.y - 75},
|
||||
right_bottom = {x = pos.x + 75, y = pos.y + 75}
|
||||
}
|
||||
local z = surface.count_tiles_filtered{area = a, limit = 1, name = "water"}
|
||||
if z == 1 then table.insert(entities, {name = steampower_raffle[math_random(1, #steampower_raffle)], position = pos}) end
|
||||
end
|
||||
break
|
||||
end
|
||||
if noise_water < -0.7 then
|
||||
if math_random(1,100) == 1 then
|
||||
local a = {
|
||||
left_top = {x = pos.x - 75, y = pos.y - 75},
|
||||
right_bottom = {x = pos.x + 75, y = pos.y + 75}
|
||||
}
|
||||
local z = surface.count_tiles_filtered{area = a, limit = 1, name = "water"}
|
||||
if z == 1 then table.insert(entities, {name = nuclearpower_raffle[math_random(1, #nuclearpower_raffle)], position = pos}) end
|
||||
end
|
||||
break
|
||||
end
|
||||
if noise_assembly > 0.6 then
|
||||
if math_random(1,75) == 1 then
|
||||
table.insert(entities, {name = assembly_raffle[math_random(1, #assembly_raffle)], position = pos})
|
||||
end
|
||||
end
|
||||
if noise_assembly < -0.8 then
|
||||
if math_random(1,35) == 1 then
|
||||
table.insert(entities, {name = smelting_raffle[math_random(1, #smelting_raffle)], position = pos})
|
||||
end
|
||||
end
|
||||
if math_random(1,250) == 1 then
|
||||
if noise_assembly < -0.6 or noise_assembly > 0.6 or noise_water < -0.6 or noise_water > 0.6 then
|
||||
table.insert(entities, {name = splitter_raffle[math_random(1, #splitter_raffle)], position = pos})
|
||||
end
|
||||
end
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
surface.set_tiles(tiles, true)
|
||||
|
||||
for _, e in pairs(entities) do
|
||||
local d = direction_raffle[math_random(1, #direction_raffle)]
|
||||
if surface.can_place_entity({name = e.name, position = e.position, direction = d}) then
|
||||
local entity = surface.create_entity{name = e.name, position = e.position, direction = d, force = "player"}
|
||||
entity.minable = false
|
||||
entity.destructible = false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function cheat_mode()
|
||||
local cheat_mode_enabed = false
|
||||
if cheat_mode_enabed == true then
|
||||
local surface = game.surfaces["spaghettorio"]
|
||||
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
|
||||
surface.freeze_daytime = 1
|
||||
game.player.force.research_all_technologies()
|
||||
game.forces["enemy"].evolution_factor = 0.2
|
||||
local chart = 200
|
||||
local surface = game.surfaces["spaghettorio"]
|
||||
game.forces["player"].chart(surface, {lefttop = {x = chart*-1, y = chart*-1}, rightbottom = {x = chart, y = chart}})
|
||||
local disabled_entities = {"stone-furnace", "electric-furnace", "solar-panel"}
|
||||
local function on_built_entity(event)
|
||||
for _, e in pairs(disabled_entities) do
|
||||
if e == event.created_entity.name then
|
||||
if event.player_index then
|
||||
local player = game.players[event.player_index]
|
||||
player.insert({name = event.created_entity.name, count = 1})
|
||||
end
|
||||
event.created_entity.destroy()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function on_robot_built_entity(event)
|
||||
on_built_entity(event)
|
||||
end
|
||||
|
||||
local function on_research_finished(event)
|
||||
disable_recipes()
|
||||
end
|
||||
|
||||
event.add(defines.events.on_research_finished, on_research_finished)
|
||||
event.add(defines.events.on_robot_built_entity, on_robot_built_entity)
|
||||
event.add(defines.events.on_entity_damaged, on_entity_damaged)
|
||||
event.add(defines.events.on_built_entity, on_built_entity)
|
||||
event.add(defines.events.on_entity_died, on_entity_died)
|
||||
event.add(defines.events.on_player_mined_entity, on_player_mined_entity)
|
||||
event.add(defines.events.on_chunk_generated, on_chunk_generated)
|
||||
event.add(defines.events.on_player_joined_game, on_player_joined_game)
|
20
maps/tools/cheat_mode.lua
Normal file
20
maps/tools/cheat_mode.lua
Normal file
@ -0,0 +1,20 @@
|
||||
function cheat_mode()
|
||||
local surface = game.surfaces["spaghettorio"]
|
||||
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.players[1].insert({name="loader"})
|
||||
game.players[1].insert({name="fast-loader"})
|
||||
game.players[1].insert({name="express-loader"})
|
||||
game.players[1].insert({name="infinity-chest"})
|
||||
game.speed = 3
|
||||
surface.daytime = 1
|
||||
surface.freeze_daytime = 1
|
||||
game.player.force.research_all_technologies()
|
||||
--game.forces["enemy"].evolution_factor = 0.2
|
||||
local chart = 500
|
||||
game.forces["player"].chart(surface, {lefttop = {x = chart*-1, y = chart*-1}, rightbottom = {x = chart, y = chart}})
|
||||
end
|
29
maps/tools/map_pregen.lua
Normal file
29
maps/tools/map_pregen.lua
Normal file
@ -0,0 +1,29 @@
|
||||
local event = require 'utils.event'
|
||||
|
||||
local function on_tick(event)
|
||||
if global.map_pregeneration_is_active then
|
||||
if game.tick % 600 == 0 then
|
||||
local r = 1
|
||||
for x = 1,48,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, {48,48}) then
|
||||
game.print("Map generation done!", {r=0.22, g=0.99, b=0.99})
|
||||
|
||||
game.players[1].force = game.forces["player"]
|
||||
global.map_pregeneration_is_active = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function map_pregen()
|
||||
local radius = 1536
|
||||
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}})
|
||||
global.map_pregeneration_is_active = true
|
||||
end
|
||||
|
||||
event.add(defines.events.on_tick, on_tick)
|
@ -84,7 +84,7 @@ local function get_rank(player)
|
||||
|
||||
--52 ranks
|
||||
|
||||
local time_needed = 60 -- in minutes between rank upgrades
|
||||
local time_needed = 120 -- in minutes between rank upgrades
|
||||
m = m / time_needed
|
||||
m = math.floor(m)
|
||||
m = m + 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user