So, a while back I posted in this issue:
https://github.com/DFHack/dfhack/issues/1784In short, emigration.lua worked in past, but no longer works.
I fixed it. Do you want it?
In the issue people didn't seem to believe that it's broken, but I also made
a test script that can be used with
a more debug-friendly version.
I found that my solution works with merchants and without merchants, but leaving with diplomats didn't seem to work work + there was an announcement about a diplomat leaving unhappy, so I commented that part out. Another pitfall is that it's tested only on 0.47.05, so dunno if stuff's changed since. My solution also attempts to find a new group for the emigrants to join, and a new site, and it has your own civilization as fallback. I only tried it with merchants from own civ, though. I also am not exactly sure if the units travel to their new homes after they leave the embark, or what happens to them.
The script could also use some optimizing, but I didn't do a complete rewrite. Also, I don't know if the algorithm could use some tuning. I mean, 250k stress is when there's 50% chance for a dwarf to join merchants of your own civilization, and at that point they're already going insane. Maybe the chance should rise faster, since it runs only once per month. At 50k stress it's still at about 90% chance to stay, despite it causing mental breakdowns. But maybe the fact that it runs monthly compensates for the percentages. Sometimes even a slightly stressed dwarf leaves if the roll is a 100.
I also implemented the solution in a script that allows choosing a dwarf for emigration, because I wanted a world where my dwarves make a gazillion babies and then send them to the world at adulthood.