Modding Resources

Modding BFGA2

Because this game is so much more easily moddable than the first game, I want to give a brief overview of the basics of modding this game, this is that. It'll presumably expand over time? We'll see if a modding community for this game forms.
The actual mods by the Veritatem Imperialis team are still in development at this time.

Restoring original game state

Before modding anything, a note on how to get back to an online-playable state: You can revert your game files back to their original state by using the "Verify Game Files" feature of Steam (Right-click the game in your Steam library, select Properties, select the "Local Files" tab, select "Verify Integrity Of Game Files"). Note that this will not remove additional files you may have added to the game folder. You will have to remove these manually.

EasyAntiCheat

-NoEAC launch option

In order to play mods, you must disable EasyAntiCheat, as EAC protects the game from modification in order to avoid cheaters online. Adding -NoEAC to your Steam launch options will disable EAC (Right-click the game in your Steam library, select Properties, select Set Launch Options and add the text -NoEAC). You can verify that this works by checking the top right corner on the main menu; it should say "Stormancer deactivated" and have a red icon to the left of it. This will disconnect you from the online matchmaking server and disable EAC. You can still play 1v1 by inviting a friend in Battle mode.

version.bfgver

Located at /BattlefleetGothic2/version.bfgver, it is responsible for making sure that people running different versions of the game don't match together in the matchmaker. Even though it is a somewhat moot point considering we're running disconnected from the matchmaker, I recommend you modify this file if running anything modded to mitigate potential risk of being flagged as a cheater for accidentally playing online with modified files as well as displaying what mod is currently installed in the top right corner of the main menu. Mod developers should probably distribute this file as part of their release package.

CSV & XML Data

Location

The primary area of interest this time around is the Data subdirectory at /BattlefleetGothic2/Content/Data. These directories contain CSV and JSON files defining a lot of the raw data aspects of the game. All of these files can (and probably should) be edited using your favorite text editor after having been decrypted if necessary (see below). Preferably something better than Windows Notepad. Some points of interest include:

  • The unit schema, located under /UnitSchema/Official/UnitSchemaOfficial.json defines all units in the game (ships, titans, stations) and their body parts (hull, prow, weapons, etc.).
  • The unit stats, located under /UnitStats/Official/UnitStatsOfficial.csv define other properties of the ship (point cost, number of turrets, attributes).
    These files refer to strings through their localization keys: the relevant translations can be found in the respective XML file for the language in /BattlefleetGothic2/Content/Localization/; EN is for English. These files are also encrypted.

Encryption

Most data files (some, like fleet names, are excepted) are encrypted with AES-128-ECB encryption with the key abcdefghijklmnopqrstuvwxyz123456. A simple Python script for encryption and decryption is attached to this post here. This will add artifact null bytes at the end of the file; make sure to remove this before editing & reencrypting. The files are encoded in UTF-16.

Paks

I'll possibly expand this in the future, but the gist is that the game runs off of UnrealEngine version 4.18 and to extract the main Pak file, located at /BattlefleetGothic2/Content/Paks/BattlefleetGothic2-WindowsNoEditor.pak, you may use UnrealPak from the UE 4.18 SDK.

If you have any further questions you can contact me, PistonMiner, or any of the other VI devs; we're setting up a Discord server to more easily facilitate this once mods start being released. This is just a public service announcement of sorts ahead of time; and to assist other aspiring moders who maybe want to create mods of their own.

You're a good lad, thank you for this. EAC basically killed my interest in modding, glad to hear it's easy (Pun 100% intended) to defeat.

Amazing guys! Im going to start diving into it as soon as I can.

@PistonMiner so a little offtopic, I don't know pretty much anything about modding but I tried to modify Renown_Design_Imperium.csv to get bigger fleets in the campaign, following your guide. It didn't have the desired effect, more importantly - the values I've got in the game didn't correlate even with those that were originally in this file. Say, the value for fleet cap in the file for renown level 1 is stated as 400 but I got 200 and for level 2 it originally was 450, changed to 500, got 300. Any idea what might cause that?

I cannot thank you guys enough.

I will start working on some community tools this evening, this means so much! Thank you again!

@b3anmarine If you haven't figured this out yet, make sure to erase null values at the end of file after decryption.

@harbingercom21 yeah I did that, but the reencrypted file doesn't match the size of the original one so maybe the encrypt function isn't precise which makes the game not detect the updated file properly and fall back to some other set of values which is supposed to be overriden by it. Or probably I'm doing something wrong.

