mirror of
https://github.com/Oarcinae/FactorioScenarioMultiplayerSpawn.git
synced 2025-01-05 22:53:48 +02:00
Returning alien params config since --map-settings doesn't work.
Also improved biter/worm spawning and scaling with overall distance and distance to bases. Reimplemented anti-grief stuff, not really tested though. Getting pretty close to a good .17 stable version.
This commit is contained in:
parent
acf2ea028a
commit
f870f720db
46
config.lua
46
config.lua
@ -224,13 +224,18 @@ SPAWN_TREE_OCTAGON_ENABLED = true
|
||||
-- +/- this in x and y direction
|
||||
SAFE_AREA_TILE_DIST = CHUNK_SIZE*5
|
||||
|
||||
-- Warning area has reduced aliens
|
||||
-- Warning area has significantly reduced aliens
|
||||
-- +/- this in x and y direction
|
||||
WARNING_AREA_TILE_DIST = CHUNK_SIZE*10
|
||||
|
||||
-- 1 : X (spawners alive : spawners destroyed) in this area
|
||||
WARN_AREA_REDUCTION_RATIO = 10
|
||||
WARN_AREA_REDUCTION_RATIO = 20
|
||||
|
||||
-- Danger area has slightly reduce aliens
|
||||
REDUCED_DANGER_AREA_TILE_DIST = CHUNK_SIZE*30
|
||||
|
||||
-- 1 : X (spawners alive : spawners destroyed) in this area
|
||||
REDUCED_DANGER_AREA_REDUCTION_RATIO = 5
|
||||
|
||||
---------------------------------------
|
||||
-- Other Forces/Teams Options
|
||||
@ -268,6 +273,16 @@ RESPAWN_COOLDOWN_TICKS = TICKS_PER_MINUTE * RESPAWN_COOLDOWN_IN_MINUTES
|
||||
MIN_ONLINE_TIME_IN_MINUTES = 15
|
||||
MIN_ONLINE_TIME = TICKS_PER_MINUTE * MIN_ONLINE_TIME_IN_MINUTES
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- 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.
|
||||
-- It is very very basic only, nothing fancy.
|
||||
--------------------------------------------------------------------------------
|
||||
-- Enable this to disable some basic things like friendly fire, deconstructing from map view, etc.
|
||||
ENABLE_ANTI_GRIEFING = true
|
||||
|
||||
-- Makes blueprint ghosts dissapear if they have been placed longer than this
|
||||
GHOST_TIME_TO_LIVE = 15 * TICKS_PER_MINUTE -- set to 0 for infinite ghost life
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Frontier Rocket Silo Options
|
||||
@ -317,12 +332,28 @@ AUTOFILL_TURRET_AMMO_QUANTITY = 10
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Alien 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-settings option
|
||||
-- since it works with --start-server-load-scenario
|
||||
-- Read the README.md file for instructions.
|
||||
-- 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 = false -- 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 = 1
|
||||
|
||||
-- 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.)
|
||||
-- These things were added from other people's requests/changes and are disabled by default.
|
||||
@ -336,6 +367,9 @@ AUTOFILL_TURRET_AMMO_QUANTITY = 10
|
||||
-------------------------------------------------------------------------------
|
||||
-- DEBUG / Custom stuff
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
OARC_DIFFICULTY_CUSTOM = false
|
||||
|
||||
-- DEBUG prints for me
|
||||
global.oarcDebugEnabled = false
|
||||
|
||||
|
94
control.lua
94
control.lua
@ -47,54 +47,22 @@ require("lib/separate_spawns_guis")
|
||||
-- In this case, we are using the default surface.
|
||||
GAME_SURFACE_NAME="nauvis"
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Rocket Launch Event Code
|
||||
-- Controls the "win condition"
|
||||
--------------------------------------------------------------------------------
|
||||
function RocketLaunchEvent(event)
|
||||
local force = event.rocket.force
|
||||
|
||||
if event.rocket.get_item_count("satellite") == 0 then
|
||||
for index, player in pairs(force.players) do
|
||||
player.print("You launched the rocket, but you didn't put a satellite inside.")
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if not global.satellite_sent then
|
||||
global.satellite_sent = {}
|
||||
end
|
||||
|
||||
if global.satellite_sent[force.name] then
|
||||
global.satellite_sent[force.name] = global.satellite_sent[force.name] + 1
|
||||
else
|
||||
game.set_game_state{game_finished=true, player_won=true, can_continue=true}
|
||||
global.satellite_sent[force.name] = 1
|
||||
end
|
||||
|
||||
for index, player in pairs(force.players) do
|
||||
if player.gui.left.rocket_score then
|
||||
player.gui.left.rocket_score.rocket_count.caption = tostring(global.satellite_sent[force.name])
|
||||
else
|
||||
local frame = player.gui.left.add{name = "rocket_score", type = "frame", direction = "horizontal", caption="Score"}
|
||||
frame.add{name="rocket_count_label", type = "label", caption={"", "Satellites launched", ":"}}
|
||||
frame.add{name="rocket_count", type = "label", caption=tostring(global.satellite_sent[force.name])}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- ALL EVENT HANLDERS ARE HERE IN ONE PLACE!
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
----------------------------------------
|
||||
-- On Init - only runs once the first
|
||||
-- time the game starts
|
||||
----------------------------------------
|
||||
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
|
||||
InitSpawnGlobalsAndForces()
|
||||
end
|
||||
@ -251,6 +219,10 @@ script.on_event(defines.events.on_built_entity, function(event)
|
||||
if ENABLE_REGROWTH then
|
||||
OarcRegrowthOffLimitsChunk(event.created_entity.position)
|
||||
end
|
||||
|
||||
if ENABLE_ANTI_GRIEFING then
|
||||
SetItemBlueprintTimeToLive(event)
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
@ -327,3 +299,49 @@ script.on_event(defines.events.on_research_finished, function(event)
|
||||
end
|
||||
end)
|
||||
|
||||
----------------------------------------
|
||||
-- On Entity Spawned
|
||||
-- This is where I modify biter spawning based on location and other factors.
|
||||
----------------------------------------
|
||||
script.on_event(defines.events.on_entity_spawned, function(event)
|
||||
if (OARC_MODIFIED_ENEMY_SPAWNING) then
|
||||
ModifyEnemySpawnsNearPlayerStartingAreas(event)
|
||||
end
|
||||
end)
|
||||
-- on_biter_base_built -- Worth considering for later.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Rocket Launch Event Code
|
||||
-- Controls the "win condition"
|
||||
--------------------------------------------------------------------------------
|
||||
function RocketLaunchEvent(event)
|
||||
local force = event.rocket.force
|
||||
|
||||
if event.rocket.get_item_count("satellite") == 0 then
|
||||
for index, player in pairs(force.players) do
|
||||
player.print("You launched the rocket, but you didn't put a satellite inside.")
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if not global.satellite_sent then
|
||||
global.satellite_sent = {}
|
||||
end
|
||||
|
||||
if global.satellite_sent[force.name] then
|
||||
global.satellite_sent[force.name] = global.satellite_sent[force.name] + 1
|
||||
else
|
||||
game.set_game_state{game_finished=true, player_won=true, can_continue=true}
|
||||
global.satellite_sent[force.name] = 1
|
||||
end
|
||||
|
||||
for index, player in pairs(force.players) do
|
||||
if player.gui.left.rocket_score then
|
||||
player.gui.left.rocket_score.rocket_count.caption = tostring(global.satellite_sent[force.name])
|
||||
else
|
||||
local frame = player.gui.left.add{name = "rocket_score", type = "frame", direction = "horizontal", caption="Score"}
|
||||
frame.add{name="rocket_count_label", type = "label", caption={"", "Satellites launched", ":"}}
|
||||
frame.add{name="rocket_count", type = "label", caption=tostring(global.satellite_sent[force.name])}
|
||||
end
|
||||
end
|
||||
end
|
@ -426,16 +426,131 @@ function ReduceAliensInArea(surface, area, reductionFactor)
|
||||
entity.destroy()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Remove all big and huge worms
|
||||
for _, entity in pairs(surface.find_entities_filtered{area = area, name = "medium-worm-turret"}) do
|
||||
entity.destroy()
|
||||
-- Downgrades worms in an area based on chance.
|
||||
-- 100% small would mean all worms are changed to small.
|
||||
function DowngradeWormsInArea(surface, area, small_percent, medium_percent, big_percent)
|
||||
|
||||
local worm_types = {"small-worm-turret", "medium-worm-turret", "big-worm-turret", "behemoth-worm-turret"}
|
||||
|
||||
for _, entity in pairs(surface.find_entities_filtered{area = area, name = worm_types}) do
|
||||
|
||||
-- Roll a number between 0-100
|
||||
local rand_percent = math.random(0,100)
|
||||
local worm_pos = entity.position
|
||||
local worm_name = entity.name
|
||||
|
||||
-- If number is more than small percent, change to small
|
||||
if (rand_percent <= small_percent) then
|
||||
if (not (worm_name == "small-worm-turret")) then
|
||||
entity.destroy()
|
||||
surface.create_entity{name = "small-worm-turret", position = worm_pos, force = game.forces.enemy}
|
||||
end
|
||||
|
||||
-- ELSE If number is more than medium percent, change to small
|
||||
elseif (rand_percent <= medium_percent) then
|
||||
if (not (worm_name == "medium-worm-turret")) then
|
||||
entity.destroy()
|
||||
surface.create_entity{name = "medium-worm-turret", position = worm_pos, force = game.forces.enemy}
|
||||
end
|
||||
|
||||
-- ELSE If number is more than big percent, change to small
|
||||
elseif (rand_percent <= big_percent) then
|
||||
if (not (worm_name == "big-worm-turret")) then
|
||||
entity.destroy()
|
||||
surface.create_entity{name = "big-worm-turret", position = worm_pos, force = game.forces.enemy}
|
||||
end
|
||||
|
||||
-- ELSE ignore it.
|
||||
end
|
||||
end
|
||||
for _, entity in pairs(surface.find_entities_filtered{area = area, name = "big-worm-turret"}) do
|
||||
entity.destroy()
|
||||
end
|
||||
|
||||
function DowngradeWormsDistanceBasedOnChunkGenerate(event)
|
||||
if (getDistance({x=0,y=0}, event.area.left_top) < (NEAR_MAX_DIST*CHUNK_SIZE)) then
|
||||
DowngradeWormsInArea(event.surface, event.area, 100, 100, 100)
|
||||
elseif (getDistance({x=0,y=0}, event.area.left_top) < (FAR_MIN_DIST*CHUNK_SIZE)) then
|
||||
DowngradeWormsInArea(event.surface, event.area, 50, 90, 100)
|
||||
elseif (getDistance({x=0,y=0}, event.area.left_top) < (FAR_MAX_DIST*CHUNK_SIZE)) then
|
||||
DowngradeWormsInArea(event.surface, event.area, 50, 80, 99)
|
||||
else
|
||||
DowngradeWormsInArea(event.surface, event.area, 10, 40, 85)
|
||||
end
|
||||
for _, entity in pairs(surface.find_entities_filtered{area = area, name = "behemoth-worm-turret"}) do
|
||||
entity.destroy()
|
||||
end
|
||||
|
||||
-- A function to help me remove worms in an area.
|
||||
-- Yeah kind of an unecessary wrapper, but makes my life easier to remember the worm types.
|
||||
function RemoveWormsInArea(surface, area, small, medium, big, behemoth)
|
||||
local worm_types = {}
|
||||
|
||||
if (small) then
|
||||
table.insert(worm_types, "small-worm-turret")
|
||||
end
|
||||
if (medium) then
|
||||
table.insert(worm_types, "medium-worm-turret")
|
||||
end
|
||||
if (big) then
|
||||
table.insert(worm_types, "big-worm-turret")
|
||||
end
|
||||
if (behemoth) then
|
||||
table.insert(worm_types, "behemoth-worm-turret")
|
||||
end
|
||||
|
||||
-- Destroy
|
||||
if (TableLength(worm_types) > 0) then
|
||||
for _, entity in pairs(surface.find_entities_filtered{area = area, name = worm_types}) do
|
||||
entity.destroy()
|
||||
end
|
||||
else
|
||||
DebugPrint("RemoveWormsInArea had empty worm_types list!")
|
||||
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
|
||||
|
||||
@ -742,160 +857,6 @@ end
|
||||
|
||||
|
||||
|
||||
-- Generate the basic starter resource around a given location.
|
||||
function GenerateStartingResources(surface, pos)
|
||||
-- Generate stone
|
||||
local stonePos = {x=pos.x+START_RESOURCE_STONE_POS_X,
|
||||
y=pos.y+START_RESOURCE_STONE_POS_Y}
|
||||
|
||||
-- Generate coal
|
||||
local coalPos = {x=pos.x+START_RESOURCE_COAL_POS_X,
|
||||
y=pos.y+START_RESOURCE_COAL_POS_Y}
|
||||
|
||||
-- Generate copper ore
|
||||
local copperOrePos = {x=pos.x+START_RESOURCE_COPPER_POS_X,
|
||||
y=pos.y+START_RESOURCE_COPPER_POS_Y}
|
||||
|
||||
-- Generate iron ore
|
||||
local ironOrePos = {x=pos.x+START_RESOURCE_IRON_POS_X,
|
||||
y=pos.y+START_RESOURCE_IRON_POS_Y}
|
||||
|
||||
-- Generate uranium
|
||||
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
|
||||
|
||||
-- Generate oil patches
|
||||
oil_patch_x=pos.x+START_RESOURCE_OIL_POS_X
|
||||
oil_patch_y=pos.y+START_RESOURCE_OIL_POS_Y
|
||||
for i=1,START_RESOURCE_OIL_NUM_PATCHES do
|
||||
surface.create_entity({name="crude-oil", amount=START_OIL_AMOUNT,
|
||||
position={oil_patch_x, oil_patch_y}})
|
||||
oil_patch_x=oil_patch_x+START_RESOURCE_OIL_X_OFFSET
|
||||
oil_patch_y=oil_patch_y+START_RESOURCE_OIL_Y_OFFSET
|
||||
end
|
||||
|
||||
-- Generate Stone
|
||||
GenerateResourcePatch(surface, "stone", START_RESOURCE_STONE_SIZE, stonePos, START_STONE_AMOUNT)
|
||||
|
||||
-- Generate Coal
|
||||
GenerateResourcePatch(surface, "coal", START_RESOURCE_COAL_SIZE, coalPos, START_COAL_AMOUNT)
|
||||
|
||||
-- Generate Copper
|
||||
GenerateResourcePatch(surface, "copper-ore", START_RESOURCE_COPPER_SIZE, copperOrePos, START_COPPER_AMOUNT)
|
||||
|
||||
-- Generate Iron
|
||||
GenerateResourcePatch(surface, "iron-ore", START_RESOURCE_IRON_SIZE, ironOrePos, START_IRON_AMOUNT)
|
||||
|
||||
-- Generate Uranium
|
||||
GenerateResourcePatch(surface, "uranium-ore", START_RESOURCE_URANIUM_SIZE, uraniumOrePos, START_URANIUM_AMOUNT)
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- Clear the spawn areas.
|
||||
-- This should be run inside the chunk generate event and be given a list of all
|
||||
-- unique spawn points.
|
||||
-- This clears enemies in the immediate area, creates a slightly safe area around it,
|
||||
-- It no LONGER generates the resources though as that is now handled in a delayed event!
|
||||
function SetupAndClearSpawnAreas(surface, chunkArea, spawnPointTable)
|
||||
for name,spawn in pairs(spawnPointTable) do
|
||||
|
||||
-- Create a bunch of useful area and position variables
|
||||
local landArea = GetAreaAroundPos(spawn.pos, ENFORCE_LAND_AREA_TILE_DIST+CHUNK_SIZE)
|
||||
local safeArea = GetAreaAroundPos(spawn.pos, SAFE_AREA_TILE_DIST)
|
||||
local warningArea = GetAreaAroundPos(spawn.pos, WARNING_AREA_TILE_DIST)
|
||||
local chunkAreaCenter = {x=chunkArea.left_top.x+(CHUNK_SIZE/2),
|
||||
y=chunkArea.left_top.y+(CHUNK_SIZE/2)}
|
||||
local spawnPosOffset = {x=spawn.pos.x+ENFORCE_LAND_AREA_TILE_DIST,
|
||||
y=spawn.pos.y+ENFORCE_LAND_AREA_TILE_DIST}
|
||||
|
||||
-- Make chunks near a spawn safe by removing enemies
|
||||
if CheckIfInArea(chunkAreaCenter,safeArea) then
|
||||
RemoveAliensInArea(surface, chunkArea)
|
||||
|
||||
-- Create a warning area with reduced enemies
|
||||
elseif CheckIfInArea(chunkAreaCenter,warningArea) then
|
||||
ReduceAliensInArea(surface, chunkArea, WARN_AREA_REDUCTION_RATIO)
|
||||
end
|
||||
|
||||
-- If the chunk is within the main land area, then clear trees/resources
|
||||
-- and create the land spawn areas (guaranteed land with a circle of trees)
|
||||
if CheckIfInArea(chunkAreaCenter,landArea) then
|
||||
|
||||
-- Remove trees/resources inside the spawn area
|
||||
RemoveInCircle(surface, chunkArea, "tree", spawn.pos, ENFORCE_LAND_AREA_TILE_DIST)
|
||||
RemoveInCircle(surface, chunkArea, "resource", spawn.pos, ENFORCE_LAND_AREA_TILE_DIST+5)
|
||||
RemoveInCircle(surface, chunkArea, "cliff", spawn.pos, ENFORCE_LAND_AREA_TILE_DIST+5)
|
||||
-- RemoveDecorationsArea(surface, chunkArea)
|
||||
|
||||
if (SPAWN_TREE_CIRCLE_ENABLED) then
|
||||
CreateCropCircle(surface, spawn.pos, chunkArea, ENFORCE_LAND_AREA_TILE_DIST)
|
||||
end
|
||||
if (SPAWN_TREE_OCTAGON_ENABLED) then
|
||||
CreateCropOctagon(surface, spawn.pos, chunkArea, ENFORCE_LAND_AREA_TILE_DIST)
|
||||
end
|
||||
if (SPAWN_MOAT_CHOICE_ENABLED) then
|
||||
if (spawn.moat) then
|
||||
CreateMoat(surface, spawn.pos, chunkArea, ENFORCE_LAND_AREA_TILE_DIST)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Provide starting resources
|
||||
-- This is run on the bottom, right chunk of the spawn area which should be
|
||||
-- generated last, so it should work everytime.
|
||||
-- if CheckIfInArea(spawnPosOffset,chunkArea) then
|
||||
-- CreateWaterStrip(surface,
|
||||
-- {x=spawn.pos.x+WATER_SPAWN_OFFSET_X, y=spawn.pos.y+WATER_SPAWN_OFFSET_Y},
|
||||
-- WATER_SPAWN_LENGTH)
|
||||
-- CreateWaterStrip(surface,
|
||||
-- {x=spawn.pos.x+WATER_SPAWN_OFFSET_X, y=spawn.pos.y+WATER_SPAWN_OFFSET_Y+1},
|
||||
-- WATER_SPAWN_LENGTH)
|
||||
-- GenerateStartingResources(surface, spawn.pos)
|
||||
-- end
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Surface Generation Functions
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
-- RSO_MODE = 1
|
||||
-- VANILLA_MODE = 2
|
||||
|
||||
-- function CreateGameSurface(dww)
|
||||
-- local mapSettings = game.surfaces["nauvis"].map_gen_settings
|
||||
|
||||
-- if CMD_LINE_MAP_GEN then
|
||||
-- mapSettings.terrain_segmentation = global.clMapGen.terrain_segmentation
|
||||
-- mapSettings.water = global.clMapGen.water
|
||||
-- mapSettings.starting_area = global.clMapGen.starting_area
|
||||
-- mapSettings.peaceful_mode = global.clMapGen.peaceful_mode
|
||||
-- mapSettings.seed = global.clMapGen.seed
|
||||
-- mapSettings.height = global.clMapGen.height
|
||||
-- mapSettings.width = global.clMapGen.width
|
||||
-- mapSettings.autoplace_controls = global.clMapGen.autoplace_controls
|
||||
-- mapSettings.cliff_settings = global.clMapGen.cliff_settings
|
||||
-- mapSettings.property_expression_names = global.clMapGen.property_expression_names
|
||||
-- end
|
||||
|
||||
-- -- To use RSO resources, we have to disable vanilla ore generation
|
||||
-- if (mode == RSO_MODE) then
|
||||
-- mapSettings.autoplace_controls["coal"].size="none"
|
||||
-- mapSettings.autoplace_controls["copper-ore"].size="none"
|
||||
-- mapSettings.autoplace_controls["iron-ore"].size="none"
|
||||
-- mapSettings.autoplace_controls["stone"].size="none"
|
||||
-- mapSettings.autoplace_controls["uranium-ore"].size="none"
|
||||
-- mapSettings.autoplace_controls["crude-oil"].size="none"
|
||||
-- mapSettings.autoplace_controls["enemy-base"].size="none"
|
||||
-- end
|
||||
|
||||
-- local surface = game.create_surface(GAME_SURFACE_NAME,mapSettings)
|
||||
-- surface.set_tiles({{name = "out-of-map",position = {1,1}}})
|
||||
-- end
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Holding pen for new players joining the map
|
||||
|
@ -4,6 +4,8 @@
|
||||
-- Code that handles everything regarding giving each player a separate spawn
|
||||
-- Includes the GUI stuff
|
||||
|
||||
require("lib/oarc_utils")
|
||||
require("config")
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- EVENT RELATED FUNCTIONS
|
||||
@ -33,6 +35,11 @@ function SeparateSpawnsGenerateChunk(event)
|
||||
local surface = event.surface
|
||||
local chunkArea = event.area
|
||||
|
||||
-- Modify enemies first.
|
||||
if OARC_MODIFIED_ENEMY_SPAWNING then
|
||||
DowngradeWormsDistanceBasedOnChunkGenerate(event)
|
||||
end
|
||||
|
||||
-- This handles chunk generation near player spawns
|
||||
-- If it is near a player spawn, it does a few things like make the area
|
||||
-- safe and provide a guaranteed area of land and water tiles.
|
||||
@ -127,11 +134,150 @@ function FindUnusedSpawns(event)
|
||||
end
|
||||
end
|
||||
|
||||
-- Clear the spawn areas.
|
||||
-- This should be run inside the chunk generate event and be given a list of all
|
||||
-- unique spawn points.
|
||||
-- This clears enemies in the immediate area, creates a slightly safe area around it,
|
||||
-- It no LONGER generates the resources though as that is now handled in a delayed event!
|
||||
function SetupAndClearSpawnAreas(surface, chunkArea, spawnPointTable)
|
||||
for name,spawn in pairs(spawnPointTable) do
|
||||
|
||||
-- Create a bunch of useful area and position variables
|
||||
local landArea = GetAreaAroundPos(spawn.pos, ENFORCE_LAND_AREA_TILE_DIST+CHUNK_SIZE)
|
||||
local safeArea = GetAreaAroundPos(spawn.pos, SAFE_AREA_TILE_DIST)
|
||||
local warningArea = GetAreaAroundPos(spawn.pos, WARNING_AREA_TILE_DIST)
|
||||
local reducedArea = GetAreaAroundPos(spawn.pos, REDUCED_DANGER_AREA_TILE_DIST)
|
||||
local chunkAreaCenter = {x=chunkArea.left_top.x+(CHUNK_SIZE/2),
|
||||
y=chunkArea.left_top.y+(CHUNK_SIZE/2)}
|
||||
local spawnPosOffset = {x=spawn.pos.x+ENFORCE_LAND_AREA_TILE_DIST,
|
||||
y=spawn.pos.y+ENFORCE_LAND_AREA_TILE_DIST}
|
||||
|
||||
-- Make chunks near a spawn safe by removing enemies
|
||||
if CheckIfInArea(chunkAreaCenter,safeArea) then
|
||||
RemoveAliensInArea(surface, chunkArea)
|
||||
|
||||
-- Create a warning area with heavily reduced enemies
|
||||
elseif CheckIfInArea(chunkAreaCenter,warningArea) then
|
||||
ReduceAliensInArea(surface, chunkArea, WARN_AREA_REDUCTION_RATIO)
|
||||
-- DowngradeWormsInArea(surface, chunkArea, 100, 100, 100)
|
||||
RemoveWormsInArea(surface, chunkArea, false, true, true, true) -- remove all non-small worms.
|
||||
|
||||
-- Create a third area with moderatly reduced enemies
|
||||
elseif CheckIfInArea(chunkAreaCenter,reducedArea) then
|
||||
ReduceAliensInArea(surface, chunkArea, REDUCED_DANGER_AREA_REDUCTION_RATIO)
|
||||
-- DowngradeWormsInArea(surface, chunkArea, 50, 100, 100)
|
||||
RemoveWormsInArea(surface, chunkArea, false, false, true, true) -- remove all huge/behemoth worms.
|
||||
end
|
||||
|
||||
-- If the chunk is within the main land area, then clear trees/resources
|
||||
-- and create the land spawn areas (guaranteed land with a circle of trees)
|
||||
if CheckIfInArea(chunkAreaCenter,landArea) then
|
||||
|
||||
-- Remove trees/resources inside the spawn area
|
||||
RemoveInCircle(surface, chunkArea, "tree", spawn.pos, ENFORCE_LAND_AREA_TILE_DIST)
|
||||
RemoveInCircle(surface, chunkArea, "resource", spawn.pos, ENFORCE_LAND_AREA_TILE_DIST+5)
|
||||
RemoveInCircle(surface, chunkArea, "cliff", spawn.pos, ENFORCE_LAND_AREA_TILE_DIST+5)
|
||||
-- RemoveDecorationsArea(surface, chunkArea)
|
||||
|
||||
if (SPAWN_TREE_CIRCLE_ENABLED) then
|
||||
CreateCropCircle(surface, spawn.pos, chunkArea, ENFORCE_LAND_AREA_TILE_DIST)
|
||||
end
|
||||
if (SPAWN_TREE_OCTAGON_ENABLED) then
|
||||
CreateCropOctagon(surface, spawn.pos, chunkArea, ENFORCE_LAND_AREA_TILE_DIST)
|
||||
end
|
||||
if (SPAWN_MOAT_CHOICE_ENABLED) then
|
||||
if (spawn.moat) then
|
||||
CreateMoat(surface, spawn.pos, chunkArea, ENFORCE_LAND_AREA_TILE_DIST)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- I wrote this to ensure everyone gets safer spawns regardless of evolution level.
|
||||
-- This is intended to downgrade any biters/spitters spawning near player bases.
|
||||
-- I'm not sure the performance impact of this but I'm hoping it's not bad.
|
||||
function ModifyEnemySpawnsNearPlayerStartingAreas(event)
|
||||
|
||||
if (not event.entity or not (event.entity.force.name == "enemy")) then
|
||||
DebugPrint("ModifyBiterSpawns - Unexpected use.")
|
||||
return
|
||||
end
|
||||
|
||||
local enemy_pos = event.entity.position
|
||||
local surface = event.entity.surface
|
||||
local enemy_name = event.entity.name
|
||||
|
||||
for name,spawn in pairs(global.uniqueSpawns) do
|
||||
if (getDistance(enemy_pos, spawn.pos) < WARNING_AREA_TILE_DIST) then
|
||||
if ((enemy_name == "big-biter") or (enemy_name == "behemoth-biter")) then
|
||||
event.entity.destroy()
|
||||
surface.create_entity{name = "medium-biter", position = pos, force = game.forces.enemy}
|
||||
DebugPrint("Downgraded biter close to spawn.")
|
||||
elseif ((enemy_name == "big-spitter") or (enemy_name == "behemoth-spitter")) then
|
||||
event.entity.destroy()
|
||||
surface.create_entity{name = "medium-spitter", position = pos, force = game.forces.enemy}
|
||||
DebugPrint("Downgraded spitter close to spawn.")
|
||||
end
|
||||
elseif (getDistance(enemy_pos, spawn.pos) < REDUCED_DANGER_AREA_REDUCTION_RATIO) then
|
||||
if (enemy_name == "behemoth-biter") then
|
||||
event.entity.destroy()
|
||||
surface.create_entity{name = "medium-biter", position = pos, force = game.forces.enemy}
|
||||
DebugPrint("Downgraded biter further from spawn.")
|
||||
elseif (enemy_name == "behemoth-spitter") then
|
||||
event.entity.destroy()
|
||||
surface.create_entity{name = "medium-spitter", position = pos, force = game.forces.enemy}
|
||||
DebugPrint("Downgraded spitter further from spawn.")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- NON-EVENT RELATED FUNCTIONS
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
-- Generate the basic starter resource around a given location.
|
||||
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
|
||||
|
||||
-- Generate oil patches
|
||||
oil_patch_x=pos.x+START_RESOURCE_OIL_POS_X
|
||||
oil_patch_y=pos.y+START_RESOURCE_OIL_POS_Y
|
||||
for i=1,START_RESOURCE_OIL_NUM_PATCHES do
|
||||
surface.create_entity({name="crude-oil", amount=START_OIL_AMOUNT,
|
||||
position={oil_patch_x, oil_patch_y}})
|
||||
oil_patch_x=oil_patch_x+START_RESOURCE_OIL_X_OFFSET
|
||||
oil_patch_y=oil_patch_y+START_RESOURCE_OIL_Y_OFFSET
|
||||
end
|
||||
|
||||
-- Generate Stone
|
||||
GenerateResourcePatch(surface, "stone", START_RESOURCE_STONE_SIZE, stonePos, START_STONE_AMOUNT)
|
||||
|
||||
-- Generate Coal
|
||||
GenerateResourcePatch(surface, "coal", START_RESOURCE_COAL_SIZE, coalPos, START_COAL_AMOUNT)
|
||||
|
||||
-- Generate Copper
|
||||
GenerateResourcePatch(surface, "copper-ore", START_RESOURCE_COPPER_SIZE, copperOrePos, START_COPPER_AMOUNT)
|
||||
|
||||
-- Generate Iron
|
||||
GenerateResourcePatch(surface, "iron-ore", START_RESOURCE_IRON_SIZE, ironOrePos, START_IRON_AMOUNT)
|
||||
|
||||
-- Generate Uranium
|
||||
GenerateResourcePatch(surface, "uranium-ore", START_RESOURCE_URANIUM_SIZE, uraniumOrePos, START_URANIUM_AMOUNT)
|
||||
end
|
||||
|
||||
-- Add a spawn to the shared spawn global
|
||||
-- Used for tracking which players are assigned to it, where it is and if
|
||||
-- it is open for new players to join
|
||||
@ -306,7 +452,7 @@ end
|
||||
|
||||
function SendPlayerToNewSpawnAndCreateIt(playerName, spawn, moatEnabled)
|
||||
|
||||
-- Make sure the area is super safe.
|
||||
-- DOUBLE CHECK and make sure the area is super safe.
|
||||
ClearNearbyEnemies(spawn, SAFE_AREA_TILE_DIST, game.surfaces[GAME_SURFACE_NAME])
|
||||
|
||||
-- Create the spawn resources here
|
||||
|
@ -124,7 +124,7 @@ function DisplaySpawnOptions(player)
|
||||
soloSpawnFlow.add{name = "isolated_spawn_main_team_radio",
|
||||
type = "radiobutton",
|
||||
caption="Join Main Team (shared research)",
|
||||
state=false}
|
||||
state=true}
|
||||
soloSpawnFlow.add{name = "isolated_spawn_new_team_radio",
|
||||
type = "radiobutton",
|
||||
caption="Create Your Own Team (own research tree)",
|
||||
|
Loading…
Reference in New Issue
Block a user