From d0aab275c1bd7077b13bf25dac7322f2b0367824 Mon Sep 17 00:00:00 2001 From: HySpeed Date: Sat, 14 Sep 2019 13:18:30 -0400 Subject: [PATCH] Added adjustable Respawn Time to CrashSite (#957) Based on conversation with GrilledHam: - Respawn delay is to prevent / punish early game suicide runs to clear nests. This implementation decreases the respawn time from default of 60 seconds to a minimum of 10 seconds, by 5 seconds per 10% of evolution. --- config.lua | 10 ++++++---- map_gen/maps/crash_site/entity_died_events.lua | 7 +++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/config.lua b/config.lua index 2c55e3680..1d6bc3135 100644 --- a/config.lua +++ b/config.lua @@ -206,14 +206,16 @@ global.config = { } } }, - -- settings for controlling length of delay before player respawn + -- settings for controlling length of delay before player respawn - the delay goes *down* over time -- respawn time is determined by biter progression: - -- min_time + (increment_amount * biter_progression ) + -- respawn_delay = max_time - (decrement_amount * biter_progression) + -- respawn_time = max( min_time, respawn_delay ) -- min_time default is 10 seconds - -- increment_amount default of 3000 will add ~5 seconds per 10% evolution and max at 60 seconds + -- decrement_amount default of 3000 will remove ~5 seconds per 10% evolution player_respawn_time = { min_time = 600, - increment_amount = 3000 + max_time = 3600, + decrement_amount = 3000 }, -- spawns more units when one dies hail_hydra = { diff --git a/map_gen/maps/crash_site/entity_died_events.lua b/map_gen/maps/crash_site/entity_died_events.lua index d33bb14d1..5b526c7bc 100644 --- a/map_gen/maps/crash_site/entity_died_events.lua +++ b/map_gen/maps/crash_site/entity_died_events.lua @@ -5,6 +5,7 @@ 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 @@ -174,8 +175,10 @@ local spawn_player = Token.register( function(player) if player and player.valid then - local increment = round(game.forces.enemy.evolution_factor * global.config.player_respawn_time.increment_amount) - player.ticks_to_respawn = global.config.player_respawn_time.min_time + increment + 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 + local respawn_delay = max(global.config.player_respawn_time.min_time, adjusted_respawn) -- limit smallest delay to min_time, if evolution goes above 100% + player.ticks_to_respawn = respawn_delay end end )