Got everything to work (with some help from Pistonminer) and I got to say its really nice to mod the game now. Twice the fleet-sizes, statchanges to make the factions feel even more unique and lore-friendly, Battleships that are worth more to the player while costing more, giving the feeling of having truly gigantic ships amongst a fleet of lesser. There is so much that can be done. Tried getting the titan ships in standard skirmish, but got a strange error with no information being shown for any ships but I just poked around a bit as a first attempt. Again, amazing work guys.

Thanks to the modders assistance I was able to make every ship cost a quarter of the points cost, now can gain fleets of between 20-30 vessels. Oh god the gameplay is different when you are having to act like a Lord Admiral with fleet clashes spanning the whole map in skirmish. Heavy causalties expected. Have yet to try it in the campaign. Having titans in skirmish is a sight to see, both the Macragge's Honour and Vengeful Spirit are beasts.

last edited by Dark King

So, not sure if I'm just a moron or something (Don't answer that), but I cannot get the Python script to decrypt any of the encrypted files...

Sounds like you're able to futz around with cool stuff and tune the game to be a more fun experience for yourself like this. I gotta ask then, how easy is it to mod this with someone who has no experience with this kind of stuff?

Watching the stream and seeing that the devs are ok with modding. I am wondering how easy it is or would be to import models. Lots of fan built ships to model after would make for some great titans, or other various ships especially for those that lack hulls.

@smoothrunes Its fairly easy. For me it was just a matter of learning the whole python bit needed to decrypt/encrypt the textfiles that hold all that information-goodness that we want to change to get the game as we like. But if you have no previous experience at all it might be a new world to open up.

@skalgrim-fellaxe said in Modding Resources:

@smoothrunes Its fairly easy. For me it was just a matter of learning the whole python bit needed to decrypt/encrypt the textfiles that hold all that information-goodness that we want to change to get the game as we like. But if you have no previous experience at all it might be a new world to open up.

How did you get it to? I've tried placing the filenames in to the script itself, but it never seems to latch on an decrypt them.

@romeo You need the program Python installed to be able to run the script. You also have to run it through the command prompt.

This straightforward guide helped me out a ton:

"Download and install latest Python 3 from their website, make sure during installation you check "Add python.exe to path" or similar, and then you can open a command prompt wherever you want (type 'cmd' (no quotes) in the title bar of explorer in the folder you put the script in, upon the first time using it, enter pip install pycryptodome to install the crypto library, and then you can run the script with the command 'python bfga2_aes.py' (no quotes); you may need to rename the downloaded file into 'bfga2_aes.py' (no quotes). Running it like that will give you the usage information; e.g. to decrypt a command might be: 'python bfga2_aes.py decrypt C:\Example\Path\To\Encrypted\Data\Without\Spaces\UnitStatsOfficial.json C:\Path\To\Output\Data\UnitSchemaOfficial.json.dec' (no quotes) and vice versa for encryption." - Pistonminer

Hope this helps. It got me to get almost everything to work. The rest is trial and error.

last edited by Skalgrim Fellaxe

@skalgrim-fellaxe said in Modding Resources:

@romeo You need the program Python installed to be able to run the script. You also have to run it through the command prompt.

This straightforward guide helped me out a ton:

"Download and install latest Python 3 from their website, make sure during installation you check "Add python.exe to path" or similar, and then you can open a command prompt wherever you want (type 'cmd' (no quotes) in the title bar of explorer in the folder you put the script in, upon the first time using it, enter pip install pycryptodome to install the crypto library, and then you can run the script with the command 'python bfga2_aes.py' (no quotes); you may need to rename the downloaded file into 'bfga2_aes.py' (no quotes). Running it like that will give you the usage information; e.g. to decrypt a command might be: 'python bfga2_aes.py decrypt C:\Example\Path\To\Encrypted\Data\Without\Spaces\UnitStatsOfficial.json C:\Path\To\Output\Data\UnitSchemaOfficial.json.dec' (no quotes) and vice versa for encryption." - Pistonminer

Hope this helps. It got me to get almost everything to work. The rest is trial and error.

Oh I've got Python installed (Use it for modding other things), but the script itself was what wasn't working for me.

Will try modifying my install, see if that changes things.

Hey, I'm using wing IDE and don't know how I'm improperly putting in the command line. Does anyone have examples they could give me as a reference?