1
0
mirror of https://github.com/Oarcinae/FactorioScenarioMultiplayerSpawn.git synced 2024-12-12 10:13:58 +02:00

Multiple config options added. Gravestones returned as well.

This commit is contained in:
Oarcinae 2017-05-11 19:42:23 -04:00
parent 6f78237362
commit 4b8c52dd2d
3 changed files with 92 additions and 30 deletions

View File

@ -17,8 +17,8 @@ WELCOME_MSG_TITLE = "[INSERT SERVER OWNER MSG HERE!]"
WELCOME_MSG1 = "Rules: Be polite. Ask before changing other players's stuff. Have fun!"
WELCOME_MSG2 = "This server is running a custom scenario that changes spawn locations."
OTHER_MSG1 = "Latest updates in this scenario version (0.4.0):"
OTHER_MSG2 = "Separate teams are enabled."
OTHER_MSG1 = "Latest updates in this scenario version (0.4.1):"
OTHER_MSG2 = "Gravestones are back in."
WELCOME_MSG3 = "Due to the way this scenario works, it may take some time for the land"
WELCOME_MSG4 = "around your new spawn area to generate..."
@ -31,9 +31,9 @@ SPAWN_MSG3 = "Resources are spread out far apart but are quite rich."
-- These are my specific welcome messages that get used only if I am the user
-- that creates the game.
SERVER_OWNER_IS_OARC = false -- This should be false for you, it's just a convenience for me.
SERVER_OWNER_IS_OARC = true -- This should be false for you, it's just a convenience for me.
WELCOME_MSG_OARC = "Welcome to Oarc's official server! Join the discord here: discord.gg/TPYxRrS"
WELCOME_MSG_TITLE_OARC = "Welcome to Oarc's Server - Happy 0.15.X Bug Fest!"
WELCOME_MSG_TITLE_OARC = "Welcome to Oarc's Server - Happy 0.15.X!"
--------------------------------------------------------------------------------
@ -69,10 +69,50 @@ ENABLE_AUTOFILL = true
-- Enable Playerlist
ENABLE_PLAYER_LIST = true
-- Enable Gravestone Chests
ENABLE_GRAVESTONE_ON_DEATH = true
ENABLE_GRAVESTONE_ON_LEAVING = false -- (Items dumped into chest when you leave.)
-- Enable quick start items
ENABLE_POWER_ARMOR_QUICK_START = false
-- Enable shared vision between teams (all teams are still COOP)
ENABLE_SHARED_TEAM_VISION = true
--------------------------------------------------------------------------------
-- Spawn Options
--------------------------------------------------------------------------------
---------------------------------------
-- Starting Items
---------------------------------------
-- Items provided to the player the first time they join ("quick start" commented out)
PLAYER_SPAWN_START_ITEMS = {
{name="pistol", count=1},
{name="firearm-magazine", count=100},
{name="iron-plate", count=8},
{name="burner-mining-drill", count = 1},
{name="stone-furnace", count = 1},
-- {name="iron-plate", count=20},
-- {name="burner-mining-drill", count = 1},
-- {name="stone-furnace", count = 1},
-- {name="power-armor", count=1},
-- {name="fusion-reactor-equipment", count=1},
-- {name="battery-mk2-equipment", count=3},
-- {name="exoskeleton-equipment", count=1},
-- {name="personal-roboport-mk2-equipment", count=3},
-- {name="solar-panel-equipment", count=7},
-- {name="construction-robot", count=100},
-- {name="repair-pack", count=100},
-- {name="steel-axe", count=3},
}
-- Items provided after EVERY respawn (disabled by default)
PLAYER_RESPAWN_START_ITEMS = {
-- {name="pistol", count=1},
-- {name="firearm-magazine", count=100}
}
---------------------------------------
-- Distance Options
---------------------------------------

View File

