mirror of
https://github.com/Oarcinae/FactorioScenarioMultiplayerSpawn.git
synced 2024-12-12 10:13:58 +02:00
Merge pull request #244 from Oarcinae/233-spawner-health-at-high-evo-is-a-problem-for-new-players-joining-a-late-game
233 spawner health at high evo is a problem for new players joining a late game
This commit is contained in:
commit
432db3bed0
@ -1,4 +1,9 @@
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Version: 2.1.8
|
||||
Date: 2024-11-05
|
||||
Changes:
|
||||
- Adding bonus damage to spawners that scales with evolution factor and distance to spawns. This is to help new players joining late games where spawner health is too high due to evolution. This can be toggled in the in game GUI settings (not mod settings).
|
||||
---------------------------------------------------------------------------------------------------
|
||||
Version: 2.1.7
|
||||
Date: 2024-11-05
|
||||
Bugfixes:
|
||||
|
@ -363,6 +363,13 @@ script.on_event(defines.events.on_post_entity_died, function(event)
|
||||
end,
|
||||
{{filter="type", type = "unit"}, {filter="type", type = "unit-spawner"}, {filter="type", type = "turret"}})
|
||||
|
||||
script.on_event(defines.events.on_entity_damaged, function(event)
|
||||
if storage.ocfg.gameplay.scale_spawner_damage then
|
||||
ApplySpawnerDamageScaling(event)
|
||||
end
|
||||
end,
|
||||
{{filter="type", type = "unit-spawner"}})
|
||||
|
||||
----------------------------------------
|
||||
-- Gui Events
|
||||
----------------------------------------
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "oarc-mod",
|
||||
"version": "2.1.7",
|
||||
"version": "2.1.8",
|
||||
"factorio_version": "2.0",
|
||||
"title": "Oarc Multiplayer Spawn",
|
||||
"author": "Oarcinae",
|
||||
|
@ -379,6 +379,9 @@ OCFG = {
|
||||
-- If you're trying out the vanilla spawning, you might want to disable this.
|
||||
modified_enemy_spawning = true,
|
||||
|
||||
-- Scale damage to spawners based on distance to spawn.
|
||||
scale_spawner_damage = false,
|
||||
|
||||
-- -- Enemy evolution factor for the easy force (inside warning area).
|
||||
-- modified_enemy_easy_evo = 0.0,
|
||||
|
||||
@ -610,6 +613,7 @@ OCFG = {
|
||||
---@field enable_secondary_spawns boolean Enable secondary spawns for players. This automatically creates a new spawn point when they first move to a separate spawns enabled surface.
|
||||
---@field scale_resources_around_spawns boolean Scales resources so that even if you spawn "far away" from the center of the map, resources near to your spawn point scale so you aren't surrounded by 100M patches or something. This is useful depending on what map gen settings you pick.
|
||||
---@field modified_enemy_spawning boolean Adjust enemy spawning based on distance to spawns. All it does it make things more balanced based on your distance and makes the game a little easier. No behemoth worms everywhere just because you spawned far away.
|
||||
---@field scale_spawner_damage boolean Scale damage to spawners based on distance to spawn.
|
||||
----@field modified_enemy_easy_evo number Enemy evolution factor for the easy force (inside warning area).
|
||||
----@field modified_enemy_medium_evo number Enemy evolution factor for the medium force (inside danger area).
|
||||
---@field minimum_online_time number Require playes to be online for at least X minutes Else their character is removed and their spawn point is freed up for use
|
||||
|
@ -85,7 +85,8 @@ OCFG_KEYS =
|
||||
["coin_generation_SUBHEADER"] = {mod_key = "" , ocfg_keys = {""}, type = "subheader", text = "Coin Generation"},
|
||||
["coin_generation.enabled"] = {mod_key = "" , ocfg_keys = {"coin_generation", "enabled"}, type = "boolean", caption = "Coin Generation", tooltip = "Enemies drop coins when killed."},
|
||||
["coin_generation.auto_decon_coins"] = {mod_key = "" , ocfg_keys = {"coin_generation", "auto_decon_coins"}, type = "boolean", caption = "Auto Decon Coins", tooltip = "Automatically marks coins dropped by enemies for deconstruction so robots will pick them up."},
|
||||
["gameplayer.enable_player_self_reset"] = {mod_key = "" , ocfg_keys = {"gameplay", "enable_player_self_reset"}, type = "boolean", caption = "Player Self Reset", tooltip = "Allow players to reset themselves in the spawn controls."}
|
||||
["gameplay.enable_player_self_reset"] = {mod_key = "" , ocfg_keys = {"gameplay", "enable_player_self_reset"}, type = "boolean", caption = "Player Self Reset", tooltip = "Allow players to reset themselves in the spawn controls."},
|
||||
["gameplay.scale_spawner_damage"] = {mod_key = "" , ocfg_keys = {"gameplay", "scale_spawner_damage"}, type = "boolean", caption = "Scale Spawner Damage", tooltip = "Scales damage done to spawners with evolution factor and distance to cloest spawn point. This helps compensate for spawner health scaling at a high evolution factor."}
|
||||
}
|
||||
|
||||
---Easy reverse lookup for mod settings keys.
|
||||
|
@ -600,7 +600,6 @@ function ShareChatBetweenForces(player, msg)
|
||||
for _,force in pairs(game.forces) do
|
||||
if (force ~= nil) then
|
||||
if ((force.name ~= "enemy") and
|
||||
(force.name ~= "enemy-easy") and
|
||||
(force.name ~= "neutral") and
|
||||
(force.name ~= "player") and
|
||||
(force ~= player.force)) then
|
||||
|
@ -229,4 +229,47 @@ function ModifyEnemySpawnsNearPlayerStartingAreas(event)
|
||||
-- log("Downgraded worm further from spawn.")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---Applies bonus damage directly to spawner health to compensate for evolution health scaling
|
||||
---This is a temporary measure until they release an API to directly change the health scaling of spawners.
|
||||
---It does not scale properly with the evolution factor because this is linear and that evo is not, but it's better than nothing.
|
||||
---@param event EventData.on_entity_damaged
|
||||
---@return nil
|
||||
function ApplySpawnerDamageScaling(event)
|
||||
|
||||
-- Check if force is a player force
|
||||
if (event.force == nil) then
|
||||
log("Entity damaged with no force")
|
||||
return
|
||||
end
|
||||
|
||||
local entity = event.entity
|
||||
local surface_name = entity.surface.name
|
||||
|
||||
-- Get the closest player spawn to the entity that was damaged.
|
||||
local spawn = GetClosestUniqueSpawn(surface_name, entity.position)
|
||||
if (spawn == nil) then return end
|
||||
|
||||
-- Get distance to spawn_position
|
||||
local distance = util.distance(spawn.position, entity.position)
|
||||
local max_danger_distance = storage.ocfg.surfaces_config[surface_name].spawn_config.safe_area.danger_radius * CHUNK_SIZE
|
||||
|
||||
-- If distance is greater than the danger radius, ignore.
|
||||
if (distance > max_danger_distance) then return end
|
||||
|
||||
-- Boost the damage based on distance from spawn and current evolution factor.
|
||||
local evo_factor = entity.force.get_evolution_factor(entity.surface)
|
||||
local distance_factor = 1 - (distance / max_danger_distance)
|
||||
|
||||
-- spawner_evolution_factor_health_modifier = 10 -- This is from https://github.com/wube/factorio-data/blob/master/core/prototypes/utility-constants.lua somehow?
|
||||
-- I do 9 because we're assuming 1 (base) + 9 (bonus) = 10.
|
||||
local bonus_damange = (distance_factor * evo_factor * 9) * event.final_damage_amount
|
||||
|
||||
-- Apply the additional damage. We do not call entity.damage because that would trigger this event again.
|
||||
entity.health = entity.health - bonus_damange
|
||||
|
||||
-- If evo is 1, and distance to spawn is 0, then damage_modifier is 10
|
||||
-- If evo is 1, and distance to spawn is 1, then damage_modifier is 1
|
||||
-- If evo is 0, then damage_modifier is 1
|
||||
end
|
@ -1064,15 +1064,10 @@ end
|
||||
---@param pos MapPosition
|
||||
---@return OarcUniqueSpawn?
|
||||
function GetClosestUniqueSpawn(surface_name, pos)
|
||||
|
||||
local surface_spawns
|
||||
for surface_index, spawns in pairs(storage.unique_spawns) do
|
||||
if (surface_index == surface_name) then
|
||||
if (table_size(spawns) == 0) then return nil end -- EXIT - No spawns on requested surface
|
||||
surface_spawns = spawns
|
||||
end
|
||||
end
|
||||
if (surface_spawns == nil) then return nil end
|
||||
|
||||
local surface_spawns = storage.unique_spawns[surface_name]
|
||||
if (surface_spawns == nil) then return nil end -- EXIT - No spawns on requested surface
|
||||
if (table_size(surface_spawns) == 0) then return nil end -- EXIT - No spawns on requested surface
|
||||
|
||||
local closest_dist = nil
|
||||
local closest_spawn = nil
|
||||
|
4
migrations/oarc-mod-V2.1.8.lua
Normal file
4
migrations/oarc-mod-V2.1.8.lua
Normal file
@ -0,0 +1,4 @@
|
||||
if storage.ocfg.gameplay.scale_spawner_damage == nil then
|
||||
storage.ocfg.gameplay.scale_spawner_damage = false
|
||||
log("Updating gameplay config with new 'scale_spawner_damage' setting.")
|
||||
end
|
Loading…
Reference in New Issue
Block a user