pango wrote: ↑Sat Oct 12, 2019 3:50 am
So it seems that periodic spawns do not start by waiting for a random period of time before the first spawn, but trigger immediately, then start waiting for random periods?
I noticed a bug in CreateFoe:
Code: Select all
// Check for a new spawn event - only one spawn event can be running at a time
if (gameSeconds > lastSpawnTime + spawnInterval && !spawnInProgress)
{
// Update last spawn time
lastSpawnTime = gameSeconds;
// Roll for spawn chance
float chance = spawnChance / 100f;
if (UnityEngine.Random.Range(0f, 1f) > chance)
return;
So every spawnInterval an enemy can be spawned with a spawnChance% chance, okay...
The only small issue here is that because of ">" there must be at least spawnInterval + 1 seconds between checks, so spawning rate is slightly weakened.
Code: Select all
// Init spawn timer on first update
if (lastSpawnTime == 0)
lastSpawnTime = gameSeconds + (uint)UnityEngine.Random.Range(0, spawnInterval + 1);
We initialize the cycle by simulation a random initial phase.
Well first, as seen before, I'm not sure it's what classic does;
And second, there's a bug, it's a "nextSpawnTime" formula not a "lastSpawnTime" formula: If next spawn check must happen randomly between gameSeconds and gameSeconds + spawnInterval, then since we compare gameSeconds against lastSpawnTime + spawnInterval, lastSpawnTime should be initialized with a random value between gameSeconds - spawnInterval and gameSeconds:
Code: Select all
// Init spawn timer on first update
if (lastSpawnTime == 0)
lastSpawnTime = gameSeconds - (uint)UnityEngine.Random.Range(0, spawnInterval + 1);
This bugs delays the first spawn by one spawnInterval. That may have contributed to
House cleaning quests unbalancing.
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart