Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: [memory hacking] Identifying your own dwarves  (Read 768 times)

sphr

  • Bay Watcher
    • View Profile
[memory hacking] Identifying your own dwarves
« on: December 09, 2007, 04:50:00 am »

Background:
The creature race in creature structure (offset 0x008C in 33b) is used to identify the race of the creature.  0xA6 (unmodded) identifies a dwarf.

Problem:
When retrieving all dwarves with the race, it actually includes dwarves that do not belong to your settlement (e.g. merchants/guards).

1) Was wondering if there is another way to tell these entities apart from the other races?

2) Also, how can one distinguish the Child and babies?

3) How can one retrieve the last name and the active profession?

Erasmus Darwin

  • Bay Watcher
    • View Profile
Re: [memory hacking] Identifying your own dwarves
« Reply #1 on: December 09, 2007, 07:36:00 pm »

quote:
Originally posted by sphr:
<STRONG>1) Was wondering if there is another way to tell these entities apart from the other races?</STRONG>

I don't know the exact solution, but it seems like the 0xE4 creature flags might be used for this.

quote:
<STRONG>2) Also, how can one distinguish the Child and babies?</STRONG>

I think they've got separate professions.  If you look in raw\graphics\graphics_example.txt, it lists all the profession tokens.  Two of the last tokens are CHILD and BABY.

quote:
<STRONG>3) How can one retrieve the last name and the active profession?</STRONG>

For the profession, I suspect that's what's referred to as "Type ID" / "Dwarf Type" in the memory hacking table.  It's at offset 0x8A in the creature data.

In the 2D version, last name was encoded in 4 contiguous fields in the creature data, not too far from the first name and nickname fields.  The fields were word 1 index, word 1 subtype, word 2 index, and word 2 subtype, in that order.  I forget the exact sizes of the fields, but the word index was probably a short or a long, and the subtype was almost certainly just a single byte.

Anyway, the index value corresponded to the position of the "WORD:" tag in raw\objects\language_words.txt.  The subindex referred to the specific part of speech for that word.  0 and 1 referred to the two NOUN values, 2 was ADJ, 3 was PREFIX, and 4-8 were the VERB values.  Not every word had every defined part of speech.

I wrote a simple surname decoder for 23a -- it doesn't do any looking into the process memory.  It just reads the words out of the raw directory and decodes whatever values you feed to it.  But it might help for getting an idea of how things are set up:  http://angband.org/~erasmus/df/surname.c

Logged

sphr

  • Bay Watcher
    • View Profile
Re: [memory hacking] Identifying your own dwarves
« Reply #2 on: December 10, 2007, 03:01:00 am »

thanks for the info.  I'll try to combine that with whatever is new on the wiki and try to investigate further.

bartavelle

  • Bay Watcher
  • Coin coin!
    • View Profile
Re: [memory hacking] Identifying your own dwarves
« Reply #3 on: December 10, 2007, 07:17:00 am »

1 : i'm pretty sure it's related with the flags at e4 & e8.
2 : 0x204 & 0x208 seem related to the message "has grown up to become a", but no further clue. It's quite likely it's related to the profession id has stated previously.
3 : for the name i updated the table for .33c, look at offset 0x38 for the creature table. That way you won't have to parse a text file ...

[ December 10, 2007: Message edited by: bartavelle ]

Logged