Skip to content

Commit

Permalink
Merge pull request #254 from Oarcinae/dev_fulgora_and_more_sa_stuff
Browse files Browse the repository at this point in the history
Secondary Spawns (Fulgora Only)
  • Loading branch information
Oarcinae authored Nov 11, 2024
2 parents 0747e72 + f49a755 commit 5a74e87
Show file tree
Hide file tree
Showing 26 changed files with 1,627 additions and 600 deletions.
17 changes: 17 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
---------------------------------------------------------------------------------------------------
Version: 2.1.10
Date: 2024-11-11
Major Features:
- Adding support for secondary spawns on Fulgora. This is still VERY experimental and will likely have some hidden issues. Please report any bugs you find. If you want to use this feature, you must go into the in game GUI and check the enable secondary spawns checkbox for Fulgora specifically.
- Major work done under the hood to support secondary spawns. Depending on how Fulgora testing goes, I will add support for other planets soon.
Minor Features:
- Added some new commands: "oarc-wheres-my-cargo-pod", "oarc-reroll-spawn", "oarc-trigger-cleanup". See the in game help text for info.
- I now disable technology_notifications_enabled by default since it seems like this is highly requested. Only finished research is announced. I will expose settings for this later if needed.
- If you land on a planet where you have a custom spawn, but there is no landing-pad, you will be automatically teleported to your home spawn.
Info:
- Removed redundant "enable secondary spawns" setting. You just enable/disable per surface using the in game GUI now.
- Renamed "force grass" setting to "force tiles" since it can be used for more than just grass and change it to be default on.
- New config options (not shown in GUI) for configuring other planet/surface spawns. See planet_configs folder for examples.
Bugfixes:
- Fixed a crash if surface only had 1 basic-solid resource to place.
- Fix some ordering issues where enemies were removed after a spawn was placed resulting in gaps in the treeline.
---------------------------------------------------------------------------------------------------
Version: 2.1.9
Date: 2024-11-06
Bugfixes:
Expand Down
47 changes: 24 additions & 23 deletions control.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ require("lib/sharing")
-- TODO: Possibly remove this later?
require("lib/oarc_tests")

require("lib/oarc_commands")


--------------------------------------------------------------------------------
Expand Down Expand Up @@ -69,6 +70,8 @@ script.on_init(function(event)
for _,player in pairs(game.players) do
SeparateSpawnsInitPlayer(player.index)
end

game.technology_notifications_enabled = false
end)


Expand All @@ -82,14 +85,9 @@ end)
--------------------------------------------------------------------------------
-- On Configuration Changed - Only runs when the mod configuration changes
--------------------------------------------------------------------------------
-- oarc_new_spawn_created = script.generate_event_name()

script.on_configuration_changed(function(data)
-- Regenerate event ID:

-- Reset the players GUI
for _,player in pairs(game.players) do
RecreateOarcGui(player)
RecreateOarcGui(player) -- Reset the players GUI
end
end)

Expand Down Expand Up @@ -149,6 +147,12 @@ script.on_event(defines.events.on_player_driving_changed_state, function (event)
end
end)

script.on_event(defines.events.on_research_finished, function(event)
local research = event.research
-- TODO: Add a non-mod setting to disable this.
SendBroadcastMsg({"oarc-research-finished", research.force.name, research.name})
end)

----------------------------------------
-- CUSTOM OARC Events (shown here for demo and logging purposes)
----------------------------------------
Expand All @@ -161,45 +165,40 @@ end)
---@class OarcModOnSpawnCreatedEvent: OarcCustomEventBase
---@field spawn_data OarcUniqueSpawn
script.on_event("oarc-mod-on-spawn-created", function(event)
log("Custom event oarc-mod-on-spawn-created")
log(serpent.block(event --[[@as OarcModOnSpawnCreatedEvent]]))
log("EVENT - oarc-mod-on-spawn-created:" .. serpent.block(event --[[@as OarcModOnSpawnCreatedEvent]]))
end)

---@class OarcModOnSpawnRemoveRequestEvent: OarcCustomEventBase
---@field spawn_data OarcUniqueSpawn
script.on_event("oarc-mod-on-spawn-remove-request", function(event)
log("Custom event oarc-mod-on-spawn-remove-request")
log(serpent.block(event --[[@as OarcModOnSpawnRemoveRequestEvent]]))
log("EVENT - oarc-mod-on-spawn-remove-request:" .. serpent.block(event --[[@as OarcModOnSpawnRemoveRequestEvent]]))
end)

---@class OarcModOnPlayerResetEvent: OarcCustomEventBase
---@field player_index integer
script.on_event("oarc-mod-on-player-reset", function(event)
log("Custom event oarc-mod-on-player-reset")
log(serpent.block(event --[[@as OarcModOnPlayerResetEvent]]))
if (game.players[event.player_index]) then
log("Player is still valid: " .. game.players[event.player_index].name)
end
log("EVENT - oarc-mod-on-player-reset:" .. serpent.block(event --[[@as OarcModOnPlayerResetEvent]]))
end)

