From e69d58db33c49e40e5cbedd6afcd8337bf3182a4 Mon Sep 17 00:00:00 2001 From: HySpeed Date: Sat, 14 Sep 2019 16:03:17 -0400 Subject: [PATCH] Added adjustable Respawn time to CrashSite (#957) Added enable (default false) to control adjustable respawn delay. When disabled, respawn is 60 seconds. --- config.lua | 1 + map_gen/maps/crash_site/entity_died_events.lua | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/config.lua b/config.lua index 1d6bc3135..da4225ec5 100644 --- a/config.lua +++ b/config.lua @@ -213,6 +213,7 @@ global.config = { -- 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 diff --git a/map_gen/maps/crash_site/entity_died_events.lua b/map_gen/maps/crash_site/entity_died_events.lua index 5b526c7bc..61dd6626a 100644 --- a/map_gen/maps/crash_site/entity_died_events.lua +++ b/map_gen/maps/crash_site/entity_died_events.lua @@ -175,10 +175,15 @@ local spawn_player = Token.register( function(player) if player and player.valid then + 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 - 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 + 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 )