Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Is it possible to edit world.dat so I can edit the raws of angels?  (Read 2084 times)

Naptune

  • Bay Watcher
    • View Profile
Is it possible to edit world.dat so I can edit the raws of angels?
« on: September 15, 2019, 10:57:20 am »

Hello

Through a complicated process of conquering vaults and making adventurers, I have managed to make some angels members of my forts. They can do anything the dwarf civilization can, but my dreams of an angel-only fort is limited by the fact that the angels can't breed or migrate.

By uncompressing saves I was able to open up world.dat and read it, and I found the location of the angel's raws. I did a quick edit by adding in the phrase "did this work?" into the creature's description, but it seems that editing it causes the game to be unable to load anything from that world.

So is it possible to edit world.dat without it crashing the game? Or somehow edit the raws of angels another way?

Thanks
Logged

InsaneRationalist

  • Bay Watcher
    • View Profile
Re: Is it possible to edit world.dat so I can edit the raws of angels?
« Reply #1 on: September 17, 2019, 06:29:12 pm »

I was looking for somewhere to post this anyway, since it doesn't seem to be mentioned anywhere.

How to edit raws for forgotten beasts (and hopefully other generated creature definitions):

Make sure compressed saves are OFF in init/init.txt (obviously).

Open world.sav in a hex editor and search for the creature description.

The creature raws will be stored as a 32-bit COUNT, followed by COUNT number of LENGTH+STRING entries, where each entry is a 16-bit LENGTH, followed by LENGTH number of bytes, then the next entry. COUNTs and LENGTHs are both little-endian. Eg "A3 00 5B 44 45 53 ..." for a 163-byte DESCRIPTION tag. DESCRIPTION is likely to be the last tag, followed by the COUNT for the next creature (realisically, some nonzero byte followed by 3 zeroes, while LENGTHs are a nonzero byte followed by one zero). The first entry after the COUNT will be 000E "creature_layer" (or whatever's appropriate to your non-forgotten-beast definition).

If you change a entry, you need to update its LENGTH field to match the new number of bytes. No other changes seem to be needed. Eg, adding "did this work?" to the above DESCRIPTION would require 00A3 + 000E = 00B1 ("B1 00 5B 44 45 53 ...").

If you add or remove entries, you need to update COUNT plus or minus the net change in number of entries. You will also need to make sure any new entries have correct LENGTH fields. Again, no other changes seem to be needed; there's no checksums and the total length in bytes of generated raws doesn't seem to be stored.
« Last Edit: September 17, 2019, 06:30:44 pm by InsaneRationalist »
Logged
Dwarf Fortress: where an exploding unicorn death factory is a goal unto itself.
If it has cute cuddly features, it's probably safe to eat, so do not reason with it either.

Atkana

  • Bay Watcher
  • [CURIOUSBEAST]
    • View Profile
Re: Is it possible to edit world.dat so I can edit the raws of angels?
« Reply #2 on: September 20, 2019, 01:33:12 am »

Additionally, if you're familiar with dfhack (and ideally gui/gm-editor) you can use it to edit the raw entry from the angel while in game. From what I remember, the raws for generated creatures are saved whenever the game is, and loaded when the game is next loaded. I'm not sure to what extent you can edit them without causing problems (I imagine changing stuff like their whole body plan might cause issues, but I've never bothered to try :P).