- 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.
Utility:DFHack
This utility page applies to multiple versions of DF. |
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 and Ruby scripts. For developers, 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. For users, it is a very useful utility complex that allows users to tweak their games in numerous ways in-game. 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 usually included in recent versions of the Lazy Newb Pack on all platforms.
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. On Linux and OS X, DFHack can be bypassed by running the "df" script. On Windows, DFHack can be temporarily disabled by renaming SDL.dll to a temporary name, then renaming SDLreal.dll to SDL.dll.
All new releases are announced in a thread on the Bay12 forums. 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 an exhaustive list of and manual on the commands in the utility, see the GitHub documentation. This wiki also has a DFHack programming page.
Installation
DFHack works on Windows XP, Vista, 7, any modern Linux distribution, and OS X 10.6 and later. On Windows, you have to use the SDL version of DF. Currently, version 0.34.11 is supported (and tested). If you need DFHack for older versions, look for older releases. If you wish to use modern DFHack versions on old DF releases, 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.
Pre-bundled packages
If you use a recent edition of the Lazy Newb Pack or a similar starter pack, DFHack should be already installed and configured for you; simply run Dwarf Fortress as usual. Note that every DF update will break existing DFHack versions; if a DF release is very recent, the DFHack team may not have had the time to update it to the latest DF version, and the latest starter packs may not include it.
If you wish to install DFHack by hand without downloading a whole starter pack, head over to the main thread and read the following instructions depending on your operating system.
Windows
- Get the archive meant for your system. Extract the contents into your DF folder. Be sure to erase the SDL.dll file with the downloaded one, as it's used by DFHack to operate its magic.
- You're ready to use DFHack. Simply run Dwarf Fortress.exe and you should see a separate command-line prompt window.
OS X
- Get the archive meant for your system. Extract the contents into your DF folder.
- Run 'dfhack' in a terminal. Dwarf Fortress should start and the terminal be taken over and turned into a DFHack prompt.
Linux
- Get the archive meant for your system and your current gcc version. If you're not sure, try the latest version first (4.9.2 as of September 2014) before trying downgraded versions.
- Run 'dfhack' in a terminal. Dwarf Fortress should start and the terminal be taken over and turned into a DFHack prompt.
FreeBSD
No binaries available, sorry. Be sure to update the wiki if you can build it from source.
Source
The source is available on github. There are two main branches: master (stable, only updated when ready for release) and develop (unstable, has all the new features first). Occasionally, contributors will add new updates on their own bleeding-edge branches. By default, all releases are compiled from the stable branch; if you wish to use a branch with more experimental features, you will have to build them from source. Building instructions are available for Windows, Linux and OS X. On Linux, please note that you will need the zlib1g-dev package and multiple 32-bit libraries.
Uninstallation
- Remove 'stonesense' and 'hack' folders from your DF folder.
- On Windows, remove SDL.dll and rename SDLreal.dll to SDL.dll
- On Linux, remove the dfhack and dfhack-run scripts, and the dfhack-init file.
Common Uses
DFHack is often used to automate some aspects of the game, add features, fix bugs, or to make a specific one-off change.
Automation
See: workflow, autolabor, autobutcher, autochop, autonestbox, seedwatch, df-ai, dwarf manipulator.
One-off changes
Includes commands like "cleanowned scattered x" or "reveal".
Additional features
Steam engines, power meter, improved siege engines.
Stonesense
DFHack comes with Stonesense by default (except for unofficial r4 builds).
Isoworld
DFHack also has Isoworld integration.
Adventure mode
See: advfort, companion-order.
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 it's 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. 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.
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.
Cheating
These plugins and scripts allow cheating to various degrees. Some are covered more in-depth than the Readme on this wiki:
- createitem: Creates arbitrary items made of any material at the feet of a unit