v50 Steam/Premium information for editors
  • v50 information can now be added to pages in the main namespace. v0.47 information can still be found in the DF2014 namespace. See here for more details on the new versioning policy.
  • Use this page to report any issues related to the migration.
This notice may be cached—the current version can be found here.

Utility:DFHack

From Dwarf Fortress Wiki
Revision as of 07:12, 8 September 2023 by Myk002 (talk | contribs) (move bug warning up to the installation section)
Jump to navigation Jump to search
This utility page applies to multiple versions of DF.
DFHack
Dfhack-logo.png
Information
DFHack in-game help browser and command launcher

DFHack is a utility that can be used to improve UI, automate some aspects of the game, add features, fix bugs, make a specific one-off change... or just straight-up cheat - though DFHack's cheat (aka "Armok") tools can be hidden from the interface by enabling "mortal mode" in the DFHack control panel.

DFHack is an extensive standardized memory access library, packaged alongside a suite of basic tools that use it. Currently, tools come in the form of plugins, as well as Lua scripts. For developers and modders, DFHack is a comprehensive, standardized memory access package that unites the various ways tools access the Dwarf Fortress memory space, allowing for easier development of new tools and a vast expansion of capabilities for mods. For players, it is a very useful utility complex that allows tweaking DF in numerous ways. This is probably one of the most useful utilities for DF, acting as an advanced expansion that fixes, improves and adds to the game in many ways, and is recommended for all players.

On April 14, 2023, DFHack was additionally made available on Steam. Installing DFHack through Steam will add DFHack to an existing Steam installation of Dwarf Fortress.

Download and Install

All new releases are announced on Steam, in a thread on the Bay12 forums, on r/dwarffortress, and on the DFHack and Kitfox Discord servers. The current release can be downloaded from Steam or GitHub. You can also find all past releases on GitHub, and the latest dev build (requires GitHub login) can be downloaded from here, though its stability is not guaranteed.

Stable releases are also available for 0.47.05, 0.42.06, 0.40.24, 0.34.11, 0.31.25, and other intermediate versions of DF. DFHack is currently also being ported to versions 0.28.181.40d and 0.23.130.23a - more information can be found here and here, respectively.

For information about the commands in the utility, see the documentation. In particular, see the quickstart guide and the categorized tool index. Help for DFHack tools is also available in-game in the gui/launcher interface. For a quick list, with brief descriptions, of the commands available to you, enter the command tags to see tools by category or ls (or dir) to see the entire list. As of v50.08-r3, DFHack comes with more than 400 tools.

Bug reports

If you are using DFHack (or other utilities), do not report bugs on the Dwarf Fortress bug tracker unless you can prove that the bug is not being caused by DFHack or one of its plugins. DFHack can be temporarily disabled by passing the --disable-dfhack commandline option when you run Dwarf Fortress.exe.


Features

Screenshot of the DFHack "Move goods to Trade depot" screen, showing filtering and search options.

User Interface improvements, such as:

  • Search, sort, and filtering for screens with big lists.
  • Ability to designate placeholder buildings, furniture, and constructions that get automatically assigned building materials as they become available.
  • Ability to type characters not available on keyboards.

Automatic bugfixes, such as:

  • fix/stuck-instruments - Fix activity references on instruments whose previous player was interrupted to make them usable again.
  • fix/general-strike - Prevent dwarves from getting stuck and refusing to work.
  • orders sort - Sort manager orders by repeat frequency so one-time orders can be completed.
  • fix/empty-wheelbarrows - Empties wheelbarrows which have rocks stuck in them.

Fortress design tools, such as:

  • gui/design - Designate digging or constructions in shapes and lines
  • gui/quickfort- Designate digging, stockpiles, buildings, and/or zones from a blueprint. DFHack also comes with a library of blueprints.