---@class OarcModOnPlayerSpawnedEvent: OarcCustomEventBase
---@field player_index integer
script.on_event("oarc-mod-on-player-spawned", function(event)
log("Custom event oarc-mod-on-player-spawned")
log(serpent.block(event --[[@as OarcModOnPlayerSpawnedEvent]]))
log("Player spawned: " .. game.players[event.player_index].name)
log("EVENT - oarc-mod-on-player-spawned:" .. serpent.block(event --[[@as OarcModOnPlayerSpawnedEvent]]))
end)

---@class OarcModCharacterSurfaceChangedEvent: OarcCustomEventBase
---@field player_index integer
---@field old_surface_name string
---@field new_surface_name string
script.on_event("oarc-mod-character-surface-changed", function(event)
log("Custom event oarc-mod-character-surface-changed")
log(serpent.block(event --[[@as OarcModCharacterSurfaceChangedEvent]]))
log("EVENT - oarc-mod-character-surface-changed:" .. serpent.block(event --[[@as OarcModCharacterSurfaceChangedEvent]]))

--This is just here so I don't get lua warnings about unused variables.
---@type OarcModCharacterSurfaceChangedEvent
local custom_event = event --[[@as OarcModCharacterSurfaceChangedEvent]]

local player = game.players[event.player_index]
SeparateSpawnsPlayerChangedSurface(player, event.old_surface_name, event.new_surface_name)
local player = game.players[custom_event.player_index]
SeparateSpawnsPlayerChangedSurface(player, custom_event.old_surface_name, custom_event.new_surface_name)
end)

