Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Editing hard-coded stuff, things outside the raws.  (Read 1503 times)

Tyxaar

  • Bay Watcher
  • Skilled artist, adequate modder, great Necromancer
    • View Profile
Editing hard-coded stuff, things outside the raws.
« on: July 03, 2022, 06:26:04 am »

Hey, I've done some modding over the years, but the one thing I've never been able to figure out is how to edit things outside the raws. For example, something like making vampires behave differently, adding new structures, and such. Anyone know how to do this?
Logged
Heyo! I'm Tyxaar, I go by she/her, and I'm an Australian digital artist.
I enjoy modding, games, art, TTRPGs, and other various nerdy stuff.

Dirtcopter77

  • Bay Watcher
    • View Profile
Re: Editing hard-coded stuff, things outside the raws.
« Reply #1 on: July 03, 2022, 04:57:26 pm »

There is no way to edit things outside the raws, at least without decompiling the .exe and modifying the source code directly (which takes a lot more technical and programming know-how than raw editing, obviously). From my interpretation of the copyright info in the readme, however, distributing a modified version of the game binary (even not for profit) would be a copyright violation. I cannot stress this enough, do not distribute a modified Dwarf Fortress.exe.

If you go down this route you might be able to distribute the final product as an xdelta patch, which is a common way for fan translation projects to avoid the legal issues of distributing modded binaries-- they're essentially a file that contains only the difference between two binaries and can be used to patch one into the other. Don't take this as advice, though. I wouldn't expect Toady to approve of such a project since he seems (justifiably) defensive of the source code and hasn't given the go-ahead to any similar projects as they've been discussed over the years, at least to my knowledge.
Logged

Tyxaar

  • Bay Watcher
  • Skilled artist, adequate modder, great Necromancer
    • View Profile
Re: Editing hard-coded stuff, things outside the raws.
« Reply #2 on: July 03, 2022, 08:24:42 pm »

Alright, yeah. Note that I play on linux, so it might behave a bit differently, but I suspect only superficially. I've tried dnSpy-ing the different elements, but they're incompatible as DF isn't a compatible program lol. (I'm a Rain World modder, so dnSpy was my first attempt. I bet I can find a different tool.)
From what I understand, I can modify it and share it, but just not reveal any of the source code publicly. From what I understand things like Masterwork, dfhack, and other mods that modify more than just the raws are allowed. I know how to decompile stuff, but I'm still not sure on how to implement patches to the game, as I've only done so via mod launchers, the Steam Workshop, and other tools that do the technical stuff automatically.
Logged
Heyo! I'm Tyxaar, I go by she/her, and I'm an Australian digital artist.
I enjoy modding, games, art, TTRPGs, and other various nerdy stuff.

Ziusudra

  • Bay Watcher
    • View Profile
Re: Editing hard-coded stuff, things outside the raws.
« Reply #3 on: July 03, 2022, 09:49:38 pm »

DFHack is the main way, I think Sparking!!! uses it to do things that aren't possible with just raw modding.
Logged
Ironblood didn't use an axe because he needed it. He used it to be kind. And right now he wasn't being kind.

Tyxaar

  • Bay Watcher
  • Skilled artist, adequate modder, great Necromancer
    • View Profile
Re: Editing hard-coded stuff, things outside the raws.
« Reply #4 on: July 03, 2022, 11:13:41 pm »

I mean HOW does DFhack do it??? Also, will check out that mod. :)
I wanna figure out how to do non-raw modding without using DFhack as a proxy.
Logged
Heyo! I'm Tyxaar, I go by she/her, and I'm an Australian digital artist.
I enjoy modding, games, art, TTRPGs, and other various nerdy stuff.

Ziusudra

  • Bay Watcher
    • View Profile
Re: Editing hard-coded stuff, things outside the raws.
« Reply #5 on: July 03, 2022, 11:40:27 pm »

That is a pretty complicated process that is frankly beyond my ability to explain and varies depending on the OS - DFHack is a "Dwarf Fortress memory access library" that has taken years to develop to the point it's at. It's not a proxy, but rather a tool to achieve what you want. And if you really want to know how it works, it's open source.
Logged
Ironblood didn't use an axe because he needed it. He used it to be kind. And right now he wasn't being kind.

Tyxaar

  • Bay Watcher
  • Skilled artist, adequate modder, great Necromancer
    • View Profile
Re: Editing hard-coded stuff, things outside the raws.
« Reply #6 on: July 04, 2022, 12:16:31 am »

Yeeeeeah I might mess around with the editing stuff via DFhack then. I'll see what I can get done with raws before dipping into that. You know of any threads that give a basic overview of using dfhack in modding? I want to make a playable cannibal race lol.
Logged
Heyo! I'm Tyxaar, I go by she/her, and I'm an Australian digital artist.
I enjoy modding, games, art, TTRPGs, and other various nerdy stuff.

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: Editing hard-coded stuff, things outside the raws.
« Reply #7 on: July 04, 2022, 06:54:15 pm »

I think DFHack might actually have a built-in thing for that.

And, like, I've done some non-dfhack modding outside of the raws. It involved editing assembly. It's part of how I identified the slowdown earlier.

I mean HOW does DFhack do it???

By editing the game's memory at runtime, like cheat engine. You can do essentially arbitrary behavior this way, as long as you're willing to check as often as possible.

I wanna figure out how to do non-raw modding without using DFhack as a proxy.
You can do this by patching the binary. You will not be able to do this. This isn't a statement of no confidence in you; it's just not feasible in general, for most programs of sufficient complexity. Occasionally there's a small thing you can tweak here and there, odd behaviors that might be changeable via changing a byte or two in the .exe, but for the most part behaviors such as those listed are too all over the place to be doable.

Also, I made Sparking, and yeah, it adds new features by using DFHack and just pre-empting every single attack with my own code.

Tyxaar

  • Bay Watcher
  • Skilled artist, adequate modder, great Necromancer
    • View Profile
Re: Editing hard-coded stuff, things outside the raws.
« Reply #8 on: July 05, 2022, 07:32:44 am »

Ah right, thanks. :)
Also, well done! This probably isn't the place to ask, but what method did you use to run dfhack commands/scripts on a trigger? I'm only familiar with raw modding, so some tips would be nice. (Send me a link if this is explained in detail elsewhere lol.)
Logged
Heyo! I'm Tyxaar, I go by she/her, and I'm an Australian digital artist.
I enjoy modding, games, art, TTRPGs, and other various nerdy stuff.

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: Editing hard-coded stuff, things outside the raws.
« Reply #9 on: July 05, 2022, 12:43:55 pm »

Ah right, thanks. :)
Also, well done! This probably isn't the place to ask, but what method did you use to run dfhack commands/scripts on a trigger? I'm only familiar with raw modding, so some tips would be nice. (Send me a link if this is explained in detail elsewhere lol.)

Well, it's all open-source. Anything you put in the raw/init.d folder is run as soon as a save launches, and you can see how I make it run when the world/map are loaded. The script command I run there is going through this file.