DFHack / dfhack

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

hasty burial leaves corpses sitting outside of coffins #3609

Open ab9rf opened 1 year ago

ab9rf commented 1 year ago

When a tomb is designated based on a buildingplan blueprint and the corpse is buried before the coffin is built, the corpse ends up sitting "outside" the coffin instead of inside it: image

A solution would be to periodically scan the map (actually it would be better to scan either the all-buildings or a categorized one for tombs, if there is one) for tombs which have a coffin item in a position other than the first of the building's contents, and if found reorder the building's contents vector to put the coffin item in the first position. There may be other approaches that would work as well or better.

myk002 commented 1 year ago

is this due to something dfhack/buildingplan is doing, or can this happen in vanilla as well? e.g. if you build a coffin in a tomb with the vanilla UI but your dwarves are too busy to actually build the coffin and a dwarf gets "buried" first.

ab9rf commented 1 year ago

is this due to something dfhack/buildingplan is doing, or can this happen in vanilla as well? e.g. if you build a coffin in a tomb with the vanilla UI but your dwarves are too busy to actually build the coffin and a dwarf gets "buried" first.

this may be possible in vanilla, i haven't tried it. i don't think the game will attempt to bury a corpse in a tomb zone that doesn't contain a coffin. the issue is that buildingplan puts a "phantom" building on the map while it's waiting for the building materials to become available, and the base game is getting confused by the phantom item, thinking it's a real coffin

myk002 commented 1 year ago

The phantom building is a real coffin, though. Unless material assignment matters, it should be exactly the same as a vanilla placed coffin that was suspended before being built.

Regardless, the solution you propose sounds like a good one. We'd have to wait until the building construction stage is the max stage. What would be nice is if DF did that check before creating the entomb job

ae3qe27u commented 1 year ago

Just to chime in and confirm that this seems to be able to happen in vanilla. I have a tomb with a dwarf's hand just kinda hanging out on top of the coffin.

ab9rf commented 8 months ago

this is probably a specific case of the general problem that arises in vanilla DF if a zone is designated while it has pending constructions. in addition to the "hasty burial" issue in this issue, this also leads to dwarfs loops putting clothing away in the cabinet in their bedroom, only to have the item end up outside the cabinet, resulting in them putting it away again, ad nauseum. the misbehavior can be rectified by either removing and reconstructing the furnishing, or by removing and redesignating the civzone

so the solution here is to identify where DF goes "wrong" when a pending furniture construction within a civzone is completed (which is bugged) versus designating a civzone over completed furniture (not bugged) or designating a furniture construction in an already existing civzone (not bugged). one of these code paths is not like the others...