Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Assigning pets!  (Read 3381 times)

Jazz Cat

  • Bay Watcher
  • Adept stringed instrumentalist
    • View Profile
Assigning pets!
« on: February 03, 2019, 06:34:53 pm »

I couldn't find a tool for this, so I made one myself. It's a small DFHack script that allows you to manually assign an animal to a dwarf as a pet, instead of hoping the dwarf has the right preferences and happens to bump into the animal at the right time.

Spoiler: adopt.lua (click to show/hide)

To use the script, save the above text in you /hack/scripts director as "adopt.lua" and run it from the DFHack terminal.

The script is still in the very early stages at the moment, so the only thing it does is assigns the animal as a pet and gives it a name. When dwarves adopt pets on their own, the pet becomes a historical figure (and probably a bunch of other stuff happens), but I haven't figured out how to make that happen yet.
Logged
Give your dwarves a pet
My holiday mod (only offensive to elves)
The check-laundry script

Quote
Just give the Crossbow weapon the [AMMO:CROSSBOW] tag in the raws. You can make a crossbow that shoots crossbows.

strainer

  • Bay Watcher
  • Goatherd
    • View Profile
Re: Assigning pets!
« Reply #1 on: February 03, 2019, 10:50:13 pm »

Nice idea - better than assigning a work animal, when you don't really want it to work.

I see Meph made a create-unit script which seems to set up historic figure data. There is also this mysteriously named thing called a "Nemesis record" which is just an extra record that links the unit id and the historical figure id. Its all a bit chaotic but might be possible to copy most from Mephs script.

There is a table in the figure details called something like, figure->histfig_links
which holds histfig_ids of units relations like mother, father, lover... prisoner.. etc and in particular "PET_OWNER"

A lua syntax for it might be something like: pets_hfig.histfig_links["PET_OWNER"].target_hf = (hf_id of pets owner)
Logged
Klok the Kloker !

Jazz Cat

  • Bay Watcher
  • Adept stringed instrumentalist
    • View Profile
Re: Assigning pets!
« Reply #2 on: February 04, 2019, 01:18:08 pm »

Yeah, a lot of the work in this script is "distilled" from Meph's. By the time I got to the historical-figure data my brain was too fried to try to make it work at the time.
Logged
Give your dwarves a pet
My holiday mod (only offensive to elves)
The check-laundry script

Quote
Just give the Crossbow weapon the [AMMO:CROSSBOW] tag in the raws. You can make a crossbow that shoots crossbows.