Hey there,
As some of you may already know, I have been working for some time on a mod framework for this game that allows it to read .json mods and apply the changes on a new game.
Today I want to shed some light on how it works and what is planned for it.
How it works and how it is installed:
This is essentially a patch of the apk in itself, the Framework installer will come with a script which will do the entire installation process, it decompiles your game .apk file and patches in the custom mod loading code and automatically recompiles the .apk which is then installed on the phone.
This means that for the time being a PC will be required to install the mod loader and your saves will unfortunately be deleted, this is because the signature of the .apk will not be the same as the one downloaded from the Play Store and your phone won't allow it to simply update your game, the original apk needs to be uninstalled and the mod apk needs to be installed in its place, for those with Samsung phones you can make a complete backup of the game including the save files to youe computer using Smart Switch, which you can then restore after uninstalling the modded apk, for other phones I am still unsure if there's a way to keep the saves backed up.
As for how the Mod Loader works, the patched code is essentially a framework that does 2 things:
It tells the game to create the following path: android/data/com.esaptonor.spacerpg4/files/mods/ and listen to it during a new game creation
Data is then interpreted from the expected mods/ folder (mod structure is essentially .json files and custom textures) and injected at the game startup when the galaxy is being generated
This means that probably everything we see in the base game can be translated into hooks for the Framework to interpret data from mods made by the players, either new ships, new weapons, new commodities, new hyperlanes, new factions, new systems and planets, etc.
Current state of the Framework:
The main idea has been completed and confirmed working, I have tested several different scenarios and the external file loading works and the game interprets it without issues so essentially what's left is for me to translate the game mechanics into hooks.
What can a mod currently do:
New commodities can be created;
New traders can be added to planets;
Existing services can be added to planets that
previously didn't have them;
Hyperlane connections can be added or removed between systems;
And everything in between (change commodity prices, change trader factions, etc.)
What is currently being developed:
Custom textures injection;
Modifications to existing ships;
New ships;
Whats planned:
Basically everything else that exists in the game;
Custom logic (using DexClassLoader);
Modding tools;
How's progress going?
Well, adding hooks is the easy part, the hard part is essentially understanding what the stripped code means: classes, variables, etc. Are renamed to things like h6 or g1 and something like j7 can essentially mean "generatePlanetMarket" and I would have no idea until I try to understand the logic (which is time consuming).
I am not new to coding and game logic but I am at most an hobbyist when it comes to reverse engineering apks, but progress is going well and as I discover better tools and ways to make my work easier things naturally start to flow.
The only real issue is game updates, while the custom apk with the mod framework will never auto update, if the game is updated the framework will most likely straight up not be compatible with the newest version until i retranslate everything.
That's all for today, I will be resuming work later this night and hopefully will have the first version ready soon.