@ -120,8 +120,7 @@ script.on_init(function(event)
-- This controls evolution growth factors and enemy expansion settings.
ConfigureAlienStartingParams()
global.welcome_msg = WELCOME_MSG
global.welcome_msg_title = WELCOME_MSG_TITLE
SetServerWelcomeMessages()
end)
@ -203,10 +202,6 @@ script.on_event(defines.events.on_player_created, function(event)
-- May change this to Lobby in the future.
game.players[event.player_index].teleport(game.forces[MAIN_FORCE].get_spawn_position(GAME_SURFACE_NAME), GAME_SURFACE_NAME)
if (SERVER_OWNER_IS_OARC) then
SetOarcServerMessages()
end
if ENABLE_LONGREACH then
GivePlayerLongReach(game.players[event.player_index])
end
@ -216,22 +211,31 @@ script.on_event(defines.events.on_player_created, function(event)
else
SeparateSpawnsPlayerCreated(event)
end
end)
script.on_event(defines.events.on_player_respawned, function(event)
if not ENABLE_SEPARATE_SPAWNS then
PlayerRespawnItems(event)
else
SeparateSpawnsPlayerRespawned(event)
if ENABLE_SEPARATE_SPAWNS then
SeparateSpawnsPlayerRespawned(event)
end
PlayerRespawnItems(event)
if ENABLE_LONGREACH then
GivePlayerLongReach(game.players[event.player_index])
end
end)
script.on_event(defines.events.on_pre_player_died, function(event)
if ENABLE_GRAVESTONE_ON_DEATH then
DropGravestoneChests(game.players[event.player_index])
end
end)
script.on_event(defines.events.on_player_left_game, function(event)
if ENABLE_GRAVESTONE_ON_LEAVING then
DropGravestoneChests(game.players[event.player_index])
end
if ENABLE_SEPARATE_SPAWNS then
FindUnusedSpawns(event)
end
@ -248,11 +252,13 @@ local tick_counter = 0
script.on_event(defines.events.on_tick, function(event)
-- Every few seconds, chart all players to "share vision"
if (tick_counter >= (TICKS_PER_SECOND*5)) then
ShareVisionBetweenPlayers()
tick_counter = 0
else
tick_counter = tick_counter + 1
if ENABLE_SHARED_TEAM_VISION then
if (tick_counter >= (TICKS_PER_SECOND*5)) then
ShareVisionBetweenPlayers()
tick_counter = 0
else
tick_counter = tick_counter + 1
end
end
end)

View File

@ -52,21 +52,26 @@ function FindUnusedSpawns(event)
if (global.playerSpawns[player.name] ~= nil) then
global.playerSpawns[player.name] = nil
end
-- Remove from shared spawns, transfer ownership if other players are on their team
if (global.sharedSpawns[player.name] ~= nil) then
-- if (#global.sharedSpawns[player.name].players > 1) then
-- for _,teamMateName in pairs(global.sharedSpawns[player.name].players) do
-- if (teamMateName ~= player.name) then
-- TransferOwnershipOfSharedSpawn(player, game.players[teamMateName])
-- break
-- end
-- end
-- else
global.sharedSpawns[player.name] = nil
-- end
end
-- If a uniqueSpawn was created for the player, mark it as unused.
if (global.uniqueSpawns[player.name] ~= nil) then
table.insert(global.unusedSpawns, global.uniqueSpawns[player.name])
-- TODO: Test player joining and leaving quickly to ensure
-- spawn points are not messed up...
-- global.uniqueSpawns[player.name] = nil
SendBroadcastMsg(player.name .. " base was freed up because they left within 5 minutes of joining.")
end
-- Remove from shared spawns
if (global.sharedSpawns[player.name] ~= nil) then
global.sharedSpawns[player.name] = nil
end
-- remove that player's cooldown setting
if (global.playerCooldowns[player.name] ~= nil) then
@ -107,6 +112,17 @@ function CreateNewSharedSpawn(player)
players={}}
end
function TransferOwnershipOfSharedSpawn(prevOwner, newOwner)
-- Transfer the shared spawn global
global.sharedSpawns[newOwner.name] = global.sharedSpawns[prevOwner.name]
global.sharedSpawns[newOwner.name].openAccess = false
global.sharedSpawns[prevOwner.name] = nil
-- Transfer the unique spawn global
global.uniqueSpawns[newOwner.name] = global.uniqueSpawns[prevOwner.name]
global.uniqueSpawns[prevOwner.name] = nil
end
-- Returns the number of players currently online at the shared spawn
function GetOnlinePlayersAtSharedSpawn(ownerName)
if (global.sharedSpawns[ownerName] ~= nil) then
@ -177,7 +193,7 @@ function InitSpawnGlobalsAndForces()
game.forces[MAIN_FORCE].set_spawn_position(game.forces["player"].get_spawn_position(GAME_SURFACE_NAME), GAME_SURFACE_NAME)
SetCeaseFireBetweenAllForces()
SetFriendlyBetweenAllForces()
AntiGriefing(game.forces[MAIN_FORCE])
-- AntiGriefing(game.forces[MAIN_FORCE])
end