Part one of the tutorial, as promised! I'll get the rest of it up as soon as I can.
Before starting, you'll need a copy of TSearch. You can grab it at:
http://www.timsvault.com/cheattools/tsearch.htmHacking RelationshipsIn this tutorial, I'll be giving out a pretty basic overview of how you can hack some things in Dwarf Fortress, and give you specific instructions on how to change some things about dwarf relationships. To start out, I genned a new world in .34.06 and embarked without fiddling with anything. Here's my happy little dwarves, blissfully unaware that an unseen force will soon be meddling with their affairs. This
Looking through my unit list, I've got 5 girls and 2 boys. I picked out two suitable victims for some relationship hacking. Although you
can pick two of the same gender, I opted to avoid that territory by just picking a male and female. For this technique, I nickname the victims to make finding them in memory easier. Just for giggles, I nicknamed them Victim A and Victim B respectively. Here's a couple of screenshots of their current relationships.
The important thing is that there is already a relationship link that can be hijacked (in this case, we'll be overwriting deity links), and the two aren't already lovers or married (would that even be possible when embarking?).
Anyway, fire up TSearch. You should see a screen like the one below:
Once TSearch is up and running, hit the Open Process button and select Dwarf Fortress from the process list. You won't see much change in the interface, but TSearch will now have attached to Dwarf Fortress and you can begin hacking away at stuff. There is a search function for finding changing values in memory (works like the cheat generators in some console emulators), but we won't be touching that in this tutorial.
Instead, hit the Hex Editor button, which will open up a new sub window allowing you to view the entire process now in memory. A sample of how it looks for me is shown below. The two buttons shown below circled in green are going to be very handy. The first lets you search for either a text string or a hex value, where the second will continue the search if you've got one running.
So, we're going to need to gather a bit of information about our two dwarves. To do that, we'll need to find them in memory! There is a science to this based on memory offsets, but I just use the art of searching for them instead. To get started, let's search for our first victim, Victim A. Hit the first search button in the hex window, and enter the dwarf's name like so:
When you hit Find Next, you should with some luck see something akin to this:
This is your dwarf's creature entry. If you don't see this after the first search, hit the find next button to keep looking. If you've got a game in progress already, there may be some logs or the like that you may have to wade through first. Once you've found the creature entry, you should recognize it by it looking similar to that screen shot. The slew of FFs in the hex view should help recognize it.
This isn't actually what we're looking for though! What we need is the creature's historical figure entry, which at least in all of my searches comes after the creature entry. So, hit the search next button again until you see an entry like this what's shown below. It will look a lot like the previous screen, but the entry is much shorter. You can tell because another dwarf's name will be shown shortly after the one you're looking for.
Congratulations, you've just found the historical figure entry for your first victim. There are a number of pointers in this structure that lead to lists of several things, but what we're interested in is the list of links to other historical figures. That is how the game keeps track of lovers, spouses, parents / children, deities, and supposedly apprentices in the latest version.
These are stored in an STL Vector. Or, the vector stores pointers to them anyway. The image below shows where you can find the pointer you need to trace, highlighted in the green box on the left. You can open several hex editor windows by hitting the Hex Editor button, which can be tremendously useful when chasing pointers. You can also jump to an address by hitting the button encircled by red below.
If you don't understand how I got that memory address from the highlighted value, I'll explain all of that in part two along with an explanation on how to actually change these things. Unfortunately, it's quite late here and this is taking longer than I expected, so I'll have to split that into part two. Coming tomorrow, I expect.
Stay tuned for part 2!Sorry for being a tease. I figured if I got this up tonight it would help keep me motivated to post the rest.