I can easily determine the number of players: #game.players
But I'm too useless at math to think of a decent, non-desyncable way to calculate the throttle.
The throttle calculation would only be performed when a player dies, and even then if that death is not ignored due to throttling.
The resulting value will be added to game.tick to determine when the event can next be processed, sort of like this:
Code: Select all
local delay = 60 -- ticks
local threshold = 0
function handle_event( event )
if event.tick < threshold then return end
-- something to calculate new `delay` value based on `#game.players`
threshold = event.tick + delay
-- handle event
end
