DT: Water Management

Hey everyone! A few weeks ago, Engineer Albert mentioned he was working on a way to allow your lakes to refill, so that you can build your city beside an epic waterfall and not have that waterfall dry up and look incredibly sad. This week, I’m pleased to present his progress: introducing the Wetstone, and its super important counterpart, the Drystone.


Recap from the video:
For those of you who just want to jump in, here’s how it works: a wetstone is an object that adds a certain amount of water to the world around it at a certain rate. If you stick it in a lake or river or moat or a voxel bathtub, it will eventually fill up that volume and overflow. Thanks to some anti-flooding code, which prevents water that falls on terrain from expanding forever, it will only create a certain sized puddle on the ground, but it will still create a puddle.

If you want to create a waterfall that flows from one level to another without creating this unsightly puddle, you want to put a drystone into the destination location. Drystones absorb water at the same rate wetstones produce it, so you can reach equilibrium with your water flow.

This means that towns can at last enjoy sustainable waterfalls and water levels. It means we can finally create scenes like the one in Tom’s original concept art, with irrigation and rivers that always look good. Because water now interacts with buildings, it means we can make fountains with constantly flowing effects. As someone who has been waiting for this tech for five years, I’m super excited that Albert has finally added it!

So why has it taken so long to get to this tech when we’ve known since forever that we’ve wanted it? Well, it honestly took us a while to figure out how to model refillable bodies of water in Stonehearth. On earth, the lakes and rivers that last long enough to make it onto maps are the result of hundreds of water sources–rain, glacier melt, underground springs–filling low spaces, and then running off into the ocean at roughly a rate that allows a steady body of water to exist in the world. We didn’t actually want to simulate a whole water ecosystem or make a rain simulation just to get some lakes and rivers, so Albert actually started with the idea that lakes of a certain size should have equilibrium logic to them, to simulate the fact that groundwater is always arriving, and being absorbed into the land at roughly the same speed. He did this at first with some source and sink code, and then some equilibrium region code. The end result was a lake that would slowly refill if it was drained, by invisible means.

The problem with this was twofold: one that the equilibrium code got really hairy really fast in the face of terrain deformation: if you split the lake in half with a wall, or if you nibble away the edges of the lake slowly, the lake would have to recalculate it’s volume and that’s incredible fun from math perspective. The second problem was that it was super difficult for anyone to understand why the water was behaving as it did; where was all the new water coming from? Mining near lakes or building in lakes produced unexpected results that left everyone baffled and unsure of how to get actually create the lakes and rivers they wanted.

In the end, Albert and Artist Malley reasoned that the proper solution for manipulating water should be easy to understand, inexpensive from a CPU/simulation point of view, and most importantly, be under the player’s direct control. They therefore decided to create an object that would release water into the world, like a D&D portal to the plane of water or an everflowing bottle that could be hidden in lakes naturally, or that could be bought or crafted by players and placed in spaces by hearthlings. It wasn’t the most realistic solution–as rain or glacier melt, say, would be–but it would mean that anyone playing the game could have an active hand in manipulating their town’s water levels. Artist Allie named the object a wetstone, Malley created a model and vfx and the end result, we think, is a lot of fun to build with. Of course, in order to prevent wetstones from making puddles, Albert invented the drystone, which sucks water out of the world in the same way it entered.

Wetstones and drystones are not yet in the game, insofar as we haven’t yet implemented exactly how you should be able to make or buy them, and we also have some ideas for wetstones and drystones of different sizes and water rates that we have to balance. However, if you really want to play with them, you can find them on our steam unstable branch via the debugtools mod. Turn it on from the main screen, and then use the stamper to find the wet and dry stones. Add one to an empty area, or to your buildings, and let us know how they feel! There are still definitely some bugs: if you stamp out a lot of stones, for example, they may not emit as intended but these and other issues will continue to be fixed in later builds. Try them out, let us know how they’re working, how you might like to get them naturally in the game, and then SHOW US ALL YOUR COOL WATER PICTURES!!!!

Other Announcements

Update on the builder because I know so many of you are looking forward to it: Engineer Justin has added in most of Nikki’s new UI. We’ve also ironed out a bunch of bugs but before we turn it over to you to find more bugs, we should implement the template functionality so that you can help us figure out whether issues you discover come from the build itself, or from the CPU load of the game as a whole.

Streams: This week’s stream will be with Engineer Max, so come with all your modding, AI, and performance related questions. Max has also been working on some really cool campaigns and encounters; ask him for a sneak peek at the new face of friendship, for example. 🙂