I'm currently working on a megaproject I intend to share and while I was sealing off a few things I accidentally came up with something I thought quite clever.
Toady has said (somewhere, I cant remember where) that Dwarf Fortress will eventually have creatures and enemies that can tunnel into your fort. I accidentally discovered a way to actively defend against it AND deal with whatever was dumb enough to try to dig through.
I give you... THE WATERLOCK!
Picture a large box. Within it is a slightly-smaller block. That block is your fort and everything in it. In the gap between... is water.
As we all know, aquifers, cave lakes and the odd accident with a overseer-built reservoir can utterly kill a fort with flooded tunnels due to the unstoppable water flow. I've weaponized this into a barrier of sorts. With a wall of water enveloping the fort, any attempt to dig in will inevitably result in a lethal rush of constant pressurized water down the would-be intruder's tunnel.
Now, here's how to build one. My test version was 10z deep, but you can make them as big as you want, and the water barrier as wide as you want. Doesn't have to be 1 square wide, just add more floodgates in a row at the airlock.
The top level should look something like this;
The screwpumps were just my way of filling it quickly. You can use aquifer tiles, rivers, whatever you like.
The reason for the down-staircases were just for expediency of digging. I just set a row of up-down staircases all the way down to the bottom so it would be easier to do. Feel free to set dwarves channeling down in alternating vertical rows or something, whatever's easiest for you.
Most of the levels in the Waterlock will look like this
However, the level above the airlock (the means to get inside safely), requires flooring in order to create a ceiling for the airlock's level
Here is the fun level of the Waterlock. The airlock. Using two floodgates and two doors, a simple airlock permits water to flow around the barrier and still allow a dwarf to seal the passage so they can exit, albeit a little damp.
To reduce the water splash, especially if you make the barrier wider than one square, perhaps add a floor grate and drain outside the outer door. Open the outer door first, let the water flow down the drainage channel, and then let the dwarves in or out.
The first and third levers (counting downwards) control the doors. The second controls both of the floodgates.
When sealed, it looks like this
The yellow 'X' is the cursor
And now, the FUN part. What happens if some errant critter tries burrowing in?
As you can see, the water's about to be breached.
It should be noted that the airlock level is 6z-levels below the top of the Waterlock. If you've meddled with water pressure, you know what's coming next and just smiled a little cruelly at the test dwarf.
As you can see, the pressurized water has flooded the intruder's tunnel and thus, kept the fort safe. This WILL drain the WaterLock to that level, of course, but it will flood out whatever hole the intruder came from. To repair it, a drainage system should be dug out the lowest level so that holes can be repaired while your visitors are still enjoying their new indoor swimming pool.
I hope this is of some use to you guys, or at least provided a moment's amusement.
And as a footnote; Magma would work, but you'd have to wait for the random 1/7 tiles to cool after opening the airlock and hope a dwarf isn't in too much of a hurry to look at what he's walking through