1
0
mirror of https://github.com/Oarcinae/FactorioScenarioMultiplayerSpawn.git synced 2025-01-05 22:53:48 +02:00

Bit more cleanup and added chest randomization and minimum distribution of 1.

This commit is contained in:
Oarcinae 2020-02-04 15:10:13 -05:00
parent 543e929666
commit e138a69e93
8 changed files with 100 additions and 208 deletions

View File

@ -201,16 +201,6 @@ script.on_event(defines.events.on_player_created, function(event)
SeparateSpawnsPlayerCreated(event.player_index)
InitOarcGuiTabs(player)
SharedChestsSpawnInput(player, {x=0, y=0-5})
SharedChestsSpawnInput(player, {x=0, y=0-4})
SharedChestsSpawnInput(player, {x=0, y=0-3})
SharedChestsSpawnInput(player, {x=0, y=0-2})
SharedChestsSpawnOutput(player, {x=0, y=0+2})
SharedChestsSpawnOutput(player, {x=0, y=0+3})
SharedChestsSpawnOutput(player, {x=0, y=0+4})
SharedChestsSpawnOutput(player, {x=0, y=0+5})
end)
script.on_event(defines.events.on_player_respawned, function(event)
@ -293,7 +283,9 @@ script.on_event(defines.events.on_tick, function(event)
DelayedSiloCreationOnTick(game.surfaces[GAME_SURFACE_NAME])
end
SharedChestsOnTick()
if global.ocfg.enable_chest_sharing then
SharedChestsOnTick()
end
end)

View File

@ -80,10 +80,16 @@ ENABLE_ABANDONED_BASE_REMOVAL = true
-- Enable the new 0.17 research queue by default for all forces.
ENABLE_RESEARCH_QUEUE = true
-- Enable chest sharing system. WIP
ENABLE_CHEST_SHARING = true
-- Lock power armor mk2, atomic bombs and artillery until you launch a rocket.
-- Also lock speed/prod module-3s
LOCK_GOODIES_UNTIL_ROCKET_LAUNCH = false
-- Give cheaty items on start.
ENABLE_POWER_ARMOR_QUICK_START = false
--------------------------------------------------------------------------------
-- MAP CONFIGURATION OPTIONS
-- In past versions I had a way to config map settings here to be used for cmd

View File

@ -110,7 +110,7 @@ function CreateGameOptionsTab(tab_container, player)
if (global.ocfg.enable_regrowth) then
game_info_str = game_info_str.."\n".."Old parts of the map will slowly be deleted over time (chunks without any player buildings)."
end
if (ENABLE_POWER_ARMOR_QUICK_START) then
if (global.ocfg.enable_power_armor_start) then
game_info_str = game_info_str.."\n".."Power armor quick start enabled."
end
if (global.ocfg.lock_goodies_rocket_launch) then

View File

@ -19,181 +19,55 @@ function InitOarcConfig()
global.ocfg.locked_build_area_tile = "tutorial-grid"
end
-- SCENARIO VERSION
if (not game.active_mods["oarc-mod"]) then
global.ocfg.welcome_title = WELCOME_MSG_TITLE
global.ocfg.welcome_msg = WELCOME_MSG
global.ocfg.server_rules = SERVER_MSG
global.ocfg.minimum_online_time = MIN_ONLINE_TIME_IN_MINUTES
global.ocfg.server_contact = CONTACT_MSG
global.ocfg.enable_vanilla_spawns = ENABLE_VANILLA_SPAWNS
global.ocfg.enable_buddy_spawn = ENABLE_BUDDY_SPAWN
global.ocfg.frontier_rocket_silo = FRONTIER_ROCKET_SILO_MODE
global.ocfg.silo_islands = SILO_ISLANDS_MODE
global.ocfg.enable_undecorator = ENABLE_UNDECORATOR
global.ocfg.enable_tags = ENABLE_TAGS
global.ocfg.enable_long_reach = ENABLE_LONGREACH
global.ocfg.enable_autofill = ENABLE_AUTOFILL
global.ocfg.enable_loaders = ENABLE_LOADERS
global.ocfg.enable_player_list = ENABLE_PLAYER_LIST
global.ocfg.list_offline_players = PLAYER_LIST_OFFLINE_PLAYERS
global.ocfg.enable_shared_team_vision = ENABLE_SHARED_TEAM_VISION
global.ocfg.enable_regrowth = ENABLE_REGROWTH
global.ocfg.enable_abandoned_base_removal = ENABLE_ABANDONED_BASE_REMOVAL
global.ocfg.enable_research_queue = ENABLE_RESEARCH_QUEUE
global.ocfg.lock_goodies_rocket_launch = LOCK_GOODIES_UNTIL_ROCKET_LAUNCH
-- SCENARIO VERSION (ONLY - no more mod version.)
global.ocfg.welcome_title = WELCOME_MSG_TITLE
global.ocfg.welcome_msg = WELCOME_MSG
global.ocfg.server_rules = SERVER_MSG
global.ocfg.minimum_online_time = MIN_ONLINE_TIME_IN_MINUTES
global.ocfg.server_contact = CONTACT_MSG
global.ocfg.enable_vanilla_spawns = ENABLE_VANILLA_SPAWNS
global.ocfg.enable_buddy_spawn = ENABLE_BUDDY_SPAWN
global.ocfg.frontier_rocket_silo = FRONTIER_ROCKET_SILO_MODE
global.ocfg.silo_islands = SILO_ISLANDS_MODE
global.ocfg.enable_undecorator = ENABLE_UNDECORATOR
global.ocfg.enable_tags = ENABLE_TAGS
global.ocfg.enable_long_reach = ENABLE_LONGREACH
global.ocfg.enable_autofill = ENABLE_AUTOFILL
global.ocfg.enable_loaders = ENABLE_LOADERS
global.ocfg.enable_player_list = ENABLE_PLAYER_LIST
global.ocfg.list_offline_players = PLAYER_LIST_OFFLINE_PLAYERS
global.ocfg.enable_shared_team_vision = ENABLE_SHARED_TEAM_VISION
global.ocfg.enable_regrowth = ENABLE_REGROWTH
global.ocfg.enable_abandoned_base_removal = ENABLE_ABANDONED_BASE_REMOVAL
global.ocfg.enable_research_queue = ENABLE_RESEARCH_QUEUE
global.ocfg.enable_chest_sharing = ENABLE_CHEST_SHARING
global.ocfg.enable_power_armor_start = ENABLE_POWER_ARMOR_QUICK_START
global.ocfg.lock_goodies_rocket_launch = LOCK_GOODIES_UNTIL_ROCKET_LAUNCH
global.ocfg.modified_enemy_spawning = OARC_MODIFIED_ENEMY_SPAWNING
global.ocfg.near_dist_start = NEAR_MIN_DIST
global.ocfg.near_dist_end = NEAR_MAX_DIST
global.ocfg.far_dist_start = FAR_MIN_DIST
global.ocfg.far_dist_end = FAR_MAX_DIST
global.ocfg.vanilla_spawn_count = VANILLA_SPAWN_COUNT
global.ocfg.vanilla_spawn_spacing = VANILLA_SPAWN_SPACING
global.ocfg.modified_enemy_spawning = OARC_MODIFIED_ENEMY_SPAWNING
global.ocfg.near_dist_start = NEAR_MIN_DIST
global.ocfg.near_dist_end = NEAR_MAX_DIST
global.ocfg.far_dist_start = FAR_MIN_DIST
global.ocfg.far_dist_end = FAR_MAX_DIST
global.ocfg.vanilla_spawn_count = VANILLA_SPAWN_COUNT
global.ocfg.vanilla_spawn_spacing = VANILLA_SPAWN_SPACING
global.ocfg.spawn_config = OARC_CFG
global.ocfg.spawn_config = OARC_CFG
global.ocfg.enable_separate_teams = ENABLE_SEPARATE_TEAMS
global.ocfg.main_force = MAIN_FORCE
global.ocfg.enable_shared_spawns = ENABLE_SHARED_SPAWNS
global.ocfg.max_players_shared_spawn = MAX_PLAYERS_AT_SHARED_SPAWN
global.ocfg.enable_shared_chat = ENABLE_SHARED_TEAM_CHAT
global.ocfg.respawn_cooldown_min = RESPAWN_COOLDOWN_IN_MINUTES
global.ocfg.frontier_silo_count = SILO_NUM_SPAWNS
global.ocfg.frontier_silo_distance = SILO_CHUNK_DISTANCE
global.ocfg.frontier_fixed_pos = SILO_FIXED_POSITION
global.ocfg.frontier_pos_table = SILO_POSITIONS
global.ocfg.frontier_silo_vision = ENABLE_SILO_VISION
global.ocfg.frontier_allow_build = ENABLE_SILO_PLAYER_BUILD
global.ocfg.enable_separate_teams = ENABLE_SEPARATE_TEAMS
global.ocfg.main_force = MAIN_FORCE
global.ocfg.enable_shared_spawns = ENABLE_SHARED_SPAWNS
global.ocfg.max_players_shared_spawn = MAX_PLAYERS_AT_SHARED_SPAWN
global.ocfg.enable_shared_chat = ENABLE_SHARED_TEAM_CHAT
global.ocfg.respawn_cooldown_min = RESPAWN_COOLDOWN_IN_MINUTES
global.ocfg.frontier_silo_count = SILO_NUM_SPAWNS
global.ocfg.frontier_silo_distance = SILO_CHUNK_DISTANCE
global.ocfg.frontier_fixed_pos = SILO_FIXED_POSITION
global.ocfg.frontier_pos_table = SILO_POSITIONS
global.ocfg.frontier_silo_vision = ENABLE_SILO_VISION
global.ocfg.frontier_allow_build = ENABLE_SILO_PLAYER_BUILD
global.ocfg.enable_server_write_files = ENABLE_SERVER_WRITE_FILES
-- MOD VERSION
else
log("Oarc MOD! Version: " .. game.active_mods["oarc-mod"].version)
global.ocfg.welcome_title = settings.global["oarc-welcome-title"].value
global.ocfg.welcome_msg = settings.global["oarc-welcome-msg"].value
global.ocfg.server_rules = settings.global["oarc-server-rules"].value
global.ocfg.minimum_online_time = settings.global["oarc-minimum-online-time"].value
global.ocfg.server_contact = settings.global["oarc-server-contact"].value
global.ocfg.enable_vanilla_spawns = settings.global["oarc-enable-vanilla-spawns"].value
global.ocfg.enable_buddy_spawn = settings.global["oarc-enable-buddy-spawn"].value
global.ocfg.frontier_rocket_silo = settings.global["oarc-frontier-rocket-silo"].value
global.ocfg.enable_undecorator = settings.global["oarc-enable-undecorator"].value
global.ocfg.enable_tags = settings.global["oarc-enable-tags"].value
global.ocfg.enable_long_reach = settings.global["oarc-enable-long-reach"].value
global.ocfg.enable_autofill = settings.global["oarc-enable-autofill"].value
global.ocfg.enable_loaders = false
global.ocfg.enable_player_list = settings.global["oarc-enable-player-list"].value
global.ocfg.list_offline_players = settings.global["oarc-list-offline-players"].value
global.ocfg.enable_shared_team_vision = settings.global["oarc-enable-shared-team-vision"].value
global.ocfg.enable_regrowth = settings.global["oarc-enable-regrowth"].value
global.ocfg.enable_research_queue = settings.global["oarc-enable-research-queue"].value
global.ocfg.lock_goodies_rocket_launch = false
global.ocfg.modified_enemy_spawning = settings.global["oarc-modified-enemy-spawning"].value
global.ocfg.near_dist_start = settings.global["oarc-near-dist-start"].value
global.ocfg.near_dist_end = settings.global["oarc-near-dist-end"].value
global.ocfg.far_dist_start = settings.global["oarc-far-dist-start"].value
global.ocfg.far_dist_end = settings.global["oarc-far-dist-end"].value
global.ocfg.vanilla_spawn_count = settings.global["oarc-vanilla-spawn-count"].value
global.ocfg.vanilla_spawn_spacing = settings.global["oarc-vanilla-spawn-spacing"].value
global.ocfg.spawn_config = {
gen_settings = {
land_area_tiles = settings.global["oarc-enforce-land-area-tile-dist"].value,
moat_choice_enabled = settings.global["oarc-allow-moat-choice"].value,
moat_size_modifier = settings.global["oarc-moat-size-mod"].value,
resources_circle_shape = settings.global["oarc-resource-shape-circle"].value,
force_grass = settings.global["oarc-force-grass"].value,
tree_circle = settings.global["oarc-tree-circle"].value,
tree_octagon = settings.global["oarc-tree-octagon"].value,
},
safe_area =
{
safe_radius = CHUNK_SIZE*10,
warn_radius = CHUNK_SIZE*20,
warn_reduction = 20,
danger_radius = CHUNK_SIZE*50,
danger_reduction = 5,
},
water = {
x_offset = settings.global["oarc-water-x-offset"].value,
y_offset = settings.global["oarc-water-y-offset"].value,
length = settings.global["oarc-water-length"].value,
},
resource_rand_pos_settings =
{
enabled = settings.global["oarc-resource-rand-pos-enabled"].value,
radius = settings.global["oarc-resource-rand-pos-radius"].value,
angle_offset = settings.global["oarc-resource-rand-pos-angle-offset"].value,
angle_final = settings.global["oarc-resource-rand-pos-angle-final"].value,
},
resource_tiles =
{
[settings.global["oarc-resource-1-name"].value] =
{
amount = settings.global["oarc-resource-1-amount"].value,
size = settings.global["oarc-resource-1-size"].value,
x_offset = -29,
y_offset = 16
},
[settings.global["oarc-resource-2-name"].value] =
{
amount = settings.global["oarc-resource-2-amount"].value,
size = settings.global["oarc-resource-2-size"].value,
x_offset = -28,
y_offset = -3
},
[settings.global["oarc-resource-3-name"].value] =
{
amount = settings.global["oarc-resource-3-amount"].value,
size = settings.global["oarc-resource-3-size"].value,
x_offset = -27,
y_offset = -34
},
[settings.global["oarc-resource-4-name"].value] =
{
amount = settings.global["oarc-resource-4-amount"].value,
size = settings.global["oarc-resource-4-size"].value,
x_offset = -27,
y_offset = -20
}
-- [settings.global["oarc-resource-5-name"].value] =
-- {
-- amount = settings.global["oarc-resource-5-amount"].value,
-- size = settings.global["oarc-resource-5-size"].value,
-- x_offset = -27,
-- y_offset = -20
-- }
},
resource_patches =
{
[settings.global["oarc-resource-patch-1-name"].value] =
{
num_patches = settings.global["oarc-resource-patch-1-count"].value,
amount = settings.global["oarc-resource-patch-1-amount"].value,
x_offset_start = 0,
y_offset_start = 48,
x_offset_next = 4,
y_offset_next = 0
}
},
}
global.ocfg.enable_separate_teams = settings.global["oarc-enable-separate-teams"].value
global.ocfg.main_force = settings.global["oarc-main-force"].value
global.ocfg.enable_shared_spawns = settings.global["oarc-enable-shared-spawns"].value
global.ocfg.max_players_shared_spawn = settings.global["oarc-max-players-shared-spawn"].value
global.ocfg.enable_shared_chat = settings.global["oarc-enable-shared-chat"].value
global.ocfg.respawn_cooldown_min = settings.global["oarc-respawn-cooldown-min"].value
global.ocfg.frontier_silo_count = settings.global["oarc-frontier-silo-count"].value
global.ocfg.frontier_silo_distance = settings.global["oarc-frontier-silo-distance"].value
global.ocfg.frontier_fixed_pos = false
global.ocfg.frontier_pos_table = {{x = 0, y = 100}}
global.ocfg.frontier_silo_vision = settings.global["oarc-frontier-silo-vision"].value
global.ocfg.frontier_allow_build = true
end
global.ocfg.enable_server_write_files = ENABLE_SERVER_WRITE_FILES
-----------------------

View File

@ -51,8 +51,10 @@ function InitOarcGuiTabs(player)
SetOarcGuiTabEnabled(player, OARC_ROCKETS_GUI_TAB_NAME, true)
end
AddOarcGuiTab(player, OARC_SHARED_ITEMS_GUI_TAB_NAME)
SetOarcGuiTabEnabled(player, OARC_SHARED_ITEMS_GUI_TAB_NAME, true)
if global.ocfg.enable_chest_sharing then
AddOarcGuiTab(player, OARC_SHARED_ITEMS_GUI_TAB_NAME)
SetOarcGuiTabEnabled(player, OARC_SHARED_ITEMS_GUI_TAB_NAME, true)
end
end
function CreateOarcGuiButton(player)

View File

@ -184,7 +184,7 @@ function GivePlayerStarterItems(player)
player.insert(item)
end
if ENABLE_POWER_ARMOR_QUICK_START then
if global.ocfg.enable_power_armor_start then
GiveQuickStartPowerArmor(player)
end
end

View File

@ -622,20 +622,22 @@ function SendPlayerToNewSpawnAndCreateIt(delayedSpawn)
player.gui.screen.wait_for_spawn_dialog.destroy()
end
-- Shared chests - WIP
-- TODO Add an enable option in the config for this.
SharedChestsSpawnInput(game.players[delayedSpawn.playerName], {x=delayedSpawn.pos.x+45, y=delayedSpawn.pos.y-5})
SharedChestsSpawnInput(game.players[delayedSpawn.playerName], {x=delayedSpawn.pos.x+45, y=delayedSpawn.pos.y-4})
SharedChestsSpawnInput(game.players[delayedSpawn.playerName], {x=delayedSpawn.pos.x+45, y=delayedSpawn.pos.y-3})
SharedChestsSpawnInput(game.players[delayedSpawn.playerName], {x=delayedSpawn.pos.x+45, y=delayedSpawn.pos.y-2})
local x_dist = global.ocfg.spawn_config.resource_rand_pos_settings.radius
if global.ocfg.enable_chest_sharing then
SharedChestsSpawnOutput(game.players[delayedSpawn.playerName], {x=delayedSpawn.pos.x+45, y=delayedSpawn.pos.y+2})
SharedChestsSpawnOutput(game.players[delayedSpawn.playerName], {x=delayedSpawn.pos.x+45, y=delayedSpawn.pos.y+3})
SharedChestsSpawnOutput(game.players[delayedSpawn.playerName], {x=delayedSpawn.pos.x+45, y=delayedSpawn.pos.y+4})
SharedChestsSpawnOutput(game.players[delayedSpawn.playerName], {x=delayedSpawn.pos.x+45, y=delayedSpawn.pos.y+5})
SharedChestsSpawnInput(game.players[delayedSpawn.playerName], {x=delayedSpawn.pos.x+x_dist, y=delayedSpawn.pos.y-5})
SharedChestsSpawnInput(game.players[delayedSpawn.playerName], {x=delayedSpawn.pos.x+x_dist, y=delayedSpawn.pos.y-4})
SharedChestsSpawnInput(game.players[delayedSpawn.playerName], {x=delayedSpawn.pos.x+x_dist, y=delayedSpawn.pos.y-3})
SharedChestsSpawnInput(game.players[delayedSpawn.playerName], {x=delayedSpawn.pos.x+x_dist, y=delayedSpawn.pos.y-2})
CreateTileArrow(game.surfaces[GAME_SURFACE_NAME], {x=delayedSpawn.pos.x+41, y=delayedSpawn.pos.y-4}, "RIGHT")
CreateTileArrow(game.surfaces[GAME_SURFACE_NAME], {x=delayedSpawn.pos.x+41, y=delayedSpawn.pos.y+3}, "LEFT")
SharedChestsSpawnOutput(game.players[delayedSpawn.playerName], {x=delayedSpawn.pos.x+x_dist, y=delayedSpawn.pos.y+2})
SharedChestsSpawnOutput(game.players[delayedSpawn.playerName], {x=delayedSpawn.pos.x+x_dist, y=delayedSpawn.pos.y+3})
SharedChestsSpawnOutput(game.players[delayedSpawn.playerName], {x=delayedSpawn.pos.x+x_dist, y=delayedSpawn.pos.y+4})
SharedChestsSpawnOutput(game.players[delayedSpawn.playerName], {x=delayedSpawn.pos.x+x_dist, y=delayedSpawn.pos.y+5})
CreateTileArrow(game.surfaces[GAME_SURFACE_NAME], {x=delayedSpawn.pos.x+41, y=delayedSpawn.pos.y-4}, "RIGHT")
CreateTileArrow(game.surfaces[GAME_SURFACE_NAME], {x=delayedSpawn.pos.x+41, y=delayedSpawn.pos.y+3}, "LEFT")
end
end
function SendPlayerToSpawn(player)

View File

@ -21,6 +21,11 @@
-- electric-energy-interface for sharing electricity?
-- These items won't be sucked up since they can't be removed.
EXCEPTION_LIST = {['loader'] = true,
['fast-loader'] = true,
['express-loader'] = true}
-- This function spawns chests at the given location.
function SharedChestsSpawnInput(player, pos)
@ -78,15 +83,17 @@ function SharedChestsDepositAll()
for itemName,count in pairs(contents) do
-- log("Input chest: " .. itemName .. " " .. count)
if (global.shared_items[itemName] == nil) then
global.shared_items[itemName] = count
else
global.shared_items[itemName] = global.shared_items[itemName] + count
if (EXCEPTION_LIST[itemName] == nil) then
if (global.shared_items[itemName] == nil) then
global.shared_items[itemName] = count
else
global.shared_items[itemName] = global.shared_items[itemName] + count
end
chestInv.remove({name=itemName, count=count})
end
end
chestInv.clear()
end
end
end
@ -159,6 +166,11 @@ function SharedChestsTallyRequests()
cap = math.floor(global.shared_items[reqName] / TableLength(global.shared_requests[reqName]))
log("Cap shared " .. global.shared_items[reqName] .. " / " .. TableLength(global.shared_requests[reqName]) .. " = " .. cap)
log(serpent.block(global.shared_requests[reqName]))
-- In the case where we are rounding down to 0, let's bump the minimum distribution to 1.
if (cap == 0) then
cap = 1
end
end
-- Limit each request to the cap.
@ -200,8 +212,7 @@ function SharedChestsDistributeRequests()
(global.shared_items[req.name] ~= nil) and
(global.shared_requests[req.name][chestInfo.player] ~= nil) then
if (global.shared_requests[req.name][chestInfo.player] > 0) then
if (global.shared_requests[req.name][chestInfo.player] > 0)and (global.shared_items[req.name] > 0) then
-- How much is already in the chest?
local existingAmount = chestEntity.get_inventory(defines.inventory.chest).get_item_count(req.name)
@ -210,7 +221,7 @@ function SharedChestsDistributeRequests()
-- How much is allowed based on the player's current request amount?
local allowedAmount = math.min(requestAmount, global.shared_requests[req.name][chestInfo.player])
if ((allowedAmount > 0) and (global.shared_items[req.name] > 0)) then
if (allowedAmount > 0) then
local chestInv = chestEntity.get_inventory(defines.inventory.chest)
if chestInv.can_insert({name=req.name}) then
@ -257,6 +268,11 @@ function SharedChestsOnTick()
log("SHARED_REQ: " .. serpent.block(global.shared_requests))
log("SHARED_REQ_TOTAL: " .. serpent.block(global.shared_requests_totals))
end
-- Shuffle chests to avoid having the same chests filled first every time.
if ((game.tick % (60)) == 40) then
global.shared_chests = FYShuffle(global.shared_chests)
end
end