1
0
mirror of https://github.com/Oarcinae/FactorioScenarioMultiplayerSpawn.git synced 2025-03-03 14:42:27 +02:00

Rework of resource configuration.

This commit is contained in:
Oarcinae 2019-03-15 16:09:14 -04:00
parent 2f4fef256a
commit e3771acb2b
4 changed files with 190 additions and 196 deletions

View File

@ -55,7 +55,7 @@ FRONTIER_ROCKET_SILO_MODE = true
-- Enable Undecorator -- Enable Undecorator
-- Removes decorative items to reduce save file size. -- Removes decorative items to reduce save file size.
ENABLE_UNDECORATOR = false ENABLE_UNDECORATOR = true
-- Enable Tags -- Enable Tags
ENABLE_TAGS = true ENABLE_TAGS = true
@ -85,6 +85,23 @@ ENABLE_ABANDONED_BASE_REMOVAL = true
-- Enable the new 0.17 research queue by default. -- Enable the new 0.17 research queue by default.
ENABLE_RESEARCH_QUEUE = true ENABLE_RESEARCH_QUEUE = true
--------------------------------------------------------------------------------
-- MAP CONFIGURATION OPTIONS
-- In past versions I had a way to config map settings here to be used for cmd
-- line launching, but now you should just be using --map-gen-settings and
-- --map-settings option since it works with --start-server-load-scenario
-- Read the README.md file for instructions.
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Alien Options
--------------------------------------------------------------------------------
-- Adjust enemy spawning based on distance to spawns. All it does it make things
-- more balanced based on your distance and makes the game a little easier.
-- No behemoth worms everywhere just because you spawned far away.
OARC_MODIFIED_ENEMY_SPAWNING = true
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- Spawn Options -- Spawn Options
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
@ -141,11 +158,6 @@ FAR_MAX_DIST = 300
-- Resource & Spawn Circle Options -- Resource & Spawn Circle Options
--------------------------------------- ---------------------------------------
-- Enable this to have a vanilla style starting spawn for all new spawns.
-- This scenario normally gives you a fixed circle with resources.
-- USE_VANILLA_STARTING_SPAWN = true
-- TODO - Requires pre-allocating spawns...
-- Allow players to choose to spawn with a moat -- Allow players to choose to spawn with a moat
SPAWN_MOAT_CHOICE_ENABLED = true SPAWN_MOAT_CHOICE_ENABLED = true
-- If you change the spawn area size, you might have to adjust this as well -- If you change the spawn area size, you might have to adjust this as well
@ -156,66 +168,129 @@ MOAT_SIZE_MODIFIER = 1
-- If you make this much bigger than a few chunks, good luck. -- If you make this much bigger than a few chunks, good luck.
ENFORCE_LAND_AREA_TILE_DIST = CHUNK_SIZE*1.8 ENFORCE_LAND_AREA_TILE_DIST = CHUNK_SIZE*1.8
-- Location of water strip (horizontal)
WATER_SPAWN_OFFSET_X = -4
WATER_SPAWN_OFFSET_Y = -38
WATER_SPAWN_LENGTH = 8
-- Start resource amounts (per tile/oil spot) -- This is where you can modify what resources spawn, how much, where, etc.
START_IRON_AMOUNT = 1500 -- Once you have a config you like, it's a good idea to save it for later use
START_COPPER_AMOUNT = 1500 -- so you don't lost it if you update the scenario.
START_STONE_AMOUNT = 1000 OARC_CFG = {
START_COAL_AMOUNT = 1500 -- Misc spawn related config.
START_URANIUM_AMOUNT = 1000 gen_settings = {
START_OIL_AMOUNT = 300000 -- Start resource shape. true = circle, false = square.
resources_circle_shape = true,
-- Force the land area circle at the spawn to be fully grass
force_grass = true,
-- Spawn a circle/octagon of trees around the base outline.
tree_circle = true,
tree_octagon = false,
},
-- Location of water strip (horizontal)
water = {
x_offset = -4,
y_offset = -48,
length = 8
},
-- Handle placement of starting resources -- STILL WIP
resource_rand_pos_settings =
{
-- Autoplace resources (randomly in circle)
-- This will ignore the fixed x_offset/y_offset values in resource_tiles.
-- Only works for resource_tiles at the moment, not oil patches/water.
enabled = false,
-- Distance from center of spawn that resources are placed.
radius = 48
},
-- Resource tiles
resource_tiles =
{
["iron-ore"] =
{
amount = 1500,
size = 16,
x_offset = -29,
y_offset = 16
},
["copper-ore"] =
{
amount = 1500,
size = 14,
x_offset = -28,
y_offset = -3
},
["stone"] =
{
amount = 1000,
size = 12,
x_offset = -27,
y_offset = -34
},
["coal"] =
{
amount = 1500,
size = 12,
x_offset = -27,
y_offset = -20
}--,
-- ["uranium-ore"] =
-- {
-- amount = 0,
-- size = 0,
-- x_offset = 17,
-- y_offset = -34
-- }
-- Start resource shape -- ANGELS example
-- If this is true, it will be a circle -- ["angels-ore1"] =
-- If false, it will be a square -- {
ENABLE_RESOURCE_SHAPE_CIRCLE = true -- amount = 1500,
-- size = 16,
-- Start resource position and size -- x_offset = -29,
-- Position is relative to player starting location -- y_offset = 16
START_RESOURCE_STONE_POS_X = -27 -- },
START_RESOURCE_STONE_POS_Y = -34 -- ["angels-ore3"] =
START_RESOURCE_STONE_SIZE = 12 -- {
-- amount = 1500,
START_RESOURCE_COAL_POS_X = -27 -- size = 14,
START_RESOURCE_COAL_POS_Y = -20 -- x_offset = -28,
START_RESOURCE_COAL_SIZE = 12 -- y_offset = -3
-- },
START_RESOURCE_COPPER_POS_X = -28 -- ["angels-ore5"] =
START_RESOURCE_COPPER_POS_Y = -3 -- {
START_RESOURCE_COPPER_SIZE = 14 -- amount = 1000,
-- size = 12,
START_RESOURCE_IRON_POS_X = -29 -- x_offset = -27,
START_RESOURCE_IRON_POS_Y = 16 -- y_offset = -34
START_RESOURCE_IRON_SIZE = 16 -- },
-- ["angels-ore6"] =
START_RESOURCE_URANIUM_POS_X = 17 -- {
START_RESOURCE_URANIUM_POS_Y = -34 -- amount = 1500,
START_RESOURCE_URANIUM_SIZE = 0 -- Disabled by default. -- size = 12,
-- x_offset = -27,
-- Specify 2 oil spot locations for starting oil. -- y_offset = -20
START_RESOURCE_OIL_NUM_PATCHES = 2 -- },
-- The first patch -- ["coal"] =
START_RESOURCE_OIL_POS_X = -39 -- {
START_RESOURCE_OIL_POS_Y = -2 -- amount = 0,
-- How far each patch is offset from the others and in which direction -- size = 0,
-- Default (x=0, y=-4) means that patches spawn in a vertical row downwards. -- x_offset = 17,
START_RESOURCE_OIL_X_OFFSET = 0 -- y_offset = -34
START_RESOURCE_OIL_Y_OFFSET = -4 -- }
},
-- Special resources like oil
resource_patches =
{
["crude-oil"] =
{
num_patches = 2,
amount = 300000,
x_offset_start = 0,
y_offset_start = 48,
x_offset_next = 4,
y_offset_next = 0
}
}
}
-- Force the land area circle at the spawn to be fully grass
ENABLE_SPAWN_FORCE_GRASS = true
-- Set this to true for the spawn area to be surrounded by a circle of trees
SPAWN_TREE_CIRCLE_ENABLED = false
-- Set this to true for the spawn area to be surrounded by an octagon of trees
-- I don't recommend using this with moatsm
SPAWN_TREE_OCTAGON_ENABLED = true
--------------------------------------- ---------------------------------------
-- Safe Spawn Area Options -- Safe Spawn Area Options
@ -323,56 +398,22 @@ RESOURCE_DIST_BONUS = 2
AUTOFILL_TURRET_AMMO_QUANTITY = 10 AUTOFILL_TURRET_AMMO_QUANTITY = 10
--------------------------------------------------------------------------------
-- MAP CONFIGURATION OPTIONS
-- In past versions I had a way to config map settings here to be used for cmd
-- line launching, but now you should just be using --map-gen-settings option
-- since it works with --start-server-load-scenario
-- Read the README.md file for instructions.
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Alien Options
-- I WANTED to use --map-settings but it doesn't seem to work with
-- cmd line --start-server-load-scenario. So we're back to this. Le sigh.
--------------------------------------------------------------------------------
-- You must disable this if you want to configure the enemy settings from
-- the game GUI.
CMD_LINE_GEN = true
-- Enable/Disable enemy expansion
ENEMY_EXPANSION = true
-- Divide the alien evolution factors by this number to reduce it (or multiply if < 1)
ENEMY_TIME_FACTOR_DISABLE = true -- Set this to true to disable time based evolution completely.
ENEMY_TIME_FACTOR_DIVISOR = 10
ENEMY_POLLUTION_FACTOR_DISABLE = false -- Set this to true to disable pollution based evolution completely.
ENEMY_POLLUTION_FACTOR_DIVISOR = 10
ENEMY_DESTROY_FACTOR_DISABLE = false -- Set this to true to disable spawner destruction based evolution completely.
ENEMY_DESTROY_FACTOR_DIVISOR = 2
-- Adjust biter type spawning based on distance to spawns.
OARC_MODIFIED_ENEMY_SPAWNING = true
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- ANTI-Griefing stuff ( I don't personally maintain this as I don't care for it.) -- ANTI-Griefing stuff ( I don't personally maintain this as I don't care for it.)
-- These things were added from other people's requests/changes and are disabled by default. -- These things were added from other people's requests/changes and are disabled by default.
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
-- Enable this to disable some basic things like friendly fire, deconstructing from map view, etc. -- Enable this to disable some basic things like friendly fire, deconstructing from map view, etc.
-- ENABLE_ANTI_GRIEFING = false ENABLE_ANTI_GRIEFING = true
-- Makes blueprint ghosts dissapear if they have been placed longer than this -- Makes blueprint ghosts dissapear if they have been placed longer than this
-- GHOST_TIME_TO_LIVE = 0 * TICKS_PER_MINUTE -- set to 0 for infinite ghost life GHOST_TIME_TO_LIVE = 0 * TICKS_PER_MINUTE -- set to 0 for infinite ghost life
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
-- DEBUG / Custom stuff -- DEBUG / Custom stuff
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
OARC_DIFFICULTY_CUSTOM = false -- DEBUG prints for me in game.
global.oarcDebugEnabled = true
-- DEBUG prints for me
global.oarcDebugEnabled = false
-- These are my specific welcome messages that get used only if I am the user -- These are my specific welcome messages that get used only if I am the user
-- that creates the game. -- that creates the game.

