How is enemy spawn decided?

I have been experimenting with lights walls and such to try and make a safe town. I can’t quite seem to achieve that so I was wondering if anyone had tips or examples of towns you’ve made safe from invaders and have been able to keep them from spawning inside the town.


I’ve put a lot of effort to control enemy’s, The most annoying thing I encounter was them spawning buildings in my town, This is my very terrible way of countering it,

I placed a load of floor templates in large areas I wanted to save for later, I’m honestly not sure if this is useful in anyway but it stops them spawning inside at least :stuck_out_tongue:

I then went ahead and made huge walls around the town,

There’s 2 entrances in which enemy’s can spawn in, This means my hearthlings will be safe and its easy enough to control spawning, I can them place banners at the entrances when theres an attack.

Not the greatest advice, But hopefully that’ll help in some way :stuck_out_tongue:

1 Like

I’m writing a vastly improved version of the spawning code which should avoid a lot of the awkward spawn locations. Look for it as part of the next patch!


Thanks so you think its mainly based off of distance from buildings? at least until next update that is.

Cool. I love how far the game has come started playing at like A4 and to see it now is so cool I can’t wait to see the next set of improved features!


In my games, that I have played, enemies seem to spawn at the edge of the revealed area, so they spawn far away from my town (since I explored a great part of the map).

For me good spawning should:

  • Spawn far away enough, yet close enough so I as player need to make a thought-out decision about the threat.
  • Only spawn underground if that makes sense for their character like: Zombies or golems. (Ents and wolfs should not)
1 Like

That’s great news, @Albert!

Question: Does your new code take densely forested areas into account as well? I’ve been successful in managing spawning by the clever use of trees, settling in places with limited open space, etc. but this can also mean that when I WANT encounters, I have to clear cut space for them to happen, otherwise things turn mostly peaceful by the mid-game.

It’s up to the specific encounter to decide if it wants to clear the trees or not, but generally trees won’t affect the location much. The new code basically accounts for the zone of control of a player’s territory based on the locations of buildings, farms, etc. If you wall yourself in sensibly, they won’t violate your territorial integrity. They will also avoid spawning underwater and in mines.


Thanks for the info. Is that true now, or going forward with your new code?

Only the tree part is currently valid. Everything else is part of the next build.

1 Like

That’s weird, because in my recent saves, I have not seen any encounters that clear trees. It might be functionally capable of clearing them, but I haven’t seen it happen.

The new code didn’t make release-523 which was just a hotfix for the crafter queue.


Is there any way, such as via developer tools, for the player’s “territory”, and spawn-able area’s to be shown visually? Highlighted like a zone, though presumably with a different color? That would be greatly helpful.