DFHack / dfhack

Memory hacking library for Dwarf Fortress and a set of tools that use it
Other
1.88k stars 476 forks source link

scripts/rejuvenate.lua Forcing babies can leave them wandering, dependent on others for food and water #1573

Open Koumajutsu opened 4 years ago

Koumajutsu commented 4 years ago

Babies specifically now have a special mood set (8) that causes them to behave like a baby Forcing them to 20 years old, but not clearing their mood to -1 causes them to starve and dehydrate, and not perform any tasks.

I fixed this in my personal copy by adding the following lines after changing profession:

    if unit.mood == 8 then
        unit.mood = -1
    end

I tried using df.MoodType enums, but I guess I got the syntax wrong

I additionally checked and changed unit.profession2 for housekeeping purposes

lethosor commented 4 years ago

It should be df.mood_type.Baby going by the enum definition (i.e. not MoodType). It's actually 8 years old, so the script has probably just been broken in this case the whole time. Thanks for the fix!

Koumajutsu commented 4 years ago

Ahh, ok. the only place I found an enumeration defining Baby as 8, was in ruby-autogen-win.rb which names the enum "MoodType", and all of the other enums defined there appeared to match the naming syntax used in the lua scripts, so I foolishly made the assumption that it was correct

lethosor commented 4 years ago

Ruby actually changes the case of quite a lot of names from snake_case to camelCase - I'm not sure how much of that is necessary and how much is for the sake of being consistent with other Ruby code. I would suggest looking at gui/gm-editor in the future - it will give you the type name of an enum if you try to edit an enum field.