Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Memory Structure For Dwarfs.  (Read 1150 times)

UberJumper

  • Escaped Lunatic
    • View Profile
Memory Structure For Dwarfs.
« on: September 14, 2008, 03:16:24 pm »

Hi,

I've been looking at the memory structure of DF, for awhile now. I've read everything that i can find on, the wiki. I'm more or less interested in the actual dwarfs, and their memory locations.

(This is done with 40d, and most of the starting memory locations i borrowed from tweak, and dwarf foreman)

Okay, so i grabbed the Dwarf ID using the offset for the selected dwarf. Then i did a search for a 4byte long, matching that. I got too many results. Managed to narrow it down by looking at the structure listed here:

http://www.dwarffortresswiki.net/index.php/Memory_hacking/v0.27.169.33c#394_Structure

Except, from what i can tell the memory structure guide is horribly outdated. So is there a more recent version of something similar?

Logged

Exponent

  • Bay Watcher
    • View Profile
Re: Memory Structure For Dwarfs.
« Reply #1 on: September 14, 2008, 05:23:24 pm »

I'm not aware of anything more up-to-date.  I was trying to figure stuff out too, not too long ago.  I didn't determine much, but in case it helps, here is what I found:

The location of a creature is made of 3 16-bit integers, x, y, and z.  I would search for creatures by looking for the appropriate 6-byte string, letting the game run long enough for the creature to move a tile, and then do a subsearch for the new location.  Then, I discovered that if you take the address for the x coordinate and add 696 bytes, you get the address for a 32-bit bitfield.  The second bit (value 2) of this field indicates consciousness.  If this bit is set, then the creature is unconscious; otherwise it is awake and all.

I used this information to teleport a gremlin onto a cage trap and knock it unconscious so that it would get caged.  Hopefully it can help you out a wee bit as well.
Logged

Jifodus

  • Bay Watcher
  • Resident Lurker
    • View Profile
    • Dwarf Fortress Projects
Re: Memory Structure For Dwarfs.
« Reply #2 on: September 15, 2008, 01:44:25 am »

Dwarf Companion in creature.py would have the most complete (and probably most upto date), creature structure layout.
Logged

bartavelle

  • Bay Watcher
  • Coin coin!
    • View Profile
Re: Memory Structure For Dwarfs.
« Reply #3 on: September 15, 2008, 03:22:28 am »

Yeah I try to keep it updated, but some offsets I never use (such as the master id for pets) might be outdated. If you look at the python code in the other files, you'll see that I documented some structures, such as part of the inventory.

BTW you will see here that the quality of artifacts is 5, just the same as "masterpiece". Artifact weapons are likely to be just as powerful as masterpiece ones :(
Logged