Skip to content

Commit

Permalink
Added adjustable Respawn time to CrashSite (Refactorio#957)
Browse files Browse the repository at this point in the history
Added enable (default false) to control adjustable respawn delay.  When disabled, respawn is 60 seconds.
  • Loading branch information
HySpeed committed Sep 14, 2019
1 parent d0aab27 commit e69d58d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions map_gen/maps/crash_site/entity_died_events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down

0 comments on commit e69d58d

Please sign in to comment.