Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Dwarf Therapist like interface?  (Read 1550 times)

Spqrein

  • Escaped Lunatic
    • View Profile
Dwarf Therapist like interface?
« on: March 18, 2015, 02:20:34 pm »

Interface might be the wrong word but how does it do what it does?  Is there a basic guide or program to use to create something like it.  I am no master at programming but like to try some things out.  If its ends up above my skill lvl then that's ok too, just work on more little thing to cause fun in my fort.
Logged

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: Dwarf Therapist like interface?
« Reply #1 on: March 20, 2015, 07:56:42 am »

Write splinterz. He knows. ;)
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::

i2amroy

  • Bay Watcher
  • Cats, ruling the world one dwarf at a time
    • View Profile
Re: Dwarf Therapist like interface?
« Reply #2 on: March 24, 2015, 01:40:22 am »

IIRC it's a fair bit of hex code reading/changing from the live DF program (which is why you need the new data entry locations with each new version of DF released).
Logged
Quote from: PTTG
It would be brutally difficult and probably won't work. In other words, it's absolutely dwarven!
Cataclysm: Dark Days Ahead - A fun zombie survival rougelike that I'm dev-ing for.

orbcontrolled

  • Bay Watcher
    • View Profile
Re: Dwarf Therapist like interface?
« Reply #3 on: March 26, 2015, 01:46:58 am »

With Dwarf Fortress, if it isn't in the raws, then there is no official way to change it. Because of this, advanced utilities like Therapist have to basically resort to various hacking techniques to edit the program's memory while its running (similar to how CheatEngine works), and sometimes even inject their own code. Surprisingly, Google brings up no informative results for the phrase "memory hacking", but if you're interested in the general principle, then This search seems to be as good a place as any to start, as well as this stackoverflow thread, which links to a guide.

But learning how to do it from scratch is not strictly necessary, because we have DFHack, which was created as a one-stop-shop for everything related to manipulating the game's memory (It was a huge leap forward from the days when every single 3rd party utility had to roll its own memory hacking code, which made for high barriers to entry and terrible compatibility/reliability problems). DFHack does the memory manipulation for you and more or less provides you a standard API for interfacing with dwarf fortress.
Writing scripts for DFHack is relatively straightforward if you just want to start building something, but the code is also on github if you were more interested in how the whole process works under the hood, or in trying to replicate it for your own education.
Logged

ragundo

  • Bay Watcher
    • View Profile
Re: Dwarf Therapist like interface?
« Reply #4 on: March 27, 2015, 11:49:47 am »

Well, Dwarf Therapist is written in C++ and uses the Qt framework for the user interface in order to be platform independent (Linux, MacOs and Windows).

Dwarf Therapist access directly the memory of the Dwarf Fortress process for getting/setting the data it needs.

DFHack is a middleman between DF and the community developed plugins. These plugins can be written in lua, ruby or C++.

Also, and this is important, is possible to access to DFHack/DF via RPC (Remote Procedure Calls). In this mode, you can send commands to DFHack and it will execute / get data from DF. 

If you want to do a user interface similar to DwarfTherapist, the best way I think is to use Qt with the appropiate bindings (native C++ or PyQt for python) and RPC for connecting to DFHack/DF. There's already one project for using DF with the Iphone that uses a native MacOs GUI and connect via RPC to DF.

I'm doing something similar in order to provide a copy of all Dwarf Fortress data structures available via RPC, so you can build, for example, a Dwarf Fortress external companion window that shows additional data that the game don't show.



If you decide to use the DFHack way, visit DFhack github project page or go to the IRC #dfhack channel on Freenode where all your questions/doubts will be answered.

Greetings
« Last Edit: March 28, 2015, 04:57:38 am by ragundo »
Logged

Spqrein

  • Escaped Lunatic
    • View Profile
Re: Dwarf Therapist like interface?
« Reply #5 on: March 29, 2015, 07:54:14 am »

I will have to go to the dfhack page, never thought of that at first.  Starting to look over my head but the few little things I want to try might or might not be that hard.  No plans on anything massive.  Before I start I am going to search the forums more my guess someone already did something like what I want. 

Thanks for the help.
Logged