DFHack / dfhack

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

"Emergency mode" plugin? #2343

Open Tachytaenius opened 1 year ago

Tachytaenius commented 1 year ago

Forces your units to always run while it's on. Or maybe select units saved with persist-table, though I don't know if that is exposed to C++. I guess it could be a script anyway.

lethosor commented 1 year ago

Could you elaborate? What does it mean for a unit to "always run"?

C++ has a separate persistence API, which persist-table uses internally. persist-table is more dynamic than a typical C++ API.

Tachytaenius commented 1 year ago

"Always run" as in, up their speed. Sprint to construct the wall blocking off the horde or whatever. And by "your units" I meant your citizens.

lethosor commented 1 year ago

Oh, so like fastdwarf but with more control over the speed?

Tachytaenius commented 1 year ago

You could say that, but I don't think there's any vanilla-appropriate way to make them work faster like there is for moving faster. Moving faster on demand is a feature that already exists in adventure mode and should do in fortress mode.

myk002 commented 1 year ago

it might be a good addition to the siren script. Like the hand of the overseer slapping an imp in Dungeon Keeper : )

negative thoughts included.

Tachytaenius commented 1 year ago

Oh that would be cool, yeah. How about we make this script/plugin and then get siren to invoke it?

myk002 commented 1 year ago

why not write it as part of the siren script? I'm not sure if we need another top-level script name to add to our list. I'd like to start consolidating functionality into fewer scripts with more features each.

Tachytaenius commented 1 year ago

Can we at least expose it from siren for custom scripts? I feel like I would want to use emergency running mode without siren but can see why more top level scripts would be a problem.

myk002 commented 1 year ago

Absolutely. Any script can provide an API. I suppose there's a case for putting the code in modtools/ too and siren calling it.

As a side note, I'm not really a fan of modtools scripts being callable as commands. I feel they should just be APIs in library/lua/modtools/ (but I might not be fully aware of the use cases that drive the design of the current system)

Tachytaenius commented 1 year ago

Totally agree on modtools being better off as an API. What is the method for defining and using an API in a script that can also be called?

myk002 commented 1 year ago

You just define a global function and exit the script before running anything by checking if the script was loaded as a module. See for example quickfort.lua (with API docs at https://docs.dfhack.org/en/stable/docs/tools/quickfort.html#api)

edit: Until I merge it, here's a version of quickfort.lua that doesn't have so much distracting leftover doc text in it: https://github.com/DFHack/scripts/blob/c798f6f2d7922fd40a88325688f8a28ae98d0859/quickfort.lua

lethosor commented 1 year ago

You could say that, but I don't think there's any vanilla-appropriate way to make them work faster like there is for moving faster. Moving faster on demand is a feature that already exists in adventure mode and should do in fortress mode.

"vanilla-appropriate" is heavily dependent on the player. I would personally classify any speedups as cheaty, aside from maybe timestream.

If the goal is to make units do some things faster (e.g. movement but not jobs), I think that still fits under fastdwarf better than under siren. If some fastdwarf logic is moving to an API, that could enable siren to use it.

Tachytaenius commented 1 year ago

Oh, I was assuming I would be able to set the running speed somewhere like what is set in adventure mode, which would not use the fastdwarf API, but rather would let the game tire out the units from sprinting and make them sweat etc. Now that I think about it though it could get unset back to walking between my setting it and the unit actually making a move action...