1
0
mirror of https://github.com/Oarcinae/FactorioScenarioMultiplayerSpawn.git synced 2025-01-18 02:58:37 +02:00

Prep work before starting dev on regrowth idea.

This commit is contained in:
Oarcinae 2017-07-25 20:20:35 -04:00
parent 46c0560d51
commit afc867e263
5 changed files with 44 additions and 21 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.1):"
OTHER_MSG2 = "Gravestones are back in."
OTHER_MSG1 = "Latest updates in this scenario version (0.4.2):"
OTHER_MSG2 = "Far spawn is further now."
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..."
@ -70,7 +70,8 @@ ENABLE_AUTOFILL = true
ENABLE_PLAYER_LIST = true
-- Enable Gravestone Chests
ENABLE_GRAVESTONE_ON_DEATH = true
ENABLE_GRAVESTONE_ON_DEATH = false
-- Items dumped into chest when you leave.
ENABLE_GRAVESTONE_ON_LEAVING = false
-- If anyone leaves within first X minutes, items get dumped into chest.
@ -138,6 +139,9 @@ FAR_MAX_DIST = 300 --125
-- Resource & Spawn Circle Options
---------------------------------------
-- Allow players to choose to spawn with a moat
SPAWN_MOAT_CHOICE_ENABLED = true
-- Create a circle of land area for the spawn
-- This is the radius (I think?) in TILES.
ENFORCE_LAND_AREA_TILE_DIST = 48
@ -233,6 +237,10 @@ ENABLE_DEFAULT_SPAWN = false
ENABLE_SHARED_SPAWNS = true
MAX_ONLINE_PLAYERS_AT_SHARED_SPAWN = 3
-- Share local team chat with all teams
-- This makes it so you don't have to use /s
-- but it means you can't talk privately with your own team.
ENABLE_SHARED_TEAM_CHAT = true
---------------------------------------
-- Special Action Cooldowns
@ -302,4 +310,4 @@ MAP_SETTINGS_RSO_STARTING_AREA = "very-low" -- Does not affect Oarc spawn sizes.
--------------------------------------------------------------------------------
-- DEBUG prints for me
global.oarcDebugEnabled = false
global.oarcDebugEnabled = true

View File

