I’m trying to make a wave survival game and I want the waves to be endless so I’m having trouble figuring out a fair algorithm that calculates how many enemies to spawn in each wave
I want the number of players to affect it (fewer players = fewer enemies) and maybe (not necessarily) a difficulty value
It really depends on how tough the enemy NPC are compared to the average player.
I’d recommend starting off with maybe 10 NPC for one player in wave one. Increasing by, maybe, 5-10% each wave. Then an additional 5% with each extra player.
A way to figure out how many NPC should spawn might be:
BaseNPCValue = 10
WaveMultiplier = 1
PlayerNumber = (1 + Players * 0.05) - 0.05
-- minus 0.05 from PlayerNumber to ensure it is only extra players that add 0.05
SpawnNPCValue = 10
-- Each wave end
WaveNumber = WaveNumber + 0.1
SpawnNPCValue = BaseNPCValue * WaveMultiplier * PlayerNumber
Next you just need to figure out if you want to round up or down.
The ‘SpawnNPCValue =’ line is just multiplying the base number by the extra players (0.05 for each extra player) and the wave (0.1 for each wave past one).