• Crusader Kings II Expansion Subscription

    Subscribe to the CK II Expansion and enjoy unlimited access to 13 major expansions and more!


  • Crusader Kings III Available Now!

    The realm rejoices as Paradox Interactive announces the launch of Crusader Kings III, the latest entry in the publisher’s grand strategy role-playing game franchise. Advisors may now jockey for positions of influence and adversaries should save their schemes for another day, because on this day Crusader Kings III can be purchased on Steam, the Paradox Store, and other major online retailers.


    Real Strategy Requires Cunning

HBS_Eck

Second Lieutenant
4 Badges
Feb 23, 2018
151
10
ecktechgames.com
  • Harebrained Schemes Staff
  • BATTLETECH - Initiate of the Order
  • BATTLETECH - Beta Backer
  • BATTLETECH - Backer
To get ready for Official Mod Support, one of the big under-the-hood changes I've been working on this last year is replacing our hard-coded enumerations with a data driven system. I spoke about that at length in my dev journal here: https://www.gamedev.net/blogs/entry/2267465-battletech-developer-journal-08/.

We've been working closely with some of the modders of the larger mods (Rogue Tech, 3062 Advanced, 3025 Extended, Mission Control, etc). It's been really awesome working with them. Aidonis has been the main dev integrating much of the modders hard work into our own systems, and everyone has been banging on it nonstop to make sure everything works the way it should.

While doing this, JamieWolf identified a problem with the ease of use to mod in factions. In the first release, to mess with the enumerations, you had to mess directly with the MDD in addition to adding various files to the game. The problem is, there wasn't a way for multiple mods to play nice if they each wanted to add in factions. If one mod inserted a few factions, another one might step on the primary keys in the database and it just got a little messy. He had the idea to wire things up into the ModLoader, so that's what I did.

Code:
...
    "DataAddendumEntries":[ 
        { 
            "name":"BattleTech.FactionEnumeration",
            "path":"data/enums/MyCoolFactions.json"
        }
    ]
...

In the ModDef, I added a new section for DataAddendumEntries. Each entry is a namespace qualified class name and path to the file used to insert the data. Currently, this is only supported by the FactionEnumeration, but I have plans to extend this to all the DataDrivenEnums. And I designed it in such a way that there's room to expand it to other classes if needed.

The file it points to is a FactionEnumeration json file similar to the one found in StreamingAssets/data/enums/Faction.json. And it will contain a list of all the new factions the mod wants to add. the ID parameter is ignored by the process. It just increments to the next available ID in the database for you. I talk about the individual settings for each entry in a file that's included with the game: StreamingAssets/data/enums/DataDrivenEnumNotes.txt.

My advice is to just copy an entry for a faction that acts the way you want in the game and then adjust what you need. About the only thing that isn't automatically handled by the data is adding factions to the reputation screen. There was too much hardcoded black magic for me to easily make that moddable, but a few modders have already solved that problem anyway.

Now that you have the new FactionEnumeration value, you'll also need the supporting files. The only thing that is required is a FactionDef file, and you can add that via a ManifestEntry in the ModDef json.

Code:
...
    "Manifest":[ 
        { 
            "Type":"FactionDef",
            "Path":"data/factions",
            "ShouldMergeJSON":false
        }
    ]
...

The manifest entry loads up all the json in the specified path and adds it to the DataManager so the resources can be loaded. FactionDef is the only required file since you can make use of existing assets (cast defs, heraldry defs, icons, etc.) If you want to customize your faction further, adding those assets is a similar process to the FactionDefs mentioned above. Make directories in your mods for each type of asset and then add a Manifest Entry for those.


Gotchas:
  • Make sure the new FactionEnumerationValue FactionDefID has the exact case and spelling of the FactionDef file name.
  • Make sure the FactionDef's ID matches the spelling/case of the filename exactly.
  • Make sure the FactionDef's factionID matches the spelling/case of the FactionValue's Name exactly.

Now that the factions are integrated into the new mod system, adding them is pretty darn easy. Plus when you uninstall the mod, it removes them from the database so you can just as easily go back to a vanilla experience. The modders have done an amazing job developing a mod loading/management system and Aidonis has done a great job wiring that up into Battletech proper. I'm really excited to see what crazy new things modders cook up next.

- Eck