View File

@ -57,11 +57,6 @@ GAME_SURFACE_NAME="nauvis"
---------------------------------------- ----------------------------------------
script.on_init(function(event) script.on_init(function(event)
-- Configures the map settings for enemies
-- This controls evolution growth factors and enemy expansion settings.
-- The only reason this is here is because --map-settings doesn't seem to work
-- with --start-server-load-scenario
ConfigureAlienStartingParams()
if ENABLE_SEPARATE_SPAWNS then if ENABLE_SEPARATE_SPAWNS then
InitSpawnGlobalsAndForces() InitSpawnGlobalsAndForces()

View File

@ -507,53 +507,6 @@ function RemoveWormsInArea(surface, area, small, medium, big, behemoth)
end end
end end
-- Adjust alien params
-- I'll probably remove this if --map-settings works with command line launches.
function ConfigureAlienStartingParams()
if ENEMY_TIME_FACTOR_DISABLE then
game.map_settings.enemy_evolution.time_factor = 0
else
game.map_settings.enemy_evolution.time_factor=game.map_settings.enemy_evolution.time_factor / ENEMY_TIME_FACTOR_DIVISOR
end
if ENEMY_POLLUTION_FACTOR_DISABLE then
game.map_settings.enemy_evolution.pollution_factor = 0
else
game.map_settings.enemy_evolution.pollution_factor = game.map_settings.enemy_evolution.pollution_factor / ENEMY_POLLUTION_FACTOR_DIVISOR
end
if ENEMY_DESTROY_FACTOR_DISABLE then
game.map_settings.enemy_evolution.destroy_factor = 0
else
game.map_settings.enemy_evolution.destroy_factor = game.map_settings.enemy_evolution.destroy_factor / ENEMY_DESTROY_FACTOR_DIVISOR
end
game.map_settings.enemy_expansion.enabled = ENEMY_EXPANSION
-- This is my own extra tweaks, still pretty experimental.
if (OARC_DIFFICULTY_CUSTOM) then
-- More diffusion / larger area.
game.map_settings.pollution.diffusion_ratio = 0.06
-- Biters expand further.
game.map_settings.enemy_expansion.max_expansion_distance = 20
-- Small biter groups.
game.map_settings.enemy_expansion.settler_group_min_size = 2
game.map_settings.enemy_expansion.settler_group_max_size = 10
-- Longer cooldown / slower expansion.
game.map_settings.enemy_expansion.min_expansion_cooldown = TICKS_PER_MINUTE*15
game.map_settings.enemy_expansion.max_expansion_cooldown = TICKS_PER_MINUTE*60
-- Smaller groups, more frequent?
game.map_settings.unit_group.min_group_gathering_time = TICKS_PER_MINUTE
game.map_settings.unit_group.max_group_gathering_time = 4 * TICKS_PER_MINUTE
game.map_settings.unit_group.max_wait_time_for_late_members = 1 * TICKS_PER_MINUTE
game.map_settings.unit_group.max_unit_group_size = 15
end
end
-- Add Long Reach to Character -- Add Long Reach to Character
function GivePlayerLongReach(player) function GivePlayerLongReach(player)
player.character.character_build_distance_bonus = BUILD_DIST_BONUS player.character.character_build_distance_bonus = BUILD_DIST_BONUS
@ -753,7 +706,7 @@ function CreateCropCircle(surface, centerPos, chunkArea, tileRadius)
-- Fill in all unexpected water in a circle -- Fill in all unexpected water in a circle
if (distVar < tileRadSqr) then if (distVar < tileRadSqr) then
if (surface.get_tile(i,j).collides_with("water-tile") or ENABLE_SPAWN_FORCE_GRASS) then if (surface.get_tile(i,j).collides_with("water-tile") or OARC_CFG.gen_settings.force_grass) then
table.insert(dirtTiles, {name = "grass-1", position ={i,j}}) table.insert(dirtTiles, {name = "grass-1", position ={i,j}})
end end
end end
@ -784,7 +737,7 @@ function CreateCropOctagon(surface, centerPos, chunkArea, tileRadius)
-- Fill in all unexpected water in a circle -- Fill in all unexpected water in a circle
if (distVar < tileRadius+2) then if (distVar < tileRadius+2) then
if (surface.get_tile(i,j).collides_with("water-tile") or ENABLE_SPAWN_FORCE_GRASS) then if (surface.get_tile(i,j).collides_with("water-tile") or OARC_CFG.gen_settings.force_grass) then
table.insert(dirtTiles, {name = "grass-1", position ={i,j}}) table.insert(dirtTiles, {name = "grass-1", position ={i,j}})
end end
end end
@ -845,9 +798,9 @@ function GenerateResourcePatch(surface, resourceName, diameter, pos, amount)
if (diameter == 0) then if (diameter == 0) then
return return
end end
for y=0, diameter do for y=-midPoint, midPoint do
for x=0, diameter do for x=-midPoint, midPoint do
if (not ENABLE_RESOURCE_SHAPE_CIRCLE or ((x-midPoint)^2 + (y-midPoint)^2 < midPoint^2)) then if (not OARC_CFG.gen_settings.resources_circle_shape or ((x)^2 + (y)^2 < midPoint^2)) then
surface.create_entity({name=resourceName, amount=amount, surface.create_entity({name=resourceName, amount=amount,
position={pos.x+x, pos.y+y}}) position={pos.x+x, pos.y+y}})
end end

View File

@ -179,10 +179,10 @@ function SetupAndClearSpawnAreas(surface, chunkArea, spawnPointTable)
RemoveInCircle(surface, chunkArea, "cliff", spawn.pos, ENFORCE_LAND_AREA_TILE_DIST+5) RemoveInCircle(surface, chunkArea, "cliff", spawn.pos, ENFORCE_LAND_AREA_TILE_DIST+5)
-- RemoveDecorationsArea(surface, chunkArea) -- RemoveDecorationsArea(surface, chunkArea)
if (SPAWN_TREE_CIRCLE_ENABLED) then if (OARC_CFG.gen_settings.tree_circle) then
CreateCropCircle(surface, spawn.pos, chunkArea, ENFORCE_LAND_AREA_TILE_DIST) CreateCropCircle(surface, spawn.pos, chunkArea, ENFORCE_LAND_AREA_TILE_DIST)
end end
if (SPAWN_TREE_OCTAGON_ENABLED) then if (OARC_CFG.gen_settings.tree_octagon) then
CreateCropOctagon(surface, spawn.pos, chunkArea, ENFORCE_LAND_AREA_TILE_DIST) CreateCropOctagon(surface, spawn.pos, chunkArea, ENFORCE_LAND_AREA_TILE_DIST)
end end
if (SPAWN_MOAT_CHOICE_ENABLED) then if (SPAWN_MOAT_CHOICE_ENABLED) then
@ -239,43 +239,47 @@ end
-- Generate the basic starter resource around a given location. -- Generate the basic starter resource around a given location.
function GenerateStartingResources(surface, pos) function GenerateStartingResources(surface, pos)
local stonePos = {x=pos.x+START_RESOURCE_STONE_POS_X,
y=pos.y+START_RESOURCE_STONE_POS_Y}
local coalPos = {x=pos.x+START_RESOURCE_COAL_POS_X,
y=pos.y+START_RESOURCE_COAL_POS_Y}
local copperOrePos = {x=pos.x+START_RESOURCE_COPPER_POS_X,
y=pos.y+START_RESOURCE_COPPER_POS_Y}
local ironOrePos = {x=pos.x+START_RESOURCE_IRON_POS_X,
y=pos.y+START_RESOURCE_IRON_POS_Y}
local uraniumOrePos = {x=pos.x+START_RESOURCE_URANIUM_POS_X,
y=pos.y+START_RESOURCE_URANIUM_POS_Y}
-- Tree generation is taken care of in chunk generation local rand_settings = OARC_CFG.resource_rand_pos_settings
-- Generate oil patches -- Generate all resource tile patches
oil_patch_x=pos.x+START_RESOURCE_OIL_POS_X if (not rand_settings.enabled) then
oil_patch_y=pos.y+START_RESOURCE_OIL_POS_Y for t_name,t_data in pairs (OARC_CFG.resource_tiles) do
for i=1,START_RESOURCE_OIL_NUM_PATCHES do local pos = {x=pos.x+t_data.x_offset, y=pos.y+t_data.y_offset}
surface.create_entity({name="crude-oil", amount=START_OIL_AMOUNT, GenerateResourcePatch(surface, t_name, t_data.size, pos, t_data.amount)
position={oil_patch_x, oil_patch_y}}) end
oil_patch_x=oil_patch_x+START_RESOURCE_OIL_X_OFFSET else
oil_patch_y=oil_patch_y+START_RESOURCE_OIL_Y_OFFSET -- This places resources in a semi-circle, with a random rotation.
-- They will be in the sequence as defined in config.lua
local random_angle_offset = math.random()
local num_resources = TableLength(OARC_CFG.resource_tiles)
local theta = ((math.pi) / num_resources);
local count = 0
for t_name,t_data in pairs (OARC_CFG.resource_tiles) do
local angle = (theta * count) + random_angle_offset;
if (angle > math.pi-0.2) then angle = angle - math.pi end
local tx = (rand_settings.radius * math.cos(angle+(math.pi/2))) + pos.x
local ty = (rand_settings.radius * math.sin(angle+(math.pi/2))) + pos.y
local pos = {x=math.floor(tx), y=math.floor(ty)}
GenerateResourcePatch(surface, t_name, t_data.size, pos, t_data.amount)
count = count+1
end
end end
-- Generate Stone -- Generate special resource patches (oil)
GenerateResourcePatch(surface, "stone", START_RESOURCE_STONE_SIZE, stonePos, START_STONE_AMOUNT) for p_name,p_data in pairs (OARC_CFG.resource_patches) do
local oil_patch_x=pos.x+p_data.x_offset_start
-- Generate Coal local oil_patch_y=pos.y+p_data.y_offset_start
GenerateResourcePatch(surface, "coal", START_RESOURCE_COAL_SIZE, coalPos, START_COAL_AMOUNT) for i=1,p_data.num_patches do
surface.create_entity({name=p_name, amount=p_data.amount,
-- Generate Copper position={oil_patch_x, oil_patch_y}})
GenerateResourcePatch(surface, "copper-ore", START_RESOURCE_COPPER_SIZE, copperOrePos, START_COPPER_AMOUNT) oil_patch_x=oil_patch_x+p_data.x_offset_next
oil_patch_y=oil_patch_y+p_data.y_offset_next
-- Generate Iron end
GenerateResourcePatch(surface, "iron-ore", START_RESOURCE_IRON_SIZE, ironOrePos, START_IRON_AMOUNT) end
-- Generate Uranium
GenerateResourcePatch(surface, "uranium-ore", START_RESOURCE_URANIUM_SIZE, uraniumOrePos, START_URANIUM_AMOUNT)
end end
-- Add a spawn to the shared spawn global -- Add a spawn to the shared spawn global
@ -486,12 +490,13 @@ function SendPlayerToNewSpawnAndCreateIt(playerName, spawn, moatEnabled)
ClearNearbyEnemies(spawn, SAFE_AREA_TILE_DIST, game.surfaces[GAME_SURFACE_NAME]) ClearNearbyEnemies(spawn, SAFE_AREA_TILE_DIST, game.surfaces[GAME_SURFACE_NAME])
-- Create the spawn resources here -- Create the spawn resources here
local water_data = OARC_CFG.water
CreateWaterStrip(game.surfaces[GAME_SURFACE_NAME], CreateWaterStrip(game.surfaces[GAME_SURFACE_NAME],
{x=spawn.x+WATER_SPAWN_OFFSET_X, y=spawn.y+WATER_SPAWN_OFFSET_Y}, {x=spawn.x+water_data.x_offset, y=spawn.y+water_data.y_offset},
WATER_SPAWN_LENGTH) water_data.length)
CreateWaterStrip(game.surfaces[GAME_SURFACE_NAME], CreateWaterStrip(game.surfaces[GAME_SURFACE_NAME],
{x=spawn.x+WATER_SPAWN_OFFSET_X, y=spawn.y+WATER_SPAWN_OFFSET_Y+1}, {x=spawn.x+water_data.x_offset, y=spawn.y+water_data.y_offset+1},
WATER_SPAWN_LENGTH) water_data.length)
GenerateStartingResources(game.surfaces[GAME_SURFACE_NAME], spawn) GenerateStartingResources(game.surfaces[GAME_SURFACE_NAME], spawn)
-- Send the player to that position -- Send the player to that position