-- I raise this event whenever teleporting the player!
Expand Down Expand Up @@ -232,6 +231,7 @@ end)
script.on_event(defines.events.on_tick, function(event)
DelayedSpawnOnTick()
FadeoutRenderOnTick()
OnTickNilCharacterTeleportQueue()

if storage.ocfg.regrowth.enable_regrowth then
RegrowthOnTick()
Expand All @@ -248,12 +248,13 @@ script.on_event(defines.events.on_chunk_generated, function(event)
end

CreateHoldingPenChunks(event)
SeparateSpawnsGenerateChunk(event)

if storage.ocfg.gameplay.modified_enemy_spawning then
DowngradeWormsDistanceBasedOnChunkGenerate(event)
DowngradeAndReduceEnemiesOnChunkGenerate(event)
end

SeparateSpawnsGenerateChunk(event)
end)

----------------------------------------
Expand Down
42 changes: 10 additions & 32 deletions devplan.txt
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
ACTIVE ITEMS:
ACTIVE NOTES:

-- Look into on_player_driving_changed_state for detecting player rocket/platform transitions.
-- Look at rocket launch events and this: `event.rocket.cargo_pod`

------------------------------------------------------------------------------------------------------------------------
- What happens to multiple unique spawn hosts on "main force" when they go to a new planet?
- They get unique spawn areas, but they have to coordinate regarding the landing pad, OR they can install a mod to have multiple but it is still up to them to coordinate.

BACKLOG:
- Change permissions to be enabled/disabled when entering/leaving the holding pen (use custom surface changed event?)

Not specific:
- Get rid of storage.buddy_pairs ?? Is basically duplicate info inside the spawns right?
------------------------------------------------------------------------------------------------------------------------

BACKLOG:

Minor:
- If dead when resetting spawn... possibly delay the opening of the welcome GUI or block spawning until character is spawned?
- Expose old enemy scaling as an option? And/or remove unnecessary checks/logs
- Refresh players in admin controls when dropdown is clicked
- Add a setting for forcing primary spawns to only be on default surface maybe?

Performance:
- User on_nth_tick for any tick % (modulo) operations.
- SeparateSpawnsGenerateChunk should only search for closest spawn once and pass to sub functions!
- Rework world eater to use less find_entities_filtered

Major:
- Space Age Support (TBD)
- Space Age Support (In Progress)


------------------------------------------------------SPACE AGE---------------------------------------------------------
Expand All @@ -31,12 +31,7 @@ Major:
- Pollution changes (regrowth)?
- Enemy changes?
- Landing pad locations per FORCE limited to 1?
- Surface names for space ships?
- Spawner health tied to evolution?
- Respawn position is surface specific? Each surface needs a separate respawn point? Default respawn behavior?
- Confirm launch into scenario works (V2.0 fix supposedly) -- https://forums.factorio.com/110708
- Radar quality affects regrowth safe range?
- Update electric pole connections for shared power if things change in V2.0

- Source: https://forums.factorio.com/115737
- Specifics that I might need to investigate:
Expand All @@ -47,9 +42,6 @@ Added space-platform-starter-pack, space-location, planet and space-connection p
Added surface-property and surface prototypes.
Added new controller type (remote), which is to build space platforms, so it allows ghost building but not any physical manipulation.
Added LuaPlayer::physical_surface, physical_surface_index, physical_vehicle and physical_position read.
Electric pole created through LuaSurface::create_entity can be requested to not auto connect.
Added LuaSurface::global_effect read/write.
Added LuaSurface::localised_name read/write.
LuaGameScript::print, LuaPlayer::print, LuaSurface::print and LuaForce::print no longer accept Color as a second parameter.
Added LuaSurface::set_property() and get_property() methods.
Added LuaSurface::execute_lightning() method.
Expand All @@ -58,24 +50,10 @@ Added LuaSurface::has_global_electric_network read.
Added LuaSurface::platform read.
Added LuaSurface::pollutant_type read.
Added airborne-pollutant prototype and changed various pollution related properties to support multiple pollution types.
Added LuaSurface::deletable read.
Added LuaForce::set_surface_hidden() and get_surface_hidden() methods.
Added cause argument to LuaSurface::create_entity.
Added LuaSurfacePrototype::surface_properties read.
Added on_player_controller_changed event.
Removed LuaPlayer::open_map, zoom_to_world, and close_map. LuaPlayer::set_controller with type 'remote' replaces these.
oved LuaGameScript::styles to LuaPrototypes::style.
Removed LuaGameScript::active_mods. Use LuaBootstrap::active_mods instead.
Renamed `global` into `storage`.
Added LuaGameScript::technology_notifications_enabled (read/write).
Added LuaGameScript::planets read.
Added LuaGameScript::get_vehicles.
Added LuaForce::platforms read.
Added LuaGameScript::set_win_ending_info() and set_lose_ending_info() methods.
Added LuaForce::unlock_space_location(), lock_space_location() and is_space_location_unlocked() methods.
Added LuaForce::create_space_platform() method.
Added LuaForce::unlock_space_platforms(), lock_space_platforms() and is_space_platforms_unlocked() methods.
Changed LuaForce::evolution_factor, evolution_factor_by_pollution, evolution_factor_by_time and evolution_factor_by_killing_spawners to get_* and set_* methods.
Added LuaForce::copy_from() and copy_chart() methods.

------------------------------------------------------------------------------------------------------------------------
Expand All @@ -91,7 +69,6 @@ Other Ideas, Not Committed:
- Change enable_shared_team_vision to allow players to change this per player (like BNO)
- Change enable_friendly_fire to be per team?
- Allow players to spawn "near" an existing player (by request)
- Allow players to restart at anytime via GUI button (configurable setting by admin)
- Change regrowth to be list of surfaces indexed by surface name?
- Figure out how to reset player inventory on player reset to avoid extra items? (save and load items?)
- Work on space ex support?
Expand Down Expand Up @@ -182,4 +159,5 @@ Other Ideas, Not Committed:
- Pull out general spawn config from surfaces config
- Redo resource placement to be simpler (and make a linear layout for square base)
- Default to selecting SELF in admin controls player dropdown?
- Add refresh chunks around spidertrons based on their vision
- Add refresh chunks around spidertrons based on their vision
- Allow players to restart at anytime via GUI button (configurable setting by admin)
14 changes: 7 additions & 7 deletions example/example-map-gen-settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@

"autoplace_controls":
{
"coal" : {"frequency" : 0.20, "richness" : 10.00, "size" : 0.20},
"iron-ore" : {"frequency" : 0.20, "richness" : 10.00, "size" : 0.20},
"copper-ore" : {"frequency" : 0.20, "richness" : 10.00, "size" : 0.20},
"stone" : {"frequency" : 0.20, "richness" : 10.00, "size" : 0.20},
"uranium-ore" : {"frequency" : 0.20, "richness" : 10.00, "size" : 0.20},
"crude-oil" : {"frequency" : 0.20, "richness" : 10.00, "size" : 0.20},
"coal" : {"frequency" : 1.00, "richness" : 1.00, "size" : 1.00},
"iron-ore" : {"frequency" : 1.00, "richness" : 1.00, "size" : 1.00},
"copper-ore" : {"frequency" : 1.00, "richness" : 1.00, "size" : 1.00},
"stone" : {"frequency" : 1.00, "richness" : 1.00, "size" : 1.00},
"uranium-ore" : {"frequency" : 1.00, "richness" : 1.00, "size" : 1.00},
"crude-oil" : {"frequency" : 1.00, "richness" : 1.00, "size" : 1.00},
"water" : {"frequency": 1, "size": 1},
"trees" : {"frequency": 1, "size": 1},
"enemy-base" : {"frequency": 0.4, "size": 0.5}
"enemy-base" : {"frequency": 0.5, "size": 0.5}
},

"cliff_settings":
Expand Down
2 changes: 1 addition & 1 deletion info.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "oarc-mod",
"version": "2.1.9",
"version": "2.1.10",
"factorio_version": "2.0",
"title": "Oarc Multiplayer Spawn",
"author": "Oarcinae",
Expand Down
Loading

0 comments on commit 5a74e87

Please sign in to comment.