diff --git a/config.lua b/config.lua index 3a48d7a2b..da4225ec5 100644 --- a/config.lua +++ b/config.lua @@ -203,9 +203,21 @@ global.config = { {name = 'compilatron-chest', count = 5}, {name = 'compilatron-chest', count = 5}, {name = 'selection-tool', count = 1} + } } - } - }, + }, + -- settings for controlling length of delay before player respawn - the delay goes *down* over time + -- respawn time is determined by biter progression: + -- respawn_delay = max_time - (decrement_amount * biter_progression) + -- respawn_time = max( min_time, respawn_delay ) + -- min_time default is 10 seconds + -- decrement_amount default of 3000 will remove ~5 seconds per 10% evolution + player_respawn_time = { + enabled = false, + min_time = 600, + max_time = 3600, + decrement_amount = 3000 + }, -- spawns more units when one dies hail_hydra = { enabled = false, diff --git a/map_gen/maps/crash_site/entity_died_events.lua b/map_gen/maps/crash_site/entity_died_events.lua index 3b4268697..61dd6626a 100644 --- a/map_gen/maps/crash_site/entity_died_events.lua +++ b/map_gen/maps/crash_site/entity_died_events.lua @@ -5,7 +5,9 @@ local Global = require 'utils.global' local math = require 'utils.math' local table = require 'utils.table' +local max = math.max local random = math.random +local round = math.round local set_timeout_in_ticks = Task.set_timeout_in_ticks local ceil = math.ceil local draw_arc = rendering.draw_arc @@ -173,7 +175,15 @@ local spawn_player = Token.register( function(player) if player and player.valid then - player.ticks_to_respawn = 3600 + local respawn_delay + if global.config.player_respawn_time.enabled then + local decrement_amount = round(game.forces.enemy.evolution_factor * global.config.player_respawn_time.decrement_amount) + local adjusted_respawn = global.config.player_respawn_time.max_time - decrement_amount + respawn_delay = max(global.config.player_respawn_time.min_time, adjusted_respawn) -- limit smallest delay to min_time, if evolution goes above 100% + else + respawn_delay = global.config.player_respawn_time.max_time + end + player.ticks_to_respawn = respawn_delay end end )