Extracting .dfmods, and adding scripts to injected assets

Discuss modding questions and implementation details.
Post Reply
strata
Posts: 9
Joined: Wed Nov 21, 2018 3:09 am

Extracting .dfmods, and adding scripts to injected assets

Post by strata »

Hi folks, hoping to get help with two beginner questions here that I haven't noticed answered elsewhere.

1) Is there a process for extracting .dfmod files I'm missing? I know they're Unity Asset Bundles, which I had thought would be importable in a similar manner to Unity asset packages, but apparently they're not, and they're also not proper archives that you can extract with 7zip, and neither ModBuilder nor the official Asset Bundle Browser package seem capable of extracting them (although you can see the file structure with the latter). Or are they not meant to be unpacked?

The reason this came up is I'm trying to examine how some other mods are designed / scripted to learn from them. Specifically, I was trying to dig into the Harvestable Crops mod to see how it's replacing flats with interactive, 'clickable' objects.

Which leads me to 2) - is there a best practice, or any approach at all, to apply a new script to either a generic Daggerfall game object (by which I mean either flat or 3d object), as well as any given injected replacement that object may have in other mods? I've read the very helpful asset injection tutorials but they only seem to cover outright replacement of original content. Let's say, for example, I want to make wells replenish a small amount of health when they're clicked on* - but I don't just want to add a script to the original well flats, I'd want it to apply to any replacement it may have in DREAM, Handpainted Models, and any other mods that may replace the original well flats. Obviously, forking or making variant packages for each of these mods just to add the same script to each replacement object is suboptimal. I know from a Unity / C# perspective it's trivial to add a new script component (Monobehaviors, at least) at runtime, but is there a way to accomplish this within the boundaries of the DFU modding system?

Any help greatly appreciated!

(* what I'm really going for is trying to add a thirst / hunger mechanic, while also adding some more interactivity to the various flats that already populate the whole gameworld - but just adding basic interactivity to a flat and its replacements would be step one.)

User avatar
TheLacus
Posts: 1305
Joined: Wed Sep 14, 2016 6:22 pm

Re: Extracting .dfmods, and adding scripts to injected assets

Post by TheLacus »

I'll start with question 1
strata wrote: Mon Oct 28, 2019 3:42 pm 1) Is there a process for extracting .dfmod files I'm missing? I know they're Unity Asset Bundles, which I had thought would be importable in a similar manner to Unity asset packages, but apparently they're not, and they're also not proper archives that you can extract with 7zip, and neither ModBuilder nor the official Asset Bundle Browser package seem capable of extracting them (although you can see the file structure with the latter). Or are they not meant to be unpacked?

The reason this came up is I'm trying to examine how some other mods are designed / scripted to learn from them. Specifically, I was trying to dig into the Harvestable Crops mod to see how it's replacing flats with interactive, 'clickable' objects.
Assetbundles contain assets packaged with a format suitable for target platform. This is the reason mods are shipped in three different variations for Windows, Linux and OSX. They are not compressed archives that can be extracted to retrieved original content.
Said that, there is an Export button available from the load order window in game which can export text files, including source scripts. It can't export binary assets.

User avatar
TheLacus
Posts: 1305
Joined: Wed Sep 14, 2016 6:22 pm

Re: Extracting .dfmods, and adding scripts to injected assets

Post by TheLacus »

strata wrote: Mon Oct 28, 2019 3:42 pm Which leads me to 2) - is there a best practice, or any approach at all, to apply a new script to either a generic Daggerfall game object (by which I mean either flat or 3d object), as well as any given injected replacement that object may have in other mods? I've read the very helpful asset injection tutorials but they only seem to cover outright replacement of original content. Let's say, for example, I want to make wells replenish a small amount of health when they're clicked on* - but I don't just want to add a script to the original well flats, I'd want it to apply to any replacement it may have in DREAM, Handpainted Models, and any other mods that may replace the original well flats. Obviously, forking or making variant packages for each of these mods just to add the same script to each replacement object is suboptimal. I know from a Unity / C# perspective it's trivial to add a new script component (Monobehaviors, at least) at runtime, but is there a way to accomplish this within the boundaries of the DFU modding system?
  • PlayerActivate.RegisterModelActivation can be used to detect when a model with given id is clicked. This doesn't work for flats, also beacuse most of them are batched unless specifically replaced.
  • ImportedComponent Attribute (documented here) can be used to serialize new scripts to prefabs provided by mods. You can use a MonoBehaviour that implements IPlayerActivable to run custom behaviour when GameObject is clicked.

strata
Posts: 9
Joined: Wed Nov 21, 2018 3:09 am

Re: Extracting .dfmods, and adding scripts to injected assets

Post by strata »

Thank you, that is very helpful. Prototyping time!

Post Reply