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

Fixed resource spawning in starting areas (I think). Added player list panel. Fixed unintended gui click teleports. Changed map creation to create a new surface.

This commit is contained in:
Oarcinae 2017-04-27 21:48:28 -04:00
parent f6fe07c4e5
commit ffcc3cc4a2
6 changed files with 68 additions and 47 deletions

View File

@ -28,6 +28,10 @@ Go into config.lua and edit the strings to add your own server messages.
Rename the "FactorioScenarioMultiplayerSpawn" folder to something shorter and more convenient (optional).
### STEP 4
Generate a new map, use that save file to host if you want to.
## Configuration
@ -53,4 +57,13 @@ https://mods.factorio.com/mods/orzelek/rso-mod
Several other portions of the code (tags, frontier style rocket silo) have also been adapted from other scenario code.
Credit to 3Ra for help as well: https://github.com/3RaGaming
Credit to 3Ra for help as well: https://github.com/3RaGaming
## Random Notes
While it is an option to disable RSO, I would not recommend doing that. I can't guarantee any bugs or issues as I focus mostly on testing with RSO enabled.
Feel free to submit bugs/fixes/requests/pulls/forks whatever you want.
I do not plan on supporting PvP, but I will help anyone who wants to make it a configurable option.

View File

@ -14,8 +14,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.3.0):"
OTHER_MSG2 = "0.15.X Compatibility Update - Still in Beta!?!"
OTHER_MSG1 = "Latest updates in this scenario version (0.3.1):"
OTHER_MSG2 = "0.15.X Updates. Code cleanup behind the scenes"
WELCOME_MSG3 = "Due to the way this scenario works, it may take some time for the land"
@ -61,6 +61,9 @@ ENABLE_LONGREACH = true
-- Enable Autofill
ENABLE_AUTOFILL = true
-- Enable Playerlist
ENABLE_PLAYER_LIST = true
--------------------------------------------------------------------------------
-- Spawn Options
--------------------------------------------------------------------------------
@ -123,7 +126,7 @@ START_RESOURCE_IRON_SIZE = 16
START_RESOURCE_URANIUM_POS_X = 17
START_RESOURCE_URANIUM_POS_Y = -34
START_RESOURCE_URANIUM_SIZE = 10
START_RESOURCE_URANIUM_SIZE = 0 -- Disabled by default.
-- There are 2 oil spots generated.
START_RESOURCE_OIL_POS_X = -39
@ -230,14 +233,12 @@ RESOURCE_DIST_BONUS = 2
AUTOFILL_TURRET_AMMO_QUANTITY = 10
--------------------------------------------------------------------------------
-- Use rso_config and rso_resourece_config for RSO config settings
-- Use rso_config and rso_resource_config for RSO config settings
--------------------------------------------------------------------------------
-- Don't touch unless you know what you're doing...
-- When using RSO, all resources MUST BE SET TO SIZE=NONE!
--------------------------------------------------------------------------------
-- Surface generation stuff, don't touch unless you know what you're doing...
--------------------------------------------------------------------------------
--
-- Default map settings for disabling all vanilla resources!
MAP_SETTINGS_NO_RESOURCES={
MAP_SETTINGS_RSO={
terrain_segmentation="very-low",
water="high",
starting_area="very-low",
@ -245,38 +246,24 @@ MAP_SETTINGS_NO_RESOURCES={
seed=math.random(999999999),
autoplace_controls = {
["coal"]={
frequency="normal",
richness="normal",
size="none"
},
["copper-ore"]={
frequency="normal",
richness="normal",
size="none"
},
["iron-ore"]={
frequency="normal",
richness="normal",
size="none"
},
["stone"]={
frequency="normal",
richness="normal",
size="none"
},
["uranium-ore"]={
frequency="normal",
richness="normal",
size="none"
},
["crude-oil"]={
frequency="normal",
richness="normal",
size="none"
},
["enemy-base"]={
frequency="normal",
richness="normal",
size="none"
}
}
@ -288,4 +275,4 @@ MAP_SETTINGS_NO_RESOURCES={
--------------------------------------------------------------------------------
-- DEBUG prints for me
global.oarcDebugEnabled = true
global.oarcDebugEnabled = false

View File

@ -85,8 +85,22 @@ end
----------------------------------------
script.on_init(function(event)
CreateLobbySurface()
CreateGameSurface(MAP_SETTINGS_NO_RESOURCES)
-- CreateLobbySurface() -- Currently unused, but have plans for future.
-- Here I create the game surface. I do this so that I don't have to worry
-- about the game menu settings and I can now generate a map from the command
-- line more easily!
--
-- If you are using RSO, map settings are ignored and you MUST configure
-- the relevant map settings in config.lua
--
-- If you disable RSO, the map settings will be set from the ones that you
-- choose from the game GUI when you start a new scenario.
if ENABLE_RSO then
CreateGameSurface(MAP_SETTINGS_RSO)
else
CreateGameSurface(game.surfaces["nauvis"].map_gen_settings)
end
if ENABLE_SEPARATE_SPAWNS then
InitSpawnGlobalsAndForces()
@ -149,6 +163,10 @@ script.on_event(defines.events.on_gui_click, function(event)
TagGuiClick(event)
end
if ENABLE_PLAYER_LIST then
PlayerListGuiClick(event)
end
if ENABLE_SEPARATE_SPAWNS then
WelcomeTextGuiClick(event)
SpawnOptsGuiClick(event)
@ -169,9 +187,16 @@ script.on_event(defines.events.on_player_joined_game, function(event)
if ENABLE_TAGS then
CreateTagGui(event)
end
if ENABLE_PLAYER_LIST then
CreatePlayerListGui(event)
end
end)
script.on_event(defines.events.on_player_created, function(event)
-- Move the player to the game surface immediately.
-- 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)
SetOarcServerMessages(event)
@ -186,10 +211,6 @@ script.on_event(defines.events.on_player_created, function(event)
SeparateSpawnsPlayerCreated(event)
end
-- Not sure if this should be here or in player joined....
if ENABLE_BLUEPRINT_STRING then
bps_player_joined(event)
end
end)
-- Disabled as of 0.15.x
@ -228,19 +249,12 @@ end)
----------------------------------------
-- On Research Finished
-- This is where you can permanently add/remove researched techs
-- This is where you can permanently remove researched techs
----------------------------------------
script.on_event(defines.events.on_research_finished, function(event)
if FRONTIER_ROCKET_SILO_MODE then
RemoveRecipe(event.research.force, "rocket-silo")
end
-- Example of how to remove a particular recipe:
-- RemoveRecipe(event, "beacon")
if (global.oarcDebugEnabled) then
AddRecipe(event.research.force, "rocket-silo");
end
end)

2
locale

@ -1 +1 @@
Subproject commit c916629809bdd2f04f1dd1db67a55726880beaf4
Subproject commit 12a5963f98a1f2e800f2760df5e261c6ae8645e9

View File

@ -16,7 +16,6 @@ function SeparateSpawnsPlayerCreated(event)
local player = game.players[event.player_index]
player.force = MAIN_FORCE
DisplayWelcomeTextGui(player)
global.playerCooldowns[player.name] = {setRespawn=event.tick}
end
@ -47,7 +46,7 @@ function FindUnusedSpawns(event)
local player = game.players[event.player_index]
if (player.online_time < MIN_ONLINE_TIME) then
-- TODO dump items into a chest.
DropGravestoneChests(player)
-- Clear out global variables for that player???
if (global.playerSpawns[player.name] ~= nil) then
@ -188,6 +187,7 @@ end
function ChangePlayerSpawn(player, pos)
global.playerSpawns[player.name] = pos
global.playerCooldowns[player.name] = {setRespawn=game.tick}
end
function SendPlayerToNewSpawnAndCreateIt(player, spawn)

View File

@ -125,7 +125,7 @@ function DisplaySpawnOptions(player)
sGui.add{name = "spawn_msg_lbl3", type = "label",
caption=SPAWN_MSG3}
sGui.add{name = "spawn_msg_spacer", type = "label",
caption="~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"}
caption="~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"}
ApplyStyle(sGui.spawn_msg_lbl1, my_label_style)
ApplyStyle(sGui.spawn_msg_lbl2, my_label_style)
ApplyStyle(sGui.spawn_msg_lbl3, my_label_style)
@ -151,7 +151,7 @@ function DisplaySpawnOptions(player)
ApplyStyle(sGui.normal_spawn_lbl1, my_warning_style)
end
sGui.add{name = "normal_spawn_spacer", type = "label",
caption="~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"}
caption="~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"}
ApplyStyle(sGui.normal_spawn_spacer, my_spacer_style)
@ -167,7 +167,7 @@ function DisplaySpawnOptions(player)
sGui.add{name = "isolated_spawn_lbl2", type = "label",
caption="You will still be part of the default team."}
sGui.add{name = "isolated_spawn_spacer", type = "label",
caption="~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"}
caption="~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"}
ApplyStyle(sGui.isolated_spawn_lbl1, my_label_style)
ApplyStyle(sGui.isolated_spawn_lbl2, my_label_style)
ApplyStyle(sGui.isolated_spawn_spacer, my_spacer_style)
@ -211,7 +211,7 @@ function DisplaySpawnOptions(player)
-- Some final notes
sGui.add{name = "note_spacer1", type = "label",
caption="~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"}
caption="~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"}
sGui.add{name = "note_spacer2", type = "label",
caption=" "}
@ -361,6 +361,10 @@ function SharedSpwnOptsGuiClick(event)
local player = game.players[event.player_index]
local buttonClicked = event.element.name
if (event.element.parent.name ~= "shared_spawn_opts") then
return
end
-- Check for cancel button, return to spawn options
if (buttonClicked == "shared_spawn_cancel") then
DisplaySpawnOptions(player)
@ -487,6 +491,10 @@ function SpawnCtrlGuiClick(event)
ExpandSpawnCtrlGui(player, event.tick)
end
if ((event.element.parent) and (event.element.parent.name ~= "spwn_ctrl_panel")) then
return
end
if (name == "accessToggle") then
if event.element.state then
if DoesPlayerHaveCustomSpawn(player) then
@ -510,7 +518,6 @@ function SpawnCtrlGuiClick(event)
if (name == "setRespawnLocation") then
if DoesPlayerHaveCustomSpawn(player) then
ChangePlayerSpawn(player, player.position)
global.playerCooldowns[player.name].setRespawn = event.tick
ExpandSpawnCtrlGui(player, event.tick)
player.print("Re-spawn point updated!")
end