Wednesday, November 23, 2011

The Fifth Layer

Traditionally, the Angband dungeon has been regarded as having three layers - terrain, objects and monsters. Terrain is the stuff the dungeon is actually made of (granite, doors, floor, traps,...). Objects can lie on appropriate terrain (only floors in Vanilla Angband), and can be picked up and carried by the player or monsters. Monsters (and the player can move around the dungeon, depending on the terrain. So the state of a particular grid location in the dungeon is defined by the terrain, the objects located there (if any) and the monster located there (if any).

Now some variants (Sangband is the first one I was aware of) have made traps into a distinct layer; I have stolen this for FAangband (and Beleriand). In this system, traps are no longer terrain, but separate things which can exist in certain types of terrain, and interact with the player and/or monsters. In fact, I have also made runes and spider webs part of this layer.

But that's not all, because I lied about grids being defined by terrain, objects and monsters. There is also some other information, stored in the cave_info array/arrays; this includes whether the player has seen the grid and whether it is illuminated. Now for Beleriand, I'm planning to have a continuous wilderness, which is generated as needed. But what if the generation creates a river which needs to flow into an area which hasn't been generated?

The answer is to add a fifth layer - what might be called environmental information. In a way it already exists in cave_info, but it's going to be enlarged beyond recognition. So any grid, as well as terrain (and monsters, objects and traps sitting on it), is going to have information about the context in which it exists. The river will consist of water terrain, but all its grids will also know that they are part of that river, so when new terrain is generated adjacent, it can look around and say "OK, I need to be part of the river too".

Now all that is sufficient to solve my generation problems, but it actually raises more possibilities. The forest realm of Doriath was protected by "an unseen wall of shadow and bewilderment: the Girdle of Melian, that none thereafter could pass against her will". This is now easy to implement - give any grid on the boundary the CAVE_MELIAN flag, and make relevant monsters unable to pass through it.

This should be fun.

No comments:

Post a Comment