Spawn zones

Each zone has its own spawners that depend on its biome. Spawners are active depending on the time of day, weather and world progression. Spawns are prevented with player bases.

## Spawning logic

### Zones

The map is split up into 64x64 grid squares with 0,0 being in the center of the first zone.

Every 4 seconds, zones with a player process their spawners.

### Spawners

Each spawner tries spawning if enough time has passed since its previous spawning attempt.

Amount of tries is calculated from the elapsed time and capped at creature limit.

For example Deers have a spawn interval of 100 seconds. After 250 seconds, 2 spawn attempts would be made. After 500 seconds, only 4 spawn attempts would be made because the limit is 4.

### Spawn attempts

A spawn attempt fails if:

* The random roll fails
* Required boss has not been killed
* Wrong weather
* Wrong time of the day
* Too many same creatures already exist in loaded zones (creature limit)
* Valid spawn position is not found after 20 attempts
* There is already the same creature too close to the valid spawn position (suppression limit).

### Valid spawn position

A spawn position is randomly selected between 40 - 80 meters of a random player in the zone. Spawn position is not valid if:

* Position has wrong biome
* The zone of the position has multiple biome (if full biome is required)
* Covered by a structure
* Blocked by player base
* Wrong altitude
* Wrong terrain angle (max tilt 35 degrees by default)
* Wrong amount of water
* A player exists within 40 meters
* Position is not inside a forest (if a forest is required). Forests are determined on the world generation. Terraforming or trees don't affect it.

Note: Terraforming with Cultivator, Hoe or Pickaxes doesn't directly block spawning but affects terrain altitude and angle.

### Group size

The amount of creatures is randomly selected from the group size. The amount is capped at creature limit.

With only one creature, the enemy is spawned at the valid spawn position.

With more than one creature, the game tries finding a spawn position two times for each creature. The spawn position is randomly selected from a circle around the initial spawn position (group radius). Same rules apply for determining the validity.

### Spawning

Each spawned creature has 10% chance to level up (9% for 1 star, 1% for 2 stars), if leveling up is allowed. For some creatures, the leveling up requires enough distance from the world center.

If the spawner is only active during the night, then spawned creatures are set to despawn during the daytime (as long as their zone is active)..

Flying enemies are spawned off the ground depending on the creature. The actual spawn position is still on the ground and can be blocked by player base.

## Example

For example Serpents have two spawners which only work when zone is located in Ocean biome. The first spawner works only during the night while the second spawner only works during storms. This means both spawners are active during night time storms giving the best chance for finding a Serpent.

Serpent spawners work every 1000 seconds and only have a 5% chance to work. If you just wait on a spot then it can take hours for a Serpent to spawn. But if you keep moving to new zones then you can easily get a spawn attempt every 12-16 seconds (depending on the speed). However this requires that you haven't visited the area for 1000 seconds.

Serpents can spawn up to 80 meters away so it's good to be in a middle of the ocean. If you are near other biomes then the spawn can fail because of wrong biome. Serpents never spawn as starred variant because the max level is 1.

Serpents that spawn because of storm won't despawn on morning even when spawned during the night (but no way to tell which spawner spawned it).

A serpent suppresses other serpent spawns within 50 meters. It's still possible to spawn more serpents (since they can spawn up to 80 meters away) but the chances are drastically reduced. Serpents detect you up to 50 meters away so most of the time they won't aggro right away.

1. ↑ Technically possible for Mountains if the player is on an adjacent biome with a misty weather.