Skip to content

Commit

Permalink
Added adjustable Respawn Time to CrashSite (Refactorio#957)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
HySpeed committed Sep 14, 2019
1 parent f4acacf commit d0aab27
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
10 changes: 6 additions & 4 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
7 changes: 5 additions & 2 deletions map_gen/maps/crash_site/entity_died_events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
)
Expand Down

0 comments on commit d0aab27

Please sign in to comment.