So just an update.
Iāve create some .Net Core code that takes images
HeightMap + BiomeMap
And then produces a collection of ācellsā with corresponding data.
Eg:
{
āxā:0,
āyā:5,
āTerrainā:4,
āBiomeā:2
}
So by making each area in nwn, the equivalent of a 5px x 5px rectangle on the image - it can result in around 71000 area definitions being created.
Note - this is also including water tiles - which are not explorable, so once you remove those - the count will be significantly less.
So I uploaded all this data into a database -
Created some nwn nss code that would be attached to a trigger.
When it detects we are the Eastern Trigger, it knows to take our X coordinate and add +5 to it, in order to get the desired X,Y coordinate of the next connecting area - it then connects to the db, to find out what terrain type and biome type it should be connecting to.
It then querys the database for my list of terrain templates that match that terrain type and biome type.
Eg: It might be looking for flatground, grasslands or it could be rocky terrain, tropical rainforest, or mountain, glacier etc
The query used for the sql uses order by Rand() limit 1; to get a random area resref that matches the criteria.
It then spawns that area, sets its tag to be the x,y coordinate - so we can get the area again in the future easily.
It locates the waypoint for the western spawn point in that area - and then connects the eastern trigger in the current area, to the western wp in the new area.
Once it is all done - the player is ported to the waypoint.
When they try to go back to the area they just came from - the system will check for the existence of an area that has the correct x,y tag- if it exists - it uses that as the destination area instead of trying to make a new one.
It then knows that if you are going West, you need to connect to an Eastern WP.
Another property I have on the area templates is
connect_west
connect_east
connect_south
connect_north
With these integers, I am able to make areas that have 0-4 connectable sides.
This way, I can make it possible for some paths to be blocked off while allowing an area to always find an area that has the appropriate connections.
Eg: select from table where connect_south = 1 and biome = ? and terrain =? order rand limit 1;
This way a northern connection will always find an area that has at least a southern connection - as well as any other connection it may have - but at the very least, it must have a southern connection - because that is what the player is entering via.
The other thing to be aware of is - Once a player has explored an area - I donāt want the area to be randomly generated at that stage.
Eg: After resets
So I would track in a db, x + y coordinates against the resref of that explored area - this resref would be used for re-generation, instead of the randomized query. (Yet to do this bit)