Dungeon Placement #235
Greymerk
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Roguelike Dungeons preferably spawn near villages. This is kind of a nod to Diablo's Tristram and the dungeon to Hell. It took me a while to figure out how to decide which chunk "nearby" a village to place the tower. It started with finding the algorithm related to villages spawning. I already had this algorithm before, but it no longer provides an answer that matches in game. After digging through the source code I discovered that one of the variables was tweaked (32 changed to 34). My guess is that this number was changed to reduce the density of villages when they were added to more biomes.
Once I had an algorithm for finding village placements, I created an algorithm for determining if a given chunk near the village was a valid spawning chunk. First I would check the chunk's manhattan distance to the village (light in minecraft uses manhattan distance). Then I cast a psuedorandom angle from the village based on the village's chunk position. using that angle, and the angle to the given chunk, I used vector projection to get a magnitude value along the village ray. If that magnitude value fell inside the chunk (and the scalar was positive) then spawn a dungeon.
This would all be a lot easier if I actually understood linear algebra.
Beta Was this translation helpful? Give feedback.
All reactions