Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: A Steam Mod File Inter-Compatibility Suggestion  (Read 1186 times)

Eric Blank

  • Bay Watcher
  • *Remain calm*
    • View Profile
A Steam Mod File Inter-Compatibility Suggestion
« on: March 21, 2022, 12:02:04 am »

So a few months ago I said I had an idea that would help multiple mods to apply changes to the same files without overriding one another.

The idea basically boils down to; we would need a new raw file type, kinda like creature variations. You would use this format not to define new objects but to apply edits to objects that have been defined elsewhere. Say I wanted to edit dwarves, I would create a new file, for this example I decided to call them "mod" files, with their own headers;

Code: [Select]
mod_spellcrafts_standard

[MODIFICATION]

then select the dwarf object. probably a good idea for it to filter by object type like;

Code: [Select]
[MODIFY_OBJECT:CREATURE:DWARF]

Then since what I want to add to them is a CDI, I would add something like this:

Code: [Select]
[GO_TO_END]
[MD_NEW_TAG:CAN_DO_INTERACTION:SPELL_POWERS_RANDOM_CASTEBASED]
[MD_NEW_TAG:CDI:ADV_NAME:Unlock Racial Abilities]
[MD_NEW_TAG:CDI:USAGE_HINT:GREETING]
[MD_NEW_TAG:CDI:BP_REQUIRED:BY_CATEGORY:HEART]
[MD_NEW_TAG:CDI:TARGET:A:LINE_OF_SIGHT:SELF_ALLOWED]
[MD_NEW_TAG:CDI:VERB:practice your innate magic:practices their innate magic:NA]
[MD_NEW_TAG:CDI:TARGET_RANGE:A:10]
[MD_NEW_TAG:CDI:MAX_TARGET_NUMBER:A:5]
[MD_NEW_TAG:CDI:WAIT_PERIOD:200]

This will be applied to the end of the dwarf raws after the mod file is read and applied. Multiple such files from different mods could thus apply effects to dwarves without overriding one-another or having to be merged/patched, except when theyre both trying to change the same strings. This would have to, ideally, be robust enough to add and remove tissue layers, materials, body parts, castes, and any other aspects of a creature (and every other type of object) besides its object ID.

Ideally, these modification files would be loaded after all object definition files in the load order, then themselves are loaded and apply changes in the order in which the mods theyre part of are loaded. If the object youre trying to modify doesnt exist, it would be ideal if it didnt print a bunch of errors to the errorlog.txt but would instead just pass over it. That would let mods modify objects from other mods, if the other mod is present, but be ignored and not cause issues if they are absent, which helps work around another modding issue you run into trying to mod many games; having to create a third patch mod to make two other mods compatible with one-another. Of course if two mods do modify the same tags/variables in a file then whichever came last in the load order should overwrite the former.

This wasnt every single thought that went through my head as ive been pondering how best this work, but this is the basic gist of what I think is the bare minimum to get multiple mods to not overwrite each other while trying to change the same object, or worse, one mod trying to change dwarves and another trying to change dragons, which are both in creature_standard.txt, so traditionally overwriting one would mean the other mod would simply be ignored. This method would target only a single object definition at a time from a "third-party" file, so creature_standard.txt itself isnt overwritten and only the object in it that you wanted to change is affected.

Will probably have to reload the raw files after changes have been made? I dont know how it works behind the scenes, but possibly it will have to load all the vanilla + mods' object definitions, then load and apply modification files, then reload the now-modified object definitions for play? That would be weird.
Logged
I make Spellcrafts!
I have no idea where anything is. I have no idea what anything does. This is not merely a madhouse designed by a madman, but a madhouse designed by many madmen, each with an intense hatred for the previous madman's unique flavour of madness.

Mr Crabman

  • Bay Watcher
  • A person with the head and pincers of a crab.
    • View Profile
Re: A Steam Mod File Inter-Compatibility Suggestion
« Reply #1 on: March 21, 2022, 03:55:52 am »

A good idea, however, I definitely would hope that the MD_NEW_TAG part can be omitted entirely and that one could just write tags in directly. It's already super annoying having to type in CV_NEW_TAG in creature variations, making the files both harder to read (both from length and just sheer repetition), and write.

This general idea of "patch based edits" that allow multiple mods to change the same object (since the mods only define the specific changes they want to make) is discussed as well by voliol here in more depth (there are a few challenges to making this system a suitable replacement for manually defining the whole object): http://www.bay12forums.com/smf/index.php?topic=179270.msg8332006#msg8332006

As for your concern that you used dwarves and dragons and creature_standard.txt as an example of, it hasn't been directly confirmed/stated by Toady, but based on how Toady has said there is a mod loading order that can be set by the player, I assume that means you can actually just put your new [CREATURE:DWARF] in your mod in a file that's maybe also named creature_standard.txt (or maybe something different, either way), and it will overwrite the vanilla dwarves, and not do anything at all to the creature_standard.txt file, and you can specify only the new DWARF in that mod.

This still of course leaves the issue that no 2 mods can edit the same object (one would have to overwrite all other changes), and also that there doesn't seem to be a way for a mod to remove an object (Toady has mentioned that the vanilla raws can be disabled/not loaded, but that's not nearly granular enough for some mods; there needs to be a way for a mod to actively remove an object).