From 1bf0d4e55b9ee1e0d23e998e425b555f09c88b00 Mon Sep 17 00:00:00 2001 From: Oarcinae Date: Tue, 25 Apr 2017 19:33:58 -0400 Subject: [PATCH 1/2] Updating for 0.15.x --- README.md | 2 +- config.lua | 28 ++++++++------------------- control.lua | 46 +++++++++++++++++---------------------------- locale | 2 +- separate_spawns.lua | 5 ++++- 5 files changed, 31 insertions(+), 52 deletions(-) diff --git a/README.md b/README.md index 29b870e..35a5eed 100644 --- a/README.md +++ b/README.md @@ -53,4 +53,4 @@ 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 as well: https://github.com/3RaGaming/3Ra-Enhanced-Vanilla \ No newline at end of file +Credit to 3Ra for help as well: https://github.com/3RaGaming \ No newline at end of file diff --git a/config.lua b/config.lua index c8dc2d2..8d38cb5 100644 --- a/config.lua +++ b/config.lua @@ -1,5 +1,5 @@ -- config.lua --- Dec 2016 +-- Apr 2017 -- Configuration Options -------------------------------------------------------------------------------- @@ -8,14 +8,14 @@ WELCOME_MSG = "[INSERT SERVER OWNER MSG HERE!]" GAME_MODE_MSG = "In the current game mode, a satellite must be launched from an existing far away rocket silo to win!" -MODULES_ENABLED = "Mods Enabled: Separate Spawns, RSO, Gravestone Chests, Long-Reach, Autofill, Blueprint Strings" +MODULES_ENABLED = "Mods Enabled: Separate Spawns, RSO, Long-Reach, Autofill" 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.2.8):" -OTHER_MSG2 = "New spawn layout. RSO resource richness reduced" +OTHER_MSG1 = "Latest updates in this scenario version (0.3.0):" +OTHER_MSG2 = "0.15 Compatibility Update - Still in Beta!?!" WELCOME_MSG3 = "Due to the way this scenario works, it may take some time for the land" @@ -24,14 +24,14 @@ WELCOME_MSG5 = "Please wait for 10-20 seconds when you select your first spawn." WELCOME_MSG6 = "Contact: SteamID:Oarc | Twitter:@_Oarc_ | oarcinae@gmail.com" -SPAWN_MSG1 = "Current Spawn Mode: HARDCORE WILDERNESS (Always in BETA)" +SPAWN_MSG1 = "Current Spawn Mode: HARDCORE WILDERNESS (BETA)" SPAWN_MSG2 = "In this mode, there is no default spawn. Everyone starts in the wild!" 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. WELCOME_MSG_OARC = "Welcome to Oarc's official server! Join the discord here: discord.gg/Wj56gkU" -WELCOME_MSG_TITLE_OARC = "Welcome to Oarc's Server" +WELCOME_MSG_TITLE_OARC = "Welcome to Oarc's Server - Happy 0.15 Release!" -------------------------------------------------------------------------------- @@ -49,9 +49,6 @@ ENABLE_SEPARATE_SPAWNS = true -- Enable Scenario version of RSO ENABLE_RSO = true --- Enable Gravestone Chests -ENABLE_GRAVESTONE_CHESTS = true - -- Enable Undecorator ENABLE_UNDECORATOR = true @@ -64,9 +61,6 @@ ENABLE_LONGREACH = true -- Enable Autofill ENABLE_AUTOFILL = true --- Enable BPS -ENABLE_BLUEPRINT_STRING = true - -------------------------------------------------------------------------------- -- Spawn Options -------------------------------------------------------------------------------- @@ -184,13 +178,7 @@ MIN_ONLINE_TIME = TICKS_PER_MINUTE * MIN_ONLIME_TIME_IN_MINUTES -------------------------------------------------------------------------------- -- Alien Options -------------------------------------------------------------------------------- - --- Enable/Disable enemy expansion (Applies to RSO as well!) -ENEMY_EXPANSION = false - --- Divide the alien factors by this number to reduce it (or multiply if < 1) -ENEMY_POLLUTION_FACTOR_DIVISOR = 10 -ENEMY_DESTROY_FACTOR_DIVISOR = 5 +-- This should now be configured in the starting map generation as of 0.15 -------------------------------------------------------------------------------- -- Frontier Rocket Silo Options @@ -229,4 +217,4 @@ AUTOFILL_TURRET_AMMO_QUANTITY = 10 -------------------------------------------------------------------------------- -- DEBUG prints for me -global.oarcDebugEnabled = false \ No newline at end of file +-- global.oarcDebugEnabled = true \ No newline at end of file diff --git a/control.lua b/control.lua index 78d90f8..6ccfabe 100755 --- a/control.lua +++ b/control.lua @@ -1,5 +1,5 @@ -- control.lua --- Nov 2016 +-- Apr 2017 -- Oarc's Separated Spawn Scenario -- @@ -9,7 +9,6 @@ -- Credit: -- RSO mod to RSO author - Orzelek - I contacted him via the forum -- Tags - Taken from WOGs scenario --- Event - Taken from WOGs scenario (looks like original source was 3Ra) -- Rocket Silo - Taken from Frontier as an idea -- -- Feel free to re-use anything you want. It would be nice to give me credit @@ -29,7 +28,6 @@ require("locale/oarc_utils") require("locale/rso/rso_control") require("locale/frontier_silo") require("locale/tag") -require("locale/blueprintstring/bps") -- Main Configuration File require("config") @@ -87,10 +85,6 @@ end ---------------------------------------- script.on_init(function(event) - -- Configures the map settings for enemies - -- This controls evolution growth factors and enemy expansion settings. - ConfigureAlienStartingParams() - if ENABLE_SEPARATE_SPAWNS then InitSpawnGlobalsAndForces() end @@ -105,10 +99,6 @@ script.on_init(function(event) ChartRocketSiloArea(game.forces[MAIN_FORCE]) end - if ENABLE_BLUEPRINT_STRING then - bps_init() - end - global.welcome_msg = WELCOME_MSG global.welcome_msg_title = WELCOME_MSG_TITLE end) @@ -163,9 +153,6 @@ script.on_event(defines.events.on_gui_click, function(event) SharedSpwnOptsGuiClick(event) end - if ENABLE_BLUEPRINT_STRING then - bps_on_gui_click(event) - end end) @@ -200,11 +187,13 @@ script.on_event(defines.events.on_player_created, function(event) end end) -script.on_event(defines.events.on_player_died, function(event) - if ENABLE_GRAVESTONE_CHESTS then - CreateGravestoneChestsOnDeath(event) - end -end) +-- Disabled as of 0.15.x +-- Gravestone is now part of vanilla game! WOO! +-- script.on_event(defines.events.on_player_died, function(event) +-- if ENABLE_GRAVESTONE_CHESTS then +-- CreateGravestoneChestsOnDeath(event) +-- end +-- end) script.on_event(defines.events.on_player_respawned, function(event) if not ENABLE_SEPARATE_SPAWNS then @@ -234,26 +223,25 @@ end) ---------------------------------------- -- On Research Finished +-- This is where you can permanently add/remove researched techs ---------------------------------------- script.on_event(defines.events.on_research_finished, function(event) if FRONTIER_ROCKET_SILO_MODE then RemoveRocketSiloRecipe(event) end - if ENABLE_BLUEPRINT_STRING then - bps_on_research_finished(event) - end - -- Example of how to remove a particular recipe: -- RemoveRecipe(event, "beacon") + + if (global.oarcDebugEnabled) then + AddRecipe(event, "resource-monitoring"); + end end) ---------------------------------------- --- BPS Specific Event +-- Other? ---------------------------------------- -script.on_event(defines.events.on_robot_built_entity, function(event) - if ENABLE_BLUEPRINT_STRING then - bps_on_robot_built_entity(event) - end -end) \ No newline at end of file +-- script.on_event(defines.events.on_robot_built_entity, function(event) + +-- end) \ No newline at end of file diff --git a/locale b/locale index a967b25..1c2d53a 160000 --- a/locale +++ b/locale @@ -1 +1 @@ -Subproject commit a967b25e0aabd16a1bceb34f5d98452f45a9c248 +Subproject commit 1c2d53a810d264e4080c5693a80b6ce26d9f4723 diff --git a/separate_spawns.lua b/separate_spawns.lua index ae7b199..96a45a8 100644 --- a/separate_spawns.lua +++ b/separate_spawns.lua @@ -57,7 +57,10 @@ function FindUnusedSpawns(event) -- 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]) - global.uniqueSpawns[player.name] = nil + + -- 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 From cf269a041d19ae7b4466f7270d412c7451056188 Mon Sep 17 00:00:00 2001 From: Oarcinae Date: Wed, 26 Apr 2017 20:59:48 -0400 Subject: [PATCH 2/2] Multiple 0.15 fixes and preparation for separate forces/teams. --- config.lua | 85 ++++++++++++++++++++++++++++++++++++---- control.lua | 13 ++++-- locale | 2 +- separate_spawns.lua | 14 ++++--- separate_spawns_guis.lua | 10 ++--- 5 files changed, 101 insertions(+), 23 deletions(-) diff --git a/config.lua b/config.lua index 8d38cb5..2bdc6e2 100644 --- a/config.lua +++ b/config.lua @@ -8,14 +8,14 @@ WELCOME_MSG = "[INSERT SERVER OWNER MSG HERE!]" GAME_MODE_MSG = "In the current game mode, a satellite must be launched from an existing far away rocket silo to win!" -MODULES_ENABLED = "Mods Enabled: Separate Spawns, RSO, Long-Reach, Autofill" +MODULES_ENABLED = "Mods Enabled: Separate Spawns, RSO, Long-Reach, Autofill, Undecorator" 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 Compatibility Update - Still in Beta!?!" +OTHER_MSG2 = "0.15.X Compatibility Update - Still in Beta!?!" WELCOME_MSG3 = "Due to the way this scenario works, it may take some time for the land" @@ -31,7 +31,7 @@ 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. WELCOME_MSG_OARC = "Welcome to Oarc's official server! Join the discord here: discord.gg/Wj56gkU" -WELCOME_MSG_TITLE_OARC = "Welcome to Oarc's Server - Happy 0.15 Release!" +WELCOME_MSG_TITLE_OARC = "Welcome to Oarc's Server - Happy 0.15.X Bug Fest!" -------------------------------------------------------------------------------- @@ -68,6 +68,13 @@ ENABLE_AUTOFILL = true --------------------------------------- -- Distance Options --------------------------------------- + +-- This is the radius, in chunks, that a spawn area is from any other generated +-- chunks. It ensures the spawn area isn't too near generated/explored/existing +-- area. The larger you make this, the further away players will spawn from +-- generated map area (even if it is not visible on the map!). +CHECK_SPAWN_UNGENERATED_CHUNKS_RADIUS = 5 + -- Near Distance in chunks NEAR_MIN_DIST = 25 --50 NEAR_MAX_DIST = 100 --125 @@ -86,9 +93,10 @@ WATER_SPAWN_LENGTH = 8 -- Start resource amounts START_IRON_AMOUNT = 1500 START_COPPER_AMOUNT = 1500 -START_STONE_AMOUNT = 1500 +START_STONE_AMOUNT = 1000 START_COAL_AMOUNT = 1500 -START_OIL_AMOUNT = 30000 +START_URANIUM_AMOUNT = 1000 +START_OIL_AMOUNT = 300000 -- Start resource shape -- If this is true, it will be a circle @@ -113,9 +121,22 @@ START_RESOURCE_IRON_POS_X = -29 START_RESOURCE_IRON_POS_Y = 16 START_RESOURCE_IRON_SIZE = 16 +START_RESOURCE_URANIUM_POS_X = 17 +START_RESOURCE_URANIUM_POS_Y = -34 +START_RESOURCE_URANIUM_SIZE = 10 + +-- There are 2 oil spots generated. START_RESOURCE_OIL_POS_X = -39 START_RESOURCE_OIL_POS_Y = 0 +-- Specify 2 oil spot locations +START_RESOURCE_OIL_A_POS_X = -39 +START_RESOURCE_OIL_A_POS_Y = -2 +START_RESOURCE_OIL_B_POS_X = -39 +START_RESOURCE_OIL_B_POS_Y = 2 + + + -- Force the land area circle at the spawn to be fully grass ENABLE_SPAWN_FORCE_GRASS = true @@ -198,7 +219,7 @@ ENABLE_RANDOM_SILO_POSITION = true -- Long Reach Options -------------------------------------------------------------------------------- -BUILD_DIST_BONUS = 15 +BUILD_DIST_BONUS = 20 REACH_DIST_BONUS = BUILD_DIST_BONUS RESOURCE_DIST_BONUS = 2 @@ -211,10 +232,60 @@ AUTOFILL_TURRET_AMMO_QUANTITY = 10 -------------------------------------------------------------------------------- -- Use rso_config and rso_resourece_config for RSO config settings -------------------------------------------------------------------------------- +-------------------------------------------------------------------------------- +-- 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={ + terrain_segmentation="very-low", + water="high", + starting_area="very-low", + peaceful_mode=false, + 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" + } + } +} + ------------------------------------------------------------------------------- -- DEBUG -------------------------------------------------------------------------------- -- DEBUG prints for me --- global.oarcDebugEnabled = true \ No newline at end of file +global.oarcDebugEnabled = true \ No newline at end of file diff --git a/control.lua b/control.lua index 6ccfabe..6eaa945 100755 --- a/control.lua +++ b/control.lua @@ -85,6 +85,9 @@ end ---------------------------------------- script.on_init(function(event) + CreateLobbySurface() + CreateGameSurface(MAP_SETTINGS_NO_RESOURCES) + if ENABLE_SEPARATE_SPAWNS then InitSpawnGlobalsAndForces() end @@ -96,7 +99,7 @@ script.on_init(function(event) end if FRONTIER_ROCKET_SILO_MODE then - ChartRocketSiloArea(game.forces[MAIN_FORCE]) + ChartRocketSiloArea(game.forces[MAIN_FORCE], game.surfaces[GAME_SURFACE_NAME]) end global.welcome_msg = WELCOME_MSG @@ -160,7 +163,7 @@ end) -- Player Events ---------------------------------------- script.on_event(defines.events.on_player_joined_game, function(event) - + game.players[event.player_index].teleport(game.forces[MAIN_FORCE].get_spawn_position(GAME_SURFACE_NAME), GAME_SURFACE_NAME) PlayerJoinedMessages(event) if ENABLE_TAGS then @@ -169,6 +172,8 @@ script.on_event(defines.events.on_player_joined_game, function(event) end) script.on_event(defines.events.on_player_created, function(event) + game.players[event.player_index].teleport(game.forces[MAIN_FORCE].get_spawn_position(GAME_SURFACE_NAME), GAME_SURFACE_NAME) + SetOarcServerMessages(event) if ENABLE_LONGREACH then @@ -227,14 +232,14 @@ end) ---------------------------------------- script.on_event(defines.events.on_research_finished, function(event) if FRONTIER_ROCKET_SILO_MODE then - RemoveRocketSiloRecipe(event) + RemoveRecipe(event.research.force, "rocket-silo") end -- Example of how to remove a particular recipe: -- RemoveRecipe(event, "beacon") if (global.oarcDebugEnabled) then - AddRecipe(event, "resource-monitoring"); + AddRecipe(event.research.force, "rocket-silo"); end end) diff --git a/locale b/locale index 1c2d53a..c916629 160000 --- a/locale +++ b/locale @@ -1 +1 @@ -Subproject commit 1c2d53a810d264e4080c5693a80b6ce26d9f4723 +Subproject commit c916629809bdd2f04f1dd1db67a55726880beaf4 diff --git a/separate_spawns.lua b/separate_spawns.lua index 96a45a8..8c2bef5 100644 --- a/separate_spawns.lua +++ b/separate_spawns.lua @@ -170,8 +170,10 @@ function InitSpawnGlobalsAndForces() end game.create_force(MAIN_FORCE) - game.forces[MAIN_FORCE].set_spawn_position(game.forces["player"].get_spawn_position("nauvis"), "nauvis") + 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]) end @@ -190,9 +192,9 @@ end function SendPlayerToNewSpawnAndCreateIt(player, spawn) -- Send the player to that position - player.teleport(spawn) + player.teleport(spawn, GAME_SURFACE_NAME) GivePlayerStarterItems(player) - ChartArea(player.force, player.position, 4) + ChartArea(player.force, player.position, 4, player.surface) -- If we get a valid spawn point, setup the area if ((spawn.x ~= 0) and (spawn.y ~= 0)) then @@ -206,9 +208,9 @@ end function SendPlayerToSpawn(player) if (DoesPlayerHaveCustomSpawn(player)) then - player.teleport(global.playerSpawns[player.name]) + player.teleport(global.playerSpawns[player.name], GAME_SURFACE_NAME) else - player.teleport(game.forces[MAIN_FORCE].get_spawn_position("nauvis")) + player.teleport(game.forces[MAIN_FORCE].get_spawn_position(GAME_SURFACE_NAME), GAME_SURFACE_NAME) end end @@ -218,7 +220,7 @@ function SendPlayerToRandomSpawn(player) local counter = 0 if (rndSpawn == 0) then - player.teleport(game.forces[MAIN_FORCE].get_spawn_position("nauvis")) + 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 diff --git a/separate_spawns_guis.lua b/separate_spawns_guis.lua index 2f904be..c54746a 100755 --- a/separate_spawns_guis.lua +++ b/separate_spawns_guis.lua @@ -261,9 +261,9 @@ function SpawnOptsGuiClick(event) if (buttonClicked == "default_spawn_btn") then CreateSpawnCtrlGui(player) GivePlayerStarterItems(player) - ChangePlayerSpawn(player, player.force.get_spawn_position("nauvis")) + ChangePlayerSpawn(player, player.force.get_spawn_position(GAME_SURFACE_NAME)) SendBroadcastMsg(player.name .. " joined the main force!") - ChartArea(player.force, player.position, 4) + ChartArea(player.force, player.position, 4, player.surface) elseif ((buttonClicked == "isolated_spawn_near") or (buttonClicked == "isolated_spawn_far")) then CreateSpawnCtrlGui(player) @@ -284,14 +284,14 @@ function SpawnOptsGuiClick(event) -- Find coordinates of a good place to spawn if (buttonClicked == "isolated_spawn_far") then - newSpawn = FindUngeneratedCoordinates(FAR_MIN_DIST,FAR_MAX_DIST) + newSpawn = FindUngeneratedCoordinates(FAR_MIN_DIST,FAR_MAX_DIST, player.surface) elseif (buttonClicked == "isolated_spawn_near") then - newSpawn = FindUngeneratedCoordinates(NEAR_MIN_DIST,NEAR_MAX_DIST) + newSpawn = FindUngeneratedCoordinates(NEAR_MIN_DIST,NEAR_MAX_DIST, player.surface) end -- If that fails, find a random map edge in a rand direction. if ((newSpawn.x == 0) and (newSpawn.x == 0)) then - newSpawn = FindMapEdge(GetRandomVector()) + newSpawn = FindMapEdge(GetRandomVector(), player.surface) DebugPrint("Resorting to find map edge! x=" .. newSpawn.x .. ",y=" .. newSpawn.y) end