@ -144,12 +144,6 @@ script.on_event(defines.events.on_rocket_launched, function(event)
end)
script.on_event(defines.events.on_console_chat, function(event)
DebugPrint(event.message)
end)
----------------------------------------
-- Chunk Generation
----------------------------------------
@ -268,6 +262,9 @@ script.on_event(defines.events.on_built_entity, function(event)
end)
----------------------------------------
-- Shared vision, charts a small area around other players
----------------------------------------
script.on_event(defines.events.on_tick, function(event)
-- Every few seconds, chart all players to "share vision"
if ENABLE_SHARED_TEAM_VISION then
@ -275,6 +272,14 @@ script.on_event(defines.events.on_tick, function(event)
end
end)
----------------------------------------
-- Shared chat, so you don't have to type /s
----------------------------------------
script.on_event(defines.events.on_console_chat, function(event)
if (ENABLE_SHARED_TEAM_CHAT) then
ShareChatBetweenForces(game.players[event.player_index], event.message)
end
end)
----------------------------------------
-- On Research Finished

2
locale

@ -1 +1 @@
Subproject commit 951dc635058a71d7c1e8f7d45930933eee7c3f18
Subproject commit ae13b315c76227a6993dcc02f640a84da26dcea3

View File

@ -41,7 +41,7 @@ end
-- Call this if a player leaves the game
-- Seems to be susceptiable to causing desyncs...
-- Still seems to have a bug.
function FindUnusedSpawns(event)
local player = game.players[event.player_index]
if (player.online_time < MIN_ONLINE_TIME) then
@ -214,7 +214,7 @@ function ChangePlayerSpawn(player, pos)
global.playerCooldowns[player.name] = {setRespawn=game.tick}
end
function SendPlayerToNewSpawnAndCreateIt(player, spawn)
function SendPlayerToNewSpawnAndCreateIt(player, spawn, moatEnabled)
-- Send the player to that position
player.teleport(spawn, GAME_SURFACE_NAME)
GivePlayerStarterItems(player)
@ -222,7 +222,7 @@ function SendPlayerToNewSpawnAndCreateIt(player, spawn)
-- If we get a valid spawn point, setup the area
if ((spawn.x ~= 0) and (spawn.y ~= 0)) then
global.uniqueSpawns[player.name] = spawn
global.uniqueSpawns[player.name] = {pos=spawn,moat=moatEnabled}
ClearNearbyEnemies(player, SAFE_AREA_TILE_DIST)
else
DebugPrint("THIS SHOULD NOT EVER HAPPEN! Spawn failed!")
@ -247,9 +247,9 @@ function SendPlayerToRandomSpawn(player)
player.teleport(game.forces[MAIN_FORCE].get_spawn_position(GAME_SURFACE_NAME), GAME_SURFACE_NAME)
else
counter = counter + 1
for name,spawnPos in pairs(global.uniqueSpawns) do
for name,spawn in pairs(global.uniqueSpawns) do
if (counter == rndSpawn) then
player.teleport(spawnPos)
player.teleport(spawn.pos)
break
end
counter = counter + 1

View File

@ -170,6 +170,12 @@ function DisplaySpawnOptions(player)
type = "radiobutton",
caption="Create Your Own Team (own research tree)",
state=false}
if (SPAWN_MOAT_CHOICE_ENABLED) then
soloSpawnFlow.add{name = "isolated_spawn_moat_option_checkbox",
type = "checkbox",
caption="Surround your spawn with a moat",
state=false}
end
soloSpawnFlow.add{name = "team_chat_warning_lbl1", type = "label",
caption="You must type '/s' before your msg to chat with other teams!!!"}
ApplyStyle(soloSpawnFlow.team_chat_warning_lbl1, my_warning_style)
@ -268,7 +274,7 @@ function SpawnOptsGuiClick(event)
return -- Gui event unrelated to this gui.
end
local joinMainTeamRadio, joinOwnTeamRadio = false
local joinMainTeamRadio, joinOwnTeamRadio, moatChoice = false
-- Check if a valid button on the gui was pressed
-- and delete the GUI
@ -283,6 +289,10 @@ function SpawnOptsGuiClick(event)
player.gui.center.spawn_opts.spawn_solo_flow.isolated_spawn_main_team_radio.state
joinOwnTeamRadio =
player.gui.center.spawn_opts.spawn_solo_flow.isolated_spawn_new_team_radio.state
if (SPAWN_MOAT_CHOICE_ENABLED) then
moatChoice =
player.gui.center.spawn_opts.spawn_solo_flow.isolated_spawn_moat_option_checkbox.state
end
end
player.gui.center.spawn_opts.destroy()
@ -325,10 +335,10 @@ function SpawnOptsGuiClick(event)
-- Re-used abandoned spawns...
if (#global.unusedSpawns >= 1) then
newSpawn = table.remove(global.unusedSpawns)
global.uniqueSpawns[player.name] = newSpawn
oldSpawn = table.remove(global.unusedSpawns)
global.uniqueSpawns[player.name] = oldSpawn
player.print("Sorry! You have been assigned to an abandoned base! This is done to keep map size small.")
ChangePlayerSpawn(player, newSpawn)
ChangePlayerSpawn(player, oldSpawn.pos)
SendPlayerToSpawn(player)
GivePlayerStarterItems(player)
SendBroadcastMsg(player.name .. " joined an abandoned base!")
@ -351,7 +361,7 @@ function SpawnOptsGuiClick(event)
ChangePlayerSpawn(player, newSpawn)
-- Send the player there
SendPlayerToNewSpawnAndCreateIt(player, newSpawn)
SendPlayerToNewSpawnAndCreateIt(player, newSpawn, moatChoice)
if (elemName == "isolated_spawn_near") then
SendBroadcastMsg(player.name .. " joined the game from a distance!")
elseif (elemName == "isolated_spawn_far") then