Way to check which regions are reanimating without embarking in them


The search for perfectly !!Fun!! region in Dwarf Fortress can be cumbersome, as many evil regions do not have zombies. Are there any methods/utilities which allow to check which regions of the given world are in fact reanimating?

Best Answer

Using in-game information

The simplest, if unreliable solution:

In order for a region to be reanimating, it has to be evil. There's more to it than just that. In particular, terrifying locations tend to be more likely to zombify the dead. Being near a necromancer tower also should more often net you reanimating biomes. Trial and error is a reasonable solution: about 50% of all terrifying locations should be reanimating.

Using DFHack

Using a few commands or using the advanced tools injected into the game by dfHack you can obtain this info with a little effort:

For starters, DFhack can tell you this property of a region. In-game, it can do so via the Embark Assistant. Read the forum topic for a complete guide to all the options in this expanded embark finder. It functions much like the normal game's embark search tool. You can also use its CLI;

region-pops list [pattern]

Allowing you to list the regional populations of all wild animals in a certain biome. You can check if it includes the !!FUN!! creatures you are interested in. Undead creatures hint a reanimating biome.

Browsing the generated raws

If you want to delve deeper...

You can look around in your world.dat file located in the save game folder. You would need to decompress it first, then open it with a hex editor. Unfortunately there is no documentation as to the specific descriptor for being reanimating.

The df-structures (also see this structure) project may provide more insight in reverse-engineering the binary format. Some publicly known information is listed in the wiki, the magic strings in there might help you locate the data. Looking at the structures, you would need to find where in the file the world_region structs are located. You could find this struct by searching for the region name in the file (encoded in ASCII). There's a pointer to this name in the world_region struct, followed by the information below.

Surmising the information from the structures, you would search for data formatted like so (if the structure were serialized into world.dat, you would get this):

len  obj
 8?  pointer to name (or the name is 
  4  region index
  2  region type
  2  x coord (0-255)
  2  y coord (0-255)
  4  number of tiles
  4  ???
  4  ???
  4  ???
  4  ???
  8  pointer to pop vector (populations for all creatures). 
204  51x biome tile counts. 
nx2  tree biomes
nx2  x coordinates of trees
nx2  y coordinates of trees
nx2  'goodness' of the trees
nx2  'evilness' of the trees
nx2  'savagery' of the trees
  1  percentage of vegetation to kill on embark
  1  ??? (boolean)
  1  ??? (boolean)
  1  boolean indicating reanimating <== the bit we're interested in.
  4  ??? (integer)
  1  boolean indicating evil <== always 1 if reanimating is 1.
  1  boolean indicating good <== always 0 if reanimating is 1.
  2  Always contains the value -30000 <== very useful to locate our data.
nx4  array of deity IDs
  4  Unknown integer
  4  coordinates (mid_x)
  4  coordinates (mid_y)
  4  coordinates (min_x)
  4  coordinates (max_x)
  4  coordinates (min_y)
  4  coordinates (max_y)

The interesting part is that the evil/good bools are very close to the reanimating bool. So it's likely the save game format would contain data formatted like

01 xx xx xx xx 01 00 D0 8A evil, reanimating
00 xx xx xx xx 01 00 D0 8A evil, not reanimating
00 xx xx xx xx 00 01 D0 8A good (never reanimating)
00 xx xx xx xx 00 00 D0 8A neutral (never reanimating)

(Note: numbers are always little-endian). These are the only four possible byte patterns (ignoring the unknown integer) for these 7 bytes.

Note that the game may have 'flattened' the pointers; instead of just taking 8 bytes to point to where in the file the vector is located, it may just be directly in the data structure, with some additional field indicating the length. It's also possible for multiple booleans to be 'packed' into one flag together, which would make my idea for locating this not work.

If you succeed in figuring out how to find out whether a region is reanimating in the file format, do share this knowledge. It can help make the community's region and legends browsing tools better.