Love the game so far, can't wait to see more!
The Open World
Over the past weeks, I've been thinking through how the open-world system would work in Deadwind. I'm happy to say it's finally come to fruition and is pretty much ready to be populated with content.
Back in August, I utilized an asset to make a tool that parses over a PNG, reads the colour value of each pixel, and writes data to a file containing information denoting what each tile of overworld map should be. (This map is 400x300 with green areas being grassland, brown being forests, grey being mountains, etc. It is still a work in progress) Once the file is created, we have all the information needed to generate tiles in the world.
Parsing the Save File
At this point, we can convert the save data to tiles in the world. Simply by assigning each value(1 = grassland, 2 = forest, etc) to a tile from a tile set. We then parse the whole room and place the tiles at their corresponding positions.
The overall random generation is achieved through a tool I purchased called jen_scripts(I'm in no way affiliated with the dev, i just genuinely think this asset is awesome). I use it to generate roads, rivers, and various ground clutter like grass tiles, flowers, and rocks.
For each area, I needed a way to generate the room with set parameters based on the area's surroundings. For example, If the area entered is the centre of a 3 way crossroads going north, east, and south-west, with grasslands surrounding it, The random generation should change to fulfill those requirements. (Forgive the upcoming paint.net art)
To do this we check the surrounding tiles of the area we want to enter and designate points in the room corresponding to said surrounding tiles. (Ex. Grass points in the corners, rivers top and bottom, and paths left and right)
From here we iterate from those points to the centre of the room; placing tiles, and creating deviance from a straight line to add more randomness and fill the area. We also perform some random scattering of ground objects based on the surrounding biomes(ie. more rocks in areas surrounded by mountains). Using this method we can generate nice forks in roads, and have nice gradients between different areas
To make sure the area generates the same every time, I'm using a function called Cantor Pairing. Basically, this function takes two numbers as inputs, and outputs a single unique number.
Using the map coordinates of the chosen area as inputs to this function, we can generate a unique seed to use. This means that every time we enter this area, it will generate exactly the same; giving the illusion of a static open world.
Using this method we can generate very big overworlds with very small file sizes. I'm sure I could get the file size smaller but at the current moment the 400x300 map generates a file that is 118kb large. Also each individual area is 170x96 tiles large. This means if every tile on the map was land, and you consider 1 tile to be 1 square meter, there is effectively 1958 square kilometres to explore at ONLY 118kb.
I'm super happy with how this system is turning out. Its not 100% fool proof as of yet, as there are still some problems getting certain areas to line up with its surrounding areas, but it really does give the sense of a massive open world to explore.
Future plans for this include quests (including radiant quests) being tied to map coordinates, random encounters as seen in the demo, and unique locations to discover.