Fortress management automation tools, such as:

  • autobutcher - Designates excess livestock for slaughter.
  • autochop - Designates trees for chopping when the fortress needs more logs.
  • autolabor - Automatically assign labors to dwarves to efficiently complete pending jobs
  • autonestbox - Assigns unpastured female egg-layers to nestbox zones.
  • prioritize - Ensures time-sensitive jobs get done quickly.
  • seedwatch - Controls settings for cooking seeds and plants so you don't run out of seeds to plant.
  • tailor - Generate manager workorders for clothing as existing clothing wears out.

Gameplay modifications, such as:

  • deteriorate - Cause corpses, clothes, and/or food to rot away over time.
  • dwarfvet - Allow animals to be treated at hospitals.
  • emigration - Allow unhappy dwarves to voluntarily leave the fortress
  • misery - Amplify negative thoughts.
  • starvingdead - Undead waste away over time.

Other scripts and plugins, such as:

Common use

Command Description
prospect To prospect your embark location for a list of all the present minerals and plants.
digv Designates a whole vein for digging.
reveal Reveal the map so you can inspect the caverns and mineral layouts.
cleanowned scattered x Collects the random junk dwarves fling about the fortress and marks it for dumping.
exportlegends For exporting Legends mode information.

Scripts and Plugins

Originally a simple memory hacking tool, DFHack has grown to become a full-fledged unofficial extension of the game itself, adding in functionality where official development has lacked. One of the best features of DFHack is its extensibility - anyone can create scripts or plugins. Due to its open-source and collaborative nature, anyone can add their own contribution to this tool. There are different kinds of contributions:

  • Binpatches are raw memory edits that alter the game's behavior, which is usually deduced from disassembling. Their main use is bugfixing or the removal of cumbersome, easily alterable constraints.
  • Plugins are snippets of C++ code that uses DFHack's library to fix bugs or add functionality. They must be compiled before use and are thus platform and dfhack-version dependent, but as a result they tend to be extremely fast. They can be found in the hack/plugins folder.
  • Scripts are files written in a scripting language DFHack provides bindings for (usually Lua or Ruby) that when loaded by DFHack fix bugs or add functionality. Contrary to plugins, they are not compiled and can be transferred between any platform. However any change within the DFHack data structures (i.e. between versions) may break some of these scripts. However, because they run in an interpreter they are unsuitable for tasks which involve large amounts of data (such as revealing the map).

Some of the more notable are listed below; feel free to add to the list.

User Interface

The best-known are Falconne's UI Plugins, a collection which improves the in-game interface with features such as search functions in screens with big lists, the ability to place furniture before it's built and have it automatically allocated when available, box-select constructions(like laying designations) - including easier material selection and open space placement, easier pasturing, live happiness monitor, mouse support, and an enhanced stocks screen. The plugins make existing tasks significantly easier, and also add new functions to the game which greatly enhance the experience - such as the autochop log quotas, or the ability (with buildingplanner) to lay out rooms with Quickfort before creating the required furniture.

There is also a GUI for the Autobutcher plugin.

Bugfixing

Many bugfixes are included with DFHack, but not enabled by default - check dfhack.init to see if the "tweak *" and "fix/*" lines are commented out. The Starter Packs enable all bugfixes by default.

Features

These plugins and scripts add features to the game that enhance the user's gameplay.

  • Digging invaders, a plugin that allows hostiles to dig and deconstruct walls to path to one's fortress.
  • Rendermax, a plugin that implements a lighting system at the graphics level.
  • Dwarven Emigration, a plugin that allows unhappy dwarves to emigrate with their families.

Modding tools

These plugins and scripts add features to the game that enhance modding possibilities.

remotefortressreader

Provides a protobuf-based (currently v2.4.1) RPC connection to the game, enabling remote clients like Armok Vision. The service listens on 127.0.0.1:5000 (configurable within dfhack-config/remote-server.json).

Currently there are no change-based or change-driven notifications, so remote fortress clients must perform the expensive operation of polling the desired volume every frame (via e.g. GetBlockList). Additionally, the sidebar menu state is shared with the native view, to avoid reimplementing construction material dependencies.