DFHack / dfhack

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

Feature Request: Tool to teleport the Embark Wagon and it’s contents. #3366

Open A-CuriousCat opened 1 year ago

A-CuriousCat commented 1 year ago

Please add a tool to allow the user to teleport the Embark Wagon and it’s contents to a chosen cursor location. Myk says that the code can be refactored from deep-embark.

myk002 commented 1 year ago

actually, looking at deep-embark, maybe this problem isn't as solved as I thought it was. deep-embark actually teleports all the wagon contents and scatters them around the target position, and then removes the wagon itself. it does not move the wagon building. perhaps it is more complicated than I thought it was to move a building safely.

A-CuriousCat commented 1 year ago

actually, looking at deep-embark, maybe this problem isn't as solved as I thought it was. deep-embark actually teleports all the wagon contents and scatters them around the target position, and then removes the wagon itself. it does not move the wagon building. perhaps it is more complicated than I thought it was to move a building safely.

Did you see my conversation with Rumrusher and Bumber, starting here?

myk002 commented 1 year ago

yeah, that's certainly a start. Plus fixing occupancy flags (that is, the tiles need to have their "I have a building" and "you can walk/build here" flags set properly). I'm just very suspicious that if it were this easy, then deep-embark would have done it already.

A-CuriousCat commented 1 year ago

Why not ask the person who wrote deep-embark?

Edit:

I just tried looking and I can’t find the file in the DFHack repository that deep-embark is defined in. I also tried searching the DF forums, but I couldn’t find any references to it (other than your post) in the first page of search results (and the remaining 33 pages all just said that no results could be found…).

myk002 commented 1 year ago

Scripts are in a separate repository: https://github.com/DFHack/scripts/blob/master/deep-embark.lua

The primary author is @AtomicChicken

AtomicChicken commented 1 year ago

Thanks @A-CuriousCat for bringing this to my attention (I haven't been very active on GitHub lately). Looking back, I believe I had experimented with moving the wagon directly, but ultimately decided to move the wagon contents instead so as to accommodate for the rare case of cramped caverns lacking a large enough area (3x3 walkable tiles) to fit the wagon into, and more so as it was my (subjective) opinion that properly implementing underground wagon "embarks" logically necessitates the verification of a wagon-accessible path between the target location and the edge of the cavern map. Checking for the existence of such a path would significantly complicate the code, markedly prolong the script execution time, and occasionally result in failure due to no such path being available. Scattering the wagon contents allowed for increased flexibility and simplicity, and I may have also found the visual result appealing, drawing parallels to the campsites of underground animal people tribes.

I don't explicitly remember whether I encountered any problems of note when moving the wagon building directly. As has been pointed out previously, the code by Rumrusher referenced above is certainly incomplete without properly updating the relevant tile flags.

A-CuriousCat commented 1 year ago

Thanks, @AtomicChicken! So, considering that my initial idea was for the script to "magically" teleport the embark wagon from one place to another (with making sure that there's enough room for it at it's destination being left up to the user), it looks like @Rumrusher's solution should work (with the inclusion of the aforementioned polishing, of course). Though it does make me wonder if the script should at least check the 3x3 area around the destination to make sure that the wagon can be placed there and abort with an error message if it can't. Another question is what should happen if the user tries to teleport the wagon to a destination that hasn't been revealed yet. Should the script work as usual, or should it always refuse such an attempt at teleportation into the unknown? Anyways, I think I'll see what @myk002 has to say, now that you've chimed in...

myk002 commented 1 year ago

I think this is entirely feasible, and should probably be implemented as a generic building teleporter. Moving a wagon should be no different from moving a trade depot or a workshop. And whereas deep-embark is a gameplay mod that is not moving the wagon because of the artistic vision of the author, we can implement this as a plain old Armok tool.

It wouldn't even be that hard to support area select and move entire groups of buildings. It's simple to copy the layout with blueprint and the suitability of the target location can be checked with quickfort, then instead of creating new buildings, we'd just move the existing ones.

ab9rf commented 1 year ago

moving a building with machine components (such as a screw pump or axle or the like) requires additional processing and should probably be excluded, at least initially

also be careful about moving building in or out of a civzone

A-CuriousCat commented 1 year ago

I think this is entirely feasible, and should probably be implemented as a generic building teleporter. Moving a wagon should be no different from moving a trade depot or a workshop.

Ok. I agree that it’d be better as a generic building teleporter. Btw, what happens if you teleport a building that a zone was created from?

myk002 commented 1 year ago

In v50, that no longer happens. Zones are no longer created from buildings. They'd have to be moved separately.

Perhaps what we need here is a commandline tool that moves a single thing -- building, zone, or stockpile -- with a GUI layer that supports area select.